var _MAINPATHSSL = 'https://securesite04.appliedi.net/coralcalcium-net/';

function liteon(obj) {obj.className = "hilighted";}
function liteoff(obj) {obj.className = "normal";}
function forward(loc) {location.href = loc;}


/**************************************************************************************/
/**************************************************************************************/
function validCustomerFirst2(cantFO)
{
	var pass=true;
	var errors='';

	firstName=document.frm.firstName; 
    middleName=document.frm.middleName; 
    lastName=document.frm.lastName; 
    ssn1=document.frm.ssn1; 
    ssn2=document.frm.ssn2; 
    ssn3=document.frm.ssn3; 
    billingAddress1=document.frm.billingAddress1; 
    billingAddress2=document.frm.billingAddress2; 
    city=document.frm.city;  
    country = document.frm.country;
	state=document.frm.state; 
    zipCode=document.frm.zipCode; 
    phone1=document.frm.phone1; 
    phone2=document.frm.phone2; 
    phone3=document.frm.phone3; 
	
    sameShippingAddress=document.frm.sameShippingAddress; 
	shippingAddress1=document.frm.shippingAddress1; 
	shippingAddress2=document.frm.shippingAddress2; 
    shippingCity=document.frm.shippingCity; 
    shippingCountry = document.frm.shippingCountry;
	shippingState=document.frm.shippingState; 
    shippingZipCode=document.frm.shippingZipCode; 
	
	paymentMethod=document.frm.paymentMethod; 	

	
    cardTypeId=document.frm.cardTypeId; 
    cCNumber=document.frm.cCNumber; 
    expireDateMM=document.frm.expireDateMM; 
    expireDateYY=document.frm.expireDateYY; 	
    cCValidNr=document.frm.cCValidNr; 
    cCHolderfirstName=document.frm.cCHolderfirstName; 
    cCHoldermiddleName=document.frm.cCHoldermiddleName; 
    cCHolderlastName=document.frm.cCHolderlastName;
	
    routingNBR=document.frm.routingNBR; 
    accountNr=document.frm.accountNr; 
    checkNr=document.frm.checkNr; 
    acctHolderName=document.frm.acctHolderName; 
    acctHolderAddress1=document.frm.acctHolderAddress1; 
    acctHolderAddress2=document.frm.acctHolderAddress2; 
    acctHolderCity=document.frm.acctHolderCity; 
    acctHolderState=document.frm.acctHolderState; 
    acctHolderZipCode=document.frm.acctHolderZipCode; 
    bankName=document.frm.bankName; 
    bankAddress=document.frm.bankAddress; 
    bankCity=document.frm.bankCity; 
    bankState=document.frm.bankState; 
    bankZipCode=document.frm.bankZipCode; 
    authorize=document.frm.authorize; 
	dlnumber=document.frm.dlnumber; 	
	
	
	if (firstName.value == '' ){errors+='-  Must complete the field [First Name].\n';pass=false;}	
    if (lastName.value == '' ){errors+='-  Must complete the field [Last Name].\n';pass=false;}
    if (ssn1.value == '' ){errors+='-  Must complete the field [Social Security Number].\n';pass=false;}
	else if (!validateNumeric(ssn1)) {errors+='-  Must contain only digit [Social Security Number].\n';pass=false;}	
    if (ssn2.value == '' ){errors+='-  Must complete the field [Social Security Number].\n';pass=false;}
	else if (!validateNumeric(ssn2)) {errors+='-  Must contain only digit [Social Security Number].\n';pass=false;}	
    if (ssn3.value == '' ){errors+='-  Must complete the field [Social Security Number].\n';pass=false;}
	else if (!validateNumeric(ssn3)) {errors+='-  Must contain only digit [Social Security Number].\n';pass=false;}	
    if (billingAddress1.value == '' ){errors+='-  Must complete the field [Billing Address 1].\n';pass=false;}
    if (city.value == '' ){errors+='-  Must complete the field [City].\n';pass=false;}  
    
	
	if (country.value == 'US'){
		if (state.value == '0' ){errors+='-  Must complete the field [State].\n';pass=false;}
	}
	
	if (zipCode.value == '' ){errors+='-  Must complete the field [Zip Code].\n';pass=false;}
    if (phone1.value == ''){errors+='-  Must complete the field [Telephone].\n';pass=false;}
	else if (!validateNumeric(phone1)) {errors+='-  Must contain only digit [Telephone].\n';pass=false;}			
    if (phone2.value == '' ){errors+='-  Must complete the field [Telephone].\n';pass=false;}
	else if (!validateNumeric(phone2)) {errors+='-  Must contain only digit [Telephone].\n';pass=false;}				
    if (phone3.value == '' ){errors+='-  Must complete the field [Telephone].\n';pass=false;}
	else if (!validateNumeric(phone3)) {errors+='-  Must contain only digit [Telephone].\n';pass=false;}				
	

	if(sameShippingAddress[1].checked)
	{
		if (shippingAddress1.value == '' ){errors+='-  Must complete the field [Shipping Address 1].\n';pass=false;}
    	if (shippingCity.value == '' ){errors+='-  Must complete the field [Shipping City].\n';pass=false;}
	    if (shippingCountry.value == 'US'){	
			if (shippingState.value == '0' ){errors+='-  Must complete the field [Shipping State].\n';pass=false;}
		}
    	if (shippingZipCode.value == '' ){errors+='-  Must complete the field [Shipping Zip Code].\n';pass=false;}		
	} 


	paymentMethodOk = false;		
	//if(paymentMethod[0].checked)
	if(paymentMethod.checked)
	{
    	if (cardTypeId.value == '0' ){errors+='-  Must complete the field [Credit Card Type].\n';pass=false;}
    	if (cCNumber.value == '' ){errors+='-  Must complete the field [Credid Card Number].\n';pass=false;} 
		else if (!validateNumeric(cCNumber)) {errors+='-  Must contain only digit [Credid Card Number].\n';pass=false;}					
    	if (cCValidNr.value == '' ){errors+='-  Must complete the field [Validation Number].\n';pass=false;}
		else if (!validateNumeric(cCValidNr)) {errors+='-  Must contain only digit [Validation Number].\n';pass=false;}					
    	if (cCHolderfirstName.value == '' ){errors+='-  Must complete the field [Card holder\'s First Name].\n';pass=false;}
    	if (cCHolderlastName.value == '' ){errors+='-  Must complete the field [Card holder\'s Last Name].\n';pass=false;}

		if((cardTypeId.value=='3') && (cCNumber.value.length!=15))
		{ //American Express
			errors+='-  Wrong [Credit Card Number] length.\n';pass=false;				
		}

		paymentMethodOk = true;		
	}		
	
	//2006-08-31 Remove Electronic check
	/*
	if(paymentMethod[1].checked)
	{
    	if (routingNBR.value == '' ){errors+='-  Must complete the field [ABA Routing Number].\n';pass=false;}
		else if (!validateNumeric(routingNBR)) {errors+='-  Must contain only digit [ABA Routing Number].\n';pass=false;}							
    	if (accountNr.value == '' ){errors+='-  Must complete the field [Checking Account Number].\n';pass=false;}
		else if (!validateNumeric(accountNr)) {errors+='-  Must contain only digit [Checking Account Number].\n';pass=false;}							
    	if (checkNr.value == '' ){errors+='-  Must complete the field [Check Number].\n';pass=false;}
		else if (!validateNumeric(checkNr)) {errors+='-  Must contain only digit [Check Number].\n';pass=false;}							
    	if (acctHolderName.value == '' ){errors+='-  Must complete the field [Account Holder Name].\n';pass=false;}
    	if (acctHolderAddress1.value == '' ){errors+='-  Must complete the field [Account Holder Address line 1:].\n';pass=false;}
    	if (acctHolderCity.value == '' ){errors+='-  Must complete the field [Account Holder City].\n';pass=false;}
    	if (acctHolderState.value == '0' ){errors+='-  Must complete the field [Account Holder State].\n';pass=false;}
    	if (acctHolderZipCode.value == '' ){errors+='-  Must complete the field [Account Holder Zip code].\n';pass=false;}
    	if (bankName.value == '' ){errors+='-  Must complete the field [Bank Name].\n';pass=false;}
    	if (bankAddress.value == '' ){errors+='-  Must complete the field [Bank Address].\n';pass=false;}
    	if (bankCity.value == '' ){errors+='-  Must complete the field [Bank City].\n';pass=false;}
    	if (bankState.value == '0' ){errors+='-  Must complete the field [Bank State].\n';pass=false;}
    	if (bankZipCode.value == '' ){errors+='-  Must complete the field [Bank Zip code].\n';pass=false;}
    	if (dlnumber.value == '' ){errors+='-  Must complete the field [Driver License].\n';pass=false;}
		else if (!validateNumeric(dlnumber)) {errors+='-  Must contain only digit [Driver License].\n';pass=false;}											
		paymentMethodOk = true;				
	}
	*/
	
	/*2006-10-02 Remove check by mail
	if(paymentMethod[1].checked)
	{
		paymentMethodOk = true;	
	}
	*/


    if (!paymentMethodOk){errors+='-  Must choose a Payment Method.\n';pass=false;}
		
	var selectedFO='';
	for (i = 1; i <= cantFO; i++) 
	{
		customerOrderIdStatus = 'document.frm.customerOrderId' + i + ".checked";
		customerOrderIdValue = 'document.frm.customerOrderId' + i + ".value";		
		if(eval(customerOrderIdStatus))
		{
			selectedFO = selectedFO + eval(customerOrderIdValue) + "," ;
		}
	}
	if(selectedFO != '')
	{
		document.frm.customerOrderList.value = selectedFO;
	}
	else
	{
		errors+='-  Must choose at leat one product for your first order.\n';pass=false;		
	}

			
	if(!authorize.checked) {errors+='-  Must authorize CoralCalcium.net to handle your payment information.\n';pass=false;}
	
	
	if (!pass) 
    {
		alert('The following error(s) occurred:\n'+errors);
	}
	else
	{      
		disableSubmitButton('submitButton');
		document.frm.submit();

	}
}


