/* 
cart
~ onclick="function();return false"
*/
function roundoff(amount) {
	return (amount == Math.floor(amount)) ? amount + '.00' : ( (amount*10 == Math.floor(amount*10)) ? amount + '0' : amount);
}

function total(what,number) {
	var grandTotal = 0;
	for (var i=0;i<number;i++) {
		if (what.elements['price' + i + 'ea'].value == '')
			what.elements['price' + i + 'ea'].value = '0.00'; // fix for Opera.

		if (what.elements['price' + i + 'doz'].value == '')
			what.elements['price' + i + 'doz'].value = '0.00'; // fix for Opera.

		what.elements['subtotal' + i].value='$' + roundoff(Math.round(((what.elements['quantity' + i + 'ea'].value - 0) * (what.elements['price' + i + 'ea'].value - 0) + (what.elements['quantity' + i + 'doz'].value - 0) * (what.elements['price' + i + 'doz'].value - 0))*Math.pow(10,2))/Math.pow(10,2));
		
		subtotal=what.elements['subtotal' + i].value
		grandTotal += (((what.elements['price' + i + 'ea'].value - 0) * (what.elements['quantity' + i + 'ea'].value - 0)) + ((what.elements['price' + i + 'doz'].value - 0) * (what.elements['quantity' + i + 'doz'].value - 0)));
	}
	
	subtotal=roundoff(Math.round(subtotal*Math.pow(10,2))/Math.pow(10,2));
	what.grandTotal.value = '$' + roundoff(Math.round(grandTotal*Math.pow(10,2))/Math.pow(10,2));
}

/* 
flash requirements() 
~ onclick="function();return false"
*/
function review(url) {
    newwindow = window.open(url,'review','"toolbar=no,address=no,left=150,top=150,status=no,width=500,height=520,scrollbars=yes,resizable=yes"')
}
function popup(url) {
    newwindow = window.open(url,'popup','"toolbar=no,address=no,left=150,top=150,status=no,width=500,height=520,scrollbars=yes,resizable=yes"')
}
function privacy() {
    newwindow = window.open('privacy.php','privacy','"toolbar=no,address=no,left=150,top=150,status=no,width=500,height=520,scrollbars=yes,resizable=yes"')
}
function terms() {
    newwindow = window.open('terms.php','terms','"toolbar=no,address=no,left=130,top=130,status=no,width=500,height=520,scrollbars=yes,resizable=yes"')
}
function subscribe() {
    newwindow = window.open('subscribe.php','subscribe','"toolbar=no,address=no,left=100,top=100,status=no,width=500,height=520,scrollbars=yes,resizable=yes"')
}

/* 
openwindow 
~ onclick="openwindow(this.href,'name','"toolbar=no,address=no,left=10,top=10,status=no,width=600,height=480,scrollbars=1,resizable=yes");return false"
*/
function openwindow(url,name,options) {
    newwindow = window.open(url,name,options)
}

/* 
NewWindow 
~ onclick="NewWindow(this.href,'name','300','400','yes');return false"
*/
var win= null;
function NewWindow(mypage,myname,w,h,scroll){
  var winl = (screen.width-getbrowserwidth())/2;
  var wint = (screen.height-getbrowserheight())/2;
  var settings  ='height='+getbrowserheight()+',';
      settings +='width='+getbrowserwidth()+',';
      settings +='top='+wint+',';
      settings +='left='+winl+',';
      settings +='scrollbars='+scroll+',';
      settings +='resizable=no';
  win=window.open(mypage,myname,settings);
  if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}

/* 
CenterPopup 
~ onclick="CenterPopup(this.href,'name','300','400','yes');return false"
*/
function CenterPopup(URL, popname, width, height, scrollbars) {

	// get center of browser window
	var X = getbrowserwidth()/2;
	var Y = getbrowserheight()/2;

	popup = window.open(URL, popname,
						'scrollbars=' + scrollbars + ',' +
						'width=' + width + ',' +
						'height=' + height + ',' +
						'top=' + ((Y - (height/2))) + ',' +
						'left=' + ((X - (width/2)))
						);

	popup.focus();
}



/* 
Misc 
*/
function loadinparent(url, closeSelf){
	self.opener.location = url;
	if(closeSelf) self.close();
	}

function displayError(formNode, validators){
 var errorHTML = "";
 for(var i=0;i<validators.length;i++){
  errorHTML += "<li>" + validators[i].message + "</li>";
 }
 document.getElementById("errorDisplay").style.display = "block";
 document.getElementById("errorDisplay").innerHTML = "<ul>" + errorHTML + "</ul>";
}

function getbrowserwidth() {
    	if (navigator.userAgent.indexOf("MSIE") > 0)	{
        		return(screen.width);
       	} else {
            	return(window.screen.width);
       	}
}

function getbrowserheight() {
	if (navigator.userAgent.indexOf("MSIE") > 0) {
		return(screen.height);
    } else {
		return(window.screen.height);
	}
}

/* 
suckerfish dropdown alist apart 
*/
var startList;
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", "");
   }
   }
  }
 }
}


