<!--

function MM_swapImgRestore() { //v2.0

  if (document.MM_swapImgData != null)

    for (var i=0; i<(document.MM_swapImgData.length-1); i+=2)

      document.MM_swapImgData[i].src = document.MM_swapImgData[i+1];

}

 

function MM_preloadImages() { //v2.0

  if (document.images) {

    var imgFiles = MM_preloadImages.arguments;

    if (document.preloadArray==null) document.preloadArray = new Array();

    var i = document.preloadArray.length;

    with (document) for (var j=0; j<imgFiles.length; j++) if (imgFiles[j].charAt(0)!="#"){

      preloadArray[i] = new Image;

      preloadArray[i++].src = imgFiles[j];

  } }

}

 

function MM_swapImage() { //v2.0

  var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.MM_swapImgData;

  for (i=0; i < (MM_swapImage.arguments.length-2); i+=3) {

    objStr = MM_swapImage.arguments[(navigator.appName == 'Netscape')?i:i+1];

    if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||

        (objStr.indexOf('document.all[')   ==0 && document.all   ==null))

      objStr = 'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.length);

    obj = eval(objStr);

    if (obj != null) {

      swapArray[j++] = obj;

      swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:oldArray[j];

      obj.src = MM_swapImage.arguments[i+2];

  } }

  document.MM_swapImgData = swapArray; //used for restore

}

