$(function() {
	$("#navWrap ul").superfish();
	$("#navWrap > ul > li:last").addClass("listItem");
	// Adds class to alternate nav li
	altItem("#navWrap > ul", "li");
	
	placeBkgd();
	$(window).resize(placeBkgd);

	// Add Class for h1+h2 and h1+h3 
	$("h1:has(+h2)").addClass("hasH2");
	$("h2:has(+h3)").addClass("hasH3");
});

function placeBkgd() {
	// Creates a min-height for #bodyWrapTwo
	if (
		( wHeight = $(window).height() ) == $(document).height() ||
		wHeight >= ( bHeight = $("body").height() ) ||
		wHeight == bHeight
	) {
		$("#bodyWrapTwo").height(wHeight);
	} else {
		$("#bodyWrapTwo").height($("#pageWrap").outerHeight(true));
	}
	// Place #bodyWrapOne background relavtive to #bodyWrapTwo placement
	// 15 is the position of #bodyWrapTwo which is 20% in the stylesheet
	// 172 is the left offset of the #bodyWrapTwo bkgd image
	$("#bodyWrapOne").css("background-position", 15*$(window).width()/100+205 + "px 0%").removeClass("noBkgd");
}

// p: jQuery selector statement for container of altItems; ie. "table"
// c: jQuery selector statement of altItems via .find() prototype; ie. "tr"
// e: Determines if altItems are odd or even; ie. ("odd" | "even") optional
// examples:  altItem("table", "tr"); altItem(".sidebar > ul", "li", "even");
function altItem(p,c,e) {
	e = (!e ? "odd" : e);
	$(p).each(function() {
		$(this).find(c).removeClass("altItem").filter(":visible:"+e).addClass("altItem");
	});
}