/**************************************************************************************/
/**************************************************************************************/
function validCustomerFirst(cantFO)
{
	var pass=true;
	var errors='';

    password=document.frm.password; 
    passwordConfirm=document.frm.passwordConfirm; 
	
    firstName=document.frm.firstName; 
    middleName=document.frm.middleName; 
    lastName=document.frm.lastName; 
    ssn1=document.frm.ssn1; 
    ssn2=document.frm.ssn2; 
    ssn3=document.frm.ssn3; 
    company=document.frm.company; 
    billingAddress1=document.frm.billingAddress1; 
    billingAddress2=document.frm.billingAddress2; 
    city=document.frm.city;
	country = document.frm.country;
    state=document.frm.state; 
    zipCode=document.frm.zipCode; 
    phone1=document.frm.phone1; 
    phone2=document.frm.phone2; 
    phone3=document.frm.phone3; 
    paypalEmail=document.frm.paypalEmail; 
    contactEmail=document.frm.contactEmail; 
    newsLetter=document.frm.newsLetter; 
    referredBy=document.frm.referredBy; 
    referredId=document.frm.referredId; 
	
    sameShippingAddress=document.frm.sameShippingAddress; 
	shippingAddress1=document.frm.shippingAddress1; 
	shippingAddress2=document.frm.shippingAddress2; 
    shippingCity=document.frm.shippingCity; 
    shippingCountry = document.frm.shippingCountry;
	shippingState=document.frm.shippingState; 
    shippingZipCode=document.frm.shippingZipCode; 
	
	
	paymentMethod=document.frm.paymentMethod; 	
	
	//checkMailed=document.frm.checkMailed; 
	
    cardTypeId=document.frm.cardTypeId; 
    cCNumber=document.frm.cCNumber; 
    expireDateMM=document.frm.expireDateMM; 
    expireDateYY=document.frm.expireDateYY; 	
    cCValidNr=document.frm.cCValidNr; 
    cCHolderfirstName=document.frm.cCHolderfirstName; 
    cCHoldermiddleName=document.frm.cCHoldermiddleName; 
    cCHolderlastName=document.frm.cCHolderlastName;
	
    routingNBR=document.frm.routingNBR; 
    accountNr=document.frm.accountNr; 
    checkNr=document.frm.checkNr; 
    acctHolderName=document.frm.acctHolderName; 
    acctHolderAddress1=document.frm.acctHolderAddress1; 
    acctHolderAddress2=document.frm.acctHolderAddress2; 
    acctHolderCity=document.frm.acctHolderCity; 
    acctHolderState=document.frm.acctHolderState; 
    acctHolderZipCode=document.frm.acctHolderZipCode; 
    bankName=document.frm.bankName; 
    bankAddress=document.frm.bankAddress; 
    bankCity=document.frm.bankCity; 
    bankState=document.frm.bankState; 
    bankZipCode=document.frm.bankZipCode; 
    authorize=document.frm.authorize; 
	dlnumber=document.frm.dlnumber; 	
	
	
	if (password.value == '' ){errors+='-  Must complete the field [Password].\n';pass=false;}	
    if (passwordConfirm.value == '' ){errors+='-  Must complete the field [Confirm Password].\n';pass=false;}	
    if (contactEmail.value == '' ){errors+='-  Must complete the field [Valid Contact E-mail Address].\n';pass=false;} 
	else if (!emailCheck(contactEmail.value)) {errors+='-  Must contain a valid [Contact Email].\n';pass=false;}			
	if (firstName.value == '' ){errors+='-  Must complete the field [First Name].\n';pass=false;}	
    if (lastName.value == '' ){errors+='-  Must complete the field [Last Name].\n';pass=false;}
    if (ssn1.value == '' ){errors+='-  Must complete the field [Social Security Number].\n';pass=false;}
	else if (!validateNumeric(ssn1)) {errors+='-  Must contain only digit [Social Security Number].\n';pass=false;}	
    if (ssn2.value == '' ){errors+='-  Must complete the field [Social Security Number].\n';pass=false;}
	else if (!validateNumeric(ssn2)) {errors+='-  Must contain only digit [Social Security Number].\n';pass=false;}	
    if (ssn3.value == '' ){errors+='-  Must complete the field [Social Security Number].\n';pass=false;}
	else if (!validateNumeric(ssn3)) {errors+='-  Must contain only digit [Social Security Number].\n';pass=false;}	
    if (billingAddress1.value == '' ){errors+='-  Must complete the field [Billing Address 1].\n';pass=false;}
    if (city.value == '' ){errors+='-  Must complete the field [City].\n';pass=false;}  
    
	if (country.value == 'US'){
		if (state.value == '0' ){errors+='-  Must complete the field [State].\n';pass=false;}
	}
	
	if (zipCode.value == '' ){errors+='-  Must complete the field [Zip Code].\n';pass=false;}
    if (phone1.value == ''){errors+='-  Must complete the field [Telephone].\n';pass=false;}
	else if (!validateNumeric(phone1)) {errors+='-  Must contain only digit [Telephone].\n';pass=false;}			
    if (phone2.value == '' ){errors+='-  Must complete the field [Telephone].\n';pass=false;}
	else if (!validateNumeric(phone2)) {errors+='-  Must contain only digit [Telephone].\n';pass=false;}				
    if (phone3.value == '' ){errors+='-  Must complete the field [Telephone].\n';pass=false;}
	else if (!validateNumeric(phone3)) {errors+='-  Must contain only digit [Telephone].\n';pass=false;}				
	
    if (password.value != passwordConfirm.value)
	{errors+='-  Confirm your [Password].\n';pass=false;}
	
    if (referredId.value != '' )
	{
		if (!validateNumeric(referredId)) {errors+='-  Must contain a valid [Referrence Id #].\n';pass=false;}				
	}

	if(sameShippingAddress[1].checked)
	{
		if (shippingAddress1.value == '' ){errors+='-  Must complete the field [Shipping Address 1].\n';pass=false;}
    	if (shippingCity.value == '' ){errors+='-  Must complete the field [Shipping City].\n';pass=false;}
	    if (shippingCountry.value == 'US'){
			if (shippingState.value == '0' ){errors+='-  Must complete the field [Shipping State].\n';pass=false;}
		}
    	if (shippingZipCode.value == '' ){errors+='-  Must complete the field [Shipping Zip Code].\n';pass=false;}		
	} 


	paymentMethodOk = false;		
	//if(paymentMethod[0].checked)
	if(paymentMethod.checked)
	{
    	if (cardTypeId.value == '0' ){errors+='-  Must complete the field [Credit Card Type].\n';pass=false;}
    	if (cCNumber.value == '' ){errors+='-  Must complete the field [Credid Card Number].\n';pass=false;} 
		else if (!validateNumeric(cCNumber)) {errors+='-  Must contain only digit [Credid Card Number].\n';pass=false;}					
    	if (cCValidNr.value == '' ){errors+='-  Must complete the field [Validation Number].\n';pass=false;}
		else if (!validateNumeric(cCValidNr)) {errors+='-  Must contain only digit [Validation Number].\n';pass=false;}					
    	if (cCHolderfirstName.value == '' ){errors+='-  Must complete the field [Card holder\'s First Name].\n';pass=false;}
    	if (cCHolderlastName.value == '' ){errors+='-  Must complete the field [Card holder\'s Last Name].\n';pass=false;}

		if((cardTypeId.value=='3') && (cCNumber.value.length!=15))
		{ //American Express
			errors+='-  Wrong [Credit Card Number] length.\n';pass=false;				
		}

		paymentMethodOk = true;		
	}		
	
	// 2006-08-31 Remove Electronic Check
	/*
	if(paymentMethod[1].checked)
	{
    	if (routingNBR.value == '' ){errors+='-  Must complete the field [ABA Routing Number].\n';pass=false;}
		else if (!validateNumeric(routingNBR)) {errors+='-  Must contain only digit [ABA Routing Number].\n';pass=false;}							
    	if (accountNr.value == '' ){errors+='-  Must complete the field [Checking Account Number].\n';pass=false;}
		else if (!validateNumeric(accountNr)) {errors+='-  Must contain only digit [Checking Account Number].\n';pass=false;}							
    	if (checkNr.value == '' ){errors+='-  Must complete the field [Check Number].\n';pass=false;}
		else if (!validateNumeric(checkNr)) {errors+='-  Must contain only digit [Check Number].\n';pass=false;}							
    	if (acctHolderName.value == '' ){errors+='-  Must complete the field [Account Holder Name].\n';pass=false;}
    	if (acctHolderAddress1.value == '' ){errors+='-  Must complete the field [Account Holder Address line 1:].\n';pass=false;}
    	if (acctHolderCity.value == '' ){errors+='-  Must complete the field [Account Holder City].\n';pass=false;}
    	if (acctHolderState.value == '0' ){errors+='-  Must complete the field [Account Holder State].\n';pass=false;}
    	if (acctHolderZipCode.value == '' ){errors+='-  Must complete the field [Account Holder Zip code].\n';pass=false;}
    	if (bankName.value == '' ){errors+='-  Must complete the field [Bank Name].\n';pass=false;}
    	if (bankAddress.value == '' ){errors+='-  Must complete the field [Bank Address].\n';pass=false;}
    	if (bankCity.value == '' ){errors+='-  Must complete the field [Bank City].\n';pass=false;}
    	if (bankState.value == '0' ){errors+='-  Must complete the field [Bank State].\n';pass=false;}
    	if (bankZipCode.value == '' ){errors+='-  Must complete the field [Bank Zip code].\n';pass=false;}
    	if (dlnumber.value == '' ){errors+='-  Must complete the field [Driver License].\n';pass=false;}
		else if (!validateNumeric(dlnumber)) {errors+='-  Must contain only digit [Driver License].\n';pass=false;}											
		paymentMethodOk = true;				
	}
	*/
	
	/*2006-09-02 Remove Check by mail
	if(paymentMethod[1].checked)
	{
		paymentMethodOk = true;			
	}

	*/
	
    if (!paymentMethodOk){errors+='-  Must choose a Payment Method.\n';pass=false;}
		
	var selectedFO='';
	for (i = 1; i <= cantFO; i++) 
	{
		customerOrderIdStatus = 'document.frm.customerOrderId' + i + ".checked";
		customerOrderIdValue = 'document.frm.customerOrderId' + i + ".value";		
		if(eval(customerOrderIdStatus))
		{
			selectedFO = selectedFO + eval(customerOrderIdValue) + "," ;
		}
	}
	if(selectedFO != '')
	{
		document.frm.customerOrderList.value = selectedFO;
	}
	else
	{
		errors+='-  Must choose at leat one product for your first order.\n';pass=false;		
	}

			
	if(!authorize.checked) {errors+='-  Must authorize CoralCalcium.net to handle your payment information.\n';pass=false;}
	
	
	if (!pass) 
    {
		alert('The following error(s) occurred:\n'+errors);
	}
	else
	{      
		disableSubmitButton('submitButton');
		document.frm.submit();
	}
}

/**************************************************************************************/
/**************************************************************************************/
function validatePaymentCommission()
{
	var pass=true;
	var errors='';
	 
	amount=document.frm2.amount; 

	if (document.frm2.amount.value == '' ){errors+='-  Must complete the field [Amount].\n';pass=false;}
	else if (!validateNumeric(amount)) {errors+='-  Must contain a valid [Amount].\n';pass=false;}				

	if (!pass) 
    {
		alert('The following error(s) occurred:\n'+errors);
	}
	else
	{      
		if(confirm('Are you sure want to pay the current commission?'))		
		{
			document.frm2.submit();			
		}
		else
		{
			//errors+='-  Commission Payment cancelled by admin.\n';			
			//alert('The following error(s) occurred:\n'+errors);			
		}
	}		
}



/**************************************************************************************/
/**************************************************************************************/
function setAutoOrder(cantAO)
{
	var pass=true;
	var errors='';
				
	var selectedAO='';
	for (i2 = 1; i2 <= cantAO; i2++) 
	{
		autoOrderIdStatus = 'document.frm.autoOrderId' + i2 + ".checked";
		autoOrderIdValue = 'document.frm.autoOrderId' + i2 + ".value";		
		if(eval(autoOrderIdStatus))
		{
			selectedAO = selectedAO + eval(autoOrderIdValue) + "," ;
		}
	}
	
	if(selectedAO != '')
	{
		document.frm.autoOrderList.value = selectedAO;
	}
	else
	{
		errors+='-  Must choose at leat one product for your Auto Monthly order.\n';pass=false;		
	}
	
	if (!pass) 
    {
		alert('The following error(s) occurred:\n'+errors);
	}
	else
	{      
		if(confirm('Are you sure you want to update your monthly auto order?'))		
		{
			document.frm.submit();			
		}
		else
		{
			//errors+='-  Commission Payment cancelled by admin.\n';			
			//alert('The following error(s) occurred:\n'+errors);			
		}

	}
}