//-->


	var messageObj = new DHTML_modalMessage();	// We only create one object of this class
	messageObj.setShadowOffset(5);	// Large shadow

	var PopupWidth = 0;
	var PopupHeight = 0;

    var loading = new Image();
	loading.src="http://www.gethealthinsurance.com/images/on_hold_ani.gif";
	var loading1 = new Image();
    loading1.src="http://www.gethealthinsurance.com/images/on_hold.jpg";

	function initRestoreDefault()
	{
		PopupWidth = 520;
		PopupHeight = 200;
		var theBody = document.getElementsByTagName("body")[0];
		theBody.style.overflow = "hidden";
		//alert(theBody);
		messageObj.setHtmlContent('<table width="500" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td height="310" background="images/on_hold.jpg"><table width="472" height="300" border="0" align="center" cellpadding="5" cellspacing="0"><tr><td width="452" align="right" valign="top"><br />  <img src="images/on_hold_ani.gif" name="loadingimg" width="32" height="32" id="loadingimg" /></td> </tr></table></td></tr></table>');
		messageObj.setSize(PopupWidth,PopupHeight);
		messageObj.setCssClassMessageBox(false);
		messageObj.setSource(false);	// no html source since we want to use a static message here.
		messageObj.setShadowDivVisible(false);	// Disable shadow for these boxes
		messageObj.display();
    	document.getElementById("loadingimg").src=loading.src;
	}
	function closeMessage()
	{
		messageObj.close();
		var theBody = document.getElementsByTagName("BODY")[0];
		theBody.style.overflow = "";

	}

	
	function sendState(zipcode)
	{
		pars = "zipcode="+zipcode;
		var myAjax = new Ajax.Request('/getState.php', {method:'post', postBody:pars, onSuccess: parseInfo});	
		function parseInfo(t)
		{
			answer = t.responseText.split("|");
			if (answer[1]) $('txtCity').value = answer[1];
			ob = $('stateid').options;
			for (i=0;i<ob.length;i++) {
				ob[i].selected = (ob[i].value==answer[0]);
			}
		}					
	}
	


	function callstate(zipcode)
	{
		if (isNaN(document.frmIHI.txtZip.value))
		{	    	alert("Valid Zip Code Required");
					document.frmIHI.txtZip.focus();
					return false;
		}
		else if (document.frmIHI.txtZip.value.length==5)
		sendState(zipcode);
		return false;
	}

	
	function generateQuote() {
		ob = document.frmIHI;
				pars = "";
		for (i=0;i<ob.elements.length;i++) {
			if (ob.elements[i].type!='checkbox' || ob.elements[i].type=='checkbox' && ob.elements[i].checked) 
				pars += ob.elements[i].name+"="+ob.elements[i].value+"&";
		}
		initRestoreDefault();
		var myAjax = new Ajax.Request('/generateQuote.php', {method:'post', postBody:pars, onSuccess: successQ});	
		
		function successQ(t) {
			closeMessage();
			if (t.responseText.search(/Sorry/)!=-1) {
				//$('develop').innerHTML = t.responseText; //DEBUG
				alert(t.responseText);
			} else {
				document.location='http://gethealthinsurance.com/health_insurance.php?action=show_quotes';
			}
		}
	}
		function validateIHIForm()
		{
			if(document.frmIHI.txtFName.value == "")
			{
				alert("First Name Required");
				document.frmIHI.txtFName.focus();
				return false;
			}
			else if(document.frmIHI.txtLName.value == "")
			{
				alert("Last Name Required");
				document.frmIHI.txtLName.focus();
				return false;
			}

			
			else if(document.frmIHI.txtZip.value == "")
			{
				alert("Zip Code Required");
				document.frmIHI.txtZip.focus();
				return false;
			}

			else if(document.frmIHI.txtZip.value.length!=5)
			{
				alert("Valid Zip Code Required");
				document.frmIHI.txtZip.focus();
				return false;
			}

			else if(isNaN(document.frmIHI.txtZip.value))
			{
				alert("Valid Zip Code Required");
				document.frmIHI.txtZip.focus();
				return false;
			}
			else if(document.frmIHI.txtZip.value.length==5 && (!(isNaN(document.frmIHI.txtZip.value))) && (document.frmIHI.txtCity.value=="" || document.frmIHI.stateid.value==0))
			{
				alert("Valid Zip Code Required");
				document.frmIHI.txtZip.focus();
				return false;	

			}
			else if(document.frmIHI.txtDayPhone1.value == "" && document.frmIHI.txtDayPhone2.value == "" && document.frmIHI.txtDayPhone3.value == "")
			{
					alert("Phone No. Required");
					document.frmIHI.txtDayPhone1.focus();
					return false;
			}
				else if(isValidPhone(document.frmIHI.txtDayPhone1.value + document.frmIHI.txtDayPhone2.value + document.frmIHI.txtDayPhone3.value))
				{
					alert("Invalid Phone No.");
					document.frmIHI.txtDayPhone1.focus();
					return false;
				}
		
			else if(document.frmIHI.txtEMail.value=="")
				{
					alert("Email Address Required");
					document.frmIHI.txtEMail.focus();
					return false;
				}
				else if (document.frmIHI.txtEMail.value !="" && !MailValidate(document.frmIHI.txtEMail.value))
				{
					alert('Enter a valid Email Address');
					document.frmIHI.txtEMail.select();
					return false;
				}

			else if(document.frmIHI.gender1.value=="-")
			{
				alert("Please select Applicant's Gender");
				document.frmIHI.gender1.focus();
				return false;
			}
		
			else if (parseInt(document.frmIHI.txtfamilytotal.value)!="")
			{
				for(i=1;i<=parseInt(document.frmIHI.txtfamilytotal.value);i++)
				{
					genderval=eval('document.frmIHI.gender'+i+'.value');
					
					ht_ft=eval('document.frmIHI.ht_ft'+i+'.value');
					ht_in=eval('document.frmIHI.ht_in'+i+'.value');
			 		wt_applicant=eval('document.frmIHI.wt_applicant'+i+'.value');
					
					mnval=eval('document.frmIHI.txtdobmn'+i+'.value');
					dtval=eval('document.frmIHI.txtdobdt'+i+'.value');
					yrval=eval('document.frmIHI.txtdobyr'+i+'.value');
					
					
					if(!isInteger(mnval))
					{
						alert("Please enter a valid Month")
						eval('document.frmIHI.txtdobmn'+i+'.focus();');
						return false;
					}
					else
					if(!isInteger(dtval))
					{
						alert("Please enter a valid Date");
						eval('document.frmIHI.txtdobdt'+i+'.focus();');
						return false;
					}
					else
					if(!isInteger(yrval))
					{
						alert("Please enter a valid Year")
						eval('document.frmIHI.txtdobyr'+i+'.focus();');
						return false;
					}
					else
					if(!isInteger(ht_ft))
					{
						alert("Valid Height Required");
						eval('document.frmIHI.ht_ft'+i+'.focus();')
						return false;
					}
					else
					if(!isInteger(ht_in))
					{
						alert("Valid Height Required");
						eval('document.frmIHI.ht_in'+i+'.focus();');
						return false;
					}
					else
					if(!isInteger(wt_applicant))
					{
						alert("Weight Required");
						eval('document.frmIHI.wt_applicant'+i+'.focus();');
						return false;
					}
					
					if(genderval=="-")
					{
						if (mnval!="" || dtval!="" || yrval!="")
						if(!isDate(mnval+"/"+dtval+"/"+yrval,i))
						{
							alert("Invalid Date");
							return false;
						}
						else
						{
							alert("Please select the Gender");
							eval('document.frmIHI.gender'+i+'.focus();');
							return false;
						}
					}
					else
					{
						if(!isDate(mnval+"/"+dtval+"/"+yrval,i))
						{
							return false;
						}
						
						if(ht_ft=="")
						{
							alert("Height Required");
							eval('document.frmIHI.ht_ft'+i+'.focus();');
							return false;
						}
						
						if (wt_applicant=="")
						{
							alert("Weight Required");
							eval('document.frmIHI.wt_applicant'+i+'.focus();');
							return false;
						}
					}
					

				}
			}

		   if (document.frmIHI.txtcoveragebegin.value=="")
			{
				alert("Enter Coverage to begin on")
				document.frmIHI.txtcoveragebegin.focus();
				return false
			}
			else
			{
				generateQuote();
				return false;
			}
		}



		function isValidPhone(str)
		{
			if(str.length == 10)
			{
				for (var i = 0; i < str.length; i++)
				{

					var ch = str.substring(i, i + 1);
					if(ch < "0" || "9" < ch)
					{
						return true;
					}
				}
			}
			else
			{
				return true;
			}
			return false
		}


		function Next(maxLen,current,next)
		{
			var ob = document.getElementById(current);
			var ob2 = document.getElementById(next);
			if (ob.value.length==maxLen) ob2.focus();
		}

		function MailValidate(str)
		{
			var at="@"
			var dot="."
			var lat=str.indexOf(at)
			var lstr=str.length
			var ldot=str.indexOf(dot)
			if (str.indexOf(at)==-1){
				return false
			}
			if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
				return false
			}
			if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
				return false
			}
			if (str.indexOf(at,(lat+1))!=-1){
				return false
			}
			if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
				return false
			}
			if (str.indexOf(dot,(lat+2))==-1){
				return false
			}
			if (str.indexOf(" ")!=-1){
				return false
			}
			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,ii){
			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")
				eval('document.frmIHI.txtdobmn'+ii+'.select();');

				return false;
			}
			if (strMonth.length<1 || month<1 || month>12){
				alert("Please enter a valid month")
				eval('document.frmIHI.txtdobmn'+ii+'.select();');
				return false;
			}
			if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
				alert("Please enter a valid day")
				eval('document.frmIHI.txtdobdt'+ii+'.select();');
				return false;
			}
			if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
				alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
				eval('document.frmIHI.txtdobyr'+ii+'.select();');
				return false
			}
			if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
				alert("Please enter a valid date")
				eval('document.frmIHI.txtdobdt'+ii+'.select();');
				return false
			}
