// JavaScript Document

$(document).ready(function(){

	// Begin Menu
	$("ul#menu").find("ul").hide(); //Drop down the subnav on click
	$("ul#menu").find("ul li.open").parent().show(); //Drop down the subnav on click
	$("ul#menu").find("li.open").next().find("ul.sub_item").show(); //Drop down the subnav on click
	
	$("ul#menu li a").click(function(event) { //When trigger is clicked...
		
		if ($(this).parent().next().find("ul.sub_item").is(':hidden') ) {
			//Following events are applied to the subnav itself (moving subnav up and down)
			$("ul#menu").find("ul").hide();
			$(this).parent().next().find("ul.sub_item").slideDown('fast').show(); //Drop down the subnav on click
		}
	
		
		

		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() {
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});
	// End Menu

});