//
// Mootools behavior - general
//

// fire up all the nice stuff:

window.addEvent('domready', function(){


	// flush the remote control
	/*var remotePull = new Fx.Style('remote', 'top',{duration: 200, transition: Fx.Transitions.Quad.easeInOut});
	
	$('remote').addEvent('mouseenter', function() {
		remotePull.start(-74,0);
	});
	
	$('remote').addEvent('mouseleave', function() {
		remotePull.start(0,-74);
	});*/
	
	
	// prepare font-sizes and cookies
	var resize = new Fx.Style('text', 'font-size', {duration: 200, wait: false});
	
	$('fontLarge').addEvent('click', function() {
		resize.start(14);
		Cookie.set("font-size", "1.4em"); //save this for 1 year
	});
	$('fontMed').addEvent('click', function() {
		resize.start(12);
		Cookie.set("font-size", "1.2em"); //save this for 1 year
	});
	$('fontNormal').addEvent('click', function() {
		resize.start(10);
		Cookie.set("font-size", "1em"); //save this for 1 year
	})
	
	
	// check for font size cookie
	if(Cookie.get("font-size") == "1.4em") {
		resize.set(14);
	} else if(Cookie.get("font-size") == "1.2em") {
		resize.set(12);
	} else {
		//do nothing, leave default
	}
	
	
	// Smoothscroll
	new SmoothScroll({
		duration: 400
	});
	
	
	// Tooltips
	var tip = new Tips($$('.tip'), {
		offsets: {
			'x': 16,
			'y': -25
		},
		initialize: function() {
			this.fx = new Fx.Style(this.toolTip, 'opacity', { 
				duration: 100,
				wait: false
			}).set(0);
		},
		onShow: function(toolTip) {
			this.fx.start(1);
		},
		onHide: function(toolTip) {
			this.fx.start(0);
		}
	});
	
	
	// latest news Kwicks
	var szNormal = 28, szSmall = 28, szFull = 350; // 300
	var kwicks_container = $$("#newsbox-content");
	var kwicks = $$("#newsbox-content .kwick-element");
	var fx = new Fx.Elements(kwicks, {wait: false, duration: 300/*, transition: Fx.Transitions.Back.easeOut*/});
	
	kwicks.each(function(kwick, i) {
		kwick.addEvent("mouseenter", function(event) {
			var o = {};
			o[i] = {height: [kwick.getStyle("height").toInt(), szFull]}
			kwicks.each(function(other, j) {
				if(i != j) {
					var w = other.getStyle("height").toInt();
					if(w != szSmall) o[j] = {height: [w, szSmall]};
				}
			});
			fx.start(o);
		});
	});
	
	// handle mouse events on main navigation
	// this is for my friend IE6 - for him an a-tag without attributes
	// ain't an a-tag you can style the pseudoclasses for ... whatever
	
	$$('#navigation a.toggler').each(function(el) {
	 	el.addEvent('mouseenter',function(){
			el.setStyle('background','url(/fileadmin/template/img/sidebar/main_menu.gif) 0 bottom repeat-x;');
		})
		el.addEvent('mouseleave',function() {
			el.setStyle('background','url(/fileadmin/template/img/sidebar/main_menu.gif) 0 top repeat-x;');
		})
	});
	
	//domready event end
});

var pfad = "fileadmin/template/img/bildergalerie/";
