

$(document).ready(function(){
	
/*###############################################
  TOPMENU
###############################################*/


	$("#menu ul li").hover(function(){
		//add class="hover" when mouseover li elements
		$(this).addClass("hover");
		
		// This function must reside here because all li elements in the submenu have duisplay:none in css so
		// jquery can't compute on them.
		//find height of first li element in .submenu_container 
		var menuheight = $(this).find('.submenu_container:first').height();
		
		// for each li element inside submenu_containter set it's height to the heighest li-element
		$(this).find('.submenu_container').each(function(){
			var thisheight = $(this).height();
	
		//console.log(menuheight);
		//console.log('-' +thisheight);
		
		// if the height of the highest li element is equal/higher than the first li element
		// set the height to whicheer is the highest
		if(thisheight >= menuheight){
		 menuheight = thisheight;
		 
		}
		});
		// add the computed height to all li elements in submenu_container as inline style
		$(this).find('.submenu_container').height(menuheight);

	},function(){
		// remouve class="hover" on mouseout
		$(this).removeClass("hover");
	});


/*##########################################
SLIDEMENU
###########################################*/
	$("#slidemenuinner>ul>li>ul").each(function(){
		$(this).attr("jqheight",$(this).height());
	});
	$("#slidemenuinner>ul>li>ul").hide();
	$("#slidemenuinner>ul>li>ul").css("height","0px");
	$("#slidemenuinner>ul>li").hover(function(){
		
		$(this).find(">ul").stop().show().animate({height:$(this).find(">ul").attr("jqheight"),marginTop:"10px",marginBottom:"10px"},500);
		$(this).addClass("active");

	},function(){
		
		$(this).find(">ul").stop().animate({height:"0px",marginTop:"0px",marginBottom:"0px"},500).css('margin',0);
		$(this).removeClass("active");

	});
	
	
/*###########################################	
// change background color in frontpage
##############################################*/
	$("div#div-col1").hover(function(){
		$(this).removeClass("bg");
		$(this).addClass("bg1");
	},function(){
		$(this).removeClass("bg1");
		$(this).addClass("bg");
	});
	$("div#div-col2").hover(function(){
		$(this).removeClass("bg");
		$(this).addClass("bg1");
	},function(){
		$(this).removeClass("bg1");
		$(this).addClass("bg");
	});
	$("div#div-col3").hover(function(){
		$(this).removeClass("bg");
		$(this).addClass("bg1");
	},function(){
		$(this).removeClass("bg1");
		$(this).addClass("bg");
	});	
});
