
function openBrWindowProd(theURL) 
{ 
  window.open(theURL,'','scrollbars=yes,resizable=yes,width=440,height=500');
}

var isNN = (navigator.appName.indexOf("Netscape")!=-1);

function autoTabContact(input,len,e)
{

				var keyCode = (isNN) ? e.which : e.keyCode; 
				var filter = (isNN) ? [0,8,9,16,17,18] : [0,8,9,16,17,18,37,38,39,40,46];
				if(input.value.length >= len && !containsElement(filter,keyCode)) {
					input.value = input.value.slice(0, len);
					input.form[(getIndex(input)+1) % input.form.length].focus();
					//input.form[(getIndex(input)+1) % input.form.length].select();
					return input;
}
}


function GetNext(CurrentField,NextField,NumberForNext)
{

	if (CurrentField.value.length==NumberForNext)
	NextField.focus();

}

function OpenBrWindow(theParams) 
{ 
  
x=window.open(theParams);
x.focus();
}

function OpenCustomBrWindow(theURL,theName,theParams) 
{ 
 x = window.open(theURL,theName,theParams);
x.focus();
}


			


				function autoTab(input,len, e) {
				SameInfo();
				var keyCode = (isNN) ? e.which : e.keyCode; 
				var filter = (isNN) ? [0,8,9,16,17,18] : [0,8,9,16,17,18,37,38,39,40,46];
				if(input.value.length >= len && !containsElement(filter,keyCode)) {
					input.value = input.value.slice(0, len);
					input.form[(getIndex(input)+1) % input.form.length].focus();
					//input.form[(getIndex(input)+1) % input.form.length].select();
					return input;
				}
			
				function containsElement(arr, ele) {
					var found = false, index = 0;
					while(!found && index < arr.length)
						if(arr[index] == ele)
							found = true;
						else
							index++;
							return found;
				}
				
				function getIndex(input) {
					var index = -1, i = 0, found = false;
					while (i < input.form.length && index == -1)
						if (input.form[i] == input)index = i;
							else i++;
							return index;
					}
					return true;
			}

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;
		document.forms["form1"].elements["ShippingPhoneTxt"].value=document.forms["form1"].elements["BillingPhoneTxt"].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["ShippingPhoneTxt"].value=document.forms["form1"].elements["BillingPhoneTxt"].value;
		document.forms["form1"].elements["TxtShippingState"].value=document.forms["form1"].elements["TxtBillingState"].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";


	

	if ((document.forms["form1"].elements["TxtBillingState"].value=="Ca") ||
	    (document.forms["form1"].elements["TxtBillingState"].value=="CA") || 
	    (document.forms["form1"].elements["TxtBillingState"].value=="cA") || 
	    (document.forms["form1"].elements["TxtBillingState"].value=="ca"))
	{

		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,'') * y.innerHTML.replace(/\,/g,'')/100).toFixed(2);
	


document.getElementById("TotalTxt").innerHTML=(y.innerHTML.replace(/\,/g,'')-0)+(s.innerHTML.replace(/\,/g,'')-0)+(z.innerHTML.replace(/\,/g,'')-0);
	
	

}

function limitText(limitField, limitCount, limitNum) {

	



	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.innerHTML  = limitNum - limitField.value.length;
	}



}
 

//ALL PULLED OUT FROM order_flexmyjoints.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,code)
    {
	if (code!='')
		 document.getElementById("CartForm").action="UpdateCart.aspx?code="+code+"&m="+method;
	else
		 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 CountryShippingFixed= document.getElementById("CountryCostTxt").innerHTML;
       var CountryShippingFixed=0;
       var Total=0;
	Total=parseFloat(CountryShippingFixed/1)+parseFloat(TotalCostFixed/1)+parseFloat(ShippingFixed/1);
		
	document.getElementById("TotalTxt").innerHTML=parseFloat(Total.toFixed(2));
       
       

        
    
    }

 function CalculateCountry(ShippingCountryID)
    {


	

       document.getElementById("CountryCostTxt").innerHTML=CountryShippingArray[ShippingCountryID].toFixed(2);
      
    	var CountryShippingFixed = CountryShippingArray[ShippingCountryID];
       var TotalCostFixed = document.getElementById("SubTotalTxt").innerHTML;
       var ShippingFixed = document.getElementById("ShippingCostTxt").innerHTML;
       var Total=0;
        
		
	
	TotalCostFixed = TotalCostFixed.replace(/,/g,"");


	Total=parseFloat(CountryShippingFixed/1)+(TotalCostFixed/1)+parseFloat(ShippingFixed/1);
		
		document.getElementById("TotalTxt").innerHTML=Total.toFixed(2);
       
     
    
    }
 //END STUFF PULLED OUT FROM VIEWCART.ASPX   


function ShowMenu(MenuName)
{
	HideAllMenus();
	document.getElementById(MenuName).style.visibility="visible";
}
	
function HideAllMenus()
{
	document.getElementById("ProductsMenu").style.visibility="hidden";
}
	