/**************************************************************************************/
/**************************************************************************************/
function validateProductBE()
{
	var pass=true;
	var errors='';
	
	if (document.frm.sku.value == '' ){errors+='-  Must complete the field [Sku].\n';pass=false;}
	if (document.frm.name.value == '' ){errors+='-  Must complete the field [Name].\n';pass=false;}
	if (document.frm.price1.value == '' ){errors+='-  Must complete the field [Customer Price].\n';pass=false;}
	if (document.frm.price2.value == '' ){errors+='-  Must complete the field [Associate Price].\n';pass=false;}	
	
	if (document.frm.cnsc.value == '' ){errors+='-  Must complete the field [Customer National Shipping Cost].\n';pass=false;}
	if (document.frm.cisc.value == '' ){errors+='-  Must complete the field [Customer Intermational Shipping Cost].\n';pass=false;}	
	
	//if (document.frm.cnhc.value == '' ){errors+='-  Must complete the field [Customer National Handling Cost].\n';pass=false;}
	//if (document.frm.cihc.value == '' ){errors+='-  Must complete the field [Customer Intermational Handling Cost].\n';pass=false;}	
	
	if (document.frm.ansc.value == '' ){errors+='-  Must complete the field [Associate National Shipping Cost].\n';pass=false;}
	if (document.frm.aisc.value == '' ){errors+='-  Must complete the field [Customer National Shipping Cost].\n';pass=false;}		
	
	//if (document.frm.anhc.value == '' ){errors+='-  Must complete the field [Associate National Handling Cost].\n';pass=false;}
	//if (document.frm.aihc.value == '' ){errors+='-  Must complete the field [Customer National Handling Cost].\n';pass=false;}		
	
	if (!pass) 
    {
		alert('The following error(s) occurred:\n'+errors);
	}
	else
	{      
		document.frm.submit();
	}		
}


/**************************************************************************************/
/**************************************************************************************/
function validateCategoryBE()
{
	var pass=true;
	var errors='';

	if (document.frm.name.value == '' ){errors+='-  Must complete the field [Name].\n';pass=false;}	

	if (!pass) 
    {
		alert('The following error(s) occurred:\n'+errors);
	}
	else
	{      
		document.frm.submit();
	}	
	
}


/**************************************************************************************/
/**************************************************************************************/
function validateLogin()
{
	var pass=true;
	var errors='';
	 
	email=document.frm.email; 
    password=document.frm.password; 
		
	if (email.value == '' ){errors+='-  Must complete the field [Email].\n';pass=false;}	
	else
	{
		if (!emailCheck(email.value)) {errors+='-  Must contain a valid [Email].\n';pass=false;}	
    }	
    if (password.value == '' ){errors+='-  Must complete the field [Password].\n';pass=false;}	
	
	if (!pass) 
    {
		alert('The following error(s) occurred:\n'+errors);
	}
	else
	{      
		document.frm.action=_MAINPATHSSL+"Login.php";
		document.frm.submit();

	}	
	
}



/**************************************************************************************/
/**************************************************************************************/
function validateAsocLogin()
{
	var pass=true;
	var errors='';
	 
	username=document.frm.username; 
    password=document.frm.password; 
		
	if (username.value == '' ){errors+='-  Must complete the field [Username].\n';pass=false;}	
    if (password.value == '' ){errors+='-  Must complete the field [Password].\n';pass=false;}	
	
	if (!pass) 
    {
		alert('The following error(s) occurred:\n'+errors);
	}
	else
	{      
		document.frm.action=_MAINPATHSSL+"asocLogin.php";
		document.frm.submit();

	}	
	
}


/**************************************************************************************/
/**************************************************************************************/
function validateLogin2()
{
	var pass=true;
	var errors='';
	 
	email=document.frm.email; 
		
	if (email.value == '' ){errors+='-  Must complete the field [Email].\n';pass=false;}
	else
	{
		if (!emailCheck(email.value)) {errors+='-  Must contain a valid [Email].\n';pass=false;}	
    }
	
	if (!pass) 
    {
		alert('The following error(s) occurred:\n'+errors);
	}
	else
	{      
		document.frm.action="forgot.php";
		document.frm.submit();

	}	
	
}


/**************************************************************************************/
/**************************************************************************************/
function validateAsocForgotPass()
{
	var pass=true;
	var errors='';
	 
	username=document.frm.username; 
		
	if (username.value == '' ){errors+='-  Must complete the field [Username].\n';pass=false;}
	
	if (!pass) 
    {
		alert('The following error(s) occurred:\n'+errors);
	}
	else
	{      
		document.frm.action="asocForgot.php";
		document.frm.submit();

	}	
	
}



/**************************************************************************************/
/**************************************************************************************/
function validCustomer()
{
	var pass=true;
	var errors='';
	 
	email=document.frm.email; 
    password=document.frm.password; 
    passwordConfirm=document.frm.passwordConfirm; 
    firstName=document.frm.firstName; 
    middleName=document.frm.middleName; 
    lastName=document.frm.lastName; 
    address=document.frm.address; 
    city=document.frm.city; 
    country = document.frm.country;
	state=document.frm.state; 
    zipCode=document.frm.zipCode; 
    shipToEmail=document.frm.shipToEmail; 
    shiptoPhone1=document.frm.shiptoPhone1; 
    shiptoPhone2=document.frm.shiptoPhone2; 
    shiptoPhone3=document.frm.shiptoPhone3; 
    uSResident=document.frm.uSResident; 
    nCResident=document.frm.nCResident; 
	
	
	if (email.value == '' ){errors+='-  Must complete the field [Email].\n';pass=false;}	
    if (password.value == '' ){errors+='-  Must complete the field [Password].\n';pass=false;}	
    if (passwordConfirm.value == '' ){errors+='-  Must complete the field [Confirm Password].\n';pass=false;}	

    if (zipCode.value != '' )
	{
		if (!validateNumeric(zipCode)) {errors+='-  Must contain a valid [Zip Code].\n';pass=false;}				
	}
    if (shipToEmail.value != '' )
	{
		if (!emailCheck(shipToEmail.value)) {errors+='-  Must contain a valid [Ship to Email].\n';pass=false;}	
	}
    if (shiptoPhone1.value != '' )
	{
		if (!validateNumeric(shiptoPhone1)) {errors+='-  Must contain a valid [Ship to Phone].\n';pass=false;}				
	}
	if (shiptoPhone2.value != '' )
	{
		if (!validateNumeric(shiptoPhone2)) {errors+='-  Must contain a valid [Ship to Phone].\n';pass=false;}				
	}
	if (shiptoPhone3.value != '' )
	{
		if (!validateNumeric(shiptoPhone3)) {errors+='-  Must contain a valid [Ship to Phone].\n';pass=false;}				
	}
    if (password.value != passwordConfirm.value)
	{errors+='-  Confirm your [Password].\n';pass=false;}	
	
	if (!pass) 
    {
		alert('The following error(s) occurred:\n'+errors);
	}
	else
	{   
		disableSubmitButton('submitButton');
		document.frm.submit();

	}	
	
}



/**************************************************************************************/
/**************************************************************************************/
function validCustomerBE()
{
	var pass=true;
	var pasTel=true;	
	var pasTel2=true;		
	var errors='';

	email=document.frm.email; 
    password=document.frm.password; 
    firstName=document.frm.firstName; 
    middleName=document.frm.middleName; 
    lastName=document.frm.lastName; 
    address=document.frm.address; 
	country=document.frm.country; 
    city=document.frm.city; 
    state=document.frm.state; 
    zipCode=document.frm.zipCode; 
    shipToEmail=document.frm.shipToEmail; 
    shiptoPhone1=document.frm.shiptoPhone1; 
    shiptoPhone2=document.frm.shiptoPhone2; 
    shiptoPhone3=document.frm.shiptoPhone3; 
	

	if (email.value == '' ){errors+='-  Must complete the field [Email].\n';pass=false;}	
	else
	{
		if (!emailCheck(email.value)) {errors+='-  Must contain a valid [Email].\n';pass=false;}	
	}	
    if (password.value == '' ){errors+='-  Must complete the field [Password].\n';pass=false;}	
	if (firstName.value == '' ){errors+='-  Must complete the field [First Name].\n';pass=false;}	
    if (lastName.value == '' ){errors+='-  Must complete the field [Last Name].\n';pass=false;}	
    if (address.value == '' ){errors+='-  Must complete the field [Address].\n';pass=false;}	
    if (city.value == '' ){errors+='-  Must complete the field [City].\n';pass=false;}	
    
	if (country.value == '0' ){errors+='-  Must complete the field [Country].\n';pass=false;}
	
	if (country.value == 'US' ){
		if (state.value == '' ){errors+='-  Must complete the field [State].\n';pass=false;}	
	}
	
    if (zipCode.value == '' ){errors+='-  Must complete the field [Zip Code].\n';pass=false;}
	/* 2006-10-02 
		Remove validation Zip Code
	else
	{
		if (!validateNumeric(zipCode)) {errors+='-  Must contain a valid [Zip Code].\n';pass=false;}				
	}
	*/
	if (shipToEmail.value == '' ){errors+='-  Must complete the field [Ship to Email].\n';pass=false;}		
	else
	{
		if (!emailCheck(shipToEmail.value)) {errors+='-  Must contain a valid [Ship to Email].\n';pass=false;}	
	}
    if (shiptoPhone1.value == '' ){pasTel=false;}		
	{
		if (!validateNumeric(shiptoPhone1)) {pasTel2=false;}				
	}
    if (shiptoPhone2.value == '' ){pasTel=false;}		
	{
		if (!validateNumeric(shiptoPhone2)) {pasTel2=false;}				
	}
    if (shiptoPhone3.value == '' ){pasTel=false;}		
	{
		if (!validateNumeric(shiptoPhone3)) {pasTel2=false;}				
	}
	
	if (!pasTel) 
    {
		pass=false;
		errors+='-  Must complete the field [Ship to Phone].\n'
	}
	if (!pasTel2) 
    {
		pass=false;
		errors+='-  Must contain a valid [Ship to Phone].\n'
	}	
	
	pasTel
	
	
	if (!pass) 
    {
		alert('The following error(s) occurred:\n'+errors);
	}
	else
	{      
		document.frm.submit();

	}	
	
}


