$(document).ready(function(){
	
	// hide sub-menus by default
	$("#nav ul").hide();
	
	// parse through each parent list item
	$.each($("#nav > li"), function(){
		
		// get child ul
		var parent_li = $(this);
		var child_ul = parent_li.find('ul');
		
		// set min width of ul to width of parent list items
		if (child_ul){
			child_ul.css('min-width', parent_li.width()+'px');
		}
		
		// setup show event
		parent_li.mouseenter(function(){
			child_ul.show();
		});
		
		// setup hide event
		parent_li.mouseleave(function(){
			child_ul.hide();
		});
	
	});
	
	// set popup functionality on links with class "opener"
	$("a.opener").click(function(){
		var href = $(this).attr('href');
		var day = new Date();
		var id = day.getTime();
		eval("page" + id + " = window.open(href, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=400,left = 383,top = 184');");
		return false;
	});
	
});