function validRequired() 
{
var form_err = true;
var setchk = 0;
var at="@"
var dot="."
for (var loop = 0; loop < window.document.the_form.elements.length; loop++)
{
var val = window.document.the_form.elements[loop].value;
var lab = window.document.the_form.elements[loop].label;
var nam = window.document.the_form.elements[loop].name;
var typ = window.document.the_form.elements[loop].type;
var chk = window.document.the_form.elements[loop].checked;

if ((lab == "Years") || (lab == "Year") || (lab == "Months") || (lab == "Credit Rating") || (lab == "Make") || (lab == "Select Carrier") || (lab == "Comprehensive") || (lab == "Collision") || (lab =="Type of residence") || (lab =="Discount") || (lab =="Quote Time"))
{
var ind = window.document.the_form.elements[loop].selectedIndex;
 if (ind == 0)
 {
   alert("Please enter a value for the " + lab + " field.");
   window.document.the_form.elements[loop].focus(); 
   var form_err = false; 
 }
}

else if ((lab == "Month Expires" || lab == "Date of Birth Month") && (val <= 0 || val >= 13))
{
  alert("Please enter a correct value for the " + lab + " field.");
  window.document.the_form.elements[loop].focus(); 
  var form_err = false; 
}

else if ((lab == "Day Expires" || lab == "Date of Birth Day") && (val <= 0 || val >= 32))
{
  alert("Please enter a correct value for the " + lab + " field.");
  window.document.the_form.elements[loop].focus(); 
  var form_err = false; 
}

else if ((lab == "Year Expires") && (val < 2003 || val >= 2051))
{
  alert("Please enter a correct value for the " + lab + " field.");
  window.document.the_form.elements[loop].focus(); 
  var form_err = false; 
}

else if ((lab == "Date of Birth Year") && (val < 1900 || val >= 2003))
{
  alert("Please enter a correct value for the " + lab + " field.");
  window.document.the_form.elements[loop].focus(); 
  var form_err = false; 
}

else if ((lab == "Zip code") && (val <= 9999 || val > 99999))
{
  alert("Please enter a correct value for the " + lab + " field.");
  window.document.the_form.elements[loop].focus(); 
  var form_err = false; 
}

//Used for life2.php to check to see if type checkbox has been selected
else if ((typ == "checkbox") && ((lab == "type_term") || (lab == "type_perm") || (lab == "type_other")))
{
 if ((lab == "type_term") && (chk == true))
 {
 setchk = 1;
 }
 else if ((lab == "type_perm") && (chk == true))
 {
 setchk = 1;
 }
 else if ((lab == "type_other") && (chk == false) && (setchk == 0))
 {
 alert("Please select a Type");
 var form_err = false;
 }
}

else if ((nam == "email") || (nam == "email2"))
{
 var lat=val.indexOf(at);
 var lstr=val.length;
 var ldot=val.indexOf(dot);
 if (val.indexOf(at)==-1){
   alert("Invalid E-mail ID")
   window.document.the_form.elements[loop].focus(); 
   return false
 }
 if (val.indexOf(at)==-1 || val.indexOf(at)==0 || val.indexOf(at)==lstr){
   alert("Invalid E-mail ID")
   window.document.the_form.elements[loop].focus(); 
   return false
 }
 if (val.indexOf(dot)==-1 || val.indexOf(dot)==0 || val.indexOf(dot)==lstr){
    alert("Invalid E-mail ID")
	window.document.the_form.elements[loop].focus(); 
    return false
 }
 if (val.indexOf(at,(lat+1))!=-1){
   alert("Invalid E-mail ID")
   window.document.the_form.elements[loop].focus(); 
   return false
 }
 if (val.substring(lat-1,lat)==dot || val.substring(lat+1,lat+2)==dot){
    alert("Invalid E-mail ID")
	window.document.the_form.elements[loop].focus(); 
    return false
 }
 if (val.indexOf(dot,(lat+2))==-1){
    alert("Invalid E-mail ID")
	window.document.the_form.elements[loop].focus(); 
    return false
 }
 if (val.indexOf(" ")!=-1){
    alert("Invalid E-mail ID")
	window.document.the_form.elements[loop].focus(); 
    return false
 } 
}

else if ((val == "") && (lab != "" ) && (typ != "hidden")) 
{ 
  alert("Please enter a value for the " + lab + " field."); 
  window.document.the_form.elements[loop].focus();
  var form_err = false; 
}
}

if (form_err == true)
{
 if (page == "driver")
 {
   if (accident == 1)
   {
   		strURL = "auto4.php";
   }
	else
   {
	strURL = "v-identity" + vehicles + ".php";
   }
   document.forms[0].action = strURL;
   document.forms[0].submit();
 }
 else
 {
document.forms[0].submit();
 }
}
return form_err;
}

function change(n)
{
   if (n == 1)
   {
   		accident = 1;
	}
	else
   {
		accident = 0;
   }
} 