/**************************************************************************************/
/**************************************************************************************/
function validCustomer2()
{
	var pass=true;
	var errors='';
	 
    firstName=document.frm.firstName; 
    middleName=document.frm.middleName; 
    lastName=document.frm.lastName; 
    address=document.frm.address; 
	country=document.frm.country; 
    city=document.frm.city; 
    state=document.frm.state; 
    zipCode=document.frm.zipCode; 
    shipToEmail=document.frm.shipToEmail; 
    shiptoPhone1=document.frm.shiptoPhone1; 
    shiptoPhone2=document.frm.shiptoPhone2; 
    shiptoPhone3=document.frm.shiptoPhone3; 
    uSResident=document.frm.uSResident; 
    nCResident=document.frm.nCResident; 

	paymentMethod=document.frm.paymentMethod; 	
	
    cardTypeId=document.frm.cardTypeId; 
    cCNumber=document.frm.cCNumber; 
    expireDateMM=document.frm.expireDateMM; 
    expireDateYY=document.frm.expireDateYY; 	
    cCValidNr=document.frm.cCValidNr; 
    cCHolderfirstName=document.frm.cCHolderfirstName; 
    cCHoldermiddleName=document.frm.cCHoldermiddleName; 
    cCHolderlastName=document.frm.cCHolderlastName;
	
    routingNBR=document.frm.routingNBR; 
    accountNr=document.frm.accountNr; 
    checkNr=document.frm.checkNr; 
    acctHolderName=document.frm.acctHolderName; 
    acctHolderAddress1=document.frm.acctHolderAddress1; 
    acctHolderAddress2=document.frm.acctHolderAddress2; 
    acctHolderCity=document.frm.acctHolderCity; 
    acctHolderState=document.frm.acctHolderState; 
    acctHolderZipCode=document.frm.acctHolderZipCode; 
    bankName=document.frm.bankName; 
    bankAddress=document.frm.bankAddress; 
    bankCity=document.frm.bankCity; 
    bankState=document.frm.bankState; 
    bankZipCode=document.frm.bankZipCode; 
    dlnumber=document.frm.dlnumber; 	
    ssn1=document.frm.ssn1; 
    ssn2=document.frm.ssn2; 
    ssn3=document.frm.ssn3; 	
	

	if (firstName.value == '' ){errors+='-  Must complete the field [First Name].\n';pass=false;}	
    if (lastName.value == '' ){errors+='-  Must complete the field [Last Name].\n';pass=false;}	
    if (address.value == '' ){errors+='-  Must complete the field [Address].\n';pass=false;}	
    if (city.value == '' ){errors+='-  Must complete the field [City].\n';pass=false;}	
    if (state.value == '0' ){errors+='-  Must complete the field [State].\n';pass=false;}	
    if (country == '0' ){errors+='-  Must complete the field [Country].\n';pass=false;}		
    if (zipCode.value == '' ){errors+='-  Must complete the field [Zip Code].\n';pass=false;}
	//else
	//{
	//	if (!validateNumeric(zipCode)) {errors+='-  Must contain a valid [Zip Code].\n';pass=false;}				
	//}
	if (shipToEmail.value == '' ){errors+='-  Must complete the field [Ship to Email].\n';pass=false;}		
	else
	{
		if (!emailCheck(shipToEmail.value)) {errors+='-  Must contain a valid [Ship to Email].\n';pass=false;}	
	}
    if (shiptoPhone1.value == '' ){errors+='-  Must complete the field [Ship to Phone].\n';pass=false;}		
	{
		if (!validateNumeric(shiptoPhone1)) {errors+='-  Must contain a valid [Ship to Phone].\n';pass=false;}				
	}
    if (shiptoPhone2.value == '' ){errors+='-  Must complete the field [Ship to Phone].\n';pass=false;}		
	{
		if (!validateNumeric(shiptoPhone2)) {errors+='-  Must contain a valid [Ship to Phone].\n';pass=false;}				
	}
    if (shiptoPhone3.value == '' ){errors+='-  Must complete the field [Ship to Phone].\n';pass=false;}		
	{
		if (!validateNumeric(shiptoPhone3)) {errors+='-  Must contain a valid [Ship to Phone].\n';pass=false;}				
	}

	paymentMethodOk = false;		
	if(paymentMethod[0].checked)
	{
		paymentMethodOk = true;				
	}
	if(paymentMethod[1].checked)
	{
    	if (cardTypeId.value == '0' ){errors+='-  Must complete the field [Credit Card Type].\n';pass=false;}
    	if (cCNumber.value == '' ){errors+='-  Must complete the field [Credid Card Number].\n';pass=false;} 
		else if (!validateNumeric(cCNumber)) {errors+='-  Must contain only digit [Credid Card Number].\n';pass=false;}					
    	if (cCValidNr.value == '' ){errors+='-  Must complete the field [Validation Number].\n';pass=false;}
		else if (!validateNumeric(cCValidNr)) {errors+='-  Must contain only digit [Validation Number].\n';pass=false;}					
    	if (cCHolderfirstName.value == '' ){errors+='-  Must complete the field [Card holder\'s First Name].\n';pass=false;}
    	if (cCHolderlastName.value == '' ){errors+='-  Must complete the field [Card holder\'s Last Name].\n';pass=false;}
		
		if((cardTypeId.value=='3') && (cCNumber.value.length!=15))
		{ //American Express
			errors+='-  Wrong [Credit Card Number] length.\n';pass=false;				
		}
		
		paymentMethodOk = true;		
	}		
	if(paymentMethod[2].checked)
	{
    	if (routingNBR.value == '' ){errors+='-  Must complete the field [ABA Routing Number].\n';pass=false;}
		else if (!validateNumeric(routingNBR)) {errors+='-  Must contain only digit [ABA Routing Number].\n';pass=false;}							
    	if (accountNr.value == '' ){errors+='-  Must complete the field [Checking Account Number].\n';pass=false;}
		else if (!validateNumeric(accountNr)) {errors+='-  Must contain only digit [Checking Account Number].\n';pass=false;}							
    	if (checkNr.value == '' ){errors+='-  Must complete the field [Check Number].\n';pass=false;}
		else if (!validateNumeric(checkNr)) {errors+='-  Must contain only digit [Check Number].\n';pass=false;}							
    	if (acctHolderName.value == '' ){errors+='-  Must complete the field [Account Holder Name].\n';pass=false;}
    	if (acctHolderAddress1.value == '' ){errors+='-  Must complete the field [Account Holder Address line 1:].\n';pass=false;}
    	if (acctHolderCity.value == '' ){errors+='-  Must complete the field [Account Holder City].\n';pass=false;}
    	if (acctHolderState.value == '0' ){errors+='-  Must complete the field [Account Holder State].\n';pass=false;}
    	if (acctHolderZipCode.value == '' ){errors+='-  Must complete the field [Account Holder Zip code].\n';pass=false;}
		//else if (!validateNumeric(acctHolderZipCode)) {errors+='-  Must contain only digit [Account Holder Zip code].\n';pass=false;}									
	   	if (dlnumber.value == '' ){errors+='-  Must complete the field [Driver License].\n';pass=false;}
		else if (!validateNumeric(dlnumber)) {errors+='-  Must contain only digit [Driver License].\n';pass=false;}
    	if (bankName.value == '' ){errors+='-  Must complete the field [Bank Name].\n';pass=false;}
    	if (bankAddress.value == '' ){errors+='-  Must complete the field [Bank Address].\n';pass=false;}
    	if (bankCity.value == '' ){errors+='-  Must complete the field [Bank City].\n';pass=false;}
    	if (bankState.value == '0' ){errors+='-  Must complete the field [Bank State].\n';pass=false;}
    	if (bankZipCode.value == '' ){errors+='-  Must complete the field [Bank Zip code].\n';pass=false;}
		//else if (!validateNumeric(bankZipCode)) {errors+='-  Must contain only digit [Bank Zip code].\n';pass=false;}							
	    if (ssn1.value == '' ){errors+='-  Must complete the field [Social Security Number].\n';pass=false;}
		else if (!validateNumeric(ssn1)) {errors+='-  Must contain only digit [Social Security Number].\n';pass=false;}	
    	if (ssn2.value == '' ){errors+='-  Must complete the field [Social Security Number].\n';pass=false;}
		else if (!validateNumeric(ssn2)) {errors+='-  Must contain only digit [Social Security Number].\n';pass=false;}	
    	if (ssn3.value == '' ){errors+='-  Must complete the field [Social Security Number].\n';pass=false;}
		else if (!validateNumeric(ssn3)) {errors+='-  Must contain only digit [Social Security Number].\n';pass=false;}	
		
		paymentMethodOk = true;				
	}

    if (!paymentMethodOk){errors+='-  Must choose a Payment Method.\n';pass=false;}
	
	
	
	
	if (paymentMethod[0].checked)
	{
		document.frm.action = 'customerPost2.php'; 
	}
	else if(paymentMethod[1].checked)
	{
		document.frm.action = _MAINPATHSSL+'myOrders.php';		
	}
	
	/*
	else if(paymentMethod[2].checked)
	{
		document.frm.action = 'customerPost2.php';		
	}	
	*/
	if (!pass) 
    {
		alert('The following error(s) occurred:\n'+errors);
	}
	else
	{      
		disableSubmitButton('submitButton');
		document.frm.submit();

	}	
	
}


/**************************************************************************************/
/**************************************************************************************/
function validAssoc2()
{
	var pass=true;
	var errors='';
	 
    firstName=document.frm.firstName; 
    middleName=document.frm.middleName; 
    lastName=document.frm.lastName; 
    address=document.frm.address; 
	country=document.frm.country; 
    city=document.frm.city; 
    state=document.frm.state; 
    zipCode=document.frm.zipCode; 
    shipToEmail=document.frm.shipToEmail; 
    shiptoPhone1=document.frm.shiptoPhone1; 
    shiptoPhone2=document.frm.shiptoPhone2; 
    shiptoPhone3=document.frm.shiptoPhone3; 
    uSResident=document.frm.uSResident; 
    nCResident=document.frm.nCResident; 
	
	
	if (firstName.value == '' ){errors+='-  Must complete the field [First Name].\n';pass=false;}	
    if (lastName.value == '' ){errors+='-  Must complete the field [Last Name].\n';pass=false;}	
    if (address.value == '' ){errors+='-  Must complete the field [Address].\n';pass=false;}	
    if (city.value == '' ){errors+='-  Must complete the field [City].\n';pass=false;}	
    if (state.value == '0' ){errors+='-  Must complete the field [State].\n';pass=false;}	
    if (country == '0' ){errors+='-  Must complete the field [Country].\n';pass=false;}		
    if (zipCode.value == '' ){errors+='-  Must complete the field [Zip Code].\n';pass=false;}
	//else
	//{
	//	if (!validateNumeric(zipCode)) {errors+='-  Must contain a valid [Zip Code].\n';pass=false;}				
	//}
	if (shipToEmail.value == '' ){errors+='-  Must complete the field [Ship to Email].\n';pass=false;}		
	else
	{
		if (!emailCheck(shipToEmail.value)) {errors+='-  Must contain a valid [Ship to Email].\n';pass=false;}	
	}
    if (shiptoPhone1.value == '' ){errors+='-  Must complete the field [Ship to Phone].\n';pass=false;}		
	{
		if (!validateNumeric(shiptoPhone1)) {errors+='-  Must contain a valid [Ship to Phone].\n';pass=false;}				
	}
    if (shiptoPhone2.value == '' ){errors+='-  Must complete the field [Ship to Phone].\n';pass=false;}		
	{
		if (!validateNumeric(shiptoPhone2)) {errors+='-  Must contain a valid [Ship to Phone].\n';pass=false;}				
	}
    if (shiptoPhone3.value == '' ){errors+='-  Must complete the field [Ship to Phone].\n';pass=false;}		
	{
		if (!validateNumeric(shiptoPhone3)) {errors+='-  Must contain a valid [Ship to Phone].\n';pass=false;}				
	}
	
	if (!pass) 
    {
		alert('The following error(s) occurred:\n'+errors);
	}
	else
	{      
		if(confirm('By making a single shopping you will cancel your current auto order. Proceed?'))		
		{
			document.frm.submit();			
		}
	}	
	
}


