
/** The p_object parameter is the object that called
 *  this function (i.e., send 'this' (without the quotes)
 *  as a parameter).  If the object calling this function
 *  is determined to be a submit button, the form is not
 *  submitted via this function, thus preventing the form
 *  from being submitted twice.
 */
 
function ShowContent2(d,m,v) {

	switch (m){
	case 1: 
	msg="Full Birth date is required!"
	break
	case 2: 
	msg="Your are ("+v+") You must be age 64 or over to apply for Medicare Supplement."
	break
	case 3:
	msg="ZIP Code is required!"
	case 4:
	msg="Zip Code was not found!";
	break
	case 5:
	msg="You do not reside in IL you reside in "+v+" Sorry we do not offer insurance in this state!";
	break
	default: msg="";
	}

document.getElementById(d).innerHTML = msg;
if(msg!="")return false
else return true

}
 
function validate(obj)
{

vl=true
dterror=false

var newdate=new Date();

yy=newdate.getFullYear()
mm=newdate.getMonth()+1
dv=newdate.getDate()




db = obj['dob_day1'].value
bm = obj['dob_month'].value
by = obj['dob_year'].value

ShowContent2("zp",0,"")
ShowContent2("bd",0,"")

if(!db || !bm || !by) {vl=ShowContent2("bd",1,"");dterror=true}

	if(!dterror)
	{
		crd =yy+"/"+mm+"/"+dv
		brd =by+"/"+bm+"/"+db

		dd1 = new Date(yy,mm,dv)
		dd2 = new Date(by,bm,db)

		firstDate = Date.parse(brd)
		secondDate= Date.parse(crd)

		age=yy-by;
		if(bm>mm)age--;
		else if(bm==mm)if(db<dv)age--;

		md = bm - mm
		if(age<64) vl=ShowContent2("bd",2,age)
	}
	
obj['dob_day'].value=bm

zipv = obj['zipcode'].value

		if(zipv!="" && zipv!=" ")
		{
			cvf=obj['county'].value
			var temp = new Array();
			temp = cvf.split('|');
			
			cnv=temp[0]
			sv=temp[1]
			cityv=temp[2]	
				
			if(sv!="IL")vl=ShowContent2("zp",5,sv)
			else
			if(sv=="")vl=ShowContent2("zp",4,"")
		}
		else{vl=ShowContent2("zp",3,"")}

return vl
}

function submitForm(p_object, p_actionType)
{

  if(validate(appForm))
   {
   document.plans.Submitform.value="Continue";
   document.plans.Submitform.className="bigbutton"
   
	for (n=0; n<document.forms.length;n++){
		document.forms[n].actionType.value = p_actionType;
		if (p_object.type != 'submit')
		{

			//only submit if the calling object is not a submit button
			// disableButtons();
			document.forms[n].submit();
		}	
	}
   }	
}

