$(function() {
	$('#navWrap ul').superfish();
	
	// Add Class for h1+h2
	$("h1:has(+h2)").addClass("hasH2");
	
	// Fixes rounded edges on #footerLinks
	//widthFix("#footerLinks");
	
	// Add alternating item styles to tables
	altItem("table.doStyle tbody","tr");
	
	// Add Javascript alert when redirecting to external site on Portable
	if(
		(d = document.domain) == "q-cardportable.mojoactive.local" ||
		d == "qcardportable.mojoactive.local" ||
		d == "q-cardportable.mojoactive.com" ||
		d == "q-cardportable.mojoactive.com"
	) {
		// All /qlab Links
		$("a[href*='/qlab']").click(function(){
			if( confirm("You will be redirected to Q-Card's main site.") ) {
				this.href = "http://www.q-card.com" + this.getAttribute("href");
				return true;
			} else {
				return false;
			}
		});
		// All www.q-card.com
		$("a[href*='www.q-card.com']").click(function(){
				return confirm("You will be redirected to Q-Card's main site.");
		});
	}
	
	// Add Javascript alert when redirecting to external site Entire Site
	$("a[href*='brushindustries.com']").click(function(){
		return confirm("You will be redirected to Brush Industries, Inc.");
	});
	
	// Run Testing Script while still testing
	//testingScripts()
});

function widthFix(c) {
	// this is use to compensated for ie6's miscalculation
	// of percent width and actual width
	if($.browser.version < 7.0 && $.browser.msie) {
		c = $(c);
		c.find(">.borderRight").css("margin-right", c.innerWidth()%2 != 0 ? "-1px" : "0px");
		c.find(">.borderBottom").css("margin-bottom", c.innerHeight()%2 != 0 ? "-1px" : "0px")
	}
}
function altItem(p,c,e) {
	e = (!e ? "odd" : e);
	$(p).each(function() {
		$(this).find(c).removeClass("altItem").filter(":visible:"+e).addClass("altItem");
	});
}

function testingScripts() {
	//temp to test alt tags
	$('img:not([alt])').css("border", "1px dashed blue").attr("title", "Need to Add Alt Text");
	
	//temporary indicator that there are links that havn't been finalized
	$("a").filter("[href='/err']").css("background-color", "#90ee90").attr("title", "Need to Add Location");
}