/**************************************************************************************/
/**************************************************************************************/
function validAssociate(cantFO,cantAO)
{
	var pass=true;
	var errors='';


    password=document.frm.password; 
    passwordConfirm=document.frm.passwordConfirm; 
	username=document.frm.passwordConfirm; 
	
    firstName=document.frm.firstName; 
    middleName=document.frm.middleName; 
    lastName=document.frm.lastName; 
    ssn1=document.frm.ssn1; 
    ssn2=document.frm.ssn2; 
    ssn3=document.frm.ssn3; 
    company=document.frm.company; 
    billingAddress1=document.frm.billingAddress1; 
    billingAddress2=document.frm.billingAddress2; 
    city=document.frm.city;  
    country = document.frm.country;
//	state=document.frm.state; 
    zipCode=document.frm.zipCode; 
    phone1=document.frm.phone1; 
    phone2=document.frm.phone2; 
    phone3=document.frm.phone3; 
    paypalEmail=document.frm.paypalEmail; 
    contactEmail=document.frm.contactEmail; 
    newsLetter=document.frm.newsLetter; 
    referredBy=document.frm.referredBy; 
    referredId=document.frm.referredId; 
	
    sameShippingAddress=document.frm.sameShippingAddress; 
	shippingAddress1=document.frm.shippingAddress1; 
	shippingAddress2=document.frm.shippingAddress2; 
    shippingCity=document.frm.shippingCity; 
    shippingCountry = document.frm.shippingCountry;
	shippingState=document.frm.shippingState; 
    shippingZipCode=document.frm.shippingZipCode; 
	
	paymentMethod=document.frm.paymentMethod; 	
	
	//checkMailed=document.frm.checkMailed; 
	
    cardTypeId=document.frm.cardTypeId; 
    cCNumber=document.frm.cCNumber; 
    expireDateMM=document.frm.expireDateMM; 
    expireDateYY=document.frm.expireDateYY; 	
    cCValidNr=document.frm.cCValidNr; 
    cCHolderfirstName=document.frm.cCHolderfirstName; 
    cCHoldermiddleName=document.frm.cCHoldermiddleName; 
    cCHolderlastName=document.frm.cCHolderlastName;
	
    routingNBR=document.frm.routingNBR; 
    accountNr=document.frm.accountNr; 
    checkNr=document.frm.checkNr; 
    acctHolderName=document.frm.acctHolderName; 
    acctHolderAddress1=document.frm.acctHolderAddress1; 
    acctHolderAddress2=document.frm.acctHolderAddress2; 
    acctHolderCity=document.frm.acctHolderCity; 
    acctHolderState=document.frm.acctHolderState; 
    acctHolderZipCode=document.frm.acctHolderZipCode; 
    bankName=document.frm.bankName; 
    bankAddress=document.frm.bankAddress; 
    bankCity=document.frm.bankCity; 
    bankState=document.frm.bankState; 
    bankZipCode=document.frm.bankZipCode; 
    authorize=document.frm.authorize; 
	dlnumber=document.frm.dlnumber; 	
	
	//country==document.frm.country; 	
	//shippingCountry==document.frm.shippingCountry; 	
	
	
	if (password.value == '' ){errors+='-  Must complete the field [Password].\n';pass=false;}	
    if (passwordConfirm.value == '' ){errors+='-  Must complete the field [Confirm Password].\n';pass=false;}	
    
	//2006-08-28
	//add validation for Refered Data 
	if( document.frm.referralInvitation[0].checked){
		
		if (referredBy.value == '' ){errors+='-  Must complete the field [Referred By ].\n';pass=false;}
		if (referredId.value == '' ){errors+='-  Must complete the field [Referrence Id #].\n';pass=false;}
		if (!validateNumeric(referredId)) {errors+='-  Must contain a valid [Referrence Id #].\n';pass=false;}					
	}
	
	
	if (contactEmail.value == '' ){errors+='-  Must complete the field [Valid Contact E-mail Address].\n';pass=false;} 
	else if (!emailCheck(contactEmail.value)) {errors+='-  Must contain a valid [Contact Email].\n';pass=false;}			
	if (firstName.value == '' ){errors+='-  Must complete the field [First Name].\n';pass=false;}	
	if (username.value == '' ){errors+='-  Must complete the field [User Name].\n';pass=false;}
    //if (middleName.value == '' ){errors+='-  Must complete the field [Middle Initial Name].\n';pass=false;}
    if (lastName.value == '' ){errors+='-  Must complete the field [Last Name].\n';pass=false;}
    if (ssn1.value == '' ){errors+='-  Must complete the field [Social Security Number].\n';pass=false;}
	else if (!validateNumeric(ssn1)) {errors+='-  Must contain only digit [Social Security Number].\n';pass=false;}	
    if (ssn2.value == '' ){errors+='-  Must complete the field [Social Security Number].\n';pass=false;}
	else if (!validateNumeric(ssn2)) {errors+='-  Must contain only digit [Social Security Number].\n';pass=false;}	
    if (ssn3.value == '' ){errors+='-  Must complete the field [Social Security Number].\n';pass=false;}
	else if (!validateNumeric(ssn3)) {errors+='-  Must contain only digit [Social Security Number].\n';pass=false;}	
    if (billingAddress1.value == '' ){errors+='-  Must complete the field [Billing Address 1].\n';pass=false;}
    if (city.value == '' ){errors+='-  Must complete the field [City].\n';pass=false;}  
    if (country.value == 'US'){
		if (document.frm.state.value == '0' ){errors+='-  Must complete the field [State].\n';pass=false;}
	}
	if (zipCode.value == '' ){errors+='-  Must complete the field [Zip Code].\n';pass=false;}
	//else if (!validateNumeric(zipCode)) {errors+='-  Must contain only digit [Zip Code].\n';pass=false;}		
    if (phone1.value == ''){errors+='-  Must complete the field [Telephone].\n';pass=false;}
	else if (!validateNumeric(phone1)) {errors+='-  Must contain only digit [Telephone].\n';pass=false;}			
    if (phone2.value == '' ){errors+='-  Must complete the field [Telephone].\n';pass=false;}
	else if (!validateNumeric(phone2)) {errors+='-  Must contain only digit [Telephone].\n';pass=false;}				
    if (phone3.value == '' ){errors+='-  Must complete the field [Telephone].\n';pass=false;}
	else if (!validateNumeric(phone3)) {errors+='-  Must contain only digit [Telephone].\n';pass=false;}				
    //if (paypalEmail.value == '' ){errors+='-  Must complete the field [Paypal E-mail Address].\n';pass=false;}
	//else if (!emailCheck(paypalEmail.value)) {errors+='-  Must contain a valid [Paypal E-mail Address].\n';pass=false;}	
    if (password.value != passwordConfirm.value)
	{errors+='-  Confirm your [Password].\n';pass=false;}
	

	
	/*
    if (referredId.value != '' )
	{
		if (!validateNumeric(referredId)) {errors+='-  Must contain a valid [Referrence Id #].\n';pass=false;}				
	}
	*/

	if(sameShippingAddress[1].checked)
	{
		if (shippingAddress1.value == '' ){errors+='-  Must complete the field [Shipping Address 1].\n';pass=false;}
    	if (shippingCity.value == '' ){errors+='-  Must complete the field [Shipping City].\n';pass=false;}
	    if (shippingCountry.value == 'US'){
			if (shippingState.value == '0' ){errors+='-  Must complete the field [Shipping State].\n';pass=false;}
		}
    	if (shippingZipCode.value == '' ){errors+='-  Must complete the field [Shipping Zip Code].\n';pass=false;}		
		//else if (!validateNumeric(shippingZipCode)) {errors+='-  Must contain only digit [Shipping Zip Code].\n';pass=false;}						
	} 

	paymentMethodOk = false;		
	/*if(paymentMethod[0].checked)
	{
		if(!checkMailed.checked) {errors+='-  Must agree with the Mail Check Payment Method.\n';pass=false;}
		paymentMethodOk = true;		
		
	}*/
	//if(paymentMethod[0].checked)
	if(paymentMethod.checked)
	{
    	if (cardTypeId.value == '0' ){errors+='-  Must complete the field [Credit Card Type].\n';pass=false;}
    	if (cCNumber.value == '' ){errors+='-  Must complete the field [Credid Card Number].\n';pass=false;} 
		else if (!validateNumeric(cCNumber)) {errors+='-  Must contain only digit [Credid Card Number].\n';pass=false;}					
    	if (cCValidNr.value == '' ){errors+='-  Must complete the field [Validation Number].\n';pass=false;}
		else if (!validateNumeric(cCValidNr)) {errors+='-  Must contain only digit [Validation Number].\n';pass=false;}					
    	if (cCHolderfirstName.value == '' ){errors+='-  Must complete the field [Card holder\'s First Name].\n';pass=false;}
    	if (cCHolderlastName.value == '' ){errors+='-  Must complete the field [Card holder\'s Last Name].\n';pass=false;}

		if((cardTypeId.value=='3') && (cCNumber.value.length!=15))
		{ //American Express
			errors+='-  Wrong [Credit Card Number] length.\n';pass=false;				
		}

		paymentMethodOk = true;		
	}		
	//2006-08-31
	//Remove Electronic Check
	/*
	if(paymentMethod[1].checked)
	{
    	if (routingNBR.value == '' ){errors+='-  Must complete the field [ABA Routing Number].\n';pass=false;}
		else if (!validateNumeric(routingNBR)) {errors+='-  Must contain only digit [ABA Routing Number].\n';pass=false;}							
    	if (accountNr.value == '' ){errors+='-  Must complete the field [Checking Account Number].\n';pass=false;}
		else if (!validateNumeric(accountNr)) {errors+='-  Must contain only digit [Checking Account Number].\n';pass=false;}							
    	if (checkNr.value == '' ){errors+='-  Must complete the field [Check Number].\n';pass=false;}
		else if (!validateNumeric(checkNr)) {errors+='-  Must contain only digit [Check Number].\n';pass=false;}							
    	if (acctHolderName.value == '' ){errors+='-  Must complete the field [Account Holder Name].\n';pass=false;}
    	if (acctHolderAddress1.value == '' ){errors+='-  Must complete the field [Account Holder Address line 1:].\n';pass=false;}
    	if (acctHolderCity.value == '' ){errors+='-  Must complete the field [Account Holder City].\n';pass=false;}
    	if (acctHolderState.value == '0' ){errors+='-  Must complete the field [Account Holder State].\n';pass=false;}
    	if (acctHolderZipCode.value == '' ){errors+='-  Must complete the field [Account Holder Zip code].\n';pass=false;}
		//else if (!validateNumeric(acctHolderZipCode)) {errors+='-  Must contain only digit [Account Holder Zip code].\n';pass=false;}									
    	if (bankName.value == '' ){errors+='-  Must complete the field [Bank Name].\n';pass=false;}
    	if (bankAddress.value == '' ){errors+='-  Must complete the field [Bank Address].\n';pass=false;}
    	if (bankCity.value == '' ){errors+='-  Must complete the field [Bank City].\n';pass=false;}
    	if (bankState.value == '0' ){errors+='-  Must complete the field [Bank State].\n';pass=false;}
    	if (bankZipCode.value == '' ){errors+='-  Must complete the field [Bank Zip code].\n';pass=false;}
		//else if (!validateNumeric(bankZipCode)) {errors+='-  Must contain only digit [Bank Zip code].\n';pass=false;}							
    	if (dlnumber.value == '' ){errors+='-  Must complete the field [Driver License].\n';pass=false;}
		else if (!validateNumeric(dlnumber)) {errors+='-  Must contain only digit [Driver License].\n';pass=false;}											
		paymentMethodOk = true;				
	}
	*/
	
	/* 2006-10-02 Remove check by mail
	if(paymentMethod[1].checked)
	{
		paymentMethodOk = true;				
	}
	*/
	
    if (!paymentMethodOk){errors+='-  Must choose a Payment Method.\n';pass=false;}

		
	var selectedFO='';
	for (i = 1; i <= cantFO; i++) 
	{
		firstOrderIdStatus = 'document.frm.firstOrderId' + i + ".checked";
		firstOrderIdValue = 'document.frm.firstOrderId' + i + ".value";		
		if(eval(firstOrderIdStatus))
		{
			selectedFO = selectedFO + eval(firstOrderIdValue) + "," ;
		}
	}
	if(selectedFO != '')
	{
		document.frm.fistOrderList.value = selectedFO;
	}
	else
	{
		errors+='-  Must choose at leat one product for your first order.\n';pass=false;		
	}

			
			
			
			
	var selectedAO='';
	for (i2 = 1; i2 <= cantAO; i2++) 
	{
		autoOrderIdStatus = 'document.frm.autoOrderId' + i2 + ".checked";
		autoOrderIdValue = 'document.frm.autoOrderId' + i2 + ".value";		
		if(eval(autoOrderIdStatus))
		{
			selectedAO = selectedAO + eval(autoOrderIdValue) + "," ;
		}
	}
	
	if(selectedAO != '')
	{
		document.frm.autoOrderList.value = selectedAO;
	}
	else
	{
		errors+='-  Must choose at leat one product for your Auto Monthly order.\n';pass=false;		
	}
	

	if(!authorize.checked) {errors+='-  Must authorize CoralCalcium.net to handle your payment information.\n';pass=false;}
	
	
	if (!pass) 
    {
		alert('The following error(s) occurred:\n'+errors);
	}
	else
	{      
		disableSubmitButton('submitButton');
		document.frm.submit();

	}
}



