/* Copyright (C) 2007 - 2009 YOOtheme GmbH */

eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('3 1a={1h:6(13,w){3 9=0;3 k=[];3 s=13.1g(" ");3 17=s.1f();3 x=\'\';s.d(6(8,i){x+=\'.1d("\'+8+\'")\'});$1i(17).d(6(m,i){1b(\'k.1e(m\'+x+\');\')});k.d(6(4,i){7(!$q(4))S;3 b,j;7(4.K){b=4.K;j=0;j+=4.n(\'L-J\').p();j+=4.n(\'L-G\').p();b-=j;l=0;l+=4.n(\'F-J-N\').p();l+=4.n(\'F-G-N\').p();b-=l}D 7(4.T.P){b=4.T.P}9=R.Q(9,b)});7(w!=1v){9=R.Q(9,w)}k.d(6(4,i){7(!$q(4))S;7(1y.1x){4.V(\'O\',9+\'H\')}D{4.V(\'1j-O\',9+\'H\')}})}};3 11=c 12({14:6(m,19,Z,r,10,u){a.o({A:1B,X:v.I.1C,U:M,z:\'\'},r);3 5=a.5;$$(m).d(6(8,i){3 t=8;7(u){3 y=8.1A(u);7(y.W>0){t=y[0]}}3 f=c v.1n(t,5);7(!($q(5.z)&&8.1k(5.z))){8.16(\'1l\',6(e){f.o(5,r).C(19)});8.16(\'1u\',6(e){f.o(5,10).C(Z)})}})}});11.15(c 18);3 Y=c 12({14:6(5){a.o({X:v.I.1s,A:1r,U:M,h:[\'#1t\',\'#1q\']},5);3 E=c 1p(1m.E);3 f=E.1o(a.5);3 g=0;3 h=a.5.h;3 1w=B.1D(a.5.A*2);B();6 B(){f.C({\'1z-1c\':h[g]});7(g+1>=h.W){g=0}D{g++}}}});Y.15(c 18);',62,102,'|||var|div|options|function|if|el|maxHeight|this|divHeight|new|each||fx|index|colors||divPadding|matchDivs|divBorder|element|getStyle|setOptions|toInt|chk|enterFx|selectors|elfx|elementFx|Fx|minWidth|script|elms|ignoreClass|duration|animate|start|else|body|border|bottom|px|Transitions|top|offsetHeight|padding|false|width|height|pixelHeight|max|Math|return|style|wait|setStyle|length|transition|YOOBackgroundFx|leave|leaveFx|YOOMorph|Class|selector|initialize|implement|addEvent|elements|Options|enter|YOOBase|eval|color|getElement|push|shift|split|matchDivHeight|ES|min|hasClass|mouseenter|document|Styles|effects|Element|999999|9000|linear|FFFFFF|mouseleave|undefined|timer|ie6|window|background|getElementsBySelector|500|expoOut|periodical'.split('|'),0,{}))
/* Copyright (C) 2007 - 2009 YOOtheme GmbH */

eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('5 t=6 v({w:4(q,p,2){0.x({r:\'m\'},2);0.7=q;0.9=p;y(0.2.r){A\'z\':0.j();C;m:0.g()}},g:4(){5 2={};e(!$n(0.2.8)&&!$n(0.2.c)){2={c:-1}}$k(0.7).l(4(3,i){e(3.o(\'s\'))2={c:i}}.u(0));5 B=6 d.Q(0.7,0.9,$N(0.2,2))},j:4(){$k(0.7).l(4(3,i){5 a=3.h(\'a\');5 f=3.h(0.9);5 b=6 d.M(f,{D:d.P.R,L:K});e(!(3.o(\'s\')||0.2.8==\'F\'||0.2.8==i)){b.E()}a.G(\'H\',4(){b.J()})}.u(0))}});t.I(6 O);',54,54,'this||options|tog|function|var|new|togs|display|elms|span|fx|show|Fx|if|ul|createDefault|getElement||createSlide|ES|each|default|defined|hasClass|elements|togglers|accordion|active|YOOAccordionMenu|bind|Class|initialize|setOptions|switch|slide|case|accordionMenu|break|transition|hide|all|addEvent|click|implement|toggle|250|duration|Slide|extend|Options|Transitions|Accordion|linear'.split('|'),0,{}))
/* Copyright (C) 2007 - 2009 YOOtheme GmbH */

eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('h 16=d R({1g:8(e,7){4.N({1e:1l.1s.1p,I:1n,1o:F,10:R.1q,f:1,g:\'n\',18:1t,W:[\'1j\',\'1f\',\'1d\',\'1k\',\'1i\',\'1h\',\'1m\',\'1v\'],U:\'6.1B\',T:\'6.V\'},7);4.e=$(e),4.c=4.e.Q(4.7.T);4.6=[];4.a=[];4.e.1C(4.7.U).Z(8(5,i){4.X(5,i);5.w(\'1E\',8(E){4.1b(E,5)}.k(4));5.w(\'1u\',8(){4.1c(5,i)}.k(4));b(4.7.g==\'n\'){5.w(\'S\',8(){4.G(4.c,i)}.k(4))}B{5.w(\'S\',8(){4.G(5,i)}.k(4))}}.k(4));b(4.7.g==\'n\'){b(4.c){4.r(4.c)}B{h s=4.e.Q(\'6\');s.Y(\'V\');s.Y(\'c\');4.r(s)}}},X:8(5,i){b(4.7.g==\'n\'&&i!=0)14;h K=\'u \'+\'P\'+(i+1);4.7.W.Z(8(H,i){b(5.1w(H)){K+=\' P-\'+H}});4.a[i]=d o(\'a\',{\'A\':\'u-1\'}).M(d o(\'a\',{\'A\':\'u-2\'}).M(d o(\'a\',{\'A\':\'u-3\'})));4.a[i].9=4.a[i].17(4.7);4.6[i]=d o(\'6\',{\'A\':K}).M(4.a[i]).1D(4.e);4.6[i].9=4.6[i].17(4.7)},r:8(5){4.6[0].1A({\'y\':5.j,\'z\':5.m,\'1z\':\'1F\',\'f\':4.7.f});4.c=5},1b:8(E,5){b(!4.c)4.r(5);4.c=5;4.7.10(d 1x(E),5)},1c:8(5,i){13(4.7.g){q\'12\':4.O(5,i,19);v;q\'1a\':4.J(5,i,19);v;11:4.L(5,0)}},G:8(5,i){13(4.7.g){q\'12\':4.O(5,i,F);v;q\'1a\':4.J(5,i,F);v;11:4.L(5,0)}},L:8(5,i){b(!4.c)14;4.6[i].9.l({\'y\':[4.6[i].j,5.j],\'z\':[4.6[i].m,5.m]})},O:8(5,i,D){b(D){4.6[i].9.N(4.7);4.6[i].9.C({\'y\':5.j,\'z\':5.m});4.6[i].9.l({\'f\':[0,1]})}B{h 15=4.7.I*2;4.6[i].9.N({I:15});4.6[i].9.l({\'f\':[1,0]})}},J:8(5,i,D){h x=4.7.18;b(D){4.6[i].9.C({\'f\':1,\'y\':5.j,\'z\':5.m});4.a[i].9.C({\'t-p\':x});4.a[i].9.l({\'t-p\':[x,0]})}B{4.a[i].9.C({\'t-p\':0});4.a[i].9.l({\'t-p\':[0,x]})}}});16.1r(d 1y);',62,104,'||||this|item|li|options|function|fx|div|if|current|new|menu|opacity|mode|var||offsetLeft|bind|custom|offsetWidth|move|Element|top|case|setCurrent|first|margin|fancy|break|addEvent|offset|left|width|class|else|set|show|event|false|mouseleaveItem|col|duration|slideFx|css|moveFx|adopt|setOptions|fadeFx|bg|getElement|Class|mouseleave|activeSelector|itemSelector|active|colorSelector|createBackground|addClass|each|onClick|default|fade|switch|return|dur|YOOFancyMenu|effects|slideOffset|true|slide|clickItem|mouseenterItem|blue|transition|pink|initialize|yellow|orange|red|green|Fx|lilac|500|wait|sineInOut|empty|implement|Transitions|30|mouseenter|turquoise|hasClass|Event|Options|visibility|setStyles|level1|getElements|injectInside|click|visible'.split('|'),0,{}))
/* Copyright (C) 2007 - 2009 YOOtheme GmbH */

eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('2 g=f q({u:6(e,7){9.x({i:\'w\',y:s,B:h.v.A,z:r},7);2 3={\'8\':0,\'a\':0,\'b\':0};t(9.7.i){j\'8\':3={\'8\':0,\'b\':0};m;j\'a\':3={\'a\':0,\'b\':0};m}$$(e).M(6(4){2 1=4.L(\'1\');k(1){2 5=f h.N(1,9.7);2 n=1.O(\'8\',\'a\',\'b\');1.l(3);4.Q({C:6(){2 c=4.K();k(c.J(\'d\')==\'p\')c.o(\'d\',\'E\');5.e.o(\'d\',\'p\');5.D(n)},F:6(){5.G();1.l(3)}})}}.I(9))}});g.H(f P);',53,53,'|ul|var|reset|li|fx|function|options|width|this|height|opacity|parent|overflow|element|new|YOODropdownMenu|Fx|mode|case|if|setStyles|break|styles|setStyle|hidden|Class|false|600|switch|initialize|Transitions|default|setOptions|duration|wait|linear|transition|mouseenter|start|visible|mouseleave|stop|implement|bind|getStyle|getParent|getElement|each|Styles|getStyles|Options|addEvents'.split('|'),0,{}))
/* Copyright (C) 2007 - 2009 YOOtheme GmbH */

var YOOTools = {
		
	start: function() {

		/* Match height of div tags */
		YOOTools.setDivHeight();

		/* Background Animations */
		switch (YtSettings.color) {
			
			// underwater
			case 'default':
				if ($('object1')) { new YOOMove('object1', { 'direction': 'right', 'speed': 40000, 'pause': 60 }); }
				if ($('object2')) { new YOOMove('object2', { 'direction': 'left', 'speed': 30000, 'pause': 50 }); }
				break;
				
			// countryside, snow
			case 'brown':
			case 'blue':
			case 'green':
			case 'red':
				if ($('object1')) { new YOOMove('object1', { 'direction': 'left', 'speed': 300000, 'pause': 3 }); }
				if ($('object2')) { new YOOMove('object2', { 'direction': 'right', 'speed': 60000, 'pause': 50 }); }
				if ($('object3')) { new YOOMove('object3', { 'direction': 'left', 'speed': 30000, 'pause': 60 }); }
				break;

			// mars, earth
			case 'orange':
			case 'black':
				if ($('object1')) { new YOOMove('object1', { 'direction': 'right', 'speed': 70000, 'pause': 40 }); }
				if ($('object2')) { new YOOMove('object2', { 'direction': 'right', 'speed': 30000, 'pause': 10 }); }
				if ($('object3')) { new YOOMove('object3', { 'direction': 'left', 'speed': 100000, 'pause': 90 }); }
				break;
				
			// island, sunset
			case 'mint':
			case 'turquoise':
			case 'yellow':
				if ($('object1')) { new YOOMove('object1', { 'direction': 'left', 'speed': 300000, 'pause': 3 }); }
				if ($('object2')) { new YOOMove('object2', { 'direction': 'right', 'speed': 50000, 'pause': 50 }); }
				if ($('object3')) { new YOOMove('object3', { 'direction': 'left', 'speed': 100000, 'pause': 60 }); }
				break;
		}
		
		
		/* Accordion menu */
		new YOOAccordionMenu('div#middle ul.menu li.toggler', 'ul.accordion', { accordion: 'slide' });

		/* Dropdown menu */
		new YOODropdownMenu('div#menu li.parent', { mode: 'height', transition: Fx.Transitions.Expo.easeOut });

		/* Morph: main menu - level1 (tab) */
		var menuEnter = { 'color': '#ffffaa' };
		var menuLeave = { 'color': '#F0F0DC' };

		switch (YtSettings.color) {
			case 'blue':
			case 'green':
			case 'black':
				menuEnter = { 'color': '#ff9934' };
				break;
		}

		new YOOMorph('div#menu li.level1', menuEnter, menuLeave,
			{ transition: Fx.Transitions.linear, duration: 100 },
			{ transition: Fx.Transitions.sineIn, duration: 300 }, 'a.level1');

		/* Morph: main menu - level1 subline (color) */
		new YOOMorph('div#menu li.level1', menuEnter, menuLeave,
			{ transition: Fx.Transitions.linear, duration: 100 },
			{ transition: Fx.Transitions.sineIn, duration: 300 }, 'span.sub');

		/* Morph: main menu - level2 and deeper (color) */
		var selector = 'div#menu li.level2 a, div#menu li.level2 span.separator';
		/* fix for Opera because Mootools 1.1 is not compatible with latest Opera version */
		if (window.opera) { selector = 'div#menu li.item1 li.level2 a, div#menu li.item1 li.level2 span.separator, div#menu li.item2 li.level2 a, div#menu li.item2 li.level2 span.separator, div#menu li.item3 li.level2 a, div#menu li.item3 li.level2 span.separator, div#menu li.item4 li.level2 a, div#menu li.item4 li.level2 span.separator, div#menu li.item5 li.level2 a, div#menu li.item5 li.level2 span.separator, div#menu li.item6 li.level2 a, div#menu li.item6 li.level2 span.separator, div#menu li.item7 li.level2 a, div#menu li.item7 li.level2 span.separator'; }
		
		new YOOMorph(selector, menuEnter, menuLeave,
			{ transition: Fx.Transitions.linear, duration: 0 },
			{ transition: Fx.Transitions.sineIn, duration: 500 });

		/* Morph: sub menu - level1 */
		var submenuEnter = { 'color': '#ffffaa'};
		var submenuLeave = { 'color': '#F0F0DC'};

		switch (YtSettings.color) {
			case 'blue':
				submenuEnter = { 'color': '#ba5d00'};
				submenuLeave = { 'color': '#266892'};
				break;
			case 'green':
				submenuEnter = { 'color': '#ba5d00'};
				submenuLeave = { 'color': '#669125'};
				break;
			case 'black':
				submenuEnter = { 'color': '#ba5d00'};
				submenuLeave = { 'color': '#437ca1'};
				break;
		}

		new YOOMorph('div#middle ul.menu a, div#middle ul.menu span', submenuEnter, submenuLeave,
			{ transition: Fx.Transitions.expoOut, duration: 0 },
			{ transition: Fx.Transitions.sineIn, duration: 300 });

		/* Smoothscroll */
		new SmoothScroll({ duration: 500, transition: Fx.Transitions.Expo.easeOut });
	},

	/* Include script */
	include: function(library) {
		$ES('script').each(function(s, i){
			var src  = s.getProperty('src');
			var path = '';
			if (src && src.match(/yoo_tools\.js(\?.*)?$/)) path = src.replace(/yoo_tools\.js(\?.*)?$/,'');
			if (src && src.match(/template\.js\.php(\?.*)?$/)) path = src.replace(/template\.js\.php(\?.*)?$/,'');
			if (path != '') document.write('<script language="javascript" src="' + path + library + '" type="text/javascript"></script>');
		});
	},

	/* Match height of div tags */
	setDivHeight: function() {
		YOOBase.matchDivHeight('div.headerbox div.deepest', 0, 40);
		YOOBase.matchDivHeight('div.topbox div.deepest', 0, 40);
		YOOBase.matchDivHeight('div.bottombox div.deepest', 0, 40);
		YOOBase.matchDivHeight('div.maintopbox div.deepest', 0, 40);
		YOOBase.matchDivHeight('div.mainbottombox div.deepest', 0, 40);
		YOOBase.matchDivHeight('div.contenttopbox div.deepest', 0, 40);
		YOOBase.matchDivHeight('div.contentbottombox div.deepest', 0, 40);
	}

};

