function checkTax(sState, nAmount, nTotal) {
	var oDdl = document.getElementById("ddlState");
	var oLabel = document.getElementById("taxLabel");
	var nTaxAmount = nAmount * nTotal;
	
	if (oDdl.options[oDdl.selectedIndex].value == sState) {
		oLabel.innerHTML = "$" + nTaxAmount.toFixed(2) + " sales tax will be added to your total .";
	} else {
		oLabel.innerHTML = "";	
	}
}

function disableImageClick(e) {
	var sMsg, dDate, nYear;
	var oSource;
	var aAllow = new Array("/links/");

	for (var n = 0; n < aAllow.length; n++) {
		if (window.location.href.indexOf(aAllow[n]) > -1) return true;
	}

	dDate = new Date();
	nYear = dDate.getFullYear();
	sMsg = "This image is copyright " + nYear;
	
	if (document.all)
		oSource = event.srcElement;
	else
		oSource = e.target;
	
	if (oSource.nodeName == "IMG") {
		alert(sMsg);
		return false;
	}
	return true;
}

function adjustExternalLinks() {
	if (document.getElementsByTagName) {
		var n, hyperlink;
		var linkArray = document.getElementsByTagName("a");

		for (n = 0; n < linkArray.length; n++) {
			hyperlink = linkArray[n];

			if (hyperlink.className == "external-link") {
				hyperlink.onclick = function () {window.open(this.href, "_blank", "width=640, height=480, scrollbars=yes, resizable=yes"); return false;};
			}
		}
	}
}

function popUp(sURL) {
	var oWin, sFeatures, sHTML;
	sFeatures = "width=640, height=480, scrollbars=yes";
	
	sHTML = "<html><head><title>Product Viewer</title>";
	sHTML += "<meta http-equiv='imagetoolbar' content='no'>";
	sHTML += "<script type='text/javascript' src='include/scripts.js'></script>";
	sHTML += "</head><body style='margin:0;padding:0'>";
	sHTML += "<img src='" + sURL + "' alt='Product Image'>";
	sHTML += "</body></html>";

	oWin = window.open("", "", sFeatures);
	oWin.document.write(sHTML);
}

function openWindow(sUrl, nWidth, nHeight) {
	var sFeatures = "width=" + nWidth + ", height=" + nHeight;
	
	window.open(sUrl, "_blank", sFeatures);
}

window.onload = adjustExternalLinks;
document.oncontextmenu = disableImageClick;