/**************************************************************************************/
/**************************************************************************************/
function validAssociateBE()
{
	var pass=true;
	var errors='';
	
    firstName=document.frm.firstName; 
    middleName=document.frm.middleName; 
    lastName=document.frm.lastName; 
    ssn1=document.frm.ssn1; 
    ssn2=document.frm.ssn2; 
    ssn3=document.frm.ssn3; 
    company=document.frm.company; 
    billingAddress1=document.frm.billingAddress1; 
    billingAddress2=document.frm.billingAddress2; 
    city=document.frm.city;  
    state=document.frm.state; 
    zipCode=document.frm.zipCode; 
    phone1=document.frm.phone1; 
    phone2=document.frm.phone2; 
    phone3=document.frm.phone3; 
    paypalEmail=document.frm.paypalEmail; 
    contactEmail=document.frm.contactEmail; 
    newsLetter=document.frm.newsLetter; 
    referredBy=document.frm.referredBy; 
    referredId=document.frm.referredId; 
	
    sameShippingAddress=document.frm.sameShippingAddress; 
	shippingAddress1=document.frm.shippingAddress1; 
	shippingAddress2=document.frm.shippingAddress2; 
    shippingCity=document.frm.shippingCity; 
    shippingState=document.frm.shippingState; 
    shippingZipCode=document.frm.shippingZipCode; 
	
	paymentMethod=document.frm.paymentMethod; 	
	
	//checkMailed=document.frm.checkMailed; 
	
    cardTypeId=document.frm.cardTypeId; 
    cCNumber=document.frm.cCNumber; 
    expireDateMM=document.frm.expireDateMM; 
    expireDateYY=document.frm.expireDateYY; 	
    cCValidNr=document.frm.cCValidNr; 
    cCHolderfirstName=document.frm.cCHolderfirstName; 
    cCHoldermiddleName=document.frm.cCHoldermiddleName; 
    cCHolderlastName=document.frm.cCHolderlastName;
	
    routingNBR=document.frm.routingNBR; 
    accountNr=document.frm.accountNr; 
    checkNr=document.frm.checkNr; 
    acctHolderName=document.frm.acctHolderName; 
    acctHolderAddress1=document.frm.acctHolderAddress1; 
    acctHolderAddress2=document.frm.acctHolderAddress2; 
    acctHolderCity=document.frm.acctHolderCity; 
    acctHolderState=document.frm.acctHolderState; 
    acctHolderZipCode=document.frm.acctHolderZipCode; 
    bankName=document.frm.bankName; 
    bankAddress=document.frm.bankAddress; 
    bankCity=document.frm.bankCity; 
    bankState=document.frm.bankState; 
    bankZipCode=document.frm.bankZipCode; 
    authorize=document.frm.authorize; 
	
	

	if (firstName.value == '' ){errors+='-  Must complete the field [First Name].\n';pass=false;}
    if (lastName.value == '' ){errors+='-  Must complete the field [Last Name].\n';pass=false;}
    if (ssn1.value == '' ){errors+='-  Must complete the field [Social Security Number].\n';pass=false;}
	else if (!validateNumeric(ssn1)) {errors+='-  Must contain only digit [Social Security Number].\n';pass=false;}	
    if (ssn2.value == '' ){errors+='-  Must complete the field [Social Security Number].\n';pass=false;}
	else if (!validateNumeric(ssn2)) {errors+='-  Must contain only digit [Social Security Number].\n';pass=false;}	
    if (ssn3.value == '' ){errors+='-  Must complete the field [Social Security Number].\n';pass=false;}
	else if (!validateNumeric(ssn3)) {errors+='-  Must contain only digit [Social Security Number].\n';pass=false;}	
    if (billingAddress1.value == '' ){errors+='-  Must complete the field [Billing Address 1].\n';pass=false;}
    if (city.value == '' ){errors+='-  Must complete the field [City].\n';pass=false;}  
    if (state.value == '0' ){errors+='-  Must complete the field [State].\n';pass=false;}
    if (zipCode.value == '' ){errors+='-  Must complete the field [Zip Code].\n';pass=false;}
	//else if (!validateNumeric(zipCode)) {errors+='-  Must contain only digit [Zip Code].\n';pass=false;}		
    if (phone1.value == ''){errors+='-  Must complete the field [Telephone].\n';pass=false;}
	else if (!validateNumeric(phone1)) {errors+='-  Must contain only digit [Telephone].\n';pass=false;}			
    if (phone2.value == '' ){errors+='-  Must complete the field [Telephone].\n';pass=false;}
	else if (!validateNumeric(phone2)) {errors+='-  Must contain only digit [Telephone].\n';pass=false;}				
    if (phone3.value == '' ){errors+='-  Must complete the field [Telephone].\n';pass=false;}
	else if (!validateNumeric(phone3)) {errors+='-  Must contain only digit [Telephone].\n';pass=false;}				
    //if (paypalEmail.value == '' ){errors+='-  Must complete the field [Paypal E-mail Address].\n';pass=false;}
	//else if (!emailCheck(paypalEmail.value)) {errors+='-  Must contain a valid [Paypal E-mail Address].\n';pass=false;}	
    if (contactEmail.value == '' ){errors+='-  Must complete the field [Valid Contact E-mail Address].\n';pass=false;} 
	else if (!emailCheck(contactEmail.value)) {errors+='-  Must contain a valid [Contact Email].\n';pass=false;}		
    
	

	if (referredId.value != '' )
	{
		if (!validateNumeric(referredId)) {errors+='-  Must contain a valid [Referrence Id #].\n';pass=false;}				
	}

	
	if(sameShippingAddress[1].checked)
	{
		if (shippingAddress1.value == '' ){errors+='-  Must complete the field [Shipping Address 1].\n';pass=false;}
    	if (shippingCity.value == '' ){errors+='-  Must complete the field [Shipping City].\n';pass=false;}
	    if (shippingState.value == '0' ){errors+='-  Must complete the field [Shipping State].\n';pass=false;}
    	if (shippingZipCode.value == '' ){errors+='-  Must complete the field [Shipping Zip Code].\n';pass=false;}		
		//else if (!validateNumeric(shippingZipCode)) {errors+='-  Must contain only digit [Shipping Zip Code].\n';pass=false;}						
	} 

	paymentMethodOk = false;		
	/*if(paymentMethod[0].checked)
	{
		if(!checkMailed.checked) {errors+='-  Must agree with the Mail Check Payment Method.\n';pass=false;}
		paymentMethodOk = true;		
		
	}*/
	if(paymentMethod[0].checked)
	{
    	if (cardTypeId.value == '0' ){errors+='-  Must complete the field [Credit Card Type].\n';pass=false;}
    	if (cCNumber.value == '' ){errors+='-  Must complete the field [Credid Card Number].\n';pass=false;} 
		else if (!validateNumeric(cCNumber)) {errors+='-  Must contain only digit [Credid Card Number].\n';pass=false;}					
    	if (cCValidNr.value == '' ){errors+='-  Must complete the field [Validation Number].\n';pass=false;}
		else if (!validateNumeric(cCValidNr)) {errors+='-  Must contain only digit [Validation Number].\n';pass=false;}					
    	if (cCHolderfirstName.value == '' ){errors+='-  Must complete the field [Card holder\'s First Name].\n';pass=false;}
    	if (cCHolderlastName.value == '' ){errors+='-  Must complete the field [Card holder\'s Last Name].\n';pass=false;}
		
		if((cardTypeId.value=='3') && (cCNumber.value.length!=15))
		{ //American Express
			errors+='-  Wrong [Credit Card Number] length.\n';pass=false;				
		}		
		
		paymentMethodOk = true;		
	}		
	if(paymentMethod[1].checked)
	{
    	if (routingNBR.value == '' ){errors+='-  Must complete the field [ABA Routing Number].\n';pass=false;}
		else if (!validateNumeric(routingNBR)) {errors+='-  Must contain only digit [ABA Routing Number].\n';pass=false;}							
    	if (accountNr.value == '' ){errors+='-  Must complete the field [Checking Account Number].\n';pass=false;}
		else if (!validateNumeric(accountNr)) {errors+='-  Must contain only digit [Checking Account Number].\n';pass=false;}							
    	if (checkNr.value == '' ){errors+='-  Must complete the field [Check Number].\n';pass=false;}
		else if (!validateNumeric(checkNr)) {errors+='-  Must contain only digit [Check Number].\n';pass=false;}							
    	if (acctHolderName.value == '' ){errors+='-  Must complete the field [Account Holder Name].\n';pass=false;}
    	if (acctHolderAddress1.value == '' ){errors+='-  Must complete the field [Account Holder Address line 1:].\n';pass=false;}
    	if (acctHolderCity.value == '' ){errors+='-  Must complete the field [Account Holder City].\n';pass=false;}
    	if (acctHolderState.value == '0' ){errors+='-  Must complete the field [Account Holder State].\n';pass=false;}
    	if (acctHolderZipCode.value == '' ){errors+='-  Must complete the field [Account Holder Zip code].\n';pass=false;}
		//else if (!validateNumeric(acctHolderZipCode)) {errors+='-  Must contain only digit [Account Holder Zip code].\n';pass=false;}									
    	if (bankName.value == '' ){errors+='-  Must complete the field [Bank Name].\n';pass=false;}
    	if (bankAddress.value == '' ){errors+='-  Must complete the field [Bank Address].\n';pass=false;}
    	if (bankCity.value == '' ){errors+='-  Must complete the field [Bank City].\n';pass=false;}
    	if (bankState.value == '0' ){errors+='-  Must complete the field [Bank State].\n';pass=false;}
    	if (bankZipCode.value == '' ){errors+='-  Must complete the field [Bank Zip code].\n';pass=false;}
		//else if (!validateNumeric(bankZipCode)) {errors+='-  Must contain only digit [Bank Zip code].\n';pass=false;}							
		paymentMethodOk = true;				
	}

    if (!paymentMethodOk){errors+='-  Must choose a Payment Method.\n';pass=false;}
	if(!authorize.checked) {errors+='-  Must authorize CoralCalcium.net to handle your payment information.\n';pass=false;}
	
	
	if (!pass) 
    {
		alert('The following error(s) occurred:\n'+errors);
	}
	else
	{      
		document.frm.submit();

	}
}


/**************************************************************************************/
/**************************************************************************************/
function validateNumeric(field) 
{
	var valid = "0123456789.,"
	var ok = "yes";
	var temp;
	for (var i=0; i<field.value.length; i++) 
	{
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = "no";
	}
	if (ok == "no") 
	{
		return false;
	}
	else
	{
		return true;
	}
}


/**************************************************************************************/
/**************************************************************************************/
function validateCharacter(field) 
{
	var valid = "QWERTYUIOPASDFGHJKLÑZXCVBNMqwertyuiopasdfghjklñzxcvbnm -`"
	var ok = "yes";
	var temp;
	for (var i=0; i<field.value.length; i++) 
	{
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = "no";
	}
	if (ok == "no") 
	{
		return false;
	}
	else
	{
		return true;
	}
}


/**************************************************************************************/
/**************************************************************************************/
function validateSpecialCharacters(field) 
{
	var valid = "!ºª|@#~€<>¬`+^*¨Ç´ç{}[]+-.*·$%&/()=?¿_"
	var ok = "yes";
	var temp;
	for (var i=0; i<field.value.length; i++) 
	{
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1")
		{
			 ok = "no";
		}
	}
	if (ok == "no") 
	{
		return false;
	}
	else
	{
		return true;
	}
}


/**************************************************************************************/
/**************************************************************************************/
function emailCheck (emailStr) 
{
	return emailStr.match(/^(.+)@(.+)\.(.+)$/);
}


