$(document).ready(function(){   
	
	$("#mainmenu ul > li.passive").mouseover(function(){   
		$(".iconNormal", this).stop().animate({"marginTop": "-20px"}, {queue:false, duration: 200}),
		$(".iconMirror", this).stop().animate({"marginTop": "10px"}, {queue:false, duration: 200})
	});   
	
	$("#mainmenu ul > li.passive").mouseout(function(){   
		$(".iconNormal", this).stop().animate({"marginTop": "0"}, {queue:false, duration: 200}),
		$(".iconMirror", this).stop().animate({"marginTop": "0"}, {queue:false, duration: 200})
	});   

});

/*
var timeoutMenu = new Array();

function hideMenu(obj, toHide) {
	//obj.find("span a").attr('style', 'color: #fff');
	if($.browser.msie){
		// wird per css mit :hover angezeigt
//		obj.find(toHide).css('display', 'none');
//		obj.find(toHide).css('visibility', 'hidden');
	} else {
		timeoutMenu[obj.attr('id')] = setTimeout(function() {
			obj.find(toHide).css('display', 'none');
//			obj.find(toHide).css('visibility', 'hidden');
		}, 1000);
	}
}

function showMenu(obj, toShow, isSubMenu) {
	setActiveParentElement(obj.find('.cur'));
	if(!$.browser.msie){
		resetMenu(obj, toShow);
	}
	
	if (!isSubMenu) {
//		obj.find("span a").attr('style', 'color: #000');
	}
	
//	$("#mainmenu *:animated").stop(true,true).hide(); //stop the animation
	
	var cssProp; 
	if (isSubMenu) {
		var left = eval(obj.width()+1) + "px"; //submenu offset
		cssProp = {'left' : left, 'display' : 'block'};
//			cssProp = {'left' : left, 'visibility' : 'visible'};
	} else {
		cssProp = {'display' : 'block'};
//			cssProp = {'visibility' : 'visible'};
	}
	
	if($.browser.msie){
		if (left) {
			cssProp = {'left' : left};
			obj.find(toShow).css(cssProp);
		}
	}
	else {
		obj.find(toShow).css(cssProp);
//			obj.find(toShow).css(cssProp).corner(ROUND_CORNER_SETTINGS);
	}
}

function resetMenu(obj, divId) {
	if (obj && obj != 'undefined') {
		divId = divId.substr(1,divId.length);
		var id = obj.attr('id');
		
		if (id && timeoutMenu[id]) {
			clearTimeout(timeoutMenu[id]);
		}
		
		var parent = obj.parent();
		if (parent && parent.is('ul')) {
			var children = parent.children();
			if (children) {
				children.each(function(index) {
					var childId = $(this).attr('id');
					if (childId != id) {
						var toHide = $('#'+childId+" div:first");
						if (toHide && toHide != 'undefined' && toHide.is('div')) {
							var childClass = toHide.attr('class');
							if (childClass.indexOf(divId, 0) > -1) {
								toHide.find('div').css('display', 'none');
//								toHide.find('div').css('visibility', 'hidden');
								toHide.css('display', 'none');
//								toHide.css('visibility', 'hidden');
							}
						}
					}
				});	
			}
		}
	}
}

function setActiveParentElement(child) {
	var parent = child.parents('li:first');
	var id = parent.attr('id');
	if (id && parent.is('li') && id != 'first'
		&& id != 'second' && id != 'third' && id != 'fourth') {
		
		parent.addClass('parentActive'); // pfeil beim aktiven elementen? 
		
//		var toWrap = parent.find('span a:first');
		var toWrap = parent.find('span:first');
		if (!toWrap.hasClass('cur')) {
//			if (toWrap.parent().attr('class') != 'cur') {
//			toWrap.wrap('<span class="cur" />');
			toWrap.addClass('cur');
		}
		setActiveParentElement(parent);
	}
}


$(document).ready(function() {
	//Hide menu after click on link
	$('#mainmenu ul li > span a').click(function() {
		$('#mainmenu ul li > div').css('display', 'none');
//		$('#mainmenu ul li > div').css('visibility', 'hidden');
	});
	
	//ERSTE EBENE
	$("#first, #second, #third, #fourth").hover(
		function () {
			showMenu($(this),'.subLayer1', false);
		}, 
		function () {
			hideMenu($(this),'.subLayer1');
		}
	);
	//ZWEITE EBENE
	$(".level1").hover(
		function () {
			showMenu($(this),'.subLayer2', true);
		}, 
		function () {
			hideMenu($(this),'.subLayer2');
		}
	);
	//DRITTE EBENE
	$(".level2").hover(
		function () {
			showMenu($(this),'.subLayer3', true);
		}, 
		function () {
			hideMenu($(this),'.subLayer3');
		}
	);
});
*/
