function ValidateForm()
{
    var errors = '';
    var stmp = '';
    
    // first name
    if (trim(document.getElementById("firstname").value) == "")
    {
        errors = 'First Name is required';
        stmp = ",\n";
    }
    
    // last name
    if (trim(document.getElementById("lastname").value) == "")
    {
        errors = errors + stmp + 'Last Name is required';
        stmp = ",\n";
    }
    
    // address
    if (trim(document.getElementById("address").value) == "")
    {
        errors = errors + stmp + 'Address is required';
        stmp = ",\n";
    }
    
    // city
    if (trim(document.getElementById("city").value) == "")
    {
        errors = errors + stmp + 'City is required';
        stmp = ",\n";
    }   
    
    // state
    if (document.getElementById("state").options[document.getElementById("state").selectedIndex].value == "1")
    {
        errors = errors + stmp + 'State is required';
        stmp = ",\n";
    }    
     
    // zipcode
    if (trim(document.getElementById("zipcode").value) == "")
    {
        errors = errors + stmp + 'Zip Code is required';
        stmp = ",\n";
    }  
    else if (trim(document.getElementById("zipcode").value).length != 5)
    {
        errors = errors + stmp + 'Zip Code should be 5 digits';
        stmp = ",\n";
    }      
    else if (isNumeric(trim(document.getElementById("zipcode").value)) == false)
    {
        errors = errors + stmp + 'Zip Code should be all numeric';
        stmp = ",\n";
    }         
    
    // only one of the phone numbers is required
    var blnDay = false;
    var blnEve = false;
    var blnCell = false;
    
    if (trim(document.getElementById("phoneday").value) != "")
    {
        blnDay = true;
    }
    if (trim(document.getElementById("phoneeve").value) != "")
    {
        blnEve = true;
    }
    if (trim(document.getElementById("phonecell").value) != "")
    {
        blnCell = true;
    }
    
    if ((blnDay == false) && (blnEve == false) && (blnCell == false))
    {
        errors = errors + stmp + 'Day, Evening or Cell Phone # is required';
        stmp = ",\n";
    }
     
     // email
     if (trim(document.getElementById("email").value) == "")
     {
        errors = errors + stmp + 'Email is required';
        stmp = ",\n";
     }
     else if (echeck(trim(document.getElementById("email").value)) == false)
     {
        errors = errors + stmp + 'Email is invalid';
        stmp = ",\n";
     }
     
     // email1
     if (trim(document.getElementById("email1").value) != "")
     {
         if (echeck(trim(document.getElementById("email1").value)) == false)
         {
            errors = errors + stmp + 'Optional Email is invalid';
            stmp = ",\n";
         }
     }
     
     // gender
     if(document.getElementById("app_gender").options[document.getElementById("app_gender").selectedIndex].value == "1")
     {
        errors = errors + stmp + 'Gender is required';
        stmp = ",\n";
     }
     
     // marital status
     if(document.getElementById("app_marital").options[document.getElementById("app_marital").selectedIndex].value == "1")
     {
        errors = errors + stmp + 'Marital Status is required';
        stmp = ",\n";
     }

     // relation
     if(document.getElementById("app_relation").options[document.getElementById("app_relation").selectedIndex].value == "1")
     {
        errors = errors + stmp + 'Relation is required';
        stmp = ",\n";
     }
     
     // Coverage type
     if(document.getElementById("app_instype").options[document.getElementById("app_instype").selectedIndex].value == "1")
     {
        errors = errors + stmp + 'Coverage type is required';
        stmp = ",\n";
     }
     
     // Coverage amount
     if(document.getElementById("app_insamnt").options[document.getElementById("app_insamnt").selectedIndex].value == "1")
     {
        errors = errors + stmp + 'Coverage amount is required';
        stmp = ",\n";
     }

     if (errors != "")
     {
        alert("Please correct the following errors on your application: \n\n" + errors);
        return false;
     }
     else
     {
         return true;
     }

}

