function checkForm1() {

    errMsg="";

    theForm = document.forms.consumerfeedback;

}

function checkForm()
{
    errMsg="";

    theForm = document.forms.consumerfeedback;

    if (isEmpty(theForm.emailAddress)) {
        errMsg+="- Enter a value in the 'Email address' input box.\n";
    } else {
        if (theForm.confirmEmailAddress.value!=theForm.emailAddress.value) {
            errMsg+="- The value in the 'Email address' does not match the 'Confirm Your Email' value.\n";
        }
    }

    if ( errMsg != "" ) {
        window.alert("Please correct the following items before proceeding: \n\n"+errMsg);
        return false;
    }

    return true;
}

function checkFormContactUs()
{
    errMsg="";

    theForm = document.forms.consumerfeedback;

    if (isEmpty(theForm.emailAddress))
    {
        errMsg+="- Enter a value in the 'Email address' input box.\n";
    }
    else if (theForm.confirmEmailAddress.value!=theForm.emailAddress.value)
    {
        errMsg+="- The value in the 'Email address' does not match the 'Confirm Your Email' value.\n";
    }

    if ( ! theForm.faqsRead.checked )
    {
        errMsg+="- The checkbox indicating that you have read the FAQs is not checked.\n" ;
    }

    if ( theForm.typeOfAssist.value == "X" )
    {
        errMsg+="- Please choose a reason from the drop down.\n" ;
    }

    if ( errMsg != "" )
    {
        window.alert("Please correct the following items before proceeding: \n\n"+errMsg);
        return false;
    }

    return true;
}

function checkFormLead()
{
    errMsg="";
    theForm = document.forms.webToLead;

    if (isEmpty(theForm.first_name)) {
        errMsg+="- Enter a value in the 'First Name' input box.\n";
    }

    if (isEmpty(theForm.last_name)) {
        errMsg+="- Enter a value in the 'Last name' input box.\n";
    }

    if ( isEmpty(theForm.dayTimePhone1) ||
         isEmpty(theForm.dayTimePhone2) ||
         isEmpty(theForm.dayTimePhone3) )
    {
        errMsg+="- Enter a value in the 'Day time phone' input box.\n";
    }
    else if (!isInteger(theForm.dayTimePhone1.value) ||
             !isInteger(theForm.dayTimePhone2.value) ||
             !isInteger(theForm.dayTimePhone3.value) ||
             ( !isEmpty ( theForm.DayTimePhone4 ) && !isInteger ( theForm.DayTimePhone4.value ) ) )
    {
        errMsg+="- Enter a value in the 'Day time phone' input box.\n";
    }

    if ( !isEmpty ( theForm.dayTimePhone4 ) &&
         !isInteger ( theForm.dayTimePhone4.value ) )
    {
       errMsg+="- Enter a value in the 'Day time phone' input box.\n";
    }

    if (isEmpty(theForm.street)) {
        errMsg+="- Enter a value in the 'Mailing address' input box.\n";
    }

    if (isEmpty(theForm.city)) {
        errMsg+="- Enter a value in the 'City' input box.\n";
    }

    if (isEmpty(theForm.state)) {
        errMsg+="- Enter a value in the 'State' input box.\n";
    }

    if (isEmpty(theForm.zip)) {
        errMsg+="- Enter a value in the 'Zip' input box.\n";
    }
    else if ( ! isInteger ( theForm.zip1.value ) )
    {
        errMsg+="- Enter a value in the 'Zip' input box.\n";
    }
    else if ( !isEmpty ( theForm.zip2 ) &&
              !isInteger ( theForm.zip2.value ) )
    {
        errMsg+="- Enter a value in the 'Zip' input box.\n";
    }

    if (isEmpty(theForm.email))
    {
        errMsg+="- Enter a value in the 'Email address' input box.\n";
    }
    else if ( ! emailCheck ( theForm.email.value ) )
    {
        errMsg+="- Enter a value in the 'Email address' input box.\n";
    }
    else if (theForm.confirmEmail.value!=theForm.email.value)
    {
        errMsg+="- The value in the 'Email address' does not match the 'Confirm Your Email' value.\n";
    }
    if ( ( !isEmpty ( theForm.alternatePhone1 ) && !isInteger ( theForm.alternatePhone1.value ) ) ||
         ( !isEmpty ( theForm.alternatePhone2 ) && !isInteger ( theForm.alternatePhone2.value ) ) ||
         ( !isEmpty ( theForm.alternatePhone3 ) && !isInteger ( theForm.alternatePhone3.value ) ) ||
         ( !isEmpty ( theForm.alternatePhone4 ) && !isInteger ( theForm.alternatePhone4.value ) ) )
    {
        errMsg+="- Enter a value in the 'Alternate phone number' input box.\n";
    }

    if ( errMsg != "" ) {
        window.alert("Please correct the following items before proceeding: \n\n"+errMsg);
        return false;
    }

    return true;
}


function setZipPhone() {
    theForm=document.forms.webToLead;
    theForm.zip.value=theForm.zip1.value;
    if (theForm.zip2.value+''!='') {
        theForm.zip.value=theForm.zip.value+'-'+theForm.zip2.value;
    }
}

function setDayPhone() {
    theForm=document.forms.webToLead;
    theForm.phone.value='('+theForm.dayTimePhone1.value+') ';
    theForm.phone.value=theForm.phone.value+theForm.dayTimePhone2.value+'-';
    theForm.phone.value=theForm.phone.value+theForm.dayTimePhone3.value;
    if (theForm.dayTimePhone4.value+''!='') {
        theForm.phone.value=theForm.phone.value+' x'+theForm.dayTimePhone4.value;
    }
}

function setAltPhone() {
    theForm=document.forms.webToLead;
    theForm.mobile.value='('+theForm.alternatePhone1.value+') ';
    theForm.mobile.value=theForm.mobile.value+theForm.alternatePhone2.value+'-';
    theForm.mobile.value=theForm.mobile.value+theForm.alternatePhone3.value;
    if (theForm.alternatePhone4.value+''!='') {
        theForm.mobile.value=theForm.mobile.value+' x'+theForm.alternatePhone4.value;
    }
}
