
function openWindow(url){
 	window.open (url,"openWindow","width=800,height=420,location=0,menubar=1,resizable=1,scrollbars=1,status=1,titlebar=1,toolbar=0,screenX=100,left=100,screenY=150,top=150");
}

function openLargeWindow(url){
 	window.open (url,"openWindow","width=770,height=550,location=0 ,menubar=1,resizable=1,scrollbars=1,status=1,titlebar=1,toolbar=0,screenX=50,left=50,screenY=20,top=20");
}

function removeItem(item,itemExtCost,itemWeight,itemCost){

	var submitForm = confirm("You are about to remove this item from the cart\n\nClick 'OK' if this is what you want to do.");
	if (submitForm){
		document.myForm.item.value = item;
		document.myForm.subAction.value = 'removeItem';
		document.myForm.extCost.value = itemExtCost;
		document.myForm.itemWeight.value = itemWeight;
		document.myForm.itemCost.value = itemCost;
		document.myForm.submit();
	}
}

function addItem(){
	if (isNumeric(document.myForm.quantity.value) && isNotBlank(document.myForm.products.value)){ 
		document.myForm.subAction.value = 'addItem';
		document.myForm.submit();
	}else{
		alert("Please select a Product and enter a Number in the Quantity field");
	}
}

function emptyCart(type){
	var submitForm = confirm("You are about to remove all the items from your shopping cart.\n\nClick 'OK' if this is what you want to do.");
	if (submitForm){
		location.href='orderForm.php?type=' + type;
	}
}

function cashOut(action){
	
	// make sure they haven't forgotten to enter a tracking number
	if (action == "updateAndEmail"){
		if (!document.myForm.trackingNumber.value){
    			var noTN = confirm("You are about to Update and Email this order without a Tracking Number.\n\nClick 'OK' if this is what you want to do.");
			if (!noTN){
				return;
			}
		}
	}

	document.myForm.action.value = action;
	document.myForm.subAction.value = '';
	
	// validate form...
	var message = validateForm();
	if (message){
		alert("NOTE: The following required fields are missing...\n\n" + message);
		return;
	}
	
	// validate postal/zip code...
	var zipCode = /(^\d{5}\b)|(^\d{5}-\d{4}\b)/;
	var postalCode = /(^\D\d\D\d\D\d)|((^\D\d\D-\d\D\d))|((^\D\d\D\s\d\D\d))/;
	if (document.myForm.country.value=='Canada'){
		var re = new RegExp(postalCode);
		if (!document.myForm.zipPostal.value.match(re)) {
	    		alert('Format for Postal Code is incorrect\n\n(Correct Format: A3A 3A3)');
	    		return;
		}
	}else{
		if (document.myForm.country.value=='USA'){
			var re = new RegExp(zipCode);
			if (!document.myForm.zipPostal.value.match(re)) {
		    		alert('Format for Zip Code is incorrect\n\n(Correct Format: 12345 or 12345-1234)');
		    		return;
		    	}
		}
	}

	if (document.myForm.submitHit.value == 'yes'){
		return;
	}
	document.myForm.submitHit.value = 'yes';

	
	if (action == 'cashOut'){
		var submitForm = confirm("You are about to submit your order (as it appears in the shopping cart)\n\nClick 'OK' if this is what you want to do.");
		if (submitForm){
			document.myForm.submitOrder.value = "Please Wait...";
			document.myForm.submit();
		}
	}else{
		// set action to update or updateAndEmail...
		document.myForm.submit();
	}
}

function checkForClient(){
	document.myForm.subAction.value = 'checkForClient';
	document.myForm.submit();
}

function isNumeric(val){
	return(parseFloat(val,10)==val);
}

function isNotBlank(val){
	if (val){
		return true;
	}else{
		return false;
	}
}

function validateForm(type){
	var message ='';
	
	// check required select boxes...
	var ReqSelFields = new Array();
	var ReqSelFieldsDesc = new Array();
	var selLeng = ReqSelFields.length;
	for(var s=0; s< selLeng; s++){
		var selField2check = "document.myForm." + ReqSelFields[s] + ".options[document.myForm." + ReqSelFields[s] + ".selectedIndex].value";
		if (!(eval(selField2check))){
			message = message + ReqSelFieldsDesc[s] + "\n";
		}
	}
	
	// check required Text fileds...
	if (document.myForm.type.value=='pp'){
		var ReqTextFields = new Array("productList");
		var ReqTextFieldsDesc = new Array("Products");
	}else{
		if (document.myForm.country.value!='USA' && document.myForm.country.value!='Canada'){
			// state/prov optional
			var ReqTextFields = new Array("emailAddress","name","address","city","country","zipPostal","productList");
			var ReqTextFieldsDesc = new Array("Email Address","Name","Street Name and Number","City","Country","ZipPostal","Products");
		}else{
			var ReqTextFields = new Array("emailAddress","name","address","city","stateProvince","country","zipPostal","productList");
			var ReqTextFieldsDesc = new Array("Email Address","Name","Street Name and Number","City","StateProvince","Country","ZipPostal","Products");
		}
	}
	var textLeng = ReqTextFields.length;
	for(var t=0; t< textLeng; t++){
		var textField2check = "document.myForm." + ReqTextFields[t] + ".value";
		if ((eval(textField2check)) == ""){
			message = message + ReqTextFieldsDesc[t] + "\n";
		}
	}
	
	// check required radio buttons...
	var ReqRadioFields = new Array();
	var ReqRadioFieldsDesc = new Array();
	var radioLeng = ReqRadioFields.length;
	for(var r=0; r< radioLeng; r++){
		var i;
		var flag = 0;
		var radioField2check = "document.myForm." + ReqRadioFields[r];
		var radioField2checkLen = eval(radioField2check + ".length");
		for( i=0; i < radioField2checkLen; i++){
			var r2check = eval(radioField2check + "[" + i + "]" + ".checked");
			if(r2check){
				flag = 1;
			}
		}
		if (flag == 0){
			message = message + ReqRadioFieldsDesc[r] + "\n";
		}
	}
	
	// return message to calling function...
	return message;
}


