
function CopyShippingInfo()
{

	if (document.form1.CopyShipping.checked==true)
	{

		document.forms["form1"].elements["TxtShippingFirstName"].value=document.forms["form1"].elements["TxtBillingFirstName"].value;
		document.forms["form1"].elements["TxtShippingLastName"].value=document.forms["form1"].elements["TxtBillingLastName"].value;
		document.forms["form1"].elements["TxtShippingCompany"].value=document.forms["form1"].elements["TxtBillingCompany"].value;
		document.forms["form1"].elements["TxtShippingAddress1"].value=document.forms["form1"].elements["TxtBillingAddress1"].value;
		document.forms["form1"].elements["TxtShippingAddress2"].value=document.forms["form1"].elements["TxtBillingAddress2"].value;
		document.forms["form1"].elements["TxtShippingCity"].value=document.forms["form1"].elements["TxtBillingCity"].value;
		document.forms["form1"].elements["TxtShippingZip"].value=document.forms["form1"].elements["TxtBillingZip"].value;
		document.forms["form1"].elements["ShippingPhoneTxt"].value=document.forms["form1"].elements["BillingPhoneTxt"].value;
		document.forms["form1"].elements["TxtShippingState"].value=document.forms["form1"].elements["TxtBillingState"].value;
	}

	if (document.form1.CopyShipping.checked==false)
	{
		document.forms["form1"].elements["TxtShippingFirstName"].value="";
		document.forms["form1"].elements["TxtShippingLastName"].value="";
		document.forms["form1"].elements["TxtShippingCompany"].value="";
		document.forms["form1"].elements["TxtShippingAddress1"].value="";
		document.forms["form1"].elements["TxtShippingAddress2"].value="";
		document.forms["form1"].elements["TxtShippingCity"].value="";
		document.forms["form1"].elements["TxtShippingState"].value="";
		document.forms["form1"].elements["TxtShippingZip"].value="";
		document.forms["form1"].elements["ShippingPhoneTxt"].value="";
	}



	



}

function SameInfo()
{
	if (document.form1.CopyShipping.checked==true)
	{
		document.forms["form1"].elements["TxtShippingFirstName"].value=document.forms["form1"].elements["TxtBillingFirstName"].value;
		document.forms["form1"].elements["TxtShippingLastName"].value=document.forms["form1"].elements["TxtBillingLastName"].value;
		document.forms["form1"].elements["TxtShippingCompany"].value=document.forms["form1"].elements["TxtBillingCompany"].value;
		document.forms["form1"].elements["TxtShippingAddress1"].value=document.forms["form1"].elements["TxtBillingAddress1"].value;
		document.forms["form1"].elements["TxtShippingAddress2"].value=document.forms["form1"].elements["TxtBillingAddress2"].value;
		document.forms["form1"].elements["TxtShippingCity"].value=document.forms["form1"].elements["TxtBillingCity"].value;
		document.forms["form1"].elements["TxtShippingZip"].value=document.forms["form1"].elements["TxtBillingZip"].value;
		document.forms["form1"].elements["ShippingPhoneA"].value=document.forms["form1"].elements["PhoneA"].value;
		document.forms["form1"].elements["ShippingPhoneB"].value=document.forms["form1"].elements["PhoneB"].value;
		document.forms["form1"].elements["ShippingPhoneC"].value=document.forms["form1"].elements["PhoneC"].value;
		document.forms["form1"].elements["ShippingPhoneX"].value=document.forms["form1"].elements["PhoneX"].value;
		document.forms["form1"].elements["ShippingStateList"].value=document.forms["form1"].elements["TxtBillingStateList"].value;
	}
}

function CheckStateTax()
{

	var s = document.getElementById("ShippingCostTxt");
	var x = document.getElementById("TaxCalc");	
	var y = document.getElementById("SubTotalTxt");
	var z = document.getElementById("TaxInc");
	var TaxAmount="8.75";
	var NonTaxable = document.forms["form1"].elements["NonTaxableAmount"].value;
	var SubTotal = y.innerHTML.replace(/\,/g,'');
    var BillingState = document.forms["form1"].elements["TxtBillingState"].value;

	
	
	if ( (BillingState=="CA") || (BillingState=="ca") ||  (BillingState=="california") )
	{
	
	

		if ((SubTotal - NonTaxable )>0)
			alert("An "+TaxAmount+"% tax amount will be automatically added to your total if ordering from 'CA'");
		
		x.innerHTML=TaxAmount;
	}
	else	
		x.innerHTML="0.00";

	
	z.innerHTML=(x.innerHTML.replace(/\,/g,'') * (   (SubTotal - NonTaxable )/100)).toFixed(2)	;
	document.getElementById("TotalTxt").innerHTML=((y.innerHTML.replace(/\,/g,'')-0)+(s.innerHTML.replace(/\,/g,'')-0)+(z.innerHTML.replace(/\,/g,'')-0)).toFixed(2);
	

}
//ALL PULLED OUT FROM VIEWCART.ASPX
   
    function CheckInput(sText)
    {
		var ValidChars = "0123456789";
		var IsNumber=true;
		var Char;
		
		 for (i = 0; i < sText.value.length && IsNumber == true; i++) 
		  { 
			Char = sText.value.charAt(i); 
			if (ValidChars.indexOf(Char) == -1) 
			{
				IsNumber = false;
			}
		}

		
	if (IsNumber==false)
	{
		alert("Input must be a number");
		sText.value=0;
	}
	
    }
    
    function CheckInput2(sText)
    {
    
		if (sText.value.length==0)
			sText.value=0;
	
    
    }
    
	//This function updates the cart according to the method that is called.
    function CheckoutProc(method)
    {
		
         document.getElementById("CartForm").action="UpdateCart.aspx?m="+method;
         document.getElementById("CartForm").submit();
    }
    
    
    function CalculateShipping(ShippingID)
    {
	
      	document.getElementById("ShippingCostTxt").innerHTML=ShippingArray[ShippingID].toFixed(2);

      	var ShippingFixed =ShippingArray[ShippingID];

      	var TotalCostFixed = document.getElementById("SubTotalTxt").innerHTML;
      
      	var Total=0;
        
		Total=parseFloat(CountryShippingFixed/1)+parseFloat(TotalCostFixed/1)+parseFloat(ShippingFixed/1);
		
		document.getElementById("TotalTxt").innerHTML=Total.toFixed(2);	
    }

