if (self != top) {
    if (document.images)
        top.location.replace(window.location.href);
    else
        top.location.href = window.location.href;
}

function closeLayer() {
	var x = document.getElementsByTagName('div');
	for (var i=0;i<x.length;i++) {
		if (x[i].className == 'content')
			x[i].style.display = 'none';
	}
}

function closeLogoLayer() {
	var x = document.getElementsByTagName('div');
	for (var i=0;i<x.length;i++) {
		if (x[i].className == 'graphics')
			x[i].style.display = 'none';
	}
}

var t
function timedCartAlert() {
	t = setTimeout("closeCartAlert()",3500)
}

function stopTimer() {
	clearTimeout(t)
}

function closeCartAlert() {
	var x = document.getElementsByTagName('div');
	for (var i=0;i<x.length;i++) {
		if (x[i].className == 'itemlayer')
			x[i].style.display = 'none';
	}
}

startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}
window.onload=startList;

function toggleLayer(whichLayer) {
	if (document.getElementById) {
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":"block";
	}
	else if (document.all) {
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
	else if (document.layers) {
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
}

function toggleAll(itemname,state) {
   tmp = document.getElementsByTagName('div');
    for (i=0;i<tmp.length;i++) {
        if (tmp[i].className == itemname) tmp[i].style.display = state;
    }    
}

function setProdColor(whatcolor){
	document.forms[0].storeproductdetail_prodcolor.value = whatcolor;
}

function getRadioValue() {
	for (var i=0; i < document.getElementsByName("storeproductdetail:psize").length; i++) {
		if (document.getElementsByName("storeproductdetail:psize")[i].checked) {
		
			// Ok we found the size, now what
			var currPsize = document.getElementsByName("storeproductdetail:psize")[i].value
			var subPsize = parseFloat(currPsize.substr((currPsize.indexOf('-')+1), currPsize.length));
			
			 // Include quantity
			quantIndex = document.forms[0].storeproductdetail_quantity.selectedIndex;
			var currQuant = parseFloat(document.forms[0].storeproductdetail_quantity[quantIndex].value);
			
			// Now we need to see if they have picked any extra text - sheesh
			if (document.forms[0].storeproductdetail_slogotxt) {
				textIndex = document.forms[0].storeproductdetail_slogotxt.selectedIndex;
				var currText = document.forms[0].storeproductdetail_slogotxt[textIndex].value;
				var subText = parseFloat(currText.substr((currText.indexOf('-')+1), currText.length));
				alert(currQuant * (subPsize + subText));
				// Assign the extra text specific ouput
				document.getElementById("javaTotal").innerHTML = "<b>Price: " + formatCurrency(currQuant * (subPsize + subText)) + "</b>";
			}
			else {
			// Assign the normal output
			document.getElementById("javaTotal").innerHTML = "<b>Price: " + formatCurrency(currQuant * subPsize) + "</b>";
			}
     	}
	}
}
function formatCurrency(num) {
	num = num.toString().replace(/\$|\,/g,'');
		if (isNaN(num))
			num = "0";
			sign = (num == (num = Math.abs(num)));
			num = Math.floor(num*100+0.50000000001);
			cents = num%100;
			num = Math.floor(num/100).toString();
		if (cents < 10)
			cents = "0" + cents;
				for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
					num = num.substring(0,num.length-(4*i+3))+','+
					num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + '$' + num + '.' + cents);
}
function showLarge(largeImg) {
	showImage = window.open(largeImg, 'showImg', 'width=300,height=300,resizable=1,status=0,scrollbars=0,toolbar=0,menubar=0');
	showImage.focus()
}
function formPopUp(formpage, popname, xwidth, yheight) {
	showImage = window.open(formpage, popname, 'width=' + xwidth + ',height=' + yheight + ',resizable=1,status=0,scrollbars=1,toolbar=0,menubar=0');
	showImage.focus()
}
function spambot(mailbox, domain, name) {
	 if (name == null){
   name = mailbox + "@" + domain
   }
   document.write("<a href=\"mailto");
   document.write(":" + mailbox + "@");
   document.write(domain + "\">" + name + "<\/a>");
}
