jQuery(document).ready(function(){
    jQuery('ul#main_menu li').hover(
        function() {
            jQuery(this).addClass("active");
            jQuery(this).find('ul').stop(true, true);
            jQuery(this).find('ul').slideDown();
        },
        function() {
            jQuery(this).removeClass("active");
            jQuery(this).find('ul').slideUp('fast');
        }
    );
});
 
jQuery(document).ready(function(){
 
	jQuery("ul.sub_menu").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav
	
	jQuery("ul#main_menu li span").click(function() { //When trigger is clicked...
		
		//Following events are applied to the subnav itself (moving subnav up and down)
		jQuery(this).parent().find("ul.sub_menu").slideDown('fast').show(); //Drop down the subnav on click
 
		jQuery(this).parent().hover(function() {
		}, function(){	
			jQuery(this).parent().find("ul.sub_menu").slideUp('fast'); //When the mouse hovers out of the subnav, move it back up
		});
 
		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() { 
			jQuery(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			jQuery(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});
 
});


function collapse_popup(block) {
	var block = document.getElementById(block);
	var feedback = document.getElementById('feedback');
	var scrollTop = document.documentElement.scrollTop;
	var windowHeight = document.documentElement.clientHeight;
	if (block.style.display != 'block') {
		feedback.style.display = 'none';
		block.style.display = 'block';
		//block.style.top = scrollTop + windowHeight/2 - block.offsetHeight/2 + 'px';
	} else {
		block.style.display = 'none';
	}
}