
/** 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
	case 6:
	  msg="effective date is missing and required ";
	break
	case 7:
	  msg="Your effective date is past ("+v+") please select a new effective date."
	break
	case 8:
	  msg="Month cannot bigger than 12 & day cannot be bigger than 31 you entered ("+v+") please change!"
	break
	case 9:
	  msg="You cannot request a policy effective date more than one year from today ("+v+") please change!"
	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,"")
ShowContent2("ef",0,"")

if(!db || !bm || !by) {vl=ShowContent2("bd",1,"");dterror=true}

if(bm > 12) {vl=ShowContent2("bd",8,bm);dterror=true}
if(db > 31) {vl=ShowContent2("bd",8,db);dterror=true}

	if(!dterror)
	{
	
		if(bm.length<2){bm="0"+bm;obj['dob_month'].value=bm}
		if(bm.length<2){db="0"+db;obj['dob_day1'].value=db}
		
		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<63) vl=ShowContent2("bd",2,age)
	}
	
obj['dob_day'].value=bm

// effective date

db=bm=by="";
dterror = false;

bm = obj['effDate_month'].value
db = obj['effDate_day_v'].value
by = obj['effDate_year'].value

if(!db || !bm || !by) {vl=ShowContent2("ef",6,"");dterror=true}
if(bm > 12) {vl=ShowContent2("ef",8,bm);dterror=true}
if(db > 31) {vl=ShowContent2("ef",8,db);dterror=true}

	if(!dterror)
	{
	      if(bm.length<2){bm="0"+bm;obj['effDate_month'].value=bm}
	        if(by.length<4){by="20"+by;obj['effDate_year'].value=by}
	        
		crd =mm+"/"+dv+"/"+yy
		brd =bm+"/"+db+"/"+by

		dd1 = new Date(mm/dv/yy)
		dd2 = new Date(bm/db/by)

		firstDate = Date.parse(brd)
		secondDate= Date.parse(crd)
		
		if(firstDate < secondDate) vl=ShowContent2("ef",7,brd);
		else
		{
		md = parseInt(bm) - mm
		if(md ==0) bm = parseInt(bm) +1
		 if(bm.length<2){bm="0"+bm;obj['effDate_month'].value=bm}
		
		}
		
		// alert(bm + ":" + parseInt(bm) + ">" + parseInt(mm))
		
		if((parseInt(by) > yy) && (parseInt(bm)>mm)){vl=ShowContent2("ef",9,brd);}
		
		obj['effDate_day'].value="01"
	  	
	}
	
	

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();
		}	
	}
   }	
}


