$(document).ready(function() {	
	// Submit the form when search link is clicked
	$("#search-button").click(function() {
		$("#search-form").submit();
	});
	
	$('.date-box').click(function() {
		window.location.href='/calendar';
	});
    
	$("ul.subnav").parent().addClass('dd-trigger'); //Only shows drop down trigger when js is enabled (Adds empty span tag after ul.subnav*)
	
	$(".dd-trigger").click(function(e) { //When trigger is clicked...
	
	if ($(this).parent().find("ul.subnav").is(':animated')) {
	  return false;
	}
	//Following events are applied to the subnav itself (moving subnav up and down)
	var dropDown = $(this).find("ul.subnav");
	
	dropDown.show().addClass('open-menu'); //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"
	  });
    
    $(document).bind('mouseup', function(e) {      
        $('.open-menu').hide().removeClass('open-menu');
    }); 

 });