/* Add functions on window load */
window.addEvent('domready', YOOTools.start);

/* Load IE6 fix */
if (window.ie6) {
	YOOTools.include('addons/ie6fix.js');
	YOOTools.include('addons/ie6png.js');
	YOOTools.include('yoo_ie6fix.js');
}

/* Move class */
var YOOMove = new Class({
	
	initialize: function(element, options) {
		this.setOptions({
			direction: 'left',
			speed: 10000,
			pause: 5,
			duration: 1000,
			transition: Fx.Transitions.linear
		}, options);

		this.elm = $(element);
		this.key = 'yt-' + this.elm.getProperty('id');
		this.fx = new Fx.Styles(this.elm, this.options);
		this.timer = null;

		var val = Cookie.get(this.key);
		if (val) {
			this.elm.setStyle('left', val + 'px');
		}
		
		this.memorize.periodical(2500, this);
		this.animate();
	},

	animate: function() {
		var dir   = this.options.direction;
		var pause = this.options.pause;
		var coord = this.elm.getCoordinates();
		var dest  = (dir == 'left') ? 0 - coord.width : window.getWidth();
		var track = coord.left - dest;
		if (track < 0) { track = -track; }

		this.fx.setOptions({ 'duration': (this.options.speed * track / 1024).toInt() });
		this.fx.start({
			'left': (dir == 'left') ? 0 - coord.width : window.getWidth()
		}).chain(function() {
			this.elm.setStyles({
				'left': (dir == 'left') ? window.getWidth() : 0 - coord.width
			});
			$clear(this.timer);
			this.timer = this.animate.delay((Math.floor(Math.random() * pause) * 1000).limit(1000, (1000 * pause)), this);
		}.bind(this));
	},
	
	memorize: function() {
		var coord = this.elm.getCoordinates();
		Cookie.set(this.key, coord.left);
	}
	
});

YOOMove.implement(new Options);
