$(document).ready(function()
{
	//slides the element with class "menu_body" when paragraph with class "menu_head" is clicked 
	$("#leftNav a.menu_head").click(function(event)
    {
		$(this).css({backgroundImage:""}).next("ul.menu_body").slideToggle(300).siblings("ul.menu_body").slideUp("slow");
		
		// check for submenu existance
		var childs = $(this).parent().children("*").length ;
        // if true prevent click event
        //alert($(this).parent().hasClass('on'));
		/*if(childs > 1 && ! $(this).parent().hasClass('on') ) {
            event.preventDefault();
        }*/
        
	});
	//slides the element with class "menu_body" when mouse is over the paragraph
	$("#secondpane a.menu_head").mouseover(function()
    {
	     $(this).css({backgroundImage:""}).next("ul.menu_body").slideDown(500).siblings("ul.menu_body").slideUp("slow");
	});
	
	// on window load look for selected submenu and display
	if($(".on").children("*").length > 1){
	    // displays the menu
	    $(".on ul.menu_body").slideToggle(300);
	    // get the current page
	    var selectedPage = window.location.href.split("/");
	    var arrayLength = selectedPage.length
	    var actualPage = new String (selectedPage[arrayLength-1]);
	    // aplply selected style to the selected item of the submenu
	    $(".on ul.menu_body li a[href$="+actualPage+"]").css("background","#005596 url(/images/icons/line.jpg) no-repeat scroll 27px 12px");
    
	}
	
	
	
});