/*
			if(ii==1)
			{
				var date1=new Date();
				date1=date1.getMonth()+"/"+date1.getDate()+"/"+date1.getFullYear();
				date2=eval('document.frmIHI.txtdobmn'+ii+'.value')+"/"+eval('document.frmIHI.txtdobdt'+ii+'.value')+"/"+eval('document.frmIHI.txtdobyr'+ii+'.value');
				date1 = date1.split("/");
				date2 = date2.split("/");
				var sDate = new Date(date1[0]+"/"+date1[1]+"/"+date1[2]);
				var eDate = new Date(date2[0]+"/"+date2[1]+"/"+date2[2]);
				var daysApart = Math.abs(Math.round((sDate-eDate)/86400000/365));
				if (daysApart<18)
				{
					alert("Applicant age should be > 18");
					eval('document.frmIHI.txtdobyr'+ii+'.select();');
					return false

				}
			}
			if(ii==2)
			{
				var date1=new Date();
				date1=date1.getMonth()+"/"+date1.getDate()+"/"+date1.getFullYear();
				date2=eval('document.frmIHI.txtdobmn'+ii+'.value')+"/"+eval('document.frmIHI.txtdobdt'+ii+'.value')+"/"+eval('document.frmIHI.txtdobyr'+ii+'.value');
				date1 = date1.split("/");
				date2 = date2.split("/");
				var sDate = new Date(date1[0]+"/"+date1[1]+"/"+date1[2]);
				var eDate = new Date(date2[0]+"/"+date2[1]+"/"+date2[2]);
				var daysApart = Math.abs(Math.round((sDate-eDate)/86400000/365));
				if (daysApart<18)
				{
					alert("Spouse age should be  > 18");
					eval('document.frmIHI.txtdobyr'+ii+'.select();');
					return false

				}
			}
			if(ii>2)
			{
				var date1=new Date();
				date1=date1.getMonth()+"/"+date1.getDate()+"/"+date1.getFullYear();
				date2=eval('document.frmIHI.txtdobmn'+ii+'.value')+"/"+eval('document.frmIHI.txtdobdt'+ii+'.value')+"/"+eval('document.frmIHI.txtdobyr'+ii+'.value');
				date1 = date1.split("/");
				date2 = date2.split("/");
				var sDate = new Date(date1[0]+"/"+date1[1]+"/"+date1[2]);
				var eDate = new Date(date2[0]+"/"+date2[1]+"/"+date2[2]);
				var daysApart = Math.abs(Math.round((sDate-eDate)/86400000/365));
				if (daysApart>24)
				{
					alert("Child age should not be > 24");
					eval('document.frmIHI.txtdobyr'+ii+'.select();');
					return false

				}
			}*/
			return true;
		}


