var hoverColour = "#CC9933";
//var hoverColour = "#EEEEEE";
var mline1 = "<a class='hoverBtn' href='#'>Test</a>";
var menuline2alt = "";
var menuline2neu = "default";
var animSpeed = 150;

function showSubMenu(menu){
	document.getElementById(menu).style.left=0;
}

$(document).ready(function(){
	
	$("#menu").bind("mouseleave", function(event) {

		menuline2neu = "#" + submenu;
		if (menuline2alt != menuline2neu){
			
			if (isIE == true){
				$(menuline2alt)
					.stop()
					.animate({ left: "-1000" }, animSpeed, "swing");
			} else{	
				$(menuline2alt)
					.stop()
					.animate({ top: "9", opacity: "0" }, animSpeed, "swing");
			}
			
			
			if (isIE == true){
				$(menuline2neu)
					.stop()
					.animate({ left: "0" }, animSpeed, "swing");
			} else{	
				$(menuline2neu)
					.stop()
					.animate({ top: "33", opacity: "1" }, animSpeed, "swing");
			}
				
			menuline2alt = menuline2neu;	
		}
	});
	
});



$(function(){

	$("a.hoverBtn").show("fast", function() {
		$(this).wrap("<div class=\"hoverBtn\">");
		$(this).attr("class", "");
	});
	
	//display the hover div
	$("div.hoverBtn").show("fast", function() {
		//append the background div
		$(this).append("<div></div>");
		
		//get link's size
		//var wid = $(this).children("a").width();
		//var hei = $(this).children("a").height();
		
		var wid = $(this).width();
		var hei = $(this).height();
		

		
		//set div's size
		$(this).width(wid);
		$(this).height(hei);
		$(this).children("div").width(wid);
		$(this).children("div").height(hei);
		
		//on link hover
		$(this).children("a").hover(function(){
		
		 //prompt("");
		
			// zweite zeile
			//$("#menu2").append(mline1);
		
			//store initial link colour
			if ($(this).attr("rel") == "") 
			{
				$(this).attr("rel", $(this).css("color"));
			}
			//fade in the background
            /*
			$(this).parent().children("div")
				.stop()
				.css({"display": "none", "opacity": ".38" , "filter": "alpha(opacity=38)" })
				.fadeIn("fast");
            */
			//fade in the menuline2
			//prompt($(this).parent().parent().attr("id"));
			if ($(this).parent().parent().attr("id") == "menu_main" && "#" + $(this).attr("id") + "_menu" != menuline2alt)
			{
				menuline2neu = "#" + $(this).attr("id") + "_menu"
				
				if (menuline2alt!=""){
					if (isIE == true){
						$(menuline2alt)
							.stop()
							.animate({ left: "-1000" }, animSpeed, "swing");
					} else{	
						$(menuline2alt)
							.stop()
							.animate({ top: "9", opacity: "0" }, animSpeed, "swing");
					}
				}

				if (isIE == true){
					$(menuline2neu)
						.stop()
						.animate({ left: "0" }, animSpeed, "swing");
				} else{	
					$(menuline2neu)
						.stop()
						.animate({ top: "33", opacity: "1" }, animSpeed, "swing");
				}

				menuline2alt = "#" + $(this).attr("id") + "_menu";
			}
			//fade the colour
			$(this)	.stop()
				.css({"color": $(this).attr("rel")})
				.animate({"color": hoverColour}, 250);
			},function(){
			//fade out the background
            /*
			$(this).parent().children("div")
				.stop()
				.fadeOut("slow");
            */
			//fade the colour
			$(this)	
				.stop()
				.animate({"color": $(this).attr("rel")}, 550);
		});
	});
});

