﻿// JScript File
function copyBillTo(theForm)
{
    theForm.shipToName.value = theForm.billToName.value;
	theForm.shipToFName.value = theForm.billToFName.value;
	theForm.shipToLName.value = theForm.billToLName.value;
	theForm.shipToCompany.value = theForm.billToCompany.value;
	theForm.shipToStreet1.value = theForm.billToStreet1.value;
	theForm.shipToStreet2.value = theForm.billToStreet2.value;
	if (theForm.shipToStreet3 && theForm.billToStreet3){theForm.shipToStreet3.value = theForm.billToStreet3.value;}
	theForm.shipToCity.value = theForm.billToCity.value;
	theForm.shipToState.value = theForm.billToState.value;
	theForm.shipToPostal.value = theForm.billToPostal.value;
	if (theForm.shipToCountry){theForm.shipToCountry.value = theForm.billToCountry.value;}
	theForm.shipToHomePhone.value = theForm.billToHomePhone.value;
	theForm.shipToBizPhone.value = theForm.billToBizPhone.value;
	if (theForm.shipToCompanyURL.value ){theForm.shipToCompanyURL.value = theForm.billToCompanyURL.value;}
}

function FocusNextField (currentField,nextField,maxChar)
{
    var currentFieldValue = eval('document.getElementById("'+currentField+'").value');
    if (currentFieldValue.length == maxChar)
    {
        eval('document.getElementById("'+nextField+'").focus()');
        eval('document.getElementById("'+nextField+'").select()');
    }
}


function ActivateAlternateBilling(theForm)
{
    if (theForm.ctl00_Main_ctrlBilling_alternateBillAddress != null)
        theForm.ctl00_Main_ctrlBilling_alternateBillAddress.disabled = false;
    theForm.altBillToName.disabled = false;
    theForm.altbBillToFName.disabled = false;
    theForm.altBillToLName.disabled = false;
    theForm.altBillToCompany.disabled = false;
    if (theForm.altBillToCompanyURL){theForm.altBillToCompanyURL.disabled = false;}
    theForm.altBillToStreet1.disabled = false;
    theForm.altBillToStreet2.disabled = false;
    
    if (theForm.altBillToStreet3){theForm.altBillToStreet3.disabled = false;}    
    theForm.altBillToCity.disabled = false;
    theForm.altBillToState.disabled = false;    
    theForm.altBillToPostal.disabled = false;
    theForm.altBillToHomePhone.disabled = false;
    theForm.altBillToBizPhone.disabled = false;
    theForm.altBillToEmail.disabled = false;
    theForm.altBillToCountry.disabled = false;
    if (theForm.billAlternateToStateNameVal){theForm.billAlternateToStateNameVal.disabled = false;}

    
    theForm.altPaymentMethod.disabled = false;
    theForm.altCardNumber.disabled = false;
    theForm.altCardExpMonth.disabled = false;
    theForm.altCardExpYear.disabled = false;
    theForm.altCardCVV.disabled = false;
    theForm.altCardCVV.disabled = false;
    theForm.altTxtCheckNumber.disabled = false;
    theForm.txtAltAmount.disabled = false;
}

function DeactivateAlternateBilling(theForm)
{
    if (theForm.ctl00_Main_ctrlBilling_alternateBillAddress != null)
    {
        theForm.ctl00_Main_ctrlBilling_alternateBillAddress.disabled = true;
        theForm.ctl00_Main_ctrlBilling_alternateBillAddress.selectedIndex = -1;
    }
    theForm.altBillToName.disabled = true;
    theForm.altbBillToFName.disabled = true;
    theForm.altBillToLName.disabled = true;
    theForm.altBillToCompany.disabled = true;
    if (theForm.altBillToCompanyURL){ theForm.altBillToCompanyURL.disabled = true;}
    theForm.altBillToStreet1.disabled = true;
    theForm.altBillToStreet2.disabled = true;
    if (theForm.altBillToStreet3){theForm.altBillToStreet3.disabled = true;}
    theForm.altBillToCity.disabled = true;
    theForm.altBillToState.disabled = true;    
    theForm.altBillToPostal.disabled = true;
    theForm.altBillToHomePhone.disabled = true;
    theForm.altBillToBizPhone.disabled = true;
    theForm.altBillToEmail.disabled = true;
    theForm.altBillToCountry.disabled = true;
    if (theForm.billAlternateToStateNameVal){theForm.billAlternateToStateNameVal.disabled = true;}

    theForm.altPaymentMethod.disabled = true;
    theForm.altCardNumber.disabled = true;
    theForm.altCardExpMonth.disabled = true;
    theForm.altCardExpYear.disabled = true;
    theForm.altCardCVV.disabled = true;
    theForm.altCardCVV.disabled = true;
    theForm.altTxtCheckNumber.disabled = true;
    theForm.txtAltAmount.disabled = true;
}