var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) 
{
			var keyCode = (isNN) ? e.which : e.keyCode; 
			var filter = (isNN) ? [0,8,9] : [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();
}
		 
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 validateUser()
{
	var pass=true;
	var errors='';
	 
	username=document.frm.username; 
    password=document.frm.password; 
		
	if (username.value == '' ){errors+='-  Must complete the field [User Name].\n';pass=false;}
    if (password.value == '' ){errors+='-  Must complete the field [Password].\n';pass=false;}		
	
	if (!pass) 
    {
		alert('The following error(s) occurred:\n'+errors);
	}
	else
	{      
		document.frm.submit();

	}	
	
}


/**************************************************************************************/
/**************************************************************************************/
function validAssociate3()
{
	var pass=true;
	var errors='';


	firstName=document.frm.firstName; 
    middleName=document.frm.middleName; 
    lastName=document.frm.lastName; 
    address=document.frm.address; 
	country=document.frm.country; 
    city=document.frm.city; 
    //state=document.frm.state; 
    zipCode=document.frm.zipCode; 
    shipToEmail=document.frm.shipToEmail; 
    shiptoPhone1=document.frm.shiptoPhone1; 
    shiptoPhone2=document.frm.shiptoPhone2; 
    shiptoPhone3=document.frm.shiptoPhone3; 
    ssn1=document.frm.ssn1; 
    ssn2=document.frm.ssn2; 
    ssn3=document.frm.ssn3; 
	dlnumber=document.frm.dlnumber; 
	paymentMethod=document.frm.paymentMethod; 
	
    cardTypeId=document.frm.cardTypeId; 
    cCNumber=document.frm.cCNumber; 
    expireDateMM=document.frm.expireDateMM; 
    expireDateYY=document.frm.expireDateYY; 	
    cCValidNr=document.frm.cCValidNr; 
    cCHolderfirstName=document.frm.cCHolderfirstName; 
    cCHoldermiddleName=document.frm.cCHoldermiddleName; 
    cCHolderlastName=document.frm.cCHolderlastName;
	
    routingNBR=document.frm.routingNBR; 
    accountNr=document.frm.accountNr; 
    checkNr=document.frm.checkNr; 
    acctHolderName=document.frm.acctHolderName; 
    acctHolderAddress1=document.frm.acctHolderAddress1; 
    acctHolderAddress2=document.frm.acctHolderAddress2; 
    acctHolderCity=document.frm.acctHolderCity; 
    acctHolderState=document.frm.acctHolderState; 
    acctHolderZipCode=document.frm.acctHolderZipCode; 
    bankName=document.frm.bankName; 
    bankAddress=document.frm.bankAddress; 
    bankCity=document.frm.bankCity; 
    bankState=document.frm.bankState; 
    bankZipCode=document.frm.bankZipCode; 
    authorize=document.frm.authorize; 
	dlnumber=document.frm.dlnumber; 	
	
	
	if (firstName.value == '' ){errors+='-  Must complete the field [First Name].\n';pass=false;}	
    if (lastName.value == '' ){errors+='-  Must complete the field [Last Name].\n';pass=false;}	
    if (address.value == '' ){errors+='-  Must complete the field [Address].\n';pass=false;}	
    if (city.value == '' ){errors+='-  Must complete the field [City].\n';pass=false;}	
    //if (state.value == '0' ){errors+='-  Must complete the field [State].\n';pass=false;}	
    if (country == '0' ){errors+='-  Must complete the field [Country].\n';pass=false;}		
    if (zipCode.value == '' ){errors+='-  Must complete the field [Zip Code].\n';pass=false;}
	//else{if (!validateNumeric(zipCode)) {errors+='-  Must contain a valid [Zip Code].\n';pass=false;}				}
	if (shipToEmail.value == '' ){errors+='-  Must complete the field [Ship to Email].\n';pass=false;}		
	else
	{
		if (!emailCheck(shipToEmail.value)) {errors+='-  Must contain a valid [Ship to Email].\n';pass=false;}	
	}
    if (shiptoPhone1.value == '' ){errors+='-  Must complete the field [Ship to Phone].\n';pass=false;}		
	{
		if (!validateNumeric(shiptoPhone1)) {errors+='-  Must contain a valid [Ship to Phone].\n';pass=false;}				
	}
    if (shiptoPhone2.value == '' ){errors+='-  Must complete the field [Ship to Phone].\n';pass=false;}		
	{
		if (!validateNumeric(shiptoPhone2)) {errors+='-  Must contain a valid [Ship to Phone].\n';pass=false;}				
	}
    if (shiptoPhone3.value == '' ){errors+='-  Must complete the field [Ship to Phone].\n';pass=false;}		
	{
		if (!validateNumeric(shiptoPhone3)) {errors+='-  Must contain a valid [Ship to Phone].\n';pass=false;}				
	}
	

    if (ssn1.value == '' ){errors+='-  Must complete the field [Social Security Number].\n';pass=false;}
	else if (!validateNumeric(ssn1)) {errors+='-  Must contain only digit [Social Security Number].\n';pass=false;}	
    if (ssn2.value == '' ){errors+='-  Must complete the field [Social Security Number].\n';pass=false;}
	else if (!validateNumeric(ssn2)) {errors+='-  Must contain only digit [Social Security Number].\n';pass=false;}	
    if (ssn3.value == '' ){errors+='-  Must complete the field [Social Security Number].\n';pass=false;}
	else if (!validateNumeric(ssn3)) {errors+='-  Must contain only digit [Social Security Number].\n';pass=false;}	

	paymentMethodOk = false;		
	/* Pay Pal
	if(paymentMethod[0].checked)
	{
		paymentMethodOk = true;				
	}*/
	
	//if(paymentMethod[0].checked)
	var pCheck = null;
	try {
		pCheck = paymentMethod[0];
	}catch(e){}
	try {
		pCheck = paymentMethod;
	}catch(e){}
	
	if(pCheck && pCheck.checked)
	{
    	if (cardTypeId.value == '0' ){errors+='-  Must complete the field [Credit Card Type].\n';pass=false;}
    	if (cCNumber.value == '' ){errors+='-  Must complete the field [Credid Card Number].\n';pass=false;} 
		else if (!validateNumeric(cCNumber)) {errors+='-  Must contain only digit [Credid Card Number].\n';pass=false;}					
    	if (cCValidNr.value == '' ){errors+='-  Must complete the field [Validation Number].\n';pass=false;}
		else if (!validateNumeric(cCValidNr)) {errors+='-  Must contain only digit [Validation Number].\n';pass=false;}					
    	if (cCHolderfirstName.value == '' ){errors+='-  Must complete the field [Card holder\'s First Name].\n';pass=false;}
    	if (cCHolderlastName.value == '' ){errors+='-  Must complete the field [Card holder\'s Last Name].\n';pass=false;}
		
		if((cardTypeId.value=='3') && (cCNumber.value.length!=15))
		{ //American Express
			errors+='-  Wrong [Credit Card Number] length.\n';pass=false;				
		}
		
		paymentMethodOk = true;		
	}		
	//2006-08-31
	// Remove Electronic Check.  
	/*
	if(paymentMethod[1].checked)
	{
    	if (routingNBR.value == '' ){errors+='-  Must complete the field [ABA Routing Number].\n';pass=false;}
		else if (!validateNumeric(routingNBR)) {errors+='-  Must contain only digit [ABA Routing Number].\n';pass=false;}							
    	if (accountNr.value == '' ){errors+='-  Must complete the field [Checking Account Number].\n';pass=false;}
		else if (!validateNumeric(accountNr)) {errors+='-  Must contain only digit [Checking Account Number].\n';pass=false;}							
    	if (checkNr.value == '' ){errors+='-  Must complete the field [Check Number].\n';pass=false;}
		else if (!validateNumeric(checkNr)) {errors+='-  Must contain only digit [Check Number].\n';pass=false;}							
    	if (acctHolderName.value == '' ){errors+='-  Must complete the field [Account Holder Name].\n';pass=false;}
    	if (acctHolderAddress1.value == '' ){errors+='-  Must complete the field [Account Holder Address line 1:].\n';pass=false;}
    	if (acctHolderCity.value == '' ){errors+='-  Must complete the field [Account Holder City].\n';pass=false;}
    	if (acctHolderState.value == '0' ){errors+='-  Must complete the field [Account Holder State].\n';pass=false;}
    	if (acctHolderZipCode.value == '' ){errors+='-  Must complete the field [Account Holder Zip code].\n';pass=false;}
		//else if (!validateNumeric(acctHolderZipCode)) {errors+='-  Must contain only digit [Account Holder Zip code].\n';pass=false;}									
    	if (bankName.value == '' ){errors+='-  Must complete the field [Bank Name].\n';pass=false;}
    	if (bankAddress.value == '' ){errors+='-  Must complete the field [Bank Address].\n';pass=false;}
    	if (bankCity.value == '' ){errors+='-  Must complete the field [Bank City].\n';pass=false;}
    	if (bankState.value == '0' ){errors+='-  Must complete the field [Bank State].\n';pass=false;}
    	if (bankZipCode.value == '' ){errors+='-  Must complete the field [Bank Zip code].\n';pass=false;}
		//else if (!validateNumeric(bankZipCode)) {errors+='-  Must contain only digit [Bank Zip code].\n';pass=false;}							
    	if (dlnumber.value == '' ){errors+='-  Must complete the field [Driver License].\n';pass=false;}
		else if (!validateNumeric(dlnumber)) {errors+='-  Must contain only digit [Driver License].\n';pass=false;}													
    	if (dlnumber.value == '' ){errors+='-  Must complete the field [Driver License].\n';pass=false;}
		else if (!validateNumeric(dlnumber)) {errors+='-  Must contain only digit [Driver License].\n';pass=false;}
		paymentMethodOk = true;				
	}*/
	
	/* 2006-10-02 Remove check by mail
	if(paymentMethod[1].checked)
	{
		paymentMethodOk = true;	
	}
	*/

    if (!paymentMethodOk){errors+='-  Must choose a Payment Method.\n';pass=false;}
	
	
	if (!pass) 
    {
		alert('The following error(s) occurred:\n'+errors);
	}
	else
	{      
		document.frm.submit();

	}
}



/**************************************************************************************/
/**************************************************************************************/
function validOrderDtUpdate(){
	 
	if(validateCombos(document.frm.orderShipMonth)== false){return false}
    if(validateCombos(document.frm.orderShipDay)== false){return false}
    if(validateCombos(document.frm.orderShipYear)== false){return false}
	document.frm.submit();
	
}

/**************************************************************************************/
/**************************************************************************************/
function validAssociate2()
{
	var pass=true;
	var errors='';

    password=document.frm.password; 
    passwordConfirm=document.frm.passwordConfirm; 
	
    firstName=document.frm.firstName; 
    middleName=document.frm.middleName; 
    lastName=document.frm.lastName; 
    ssn1=document.frm.ssn1; 
    ssn2=document.frm.ssn2; 
    ssn3=document.frm.ssn3; 
    company=document.frm.company; 
    billingAddress1=document.frm.billingAddress1; 
    billingAddress2=document.frm.billingAddress2; 
    city=document.frm.city;  
    country = document.frm.country;
//	state=document.frm.state; 
    zipCode=document.frm.zipCode; 
    phone1=document.frm.phone1; 
    phone2=document.frm.phone2; 
    phone3=document.frm.phone3; 
    paypalEmail=document.frm.paypalEmail; 
    contactEmail=document.frm.contactEmail; 
    newsLetter=document.frm.newsLetter; 
    referredBy=document.frm.referredBy; 
    referredId=document.frm.referredId; 
	
    sameShippingAddress=document.frm.sameShippingAddress; 
	shippingAddress1=document.frm.shippingAddress1; 
	shippingAddress2=document.frm.shippingAddress2; 
    shippingCity=document.frm.shippingCity; 
    shippingCountry = document.frm.shippingCountry;
	shippingState=document.frm.shippingState; 
    shippingZipCode=document.frm.shippingZipCode; 
	
	paymentMethod=document.frm.paymentMethod; 	
	
	//checkMailed=document.frm.checkMailed; 
	
    cardTypeId=document.frm.cardTypeId; 
    cCNumber=document.frm.cCNumber; 
    expireDateMM=document.frm.expireDateMM; 
    expireDateYY=document.frm.expireDateYY; 	
    cCValidNr=document.frm.cCValidNr; 
    cCHolderfirstName=document.frm.cCHolderfirstName; 
    cCHoldermiddleName=document.frm.cCHoldermiddleName; 
    cCHolderlastName=document.frm.cCHolderlastName;
	
    routingNBR=document.frm.routingNBR; 
    accountNr=document.frm.accountNr; 
    checkNr=document.frm.checkNr; 
    acctHolderName=document.frm.acctHolderName; 
    acctHolderAddress1=document.frm.acctHolderAddress1; 
    acctHolderAddress2=document.frm.acctHolderAddress2; 
    acctHolderCity=document.frm.acctHolderCity; 
    acctHolderState=document.frm.acctHolderState; 
    acctHolderZipCode=document.frm.acctHolderZipCode; 
    bankName=document.frm.bankName; 
    bankAddress=document.frm.bankAddress; 
    bankCity=document.frm.bankCity; 
    bankState=document.frm.bankState; 
    bankZipCode=document.frm.bankZipCode; 
    authorize=document.frm.authorize; 
	dlnumber=document.frm.dlnumber; 	
	
	
	if (password.value == '' ){errors+='-  Must complete the field [Password].\n';pass=false;}	
    if (passwordConfirm.value == '' ){errors+='-  Must complete the field [Confirm Password].\n';pass=false;}	
	if (firstName.value == '' ){errors+='-  Must complete the field [First Name].\n';pass=false;}
    if (lastName.value == '' ){errors+='-  Must complete the field [Last Name].\n';pass=false;}
    if (ssn1.value == '' ){errors+='-  Must complete the field [Social Security Number].\n';pass=false;}
	else if (!validateNumeric(ssn1)) {errors+='-  Must contain only digit [Social Security Number].\n';pass=false;}	
    if (ssn2.value == '' ){errors+='-  Must complete the field [Social Security Number].\n';pass=false;}
	else if (!validateNumeric(ssn2)) {errors+='-  Must contain only digit [Social Security Number].\n';pass=false;}	
    if (ssn3.value == '' ){errors+='-  Must complete the field [Social Security Number].\n';pass=false;}
	else if (!validateNumeric(ssn3)) {errors+='-  Must contain only digit [Social Security Number].\n';pass=false;}	
    if (billingAddress1.value == '' ){errors+='-  Must complete the field [Billing Address 1].\n';pass=false;}
    if (city.value == '' ){errors+='-  Must complete the field [City].\n';pass=false;}  
    //if (state.value == '0' ){errors+='-  Must complete the field [State].\n';pass=false;}
	if (zipCode.value == '' ){errors+='-  Must complete the field [Zip Code].\n';pass=false;}
	//else if (!validateNumeric(zipCode)) {errors+='-  Must contain only digit [Zip Code].\n';pass=false;}		
    if (phone1.value == ''){errors+='-  Must complete the field [Telephone].\n';pass=false;}
	else if (!validateNumeric(phone1)) {errors+='-  Must contain only digit [Telephone].\n';pass=false;}			
    if (phone2.value == '' ){errors+='-  Must complete the field [Telephone].\n';pass=false;}
	else if (!validateNumeric(phone2)) {errors+='-  Must contain only digit [Telephone].\n';pass=false;}				
    if (phone3.value == '' ){errors+='-  Must complete the field [Telephone].\n';pass=false;}
	else if (!validateNumeric(phone3)) {errors+='-  Must contain only digit [Telephone].\n';pass=false;}				
    //if (paypalEmail.value == '' ){errors+='-  Must complete the field [Paypal E-mail Address].\n';pass=false;}
	//else if (!emailCheck(paypalEmail.value)) {errors+='-  Must contain a valid [Paypal E-mail Address].\n';pass=false;}	
    if (contactEmail.value == '' ){errors+='-  Must complete the field [Valid Contact E-mail Address].\n';pass=false;} 
	else if (!emailCheck(contactEmail.value)) {errors+='-  Must contain a valid [Contact Email].\n';pass=false;}		
    if (referredId.value != '' )
	{
		if (!validateNumeric(referredId)) {errors+='-  Must contain a valid [Referrence Id #].\n';pass=false;}				
	}

	if(sameShippingAddress[1].checked)
	{
		if (shippingAddress1.value == '' ){errors+='-  Must complete the field [Shipping Address 1].\n';pass=false;}
    	if (shippingCity.value == '' ){errors+='-  Must complete the field [Shipping City].\n';pass=false;}
		if (shippingCountry.value == 'US'){
	    	if (shippingState.value == '0' ){errors+='-  Must complete the field [Shipping State].\n';pass=false;}
		}
    	if (shippingZipCode.value == '' ){errors+='-  Must complete the field [Shipping Zip Code].\n';pass=false;}		
		//else if (!validateNumeric(shippingZipCode)) {errors+='-  Must contain only digit [Shipping Zip Code].\n';pass=false;}						
	} 



	paymentMethodOk = false;		
	/*if(paymentMethod[0].checked)
	{
		if(!checkMailed.checked) {errors+='-  Must agree with the Mail Check Payment Method.\n';pass=false;}
		paymentMethodOk = true;		
		
	}*/
	//if(paymentMethod[0].checked)
	if(paymentMethod.checked)
	{
    	if (cardTypeId.value == '0' ){errors+='-  Must complete the field [Credit Card Type].\n';pass=false;}
    	if (cCNumber.value == '' ){errors+='-  Must complete the field [Credid Card Number].\n';pass=false;} 
		else if (!validateNumeric(cCNumber)) {errors+='-  Must contain only digit [Credid Card Number].\n';pass=false;}					
    	if (cCValidNr.value == '' ){errors+='-  Must complete the field [Validation Number].\n';pass=false;}
		else if (!validateNumeric(cCValidNr)) {errors+='-  Must contain only digit [Validation Number].\n';pass=false;}					
    	if (cCHolderfirstName.value == '' ){errors+='-  Must complete the field [Card holder\'s First Name].\n';pass=false;}
    	if (cCHolderlastName.value == '' ){errors+='-  Must complete the field [Card holder\'s Last Name].\n';pass=false;}
		
		if((cardTypeId.value=='3') && (cCNumber.value.length!=15))
		{ //American Express
			errors+='-  Wrong [Credit Card Number] length.\n';pass=false;				
		}
		
		paymentMethodOk = true;		
	}		
	/*
	if(paymentMethod[1].checked)
	{
    	if (routingNBR.value == '' ){errors+='-  Must complete the field [ABA Routing Number].\n';pass=false;}
		else if (!validateNumeric(routingNBR)) {errors+='-  Must contain only digit [ABA Routing Number].\n';pass=false;}							
    	if (accountNr.value == '' ){errors+='-  Must complete the field [Checking Account Number].\n';pass=false;}
		else if (!validateNumeric(accountNr)) {errors+='-  Must contain only digit [Checking Account Number].\n';pass=false;}							
    	if (checkNr.value == '' ){errors+='-  Must complete the field [Check Number].\n';pass=false;}
		else if (!validateNumeric(checkNr)) {errors+='-  Must contain only digit [Check Number].\n';pass=false;}							
    	if (acctHolderName.value == '' ){errors+='-  Must complete the field [Account Holder Name].\n';pass=false;}
    	if (acctHolderAddress1.value == '' ){errors+='-  Must complete the field [Account Holder Address line 1:].\n';pass=false;}
    	if (acctHolderCity.value == '' ){errors+='-  Must complete the field [Account Holder City].\n';pass=false;}
    	if (acctHolderState.value == '0' ){errors+='-  Must complete the field [Account Holder State].\n';pass=false;}
    	if (acctHolderZipCode.value == '' ){errors+='-  Must complete the field [Account Holder Zip code].\n';pass=false;}
		//else if (!validateNumeric(acctHolderZipCode)) {errors+='-  Must contain only digit [Account Holder Zip code].\n';pass=false;}									
    	if (bankName.value == '' ){errors+='-  Must complete the field [Bank Name].\n';pass=false;}
    	if (bankAddress.value == '' ){errors+='-  Must complete the field [Bank Address].\n';pass=false;}
    	if (bankCity.value == '' ){errors+='-  Must complete the field [Bank City].\n';pass=false;}
    	if (bankState.value == '0' ){errors+='-  Must complete the field [Bank State].\n';pass=false;}
    	if (bankZipCode.value == '' ){errors+='-  Must complete the field [Bank Zip code].\n';pass=false;}
		//else if (!validateNumeric(bankZipCode)) {errors+='-  Must contain only digit [Bank Zip code].\n';pass=false;}							
    	if (dlnumber.value == '' ){errors+='-  Must complete the field [Driver License].\n';pass=false;}
		else if (!validateNumeric(dlnumber)) {errors+='-  Must contain only digit [Driver License].\n';pass=false;}													
		paymentMethodOk = true;				
	}
	*/
	
	/* 2006-10-02 Remove check by mail
	if(paymentMethod[1].checked)
	{
		paymentMethodOk = true;		
	}
	*/

    if (!paymentMethodOk){errors+='-  Must choose a Payment Method.\n';pass=false;}
	

    if (password.value != passwordConfirm.value)
	{errors+='-  Confirm your [Password].\n';pass=false;}
	
	
	if (!pass) 
    {
		alert('The following error(s) occurred:\n'+errors);
	}
	else
	{      
		document.frm.submit();

	}
}

function hideState(xx){
	if(xx != 'US')
	{
		document.getElementById('state').style.display = 'none';
		document.frm.state.value = "99";
	}
	else
	{
		document.getElementById('state').style.display = '';
		document.frm.state.value = "";
	}
}


function performProductRestrictionCheck(boxId,catId,namespacex){
	if(!namespacex)
		namespacex = '';
	
	try {
		var idx = 1;
		var elem = null;
		while(elem = document.getElementById('customerOrderIdCat'+namespacex+idx)){
			if(parseInt(catId) == parseInt(elem.innerHTML) && idx != boxId){
				document.getElementById('customerOrderId'+namespacex+idx).checked = false;
			}
			idx++;	
		}
	}catch(e){}
}

function selectReferrer(sbox){
	var idx = sbox.selectedIndex;
	if(refIDS && refIDS[idx]){
		document.getElementById('referredId').value = refIDS[idx];
	}
}

function disableSubmitButton(button){
	try {
		if(document.getElementById(button)){
			document.getElementById(button).disabled = true;
		}
	}catch(e){}
}

function updateStateProvSelector(cname){
  
  try {
    var csel = document.getElementById(cname);
		if(csel){
      var cval = csel.options[csel.selectedIndex].value;
      var label = 'State / Province:&nbsp;';
      var show = 'BOTH';
      if(cval == 'US'){
        label = 'State:&nbsp;';
        show = 'US';
      }else if(cval == 'CA'){
        label = 'Province:&nbsp;';
        show = 'CA';
      }
      document.getElementById(cname+'-SSLABEL').innerHTML = label;
      
      document.getElementById(cname+'-SSBOTH').name = document.getElementById(cname+'-SSBOTH').name.replace('-inactive','')+'-inactive';
      document.getElementById(cname+'-SSBOTH').style.display = 'none';
      
      document.getElementById(cname+'-SSUS').name = document.getElementById(cname+'-SSBOTH').name.replace('-inactive','')+'-inactive';
      document.getElementById(cname+'-SSUS').style.display = 'none';
      
      document.getElementById(cname+'-SSCA').name = document.getElementById(cname+'-SSBOTH').name.replace('-inactive','')+'-inactive';
      document.getElementById(cname+'-SSCA').style.display = 'none';
      
      document.getElementById(cname+'-SS'+show).name = document.getElementById(cname+'-SSBOTH').name.replace('-inactive','');
      document.getElementById(cname+'-SS'+show).style.display = 'block';
    }
	}catch(e){}
}