function openMenu(menuId) {
	
		if (menuId == undefined) {
			menuId = 3;	
		}
		
		currentPage = menuId;
		
		// Open all parents which are 'unordered-lists'
    	var parents =  $("#menu-id-"+menuId).parents("ul")
                      .css("display", "block");

        // Open the given menu
        $("#menu-id-"+menuId+" ul:first").css("display", "block");
        
		
		// Underline the active menu
		fileUrl = $("#menu-id-"+menuId+" .menuBtn:first").attr("src");
    	hoverUrl = fileUrl.substring(0,fileUrl.lastIndexOf('.gif'))+"-active.gif";
    	//$(this).attr("src", hoverUrl);
    	$("#menu-id-"+menuId+" .menuBtn:first").attr("src", hoverUrl);

}


function changeMainMenu(modeId) {
		currentMode = modeId;
		
		
  	  	fileUrl = $("#mainmenu-id-"+modeId+" .menuBtn:first").attr("src");
   	 	hoverUrl = fileUrl.substring(0,fileUrl.lastIndexOf('.gif'))+"-active.gif";
    	 $("#mainmenu-id-"+modeId+" .menuBtn:first").attr("src", hoverUrl);

		//fileUrl = $("#mainmenu-id-"+modeId+" .menuBtn:first").attr("src");
    	//hoverUrl = fileUrl.substring(0,fileUrl.lastIndexOf('.gif'))+"-active.gif";
    	//$(this).attr("src", hoverUrl);
    	//$("#mainmenu-id-"+modeId+" .menuBtn:first").attr("src", hoverUrl);
		

}

$(document).ready(function() {

	var submenuClick = false;
	


    // Main menu click
	$(".submenu-n2").click(function () { 
	 submenuClick = true;
	
      // Collapse the open menu's
     $(".submenu-n2 ul").css("display", "none");
      // Check if the menu has a submenu, if so open 
      $(this).find("ul:first").css("display", "block");
    });
    
    
    // Main menu click
	$(".menu-n0").click(function () { 
	
	if (!submenuClick) {
      // Collapse the open menu's
     $(".menu-n0 ul, .submenu-n2 ul").css("display", "none");
      // Check if the menu has a submenu, if so open 
      $(this).find("ul:first").css("display", "block");
      }
    submenuClick = false;
    });
    
    
  $("#menu .menuBtn").mouseover(function () { 
  

  	var menuId = $(this).parents("li:first").attr("id");
  	menuNr = menuId.substring(8, menuId.length);
  	
  //	window.alert(currentPage+", "+menuNr);
  	
  	if (menuNr != currentPage) {
  	fileUrl = $(this).attr("src");
  	  	  	fileUrl = $(this).attr("src");
   	 	hoverUrl = fileUrl.substring(0,fileUrl.lastIndexOf('.gif'))+"-active.gif";
    	$(this).attr("src", hoverUrl);
  	}
   	
  	// Check the state off the rollover button
 	//if (fileUrl.search(/-active.gif/i) > 0) {

  	//	window.alert("yes");
  //	} else {
  	//window.alert("no");

  
  //	}
  	

    //}
    

 
  	//window.alert($(this).attr("src"));
  	//$(this).attr("src");
  	
  });
  
    $("#menu .menuBtn").mouseout(function () { 
    
  	var menuId = $(this).parents("li:first").attr("id");
  	menuNr = menuId.substring(8, menuId.length);
    
    if (menuNr != currentPage) {
   	  fileUrl = $(this).attr("src");
    hoverUrl = fileUrl.substring(0,fileUrl.lastIndexOf('-active.gif'))+".gif";
    $(this).attr("src", hoverUrl);
}
  });
  
  
  
  
  
  
  
  
  
      
  $("#mainMenu .menuBtn").mouseover(function () { 
  		
  	
  	var menuId = $(this).parents("li:first").attr("id");
  	menuNr = menuId.substring(12, menuId.length);
  	//window.alert(currentMode);
    if (menuNr != currentMode) {

  	  	fileUrl = $(this).attr("src");
   	 	hoverUrl = fileUrl.substring(0,fileUrl.lastIndexOf('.gif'))+"-active.gif";
    	$(this).attr("src", hoverUrl);
    	}
  });
  
  
  
    $("#mainMenu .menuBtn").mouseout(function () { 
  		
  	
  	var menuId = $(this).parents("li:first").attr("id");
  	menuNr = menuId.substring(12, menuId.length);
  	//window.alert(currentMode);
    if (menuNr != currentMode) {

  	  	fileUrl = $(this).attr("src");
   	 	 hoverUrl = fileUrl.substring(0,fileUrl.lastIndexOf('-active.gif'))+".gif";
    	$(this).attr("src", hoverUrl);
    	}
    	
   
  });


    	
    
		
});