function ActivateBilling(theForm)
{
    theForm.billToName.disabled = false;
    theForm.billToFName.disabled = false;
    theForm.billToLName.disabled = false;
    theForm.billToCompany.disabled = false;
    if(theForm.billToCompanyURL){theForm.billToCompanyURL.disabled = false;}
    theForm.billToStreet1.disabled = false;
    theForm.billToStreet2.disabled = false;
    if (theForm.billToStreet3){theForm.billToStreet3.disabled = false;}
    theForm.billToCity.disabled = false;
    theForm.billToState.disabled = false;    
    theForm.billToPostal.disabled = false;
    theForm.billToHomePhone.disabled = false;
    theForm.billToBizPhone.disabled = false;
    theForm.billToEmail.disabled = false;
    theForm.billToCountry.disabled = false;
    if (theForm.billToStateNameVal){theForm.billToStateNameVal.disabled = false;}
}

function DeactivateBilling(theForm)
{
    //use readOnly if you want to be able to submit info, otherwise use disabled
    theForm.billToName.disabled = true; 
    theForm.billToFName.disabled = true; 
    theForm.billToLName.disabled = true; 
    theForm.billToCompany.disabled = true;
    if (theForm.billToCompanyURL){theForm.billToCompanyURL.disabled = true;}
    theForm.billToStreet1.disabled = true;
    theForm.billToStreet2.disabled = true;
    if (theForm.billToStreet3){theForm.billToStreet3.disabled = true;}
    theForm.billToCity.disabled = true;
    theForm.billToState.disabled = true;
    theForm.billToPostal.disabled = true;
    theForm.billToHomePhone.disabled = true;
    theForm.billToBizPhone.disabled = true;
    theForm.billToEmail.disabled = true;
    theForm.billToCountry.disabled = true;
    if (theForm.billToStateNameVal){theForm.billToStateNameVal.disabled = true;}
}


function ActivateShipping(theForm)
{
    theForm.shipToName.disabled = false;
    theForm.shipToFName.disabled = false;
    theForm.shipToLName.disabled = false;
     theForm.shipToStreet1.disabled = false;
    theForm.shipToStreet2.disabled = false;
    if (theForm.shipToStreet3){theForm.shipToStreet3.disabled = false;}
    theForm.shipToCity.disabled = false;
    theForm.shipToState.disabled = false;    
    theForm.shipToPostal.disabled = false;
    if (theForm.shipToHomePhone){theForm.shipToHomePhone.disabled = false;}
    if (theForm.shipToBizPhone){theForm.shipToBizPhone.disabled = false;}
    theForm.shipToEmail.disabled = false;
    theForm.shipResAddress.disabled = false;
    if (theForm.shipToCountry){theForm.shipToCountry.disabled = false;}
    if (theForm.shipToStateNameVal){theForm.shipToStateNameVal.disabled = false;}    
    if (theForm.ctl00$Main$ctrlShipping$shipToAddress) { theForm.ctl00$Main$ctrlShipping$shipToAddress.disabled = false; }
    if (theForm.shipToHomePhoneAC){theForm.shipToHomePhoneAC.disabled = false;}
    if (theForm.shipToHomePhonePRE){theForm.shipToHomePhonePRE.disabled = false;}
    if (theForm.shipToHomePhoneSUF){theForm.shipToHomePhoneSUF.disabled = false;}
    
}

function DeactivateShipping(theForm)
{
    //use readOnly if you want to be able to submit info, otherwise use disabled
    theForm.shipToName.disabled = true; 
    theForm.shipToFName.disabled = true; 
    theForm.shipToLName.disabled = true; 
     theForm.shipToStreet1.disabled = true;
    theForm.shipToStreet2.disabled = true;
    if (theForm.shipToStreet3){theForm.shipToStreet3.disabled = true;}
    theForm.shipToCity.disabled = true;
    theForm.shipToState.disabled = true;
    theForm.shipToPostal.disabled = true;
    if (theForm.shipToHomePhone){theForm.shipToHomePhone.disabled = true;}
      if (theForm.shipToBizPhone){theForm.shipToBizPhone.disabled = true;}
    theForm.shipToEmail.disabled = true;
    theForm.shipResAddress.disabled = true;
    if (theForm.shipToCountry){theForm.shipToCountry.disabled = true;}
    if (theForm.shipToStateNameVal){theForm.shipToStateNameVal.disabled = true;}
    if (theForm.ctl00$Main$ctrlShipping$shipToAddress) { theForm.ctl00$Main$ctrlShipping$shipToAddress.disabled = true; }
    if (theForm.shipToHomePhoneAC){theForm.shipToHomePhoneAC.disabled = true;}
    if (theForm.shipToHomePhonePRE){theForm.shipToHomePhonePRE.disabled = true;}
    if (theForm.shipToHomePhoneSUF){theForm.shipToHomePhoneSUF.disabled = true;}
    
}

