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

var YOOTools = {
		
	start: function() {
		
		/* Match height of div tags */
		YOOTools.setDivHeight();

		/* Accordion menu */
		new YOOAccordionMenu('div#middle ul.menu li.toggler', 'ul.accordion', { accordion: 'slide' });

		/* Fancy menu */
		new YOOFancyMenu($E('ul', 'menu'), { mode: 'fade', transition: Fx.Transitions.linear, duration: 500 });

		/* Dropdown menu */
		new YOODropdownMenu('div#menu li.parent', { mode: 'height', transition: Fx.Transitions.Expo.easeOut });

		/* Morph: level1 items of main menu (tab) */
		var enterColorRed = '#ff0000';
		var enterColorBlue = '#5ae1f0';
		var enterColorPink = '#FF82FF';
		var enterColorOrange = '#f59641';
		var enterColorGreen = '#c3e63c';
		var enterColorYellow = '#ffdc57';
		var enterColorLilac = '#956ce8';
		var enterColorTurquoise = '#45f4d4';
		
		var leaveColor = '#ffffff';

		var menuEnterRed = { 'color': enterColorRed };
		var menuEnterBlue = { 'color': enterColorBlue };
		var menuEnterPink = { 'color': enterColorPink };
		var menuEnterOrange = { 'color': enterColorOrange };
		var menuEnterGreen = { 'color': enterColorGreen };
		var menuEnterYellow = { 'color': enterColorYellow };
		var menuEnterLilac = { 'color': enterColorLilac };
		var menuEnterTurquoise = { 'color': enterColorTurquoise };
		
		var menuLeave = { 'color': leaveColor };
		
		new YOOMorph('div#menu li.red', menuEnterRed, menuLeave,
			{ transition: Fx.Transitions.linear, duration: 500},
			{ transition: Fx.Transitions.sineIn, duration: 500 }, '.level1');
		
		new YOOMorph('div#menu li.blue', menuEnterBlue, menuLeave,
			{ transition: Fx.Transitions.linear, duration: 500},
			{ transition: Fx.Transitions.sineIn, duration: 500 }, '.level1');
		
		new YOOMorph('div#menu li.pink', menuEnterPink, menuLeave,
			{ transition: Fx.Transitions.linear, duration: 500},
			{ transition: Fx.Transitions.sineIn, duration: 500 }, '.level1');
		
		new YOOMorph('div#menu li.orange', menuEnterOrange, menuLeave,
			{ transition: Fx.Transitions.linear, duration: 500},
			{ transition: Fx.Transitions.sineIn, duration: 500 }, '.level1');
		
		new YOOMorph('div#menu li.green', menuEnterGreen, menuLeave,
			{ transition: Fx.Transitions.linear, duration: 500},
			{ transition: Fx.Transitions.sineIn, duration: 500 }, '.level1');
		
		new YOOMorph('div#menu li.yellow', menuEnterYellow, menuLeave,
			{ transition: Fx.Transitions.linear, duration: 500},
			{ transition: Fx.Transitions.sineIn, duration: 500 }, '.level1');
		
		new YOOMorph('div#menu li.lilac', menuEnterLilac, menuLeave,
			{ transition: Fx.Transitions.linear, duration: 500},
			{ transition: Fx.Transitions.sineIn, duration: 500 }, '.level1');
		
		new YOOMorph('div#menu li.turquoise', menuEnterTurquoise, menuLeave,
			{ transition: Fx.Transitions.linear, duration: 500},
			{ transition: Fx.Transitions.sineIn, duration: 500 }, '.level1');
		
		/* Morph: level2 and deeper items of main menu (drop down) */
		new YOOMorph('div#menu li.red ul.level2 a', menuEnterRed, menuLeave,
			{ transition: Fx.Transitions.expoOut, duration: 300},
			{ transition: Fx.Transitions.sineIn, duration: 500 });
		
		new YOOMorph('div#menu li.blue ul.level2 a', menuEnterBlue, menuLeave,
			{ transition: Fx.Transitions.expoOut, duration: 300},
			{ transition: Fx.Transitions.sineIn, duration: 500 });
		
		new YOOMorph('div#menu li.pink ul.level2 a', menuEnterPink, menuLeave,
			{ transition: Fx.Transitions.expoOut, duration: 300},
			{ transition: Fx.Transitions.sineIn, duration: 500 });
		
		new YOOMorph('div#menu li.orange ul.level2 a', menuEnterOrange, menuLeave,
			{ transition: Fx.Transitions.expoOut, duration: 300},
			{ transition: Fx.Transitions.sineIn, duration: 500 });
		
		new YOOMorph('div#menu li.green ul.level2 a', menuEnterGreen, menuLeave,
			{ transition: Fx.Transitions.expoOut, duration: 300},
			{ transition: Fx.Transitions.sineIn, duration: 500 });
		
		new YOOMorph('div#menu li.yellow ul.level2 a', menuEnterYellow, menuLeave,
			{ transition: Fx.Transitions.expoOut, duration: 300},
			{ transition: Fx.Transitions.sineIn, duration: 500 });
		
		new YOOMorph('div#menu li.lilac ul.level2 a', menuEnterLilac, menuLeave,
			{ transition: Fx.Transitions.expoOut, duration: 300},
			{ transition: Fx.Transitions.sineIn, duration: 500 });
		
		new YOOMorph('div#menu li.turquoise ul.level2 a', menuEnterTurquoise, menuLeave,
			{ transition: Fx.Transitions.expoOut, duration: 300},
			{ transition: Fx.Transitions.sineIn, duration: 500 });
		
		
		/* Morph: level1 subline of main menu (tab) */
		enterColorRed = '#C8001E';
		enterColorBlue = '#00BED2';
		enterColorPink = '#C800C8';
		enterColorOrange = '#DC5000';
		enterColorGreen = '#78C800';
		enterColorYellow = '#FFC800';
		enterColorLilac = '#6432C8';
		enterColorTurquoise = '#00DCB4';
		
		leaveColor = '#ffffff';

		menuEnterRed = { 'color': enterColorRed };
		menuEnterBlue = { 'color': enterColorBlue };
		menuEnterPink = { 'color': enterColorPink };
		menuEnterOrange = { 'color': enterColorOrange };
		menuEnterGreen = { 'color': enterColorGreen };
		menuEnterYellow = { 'color': enterColorYellow };
		menuEnterLilac = { 'color': enterColorLilac };
		menuEnterTurquoise = { 'color': enterColorTurquoise };
		
		new YOOMorph('div#menu li.red', menuEnterRed, menuLeave,
			{ transition: Fx.Transitions.linear, duration: 500},
			{ transition: Fx.Transitions.sineIn, duration: 500 }, 'span.sub');
		
		new YOOMorph('div#menu li.blue', menuEnterBlue, menuLeave,
			{ transition: Fx.Transitions.linear, duration: 500},
			{ transition: Fx.Transitions.sineIn, duration: 500 }, 'span.sub');
				
		new YOOMorph('div#menu li.pink', menuEnterPink, menuLeave,
			{ transition: Fx.Transitions.linear, duration: 500},
			{ transition: Fx.Transitions.sineIn, duration: 500 }, 'span.sub');
		
		new YOOMorph('div#menu li.orange', menuEnterOrange, menuLeave,
			{ transition: Fx.Transitions.linear, duration: 500},
			{ transition: Fx.Transitions.sineIn, duration: 500 }, 'span.sub');
		
		new YOOMorph('div#menu li.green', menuEnterGreen, menuLeave,
			{ transition: Fx.Transitions.linear, duration: 500},
			{ transition: Fx.Transitions.sineIn, duration: 500 }, 'span.sub');
		
		new YOOMorph('div#menu li.yellow', menuEnterYellow, menuLeave,
			{ transition: Fx.Transitions.linear, duration: 500},
			{ transition: Fx.Transitions.sineIn, duration: 500 }, 'span.sub');
		
		new YOOMorph('div#menu li.lilac', menuEnterLilac, menuLeave,
			{ transition: Fx.Transitions.linear, duration: 500},
			{ transition: Fx.Transitions.sineIn, duration: 500 }, 'span.sub');
		
		new YOOMorph('div#menu li.turquoise', menuEnterTurquoise, menuLeave,
			{ transition: Fx.Transitions.linear, duration: 500},
			{ transition: Fx.Transitions.sineIn, duration: 500 }, 'span.sub');
		
		/* Morph: sub menu (left) */
		switch (YtSettings.itemColor) {
			case "blue":		var enterColor = '#5ae1f0';
								break;

			case "pink": 		var enterColor = '#FF82FF';
								break;
		 
			case "orange": 		var enterColor = '#f59641';
								break;
		 
			case "green":	 	var enterColor = '#c3e63c';
								break;
							
			case "yellow":		var enterColor = '#ffdc57';
								break;
							
			case "lilac":		var enterColor = '#956ce8';
								break;
							
			case "turquoise":	var enterColor = '#45f4d4';
								break;
		 
			default: 			var enterColor = '#ff0000';
		  }
		
		var leaveColor = '#ffffff';
		var submenuEnter = { 'color': enterColor};
		var submenuLeave = { 'color': leaveColor};

		new YOOMorph('div#left ul.menu a, div#left ul.menu span.separator', submenuEnter, submenuLeave,
			{ transition: Fx.Transitions.expoOut, duration: 300 },
			{ transition: Fx.Transitions.sineIn, duration: 500 });

		var enterColor = '#000000';
		var leaveColor = '#646464';
		var submenuEnter = { 'color': enterColor};
		var submenuLeave = { 'color': leaveColor};

		new YOOMorph('div#right ul.menu a, div#right ul.menu span.separator', submenuEnter, submenuLeave,
			{ transition: Fx.Transitions.expoOut, duration: 300 },
			{ transition: Fx.Transitions.sineIn, duration: 500 });

		/* 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.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');
}