<!--

function handleError(msg, url, ln) {
   // Do you custom code here
   return true;
}

window.onerror = handleError;



/***********************************************
* Disable "Enter" key in Form script- By Nurul Fadilah(nurul@REMOVETHISvolmedia.com)
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
                
function handleEnter (field, event) {
		var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		if (keyCode == 13) {
			var i;
			for (i = 0; i < field.form.elements.length; i++)
				if (field == field.form.elements[i])
					break;
			i = (i + 1) % field.form.elements.length;
			field.form.elements[i].focus();
			return false;
		} 
		else
		return true;
	}      

/**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString ="";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}


function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month for the date of birth. This should be a number between 1 and 12. The date format should be : mm/dd/yyyy.")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day for the date of birth. The date format should be : mm/dd/yyyy.")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year for the date of birth.The date format should be : mm/dd/yyyy.")
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date of birth. The date format should be : mm/dd/yyyy.")
		return false
	}
return true
}


var div1=0;
var div2=0;
var div3=0;
var div4=0;
var div5=0;
var sbdiv=0;

function SingleSelectRequired(Form, Field)
{
	var itemSelected = eval("document." + Form + "." + Field + ".selectedIndex");
	if (itemSelected == 0)
		{ return false; }
	else { return true; }
}

function TextAreaRequired(Form, Field)
{
	var length = eval("document." + Form + "." + Field + ".value.length");
	if (length == 0)
		{ return false; }
	else { return true; }
}

function CheckBoxRequired(Form, Field)
{
	var check1 = eval("document." + Form + "." + Field + "[0].checked");
	var check2 = eval("document." + Form + "." + Field + "[1].checked");

	if (check1==false && check2==false)
  {return false;}
  else {return true;}
}

   function ExtendJS( FormName )
   {

	if (!SingleSelectRequired(FormName,'sex_pi'))
	{
		alert("Please select your gender. The cursor will move to the proper place on the form to enter this when you click OK.");
		eval("document."+FormName+".sex_pi"+".focus();");
		return false;
	}

	if (!TextAreaRequired(FormName,'dob_pi'))
	{
		alert("Please enter your date of birth. The cursor will move to the proper place on the form to enter this when you click OK.");
		eval("document."+FormName+".dob_pi"+".focus();");
		return false;
	}


	if (!SingleSelectRequired(FormName,'hgt_pi'))
	{
		alert("Please enter your height. The cursor will move to the proper place on the form to enter this when you click OK.");
		eval("document."+FormName+".hgt_pi"+".focus();");
		return false;
	}

	if (!TextAreaRequired(FormName,'wgt_pi'))
	{
		alert("Please enter your weight. The cursor will move to the proper place on the form to enter this when you click OK.");
		eval("document."+FormName+".wgt_pi"+".focus();");
		return false;
	}

      if (!CheckBoxRequired(FormName,'insure_spouse'))
      {
         alert("Please choose to insure spouse or not.");
         return false;
      }

      if (!CheckBoxRequired(FormName,'insure_child'))
      {
         alert("Please choose to insure children or not.");
         return false;
      }



 <!--- validate according to spouse choice --->
	var check1 = eval(document.TheForm.insure_spouse[0].checked);
	var check2 = eval(document.TheForm.insure_spouse[1].checked);
	if (check1==true)
    {
	if (!TextAreaRequired(FormName,'dob_spouse'))
	{
		alert("Please enter your spouse's date of birth. The cursor will move to the proper place on the form to enter this when you click OK.");
		eval("document."+FormName+".dob_spouse"+".focus();");
		return false;
	}
	  
	if (!SingleSelectRequired(FormName,'hgt_spouse'))
	{
		alert("Please enter your spouse's height. The cursor will move to the proper place on the form to enter this when you click OK.");
		eval("document."+FormName+".hgt_spouse"+".focus();");
		return false;
	}

	if (!TextAreaRequired(FormName,'wgt_spouse'))
	{
		alert("Please enter your spouse's weight. The cursor will move to the proper place on the form to enter this when you click OK.");
		eval("document."+FormName+".wgt_spouse"+".focus();");
		return false;
	}
 }
 
	if (!SingleSelectRequired(FormName,'coverage_duration'))
	  {
		alert("Please select the length of time you need coverage. The cursor will move to the proper place on the form to enter this when you click OK.");
		eval("document."+FormName+".coverage_duration"+".focus();");
		return false;
	  } 
	
       if (!CheckBoxRequired(FormName,'owner'))
      {
         alert("Please check whether you own a home or are buying a home now.");
         return false;
      }
 
 
	if (!TextAreaRequired(FormName,'first_name'))
	{
		alert("Please enter your first name. The cursor will move to the proper place on the form to enter this when you click OK.");
		eval("document."+FormName+".first_name"+".focus();");
		return false;
	}

	if (!TextAreaRequired(FormName,'last_name'))
	{
		alert("Please enter your last name. The cursor will move to the proper place on the form to enter this when you click OK.");
		eval("document."+FormName+".last_name"+".focus();");
		return false;
	}

	if (!TextAreaRequired(FormName,'address'))
	{
		alert("Please enter your address. The cursor will move to the proper place on the form to enter this when you click OK.");
		eval("document."+FormName+".address"+".focus();");
		return false;
	}

	if (!TextAreaRequired(FormName,'city'))
	{
		alert("Please enter your city. The cursor will move to the proper place on the form to enter this when you click OK.");
		eval("document."+FormName+".city"+".focus();");
		return false;
	}

	if (!SingleSelectRequired(FormName,'state'))
	{
		alert("Please enter your state. The cursor will move to the proper place on the form to enter this when you click OK.");
		eval("document."+FormName+".state"+".focus();");
		return false;
	}

	if (!TextAreaRequired(FormName,'zip_code'))
	{
		alert("Please enter your zip code. The cursor will move to the proper place on the form to enter this when you click OK.");
		eval("document."+FormName+".zip_code"+".focus();");
		return false;
	}

	if (!TextAreaRequired(FormName,'phone_1'))
	{
		alert("Please enter at least one phone number in case we need to contact you. Only persons necessary to process your quote will ever see your phone number. The cursor will move to the proper place on the form to enter this when you click OK.");
		eval("document."+FormName+".phone_1"+".focus();");
		return false;
	}

//	if (!TextAreaRequired(FormName,'email'))
//	{
//		alert("Please enter your email address in case we need to contact you. Only persons necessary to process your quote will ever see your email. The cursor will move to the proper place on the form to enter this when you click OK.");
//		eval("document."+FormName+".email"+".focus();");
//		return false;
//	}	  
   }

function domlay(id,trigger,lax,lay,content) {
// Layer visible
if (trigger=="1"){
	if (document.layers) document.layers[''+id+''].visibility = "show"
	else if (document.all) document.all[''+id+''].style.visibility = "visible"
	else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible"
	}
// Layer hidden
else if (trigger=="0"){
	if (document.layers) document.layers[''+id+''].visibility = "hide"
	else if (document.all) document.all[''+id+''].style.visibility = "hidden"
	else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden"
	}
// Set horizontal position
if (lax){
	if (document.layers){document.layers[''+id+''].left = lax}
	else if (document.all){document.all[''+id+''].style.left=lax}
	else if (document.getElementById){document.getElementById(''+id+'').style.left=lax+"px"}
	}
// Set vertical position
if (lay){
	if (document.layers){document.layers[''+id+''].top = lay}
	else if (document.all){document.all[''+id+''].style.top=lay}
	else if (document.getElementById){document.getElementById(''+id+'').style.top=lay+"px"}
	}
// change content

if (content){
if (document.layers){
	sprite=document.layers[''+id+''].document;
	// add father layers if needed! document.layers[''+father+'']...
  	sprite.open();
  	sprite.write(content);
  	sprite.close();
	}
else if (document.all) document.all[''+id+''].innerHTML = content;
else if (document.getElementById){
	//Thanx Reyn!
	rng = document.createRange();
	el = document.getElementById(''+id+'');
	rng.setStartBefore(el);
	htmlFrag = rng.createContextualFragment(content)
	while(el.hasChildNodes()) el.removeChild(el.lastChild);
	el.appendChild(htmlFrag);
	// end of Reyn ;)
	}
}
}

function reset_owner()
{
for (var i=0; i<document.TheForm.owner.length; i++)
	{
		document.TheForm.owner[i].checked=false;
	}
}

function reset_insure_child()
{
for (var i=0; i<document.TheForm.insure_child.length; i++)
	{
		document.TheForm.insure_child[i].checked=false;
	}
}


function init()
{
	if (document.getElementById)
	{
	div1=document.getElementById('health_div_1').offsetHeight;
	div2=document.getElementById('health_div_2').offsetHeight;
	subdiv1=document.getElementById('spouse_input').offsetHeight;
	subdiv2=document.getElementById('child_input').offsetHeight;
	subdiv3=document.getElementById('coverage_duration_input').offsetHeight;
	div3=document.getElementById('health_div_3').offsetHeight;
	div4=document.getElementById('health_div_4').offsetHeight;
	}

	if (document.all)
	{
	div1=document.all('health_div_1').offsetHeight;
	div2=document.all('health_div_2').offsetHeight;
	subdiv1=document.all('spouse_input').offsetHeight;
	subdiv2=document.all('child_input').offsetHeight;
	subdiv3=document.all('coverage_duration_input').offsetHeight;
	div3=document.all('health_div_3').offsetHeight;
	div4=document.all('health_div_4').offsetHeight;
	}
	
	domlay('health_div_1',1,0,div1);
	domlay('health_div_2',1,0,div1);
	domlay('spouse_input',0,0,div1+div2);
  	domlay('child_input',0,0,div1+div2+subdiv1);
  	domlay('coverage_duration_input',0,0,div1+div2+subdiv1+subdiv2);
  	domlay('health_div_3',0,0,div1+div2+subdiv1+subdiv2+subdiv3);
	domlay('health_div_4',0,0,div1+div2+subdiv1+subdiv2+subdiv3+div3);
	domlay('submit_button',1,0,div1+div2);

	scroll(0,0);
	document.TheForm.coverage_duration.selectedIndex=0;

	for (var i=0; i<document.TheForm.owner.length; i++)
	{
		document.TheForm.owner[i].checked=false;
	}

	for (var i=0; i<document.TheForm.insure_spouse.length; i++)
	{
		document.TheForm.insure_spouse[i].checked=false;
	}

	for (var i=0; i<document.TheForm.insure_child.length; i++)
	{
		document.TheForm.insure_child[i].checked=false;
	}
}

function showdivs(whattodo)
{
	if (document.getElementById)
	{
	div1=document.getElementById('health_div_1').offsetHeight;
	div2=document.getElementById('health_div_2').offsetHeight;
	subdiv1=document.getElementById('spouse_input').offsetHeight;
	subdiv2=document.getElementById('child_input').offsetHeight;
	subdiv3=document.getElementById('coverage_duration_input').offsetHeight;
	div3=document.getElementById('health_div_3').offsetHeight;
	div4=document.getElementById('health_div_4').offsetHeight;
	}

	if (document.all)
	{
	div1=document.all('health_div_1').offsetHeight;
	div2=document.all('health_div_2').offsetHeight;
	subdiv1=document.all('spouse_input').offsetHeight;
	subdiv2=document.all('child_input').offsetHeight;
	subdiv3=document.all('coverage_duration_input').offsetHeight;
	div3=document.all('health_div_3').offsetHeight;
	div4=document.all('health_div_4').offsetHeight;
	}

if(whattodo==1)
{
	// any click on spouse or child yn must reset the other triggers
	reset_owner();
	document.TheForm.coverage_duration.selectedIndex=0;

	if((document.TheForm.insure_child[0].checked==false) && (document.TheForm.insure_child[1].checked==false))
	{
 		return true;
	}

	if(document.TheForm.sex_pi.selectedIndex == 0)
 	{	
		alert("Please select your gender.");
		reset_insure_child();
		document.TheForm.sex_pi.focus();
		return true;
	}

	if(document.TheForm.dob_pi.value.length == 0)
 	{	
		alert("Please enter your date of birth.");
		reset_insure_child();
		document.TheForm.dob_pi.focus();	
		return true;
	}

	if(document.TheForm.hgt_pi.selectedIndex == 0)
 	{	
		alert("Please select your height.");
		reset_insure_child();
		document.TheForm.hgt_pi.focus();
		return true;
	}

	if(document.TheForm.wgt_pi.value.length == 0)
 	{	
		alert("Please enter your weight.");
		reset_insure_child();
		document.TheForm.wgt_pi.focus();
		return true;
	}

	if((document.TheForm.insure_spouse[0].checked==false) && (document.TheForm.insure_spouse[1].checked==false))
	{
 		alert("Please choose if would like to insure your spouse");
			reset_insure_child();
		return true;
	}
	


	if((document.TheForm.insure_spouse[0].checked==true) && (document.TheForm.insure_child[0].checked==true))
	{
	domlay('health_div_2',1,0,div1);
	domlay('spouse_input',1,0,div1+div2);
  	domlay('child_input',1,0,div1+div2+subdiv1);
  	domlay('coverage_duration_input',1,0,div1+div2+subdiv1+subdiv2);
  	domlay('health_div_3',0,0,div1+div2+subdiv1+subdiv2+subdiv3);
	domlay('health_div_4',0,0,div1+div2+subdiv1+subdiv2+subdiv3+div3);
	domlay('submit_button',1,0,div1+div2+subdiv1+subdiv2+subdiv3);
	div2height=subdiv1+subdiv2+subdiv3;
	scroll(0,div1+div2);
	return true;
	}

	if((document.TheForm.insure_spouse[0].checked==false) && (document.TheForm.insure_child[0].checked==true))
	{
	domlay('health_div_2',1,0,div1);
	domlay('spouse_input',0,0,div1+div2);
  	domlay('child_input',1,0,div1+div2);
  	domlay('coverage_duration_input',1,0,div1+div2+subdiv2);
  	domlay('health_div_3',0,0,div1+div2+subdiv1+subdiv2+subdiv3);
	domlay('health_div_4',0,0,div1+div2+subdiv1+subdiv2+subdiv3+div3);
	domlay('submit_button',1,0,div1+div2+subdiv2+subdiv3);
	scroll(0,div1+div2);
	return true;
	}

	if((document.TheForm.insure_spouse[0].checked==false) && (document.TheForm.insure_child[0].checked==false))
	{
	domlay('health_div_2',1,0,div1);
	domlay('spouse_input',0,0,div1+div2);
  	domlay('child_input',0,0,div1+div2);
  	domlay('coverage_duration_input',1,0,div1+div2);
  	domlay('health_div_3',0,0,div1+div2+subdiv1+subdiv2+subdiv3);
	domlay('health_div_4',0,0,div1+div2+subdiv1+subdiv2+subdiv3+div3);
	domlay('submit_button',1,0,div1+div2+subdiv3);
	scroll(0,div1+div2);
	return true;
	}

	if((document.TheForm.insure_spouse[0].checked==true) && (document.TheForm.insure_child[0].checked==false))
	{
	domlay('health_div_2',1,0,div1);
	domlay('spouse_input',1,0,div1+div2);
  	domlay('child_input',0,0,div1+div2);
  	domlay('coverage_duration_input',1,0,div1+div2+subdiv1);
  	domlay('health_div_3',0,0,div1+div2+subdiv1+subdiv2+subdiv3);
	domlay('health_div_4',0,0,div1+div2+subdiv1+subdiv2+subdiv3+div3);
	domlay('submit_button',1,0,div1+div2+subdiv1+subdiv3);
	scroll(0,div1+div2);
	return true;
	}

}

if(whattodo==2)
{
	// any click on spouse or child yn must reset the other triggers
	reset_owner();

	if((document.TheForm.insure_spouse[0].checked==true) && (document.TheForm.insure_child[0].checked==true))
	{
	domlay('health_div_2',1,0,div1);
	domlay('spouse_input',1,0,div1+div2);
  	domlay('child_input',1,0,div1+div2+subdiv1);
  	domlay('coverage_duration_input',1,0,div1+div2+subdiv1+subdiv2);
  	domlay('health_div_3',1,0,div1+div2+subdiv1+subdiv2+subdiv3);
	domlay('health_div_4',0,0,div1+div2+subdiv1+subdiv2+subdiv3+div3);
	domlay('submit_button',1,0,div1+div2+subdiv1+subdiv2+subdiv3+div3);
	scroll(0,div1+div2+subdiv1+subdiv2+subdiv3);
	return true;
	}

	if((document.TheForm.insure_spouse[0].checked==false) && (document.TheForm.insure_child[0].checked==true))
	{
	domlay('health_div_2',1,0,div1);
	domlay('spouse_input',0,0,div1+div2);
  	domlay('child_input',1,0,div1+div2);
  	domlay('coverage_duration_input',1,0,div1+div2+subdiv2);
  	domlay('health_div_3',1,0,div1+div2+subdiv2+subdiv3);
	domlay('health_div_4',0,0,div1+div2+subdiv1+subdiv2+subdiv3+div3);
	domlay('submit_button',1,0,div1+div2+subdiv2+subdiv3+div3);
  scroll(0,div1+div2+subdiv2+subdiv3);
	return true;
	}

	if((document.TheForm.insure_spouse[0].checked==false) && (document.TheForm.insure_child[0].checked==false))
	{
	domlay('health_div_1',1,0,div1);
	domlay('health_div_2',1,0,div1);
	domlay('spouse_input',0,0,div1+div2);
  	domlay('child_input',0,0,div1+div2);
  	domlay('coverage_duration_input',1,0,div1+div2);
  	domlay('health_div_3',1,0,div1+div2+subdiv3);
	domlay('health_div_4',0,0,div1+div2+subdiv1+subdiv2+subdiv3+div3);
	domlay('submit_button',1,0,div1+div2+subdiv3+div3);
	scroll(0,div1+div2+subdiv3);
	return true;
	}

	if((document.TheForm.insure_spouse[0].checked==true) && (document.TheForm.insure_child[0].checked==false))
	{
	domlay('health_div_1',1,0,div1);
	domlay('health_div_2',1,0,div1);
	domlay('spouse_input',1,0,div1+div2);
  	domlay('child_input',0,0,div1+div2);
  	domlay('coverage_duration_input',1,0,div1+div2+subdiv1);
  	domlay('health_div_3',1,0,div1+div2+subdiv1+subdiv3);
	domlay('health_div_4',0,0,div1+div2+subdiv1+subdiv2+subdiv3+div3);
	domlay('submit_button',1,0,div1+div2+subdiv1+subdiv3+div3);
	scroll(0,div1+div2+subdiv1+subdiv3);
	return true;
	}

}

if(whattodo==3)
{
	if((document.TheForm.insure_spouse[0].checked==true) && (document.TheForm.insure_child[0].checked==true))
	{
	domlay('health_div_2',1,0,div1);
	domlay('spouse_input',1,0,div1+div2);
  	domlay('child_input',1,0,div1+div2+subdiv1);
  	domlay('coverage_duration_input',1,0,div1+div2+subdiv1+subdiv2);
  	domlay('health_div_3',1,0,div1+div2+subdiv1+subdiv2+subdiv3);
	domlay('health_div_4',1,0,div1+div2+subdiv1+subdiv2+subdiv3+div3);
	domlay('submit_button',1,0,div1+div2+subdiv1+subdiv2+subdiv3+div3+div4);
	scroll(0,div1+div2+subdiv1+subdiv2+subdiv3+div3);
	return true;
	}

	if((document.TheForm.insure_spouse[0].checked==false) && (document.TheForm.insure_child[0].checked==true))
	{
	domlay('health_div_2',1,0,div1);
	domlay('spouse_input',0,0,div1+div2);
  	domlay('child_input',1,0,div1+div2);
  	domlay('coverage_duration_input',1,0,div1+div2+subdiv2);
  	domlay('health_div_3',1,0,div1+div2+subdiv2+subdiv3);
	domlay('health_div_4',1,0,div1+div2+subdiv2+subdiv3+div3);
	domlay('submit_button',1,0,div1+div2+subdiv2+subdiv3+div3+div4);
  scroll(0,div1+div2+subdiv2+subdiv3);
	return true;
	}

	if((document.TheForm.insure_spouse[0].checked==false) && (document.TheForm.insure_child[0].checked==false))
	{
	domlay('health_div_2',1,0,div1);
	domlay('spouse_input',0,0,div1+div2);
  	domlay('child_input',0,0,div1+div2);
  	domlay('coverage_duration_input',1,0,div1+div2);
  	domlay('health_div_3',1,0,div1+div2+subdiv3);
	domlay('health_div_4',1,0,div1+div2+subdiv3+div3);
	domlay('submit_button',1,0,div1+div2+subdiv3+div3+div4);
	scroll(0,div1+div2+subdiv3+div3);
	return true;
	}

	if((document.TheForm.insure_spouse[0].checked==true) && (document.TheForm.insure_child[0].checked==false))
	{
	domlay('health_div_2',1,0,div1);
	domlay('spouse_input',1,0,div1+div2);
  	domlay('child_input',0,0,div1+div2);
  	domlay('coverage_duration_input',1,0,div1+div2+subdiv1);
  	domlay('health_div_3',1,0,div1+div2+subdiv1+subdiv3);
	domlay('health_div_4',1,0,div1+div2+subdiv1+subdiv3+div3);
	domlay('submit_button',1,0,div1+div2+subdiv1+subdiv3+div3+div4);
	scroll(0,div1+div2+subdiv1+subdiv3+div3);
	return true;
	}

}

}


//-->


