function UPSpick(thecost,themethod)
{	
			upsmethod=themethod;
			upscost=thecost;
			document.checkout.ups_method.value=(upsmethod);
			document.checkout.ups_cost.value=(upscost);
			

			xship=(document.checkout.ups_cost.value*100);
			xextra=(document.checkout.xExtraSubTotalx.value*100);
			xtotal=((document.checkout.xTotalx.value)*100);
			xtotal=xtotal+xship;
			xthis=(0.00*100)
			document.checkout.ship.value="$"+(price_format((xship+xthis)/100));
			document.checkout.xshipx.value=(price_format((xship+xthis)/100));

			document.checkout.totalcharge.value="$"+(price_format((xtotal+xthis+xextra)/100));
			alert("Your shipping has been recalculated!");
}


function miniPop(url)
{
sealWin=window.open
(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=420,height=500');
self.name = "mainWin"; 
}

function validateForm(form)
{
// Check that required fields are not left blank

	 if (form.card_number.value == "")
	  {
        alert("Please enter a valid credit card number.");
		form.card_number.focus();
        form.card_number.select();
        return false;
      }
	 else if (form.cardcode.value == "")
	  {
        alert("Please enter a valid CVV2 security card code.");
		form.cardcode.focus();
        form.cardcode.select();
        return false;
      }
	 else if (form.cardname.value == "")
	  {
        alert("Please enter a valid card holders name.");
		form.cardname.focus();
        form.cardname.select();
        return false;
      }
	 else if (form.cardphone.value == "")
	  {
        alert("Please enter a valid card holders telephone number.");
		form.cardphone.focus();
        form.cardphone.select();
        return false;
      }

	 else if (form.cardemail.value == "")
	  {
        alert("Please enter a valid card holders email address.");
		form.cardemail.focus();
        form.cardemail.select();
        return false;
      }
	 else if ( noAtSign (form.cardemail.value))
	  {
        alert("Please use an email address that contains an '@' character.");
		form.cardemail.focus();
        form.cardemail.select();
        return false;
      }
	 else if ( nothingBeforeAt (form.cardemail.value))
	  {
        alert("Please use an email address that contains at least 1 chracter before the '@' character.");
		form.cardemail.focus();
        form.cardemail.select();
        return false;
      }
	 else if ( noValidPeriod (form.cardemail.value))
	  {
        alert("Please use an email address that contains a period ('.') character.");
		form.cardemail.focus();
        form.cardemail.select();
        return false;
      }
	 else if ( noValidSuffix (form.cardemail.value))
	  {
        alert("Please use an email address that contains a two or three character suffix.");
		form.cardemail.focus();
        form.cardemail.select();
        return false;
      }            
	 else if (form.cardaddress.value == "")
	  {
        alert("Please enter a valid billing address.");
		form.cardaddress.focus();
        form.cardaddress.select();
        return false;
      }
	 else if (form.cardcity.value == "")
	  {
        alert("Please enter a valid billing city.");
		form.cardcity.focus();
        form.cardcity.select();
        return false;
      }
	 else if (form.cardzip.value == "")
	  {
        alert("Please enter a valid billing zip code.");
		form.cardzip.focus();
        form.cardzip.select();
        return false;
      }
	 else if (form.shipname.value == "")
	  {
        alert("Please enter a valid ship to name.");
		form.shipname.focus();
        form.shipname.select();
        return false;
      }
	 else if (form.shipaddress.value == "")
	  {
        alert("Please enter a valid shipping address.");
		form.shipaddress.focus();
        form.shipaddress.select();
        return false;
      }
	 else if (form.shipcity.value == "")
	  {
        alert("Please enter a valid shipping city.");
		form.shipcity.focus();
        form.shipcity.select();
        return false;
      }
	 else if (form.shipzip.value == "")
	  {
        alert("Please enter a valid shipping zip code.");
		form.shipzip.focus();
        form.shipzip.select();
        return false;
      }
	 else if (form.shipphone.value == "")
	  {
        alert("Please enter a valid ship to telephone number.");
		form.shipphone.focus();
        form.shipphone.select();
        return false;
      }

	 else if (form.shipemail.value == "")
	  {
        alert("Please enter a valid ship to email address.");
		form.shipemail.focus();
        form.shipemail.select();
        return false;
      }
	 else if ( noAtSign (form.shipemail.value))
	  {
        alert("Please use an email address that contains an '@' character.");
		form.shipemail.focus();
        form.shipemail.select();
        return false;
      }
	 else if ( nothingBeforeAt (form.shipemail.value))
	  {
        alert("Please use an email address that contains at least 1 chracter before the '@' character.");
		form.shipemail.focus();
        form.shipemail.select();
        return false;
      }
	 else if ( noValidPeriod (form.shipemail.value))
	  {
        alert("Please use an email address that contains a period ('.') character.");
		form.shipemail.focus();
        form.shipemail.select();
        return false;
      }
	 else if ( noValidSuffix (form.shipemail.value))
	  {
        alert("Please use an email address that contains a two or three character suffix.");
		form.shipemail.focus();
        form.shipemail.select();
        return false;
      }       

       // Cornel added this.. validation for the password
      else if (form.accountPassword.value == "")
	  {
	    
        alert("Please enter a valid password for your account.");
		form.accountPassword.focus();
        form.accountPassword.select();
        return false;
      }    
      //end of Cornel's code      
        return true;
}      

function noAtSign ( address ) {
    // CHECK THAT THERE IS AN '@' CHARACTER IN THE STRING
    if ( address.indexOf ( '@', 0 ) == -1 ) {
        return ( true )
    } else {
        return ( false );
    }
}

function nothingBeforeAt ( address ) {
    // CHECK THERE IS AT LEAST ONE CHARACTER BEFORE THE '@' CHARACTER
    if ( address.indexOf ( '@', 0 ) < 1 ) {
        return ( true )
    } else {
        return ( false );
    }
}

function noValidPeriod ( address ) {
    // IF EMAIL ADDRESS IN FORM 'user@[255,255,255,0]', THEN WE ARE NOT INTERESTED
    if ( address.indexOf ( '@', 0 ) > 1 && address.charAt ( address.length - 1 ) == ']' )
        return ( false );

    // CHECK THAT THERE IS AT LEAST ONE PERIOD IN THE STRING
    if ( address.indexOf ( '.', 0 ) == -1 )
        return ( true );

    return ( false );
}

function noValidSuffix ( address ) {
    // IF EMAIL ADDRESS IN FORM 'user@[255,255,255,0]', THEN WE ARE NOT INTERESTED
    if ( address.indexOf ( '@', 0 ) > 1 && address.charAt ( address.length - 1 ) == ']' )
        return ( false );

    // CHECK THAT THERE IS A TWO OR THREE CHARACTER SUFFIX AFTER THE LAST PERIOD
    var len = address.length;
    var pos = address.lastIndexOf ( '.', len - 1 ) + 1;
    if ( ( len - pos ) < 2 || ( len - pos ) > 3 ) {
        return ( true );
    } else {
        return ( false );
    }
}

      

function writeTax()
{	
			document.write("<table>");
			document.write("<input type=text name=tax size=10 value=0 DISABLED READONLY > ");
			document.write("</table>");
}

function writeTotal()
{	
			document.write("<table>");
			document.write("<input type=text name=total size=10 value="+document.checkout.SubTotal.value+" DISABLED READONLY > ");
			//document.write(document.checkout.SubTotal.value);
			document.write("</table>");
}


function writeTotalCharge()
{	
			xtotal=(document.checkout.xTotalx.value*100)
			xship=(document.checkout.xshipx.value*100)
			xextra=(document.checkout.xExtraSubTotalx.value*100)

			document.write("<table>");
			document.write("<input type=text name=totalcharge size=10 value="+"$"+(price_format((xtotal+xship+xextra)/100))+" DISABLED READONLY > ");
			document.write("</table>");
}

function TaxYes()
{	
	 if (document.checkout.xTaxx.value == "0")
		{

			xxtotal=(document.checkout.xTotalx.value*100)
			xxship=(document.checkout.xshipx.value*100)
			xxextra=(document.checkout.xExtraSubTotalx.value*100)
			xxtaxable=((xxtotal-xxship)/100)
			xxtaxable=((xxtotal)/100)
			xxtaxable=((xxtotal+xxship)/100)

			xtax=((document.checkout.xTotalx.value*8.25)/100)

			xtax=(document.checkout.Tax_Rate.value)

			xtax=((xxtaxable*xtax)/100)

			document.checkout.xTaxx.value=(price_format(xtax))
			document.checkout.tax.value="$"+(price_format(xtax))
			xtax=(document.checkout.xTaxx.value*100)
			xtotal=(document.checkout.xTotalx.value*100)

			document.checkout.total.value="$"+(price_format((xxtotal+xtax)/100));
			document.checkout.xTotalx.value=(price_format((xxtotal+xtax)/100));

			document.checkout.totalcharge.value="$"+(price_format((xxtotal+xtax+xxship+xxextra)/100));
		}
}


function TaxNo()
{	
	 if (document.checkout.tax.value != "0")
		{
			xtax=(document.checkout.xTaxx.value*100);
			xtotal=(document.checkout.xTotalx.value*100);
			xxship=(document.checkout.xshipx.value*100)	
			xxextra=(document.checkout.xExtraSubTotalx.value*100)		

			document.checkout.xTotalx.value=(price_format((xtotal-xtax)/100));
			document.checkout.total.value="$"+(price_format((xtotal-xtax)/100));

			document.checkout.totalcharge.value="$"+(price_format(((xtotal-xtax)+xxship+xxextra)/100));

			document.checkout.xTaxx.value=(0);
			document.checkout.tax.value=(0);
		}
}

function AutoAddress()
{	
	 if (document.checkout.xcheckboxx.value == 0)
		{
			document.checkout.shipname.value=(document.checkout.cardname.value);
			document.checkout.shipaddress.value=(document.checkout.cardaddress.value);
			document.checkout.shipcity.value=(document.checkout.cardcity.value);
			document.checkout.shipstate.value=(document.checkout.cardstate.value);
			document.checkout.shipzip.value=(document.checkout.cardzip.value);
			document.checkout.shipphone.value=(document.checkout.cardphone.value);							document.checkout.shipphone2.value=(document.checkout.cardphone2.value);
			document.checkout.shipemail.value=(document.checkout.cardemail.value);

			document.checkout.xcheckboxx.value=(1);
			//alert("Shipping Address Has been Updated To Match Cardholders!");
		}
	 else if (document.checkout.xcheckboxx.value == 1)
		{
			document.checkout.shipname.value=("");
			document.checkout.shipaddress.value=("");
			document.checkout.shipcity.value=("");
			document.checkout.shipstate.value=("");
			document.checkout.shipzip.value=("");
			document.checkout.shipphone.value=("");
			document.checkout.shipemail.value=("");

			document.checkout.xcheckboxx.value=(0);
			//alert("Shipping Address Has Been Cleared!");
		}
}

function AutoCarCharger()
{	
	 if (document.additemtocart.xcheckcarcharger.value == 0)
		{
			var xcarchargerprice=(9.95*100);
			var xdummyprice=(document.additemtocart.pricedummy.value*100);
			var xnewcost = ((xdummyprice+xcarchargerprice)/100)
			document.additemtocart.xcheckcarcharger.value=(1);
			document.additemtocart.pricedummy.value=price_format(xnewcost);
			document.additemtocart.mycharger.value=" : Charger : ";
			//alert("Car Charger Added!");
		}
	 else if (document.additemtocart.xcheckcarcharger.value == 1)
		{
			var xcarchargerprice=(9.95*100);
			var xdummyprice=(document.additemtocart.pricedummy.value*100);
			var xnewcost = ((xdummyprice-xcarchargerprice)/100)
			document.additemtocart.xcheckcarcharger.value=(0);
			document.additemtocart.pricedummy.value=price_format(xnewcost);
			document.additemtocart.mycharger.value="";
			//alert("Car Charger Removed!");
		}
}

function AutoHolsterCase()
{	
	 if (document.additemtocart.xcheckholstercase.value == 0)
		{
			var xholstercaseprice=(9.95*100);
			var xdummyprice=(document.additemtocart.pricedummy.value*100);
			var xnewcost = ((xdummyprice+xholstercaseprice)/100)
			document.additemtocart.xcheckholstercase.value=(1);
			document.additemtocart.pricedummy.value=price_format(xnewcost);
			document.additemtocart.myholster.value=" : Holster : ";
			//alert("Car Charger Added!");
		}
	 else if (document.additemtocart.xcheckholstercase.value == 1)
		{
			var xholstercaseprice=(9.95*100);
			var xdummyprice=(document.additemtocart.pricedummy.value*100);
			var xnewcost = ((xdummyprice-xholstercaseprice)/100)
			document.additemtocart.xcheckholstercase.value=(0);
			document.additemtocart.pricedummy.value=price_format(xnewcost);
			document.additemtocart.myholster.value="";
			//alert("Car Charger Removed!");
		}
}


function AutoPouchCase()
{	
	 if (document.additemtocart.xcheckpouchcase.value == 0)
		{
			var xpouchcaseprice=(14.95*100);
			var xdummyprice=(document.additemtocart.pricedummy.value*100);
			var xnewcost = ((xdummyprice+xpouchcaseprice)/100)
			document.additemtocart.xcheckpouchcase.value=(1);
			document.additemtocart.pricedummy.value=price_format(xnewcost);
			document.additemtocart.mypouch.value=" : Pouch : ";
			//alert("Car Charger Added!");
		}
	 else if (document.additemtocart.xcheckpouchcase.value == 1)
		{
			var xpouchcaseprice=(14.95*100);
			var xdummyprice=(document.additemtocart.pricedummy.value*100);
			var xnewcost = ((xdummyprice-xpouchcaseprice)/100)
			document.additemtocart.xcheckpouchcase.value=(0);
			document.additemtocart.pricedummy.value=price_format(xnewcost);
			document.additemtocart.mypouch.value="";
			//alert("Car Charger Removed!");
		}
}


function AutoWarranty()
{	
	 if (document.additemtocart.xcheckwarranty.value == 0)
		{
			var xwarrantyprice=(49.95*100);
			var xdummyprice=(document.additemtocart.pricedummy.value*100);
			var xnewcost = ((xdummyprice+xwarrantyprice)/100)
			document.additemtocart.xcheckwarranty.value=(1);
			document.additemtocart.pricedummy.value=price_format(xnewcost);
			document.additemtocart.mywarranty.value=" : Warranty : ";
			//alert("Car Charger Added!");
		}
	 else if (document.additemtocart.xcheckwarranty.value == 1)
		{
			var xwarrantyprice=(49.95*100);
			var xdummyprice=(document.additemtocart.pricedummy.value*100);
			var xnewcost = ((xdummyprice-xwarrantyprice)/100)
			document.additemtocart.xcheckwarranty.value=(0);
			document.additemtocart.pricedummy.value=price_format(xnewcost);
			document.additemtocart.mywarranty.value="";
			//alert("Car Charger Removed!");
		}
}

function ExShip()
{	
mf=document.checkout.ShipMethod.selectedIndex;
zc=mf
	 if (mf== 0)
		{
			xtax=(document.checkout.xTaxx.value*100)
			xship=(document.checkout.Ship_Stand.value*100);
			xextra=(document.checkout.xExtraSubTotalx.value*100);
			xtotal=((document.checkout.xTotalx.value)*100);
			xtotal=xtotal+xship;
			xthis=(0.00*100)
			document.checkout.ship.value="$"+(price_format((xship+xthis)/100));
			document.checkout.xshipx.value=(price_format((xship+xthis)/100));

			document.checkout.totalcharge.value="$"+(price_format((xtotal+xthis+xextra)/100));
			alert("Your shipping has been recalculated to GROUND!");

		}
	 if (mf== 1)
		{
			xtax=(document.checkout.xTaxx.value*100)
			xship=(document.checkout.Ship_Stand.value*100);
			xextra=(document.checkout.xExtraSubTotalx.value*100);
			xtotal=((document.checkout.xTotalx.value)*100);
			xtotal=xtotal+xship;
			xthis=(12.00*100)
			document.checkout.ship.value="$"+(price_format((xship+xthis)/100));
			document.checkout.xshipx.value=(price_format((xship+xthis)/100));

			document.checkout.totalcharge.value="$"+(price_format((xtotal+xthis+xextra)/100));
			alert("Your shipping has been recalculated to GROUND to Hawaii or Alaska!");

		}
	 if (mf== 2)
		{
			xtax=(document.checkout.xTaxx.value*100)
			xship=(document.checkout.Ship_Stand2.value*100);
			xextra=(document.checkout.xExtraSubTotalx.value*100);
			xtotal=((document.checkout.xTotalx.value)*100);
			xtotal=xtotal+xship;
			xthis=(0.00*100)
			document.checkout.ship.value="$"+(price_format((xship+xthis)/100));
			document.checkout.xshipx.value=(price_format((xship+xthis)/100));

			document.checkout.totalcharge.value="$"+(price_format((xtotal+xthis+xextra)/100));
			alert("Your shipping has been recalculated to PREFERRED!");

		}
	 if (mf== 3)
		{
			xtax=(document.checkout.xTaxx.value*100)
			xship=(document.checkout.Ship_Stand3.value*100);
			xextra=(document.checkout.xExtraSubTotalx.value*100);
			xtotal=((document.checkout.xTotalx.value)*100);
			xtotal=xtotal+xship;
			xthis=(0.00*100)
			document.checkout.ship.value="$"+(price_format((xship+xthis)/100));
			document.checkout.xshipx.value=(price_format((xship+xthis)/100));

			document.checkout.totalcharge.value="$"+(price_format((xtotal+xthis+xextra)/100));
			alert("Your shipping has been recalculated to 2nd DAY!");

		}
	 if (mf== 4)
		{
			xtax=(document.checkout.xTaxx.value*100)
			xship=(document.checkout.Ship_Stand4.value*100);
			xextra=(document.checkout.xExtraSubTotalx.value*100);
			xtotal=((document.checkout.xTotalx.value)*100);
			xtotal=xtotal+xship;
			xthis=(0.00*100)
			document.checkout.ship.value="$"+(price_format((xship+xthis)/100));
			document.checkout.xshipx.value=(price_format((xship+xthis)/100));

			document.checkout.totalcharge.value="$"+(price_format((xtotal+xthis+xextra)/100));
			alert("Your shipping has been recalculated to NEXT DAY!");

		}
}

function ExShipCart()
{
mf=document.cartcheckout.ShipMethod.selectedIndex;
	if(mf==0)
	{
		var xshipping1=(document.cartcheckout.shipping1.value*100);
		var xxsubtotalx=(document.cartcheckout.xsubtotalx.value*100);
		var xnewsubtotal = ((xshipping1+xxsubtotalx)/100);
		document.cartcheckout.shippingdummy.value="$"+(price_format(xshipping1/100));
		document.cartcheckout.subtotaldummy.value="$"+(price_format(xnewsubtotal));
		document.cartsubmit.passshipmethod.value="Ground";
		document.cartsubmit.passshipcost.value="$"+(price_format(xshipping1/100));
		document.cartsubmit.passtotalcost.value="$"+(price_format(xnewsubtotal));
	}
	if(mf==1)
	{
		var xshipping2=(document.cartcheckout.shipping2.value*100);
		var xxsubtotalx=(document.cartcheckout.xsubtotalx.value*100);
		var xnewsubtotal = ((xshipping2+xxsubtotalx)/100);
		document.cartcheckout.shippingdummy.value="$"+(price_format(xshipping2/100));
		document.cartcheckout.subtotaldummy.value="$"+(price_format(xnewsubtotal));
		document.cartsubmit.passshipmethod.value="Ground To Hawaii or Alaska";
		document.cartsubmit.passshipcost.value="$"+(price_format(xshipping2/100));
		document.cartsubmit.passtotalcost.value="$"+(price_format(xnewsubtotal));
	}
	if(mf==2)
	{
		var xshipping3=(document.cartcheckout.shipping3.value*100);
		var xxsubtotalx=(document.cartcheckout.xsubtotalx.value*100);
		var xnewsubtotal = ((xshipping3+xxsubtotalx)/100);
		document.cartcheckout.shippingdummy.value="$"+(price_format(xshipping3/100));
		document.cartcheckout.subtotaldummy.value="$"+(price_format(xnewsubtotal));
		document.cartsubmit.passshipmethod.value="Preferred (up to 4 days)";						document.cartsubmit.passshipcost.value="$"+(price_format(xshipping3/100));
		document.cartsubmit.passtotalcost.value="$"+(price_format(xnewsubtotal));
	}
	if(mf==3)
	{
		var xshipping4=(document.cartcheckout.shipping4.value*100);
		var xxsubtotalx=(document.cartcheckout.xsubtotalx.value*100);
		var xnewsubtotal = ((xshipping4+xxsubtotalx)/100);
		document.cartcheckout.shippingdummy.value="$"+(price_format(xshipping4/100));
		document.cartcheckout.subtotaldummy.value="$"+(price_format(xnewsubtotal));
		document.cartsubmit.passshipmethod.value="2nd Day";
		document.cartsubmit.passshipcost.value="$"+(price_format(xshipping4/100));
		document.cartsubmit.passtotalcost.value="$"+(price_format(xnewsubtotal));
	}
	if(mf==4)
	{
		var xshipping5=(document.cartcheckout.shipping5.value*100);
		var xxsubtotalx=(document.cartcheckout.xsubtotalx.value*100);
		var xnewsubtotal = ((xshipping5+xxsubtotalx)/100);
		document.cartcheckout.shippingdummy.value="$"+(price_format(xshipping5/100));
		document.cartcheckout.subtotaldummy.value="$"+(price_format(xnewsubtotal));
		document.cartsubmit.passshipmethod.value="Next Day";
		document.cartsubmit.passshipcost.value="$"+(price_format(xshipping5/100));
		document.cartsubmit.passtotalcost.value="$"+(price_format(xnewsubtotal));
	}
}

function price_format(tmpprice){
// get rid of the extra digits behind "."
   dot = tmpprice.toString().indexOf(".");
   if(dot!=-1)
      tmpprice=tmpprice.toString().substr(0,dot+4);
   tmpprice=Math.round(tmpprice*100)/100;
// add "0" if necessary
   dot = tmpprice.toString().indexOf(".");
   if(dot ==-1)
      tmpprice=tmpprice.toString()+".00";
   else if((tmpprice.toString().length-dot)==2)
      tmpprice=tmpprice.toString()+"0";
   return tmpprice;
}

function verify_ccard(inNumber, type)
{// returns 0 if valid, positive number if invalid.

        total = 1*0;
        tmp = 1*0;

        number = "";

	mystr=type;

	type=mystr
	type=inNumber;

	if(type.substr(0,1) == "5")
	{
		document.checkout.my_card_type.value="MC";
		type="MC";
	}
	else if(type.substr(0,1) == "4")
	{
		document.checkout.my_card_type.value="VISA";
		type="VISA";
	} 
	else if(type.substr(0,1) == "3")
	{
		document.checkout.my_card_type.value="AMEX";
		type="AMEX";
	} 
	else if(type.substr(0,4) == "6011")
	{
		document.checkout.my_card_type.value="DISC";
		type="DISC";
	} 

        // make sure there are only numbers in the string...
        for(i = 0; i < inNumber.length; i++)
        {
		if(inNumber.charAt(i) >= "0" && inNumber.charAt(i) <= "9")
                {
                        number = number + inNumber.charAt(i);
                }
        }

        if(number.length < 13) return 10; // too short for anything

        first = "" + number.charAt(0);
        second = "" + number.charAt(1);
        third = "" + number.charAt(2);
        firstTwo = first + second;
        firstFour = firstTwo + third + number.charAt(3);

        if(type == "MC")
        {
                if(first != "5" || second < "1" || second > "5")
                        return 11;// invalid Mastercard prefix
                if(number.length != 16)
                        return 21;
        }
        else if(type == "VISA")
        {
                if(first != "4")
                        return 12;// invalid Visa prefix
                if(number.length != 13 && number.length != 16)
                        return 22;
        }
        else if(type == "AMEX")
        {
                if(first != "3" || (second != "4" && second != "7"))
                        return 13;// invalid American Express Prefix
                if(number.length != 15) 
                        return 23;
        }
        else if(type == "DISC")
        {
                        if(firstFour != "6011")
                                return 14;// invalid prefix.
                        if(number.length != 16)
                                return 24;
        }
        else if(type == "DCCB")
        {
                if(firstTwo != "36"
                        && firstTwo != "38"
                        && (firstTwo != "30" ||
                                (third < "0" || third > "5")))
                {
                        return 15;
                }
                if(number.length != 14)
                        return 25;
        }
        else if(type == "enRoute")
        {
                if(firstFour != "2014"
                        && firstFour != "2149")
                        return 16;// invalid enRoute card
                if(number.length != 15)
                        return 26;
		return 0; // no check sum calculation needed
        }
        else if(type == "JCB")
        {
                if(firstFour != "2131"
                        && firstFour != "1800"
                        && (first != "3") )
                        return 17;
                if(number.length != 16 && first =="3")
                        return 27;
                if(number.length != 15 && first != "3")
                        return 28;
        }
        // now check the credit card suffix and length vs. the type

    
         // do the check sum
        for(loc = number.length - 2; loc >= 0; loc -= 2)
        {
                total += 1 * number.charAt(loc +1);
                tmp = number.charAt(loc) * 2;
		if(tmp > 9) total += 1;
		total += tmp%10;
        }
	if(number.length % 2 > 0)
	total += 1 * number.charAt(0);


        return (total % 10);
}

function confirm()
{
        if((reason = verify_ccard(document.checkout.card_number.value, document.checkout.my_card_type.value)) == 0)
        {
                return true;
        }
        else
        {
                alert("Card Number Invalid.");
	document.checkout.card_number.focus();
	document.checkout.card_number.select();
	return false;
        }
}


function IsReserved(sText,form)
	{
   var ValidChars = " 1234567890!@#$%^&*()_+-=[]\{}|;:,./<>?`~:,.ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
   var IsNumber=true;
   var Char;
   for (i = 0; i < sText.length && IsNumber == true; i++) 
		{ 
		Char = sText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) 
			{
			alert("No quotes or single quotes please. The following characters are not allowed to be used.   '    and    ''   ");
			form.focus();
			form.select();
			return false;
			}
		}
   return IsNumber;
   alert("true.");
   }

function ExtraAlert()
	{
		alert("An extra charge has been added to your order to meet our minimum purchase requirement. To remove this charge, simply place 1 or more additional items into your cart.");
	        return false;
	}

function PopUpClose(ref) 
	{
		window.opener.location = ref
		window.opener.focus();
		window.close();
	}

function help_window(myurl,name,windowwidth,windowheight)
{
	var l = (screen.width-windowwidth)/2;
	var t = (screen.height-windowheight)/2;
	var hwinfound = 0;
	
	var props = 'scrollBars=yes,resizable=no,toolbar=no,menubar=no,location=no,directories=no,width='+windowwidth+',height='+windowheight+',screenX='+l+',screenY='+l+',left='+l+',top='+t;
	promopopup=window.open(myurl, name, props);
	promopopup.focus();
}
