// Initialize menus

var primaryNav;

Spry.Utils.addLoadListener(function()
{
	primaryNav = new Spry.Widget.MenuBar("primaryNav");
});

// Set up navigation highlighting
$(document).ready(function(){
	//set up path variable for nav highlighting
	var path = location.pathname, lastChar;
	lastChar = path.charAt(path.length - 1);
	if (lastChar === "/")
	{
		path = path + "index.html";
	}
	
	// Highlight primary nav items
	if (path.indexOf("/about/") != -1)
	{
		$("a#pnavAbout").addClass("highlight");
	}
	else if (path.indexOf("/methodology/") != -1)
	{
		$("a#pnavMethodology").addClass("highlight");
	}
	else if (path.indexOf("/order/") != -1)
	{
		$("a#pnavOrder").addClass("highlight");
	}
	//Equal heights for content area and sidebar
	$(".sameHeight").equalHeights();
			
	// Highlight current page
	$("#secondaryNav li a[href=" + path + "]").addClass("highlight");
	
	//Open external links in a new window
	$("a[href^='http']").click(function(){
		window.open(this.href);
		return false;
	});
	
	//Open PDFs in a new window
	$("a[href*=.pdf]").click(function(){
		window.open(this.href);
		return false;
	});
	// Lightbox for Disclaimer
	$("a#legal").nyroModal({
		width: 600, // default Width If null, will be calculate automatically
		height: 400, // default Height If null, will be calculate automatically
		minWidth: 600, // Minimum width
		minHeight: 400, // Minimum height
		resizable: false
	});
});