// capture enter key and submit form...
function NNKeyCap(thisOne){
    if (thisOne.which == 13){
    	cashOut('updateAndEmail');
    }
}

function IEKeyCap(){
    if (window.event.keyCode == 13){
    	cashOut('updateAndEmail');
    }
}

// this gets loaded into RAM
if (navigator.appName == 'Netscape') {
	window.captureEvents(Event.KEYPRESS);
	window.onKeyPress = NNKeyCap;
}

function submitReturns(action){
	document.myForm.action.value = action;
	document.myForm.subAction.value = '';
	
	var message='';
	
	// check required select boxes...
	var ReqSelFields = new Array("returnedReason");
	var ReqSelFieldsDesc = new Array("Reason For Return");
	var selLeng = ReqSelFields.length;
	for(var s=0; s< selLeng; s++){
		var selField2check = "document.myForm." + ReqSelFields[s] + ".options[document.myForm." + ReqSelFields[s] + ".selectedIndex].value";
		if (!(eval(selField2check))){
			message = message + ReqSelFieldsDesc[s] + "\n";
		}
	}
	
	// check required Text fileds...
	var ReqTextFields = new Array("emailAddress","name","address","city","stateProvince","country","zipPostal","productList","orderID");
	var ReqTextFieldsDesc = new Array("Email Address","Name","Street Name and Number","City","StateProvince","Country","ZipPostal","Products","Order ID");

	var textLeng = ReqTextFields.length;
	for(var t=0; t< textLeng; t++){
		var textField2check = "document.myForm." + ReqTextFields[t] + ".value";
		if ((eval(textField2check)) == ""){
			message = message + ReqTextFieldsDesc[t] + "\n";
		}
	}

	if (message){
		alert("NOTE: The following required fields are missing...\n\n" + message);
		return;
	}
	
	// validate postal/zip code...
	var zipCode = /(^\d{5}\b)|(^\d{5}-\d{4}\b)/;
	var postalCode = /(^\D\d\D\d\D\d)|((^\D\d\D-\d\D\d))|((^\D\d\D\s\d\D\d))/;
	if (document.myForm.country.value=='Canada'){
		var re = new RegExp(postalCode);
		if (!document.myForm.zipPostal.value.match(re)) {
	    		alert('Format for Postal Code is incorrect\n\n(Correct Format: A3A 3A3)');
	    		return;
		}
	}else{
		var re = new RegExp(zipCode);
		if (!document.myForm.zipPostal.value.match(re)) {
	    		alert('Format for Zip Code is incorrect\n\n(Correct Format: 12345 or 12345-1234)');
	    		return;
	    	}
	}
	
	var submitForm = confirm("This will submit your return form.\n\nClick 'OK' if this is what you want to do.");
	if (submitForm){
		document.myForm.submit();
	}
}

function emptyBox(){
	var submitForm = confirm("You are about to remove all the items from your return box.\n\nClick 'OK' if this is what you want to do.");
	if (submitForm){
		location.href='returnForm.php';
	}
}

function changeWeight(func){
	var num1=new Number(document.myForm.weightToAdd.value);
	var num2=new Number(50);
	if (func == 'add'){
		document.myForm.weightToAdd.value = (num1 + 50);
	}
	if (func == 'subtract'){
		document.myForm.weightToAdd.value = (document.myForm.weightToAdd.value - 50);
	}
}


<!--popunder code-->
var popunder=new Array();
popunder[0]=""
//popunder[1]="http://.com"

var width = '550'; 
var height = '200';

var p = 'scrollbars=no,resizable=no,toolbar=no,' + //these are obvious variables. set "yes" or "no".
'menubar=no,status=no,location=no,left=85,top=20,height=' +  //yes/no, & the screen location
height + ',width=' + width;

// Load new PopUnder only once per browser session? (0=no, 1=yes)
// Putting 0 will cause the Popunder to load every time page is loaded
// Specifying 1 will cause it to load only once per session
var one_time=1

function B_get_cookie(Name) {
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    if (offset != -1) { // if the cookie exists
      offset += search.length
      end = document.cookie.indexOf(";", offset); // set the index of beginning value
      
    if (end == -1) // set the index of the end of cookie value
         end = document.cookie.length;
         returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}

function loadornot(){
	if (B_get_cookie('popunder')==''){
		load_pop_power()
	document.cookie="popunder=yes"
	}
}

function load_pop_power(){
	//win2=window.open(popunder[Math.floor(Math.random()*(popunder.length))],"bw",p)
	//win2.blur()
	//window.focus()
}

if (one_time==0){
	load_pop_power();
}else{
	loadornot();
}
<!--end of popunder code-->


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

