// JavaScript Document

$(document).ready(function() {
	var currentMenu = ""; // sets global variable for the selected menu
	$(".navButton").live("mouseover",function() {
		if(currentMenu != "" && currentMenu != $(this).attr("id")) {
			var currentSub = currentMenu.replace("nav","sub"); // maked a submenu id form the menu id
			$("#"+currentMenu).fadeTo(0,1); // sets the menu to 100%
			$("#"+currentSub).hide(); // hide the submenu that is visible
		}
		$(this).fadeTo(0,.3); // fades the selected menu to 50%
		currentMenu = $(this).attr("id"); // change the global variable to the selected menu
		var submenu = $(this).attr("id").replace("nav","sub");   // maked a submenu id form the menu id
		$("#"+submenu).show(); // shows the submenu
		$("#"+submenu).delay(4000).fadeOut(); // fades away after 4 seconds
	 });
	$('#loginFrame').mouseover(function() { // this hides the submenu when the login in bar is moused over
		$(".navSubmenu").each(function() {
			$(this).hide();							   
		});
	});
	$('#loginStatus').mouseover(function() { // this hides the submenu when the login in bar is moused over
		$(".navSubmenu").each(function() {
			$(this).hide();							   
		});
	});
	
});