function validateEmailForm1()
	{
		if(document.frmEmaillogin.txtEMail.value=="")
		{
			alert("Email Address Required");
			document.frmEmaillogin.txtEMail.focus();
			return false;
		}
		else if (document.frmEmaillogin.txtEMail.value !="" && !MailValidate(document.frmEmaillogin.txtEMail.value))
		{
			alert('Enter a valid Email Address');
			document.frmEmaillogin.txtEMail.select();
			return false;
		}

		else if(document.frmEmaillogin.txtPassword.value == "")
		{
			alert("Password Required");
			document.frmEmaillogin.txtPassword.focus();
			return false;
		}
		else if(document.frmEmaillogin.txtPassword.value.length < 6)
		{
			alert("Password should be 6 characters minimum");
			document.frmEmaillogin.txtPassword.focus();
			return false;
		}
		else
		document.frmEmaillogin.submit();
}

function MailValidate(str)
{
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   return false
	}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	    return false
	}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    return false
	}
	 if (str.indexOf(at,(lat+1))!=-1){
	      return false
	 }
	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	    return false
	 }
	 if (str.indexOf(dot,(lat+2))==-1){
	     return false
	 }
	 if (str.indexOf(" ")!=-1){
	    return false
	 }
	 return true
}

<!-- helper script that uses the calendar -->

var oldLink = null;
// code to change the active stylesheet
function setActiveStyleSheet(link, title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
  if (oldLink) oldLink.style.fontWeight = 'normal';
  oldLink = link;
  link.style.fontWeight = 'bold';
  return false;
}

// This function gets called when the end-user clicks on some date.
function selected(cal, date) {
  cal.sel.value = date; // just update the date in the input field.
  if (cal.dateClicked && (cal.sel.id == "sel1" || cal.sel.id == "sel3"))
    // if we add this call we close the calendar on single-click.
    // just to exemplify both cases, we are using this only for the 1st
    // and the 3rd field, while 2nd and 4th will still require double-click.
    cal.callCloseHandler();
}

// And this gets called when the end-user clicks on the _selected_ date,
// or clicks on the "Close" button.  It just hides the calendar without
// destroying it.
function closeHandler(cal) {
  cal.hide();                        // hide the calendar
//  cal.destroy();
  _dynarch_popupCalendar = null;
}

// This function shows the calendar under the element having the given id.
// It takes care of catching "mousedown" signals on document and hiding the
// calendar if the click was outside.
function showCalendar(id, format, showsTime, showsOtherMonths) {
  var el = document.getElementById(id);
  //alert(el);
  if (_dynarch_popupCalendar != null) {
    // we already have some calendar created
    _dynarch_popupCalendar.hide();                 // so we hide it first.
  } else {
    // first-time call, create the calendar.
    var cal = new Calendar(1, null, selected, closeHandler);
    // uncomment the following line to hide the week numbers
    // cal.weekNumbers = false;
    if (typeof showsTime == "string") {
      cal.showsTime = true;
      cal.time24 = (showsTime == "24");
    }
    if (showsOtherMonths) {
      cal.showsOtherMonths = true;
    }
    _dynarch_popupCalendar = cal;                  // remember it in the global var
    cal.setRange(1900, 2070);        // min/max year allowed.
    cal.create();
  }
  _dynarch_popupCalendar.setDateFormat(format);    // set the specified date format
  _dynarch_popupCalendar.parseDate(el.value);      // try to parse the text in field
  _dynarch_popupCalendar.sel = el;                 // inform it what input field we use

  // the reference element that we pass to showAtElement is the button that
  // triggers the calendar.  In this example we align the calendar bottom-right
  // to the button.
  _dynarch_popupCalendar.showAtElement(el.nextSibling, "tr");        // show the calendar

  return false;
}