/*****************************************************************************
 *  File Name     : healthSearch.js						                     *
 *  Author        : T. Manimaran		                                     *
 *  Owner         : ICM Solutions                                            *
 *  Creation Date : 04-July-08									             *
 *  Last Modified : 		      	                                         *
 *  Modified Date :															 *
 *  Usage         : This javascript class is mainly responsible for 		 *
 * 					validation customer	inputs for health search screen      *
 * 																			 *
 *																			 *
 *****************************************************************************/
function validationExtendedFamily(){ 
var sumins                     =document.getElementById("sumInsureda");
var primeryPersonDOB           =document.getElementById("primeryPersonDOB");
var SpouseDOB                  =document.getElementById("SpouseDOB");
var firstChildDOB              =document.getElementById("firstChildDOB");
var secondChildDOB             =document.getElementById("secondChildDOB");
var thirdChildDOB              =document.getElementById("thirdChildDOB");
var motherDOB                  =document.getElementById("motherDOBa");
var fatherDoB                  =document.getElementById("fatherDoBa");
var motherInLawDOB             =document.getElementById("motherInLawDOBa");
var fatherInLawDOB             =document.getElementById("fatherInLawDOBa");
var addtionalPersons           =document.getElementById("addtionalPersons");

var SpouseDOBcheck             =document.getElementById("SpouseDOBcheck").checked;
var firstChildDOBcheck         =document.getElementById("firstChildDOBcheck").checked;
var secondChildDOBcheck        =document.getElementById("secondChildDOBcheck").checked;
var thirdChildDOBcheck         =document.getElementById("thirdChildDOBcheck").checked;
var motherDOBcheck             =document.getElementById("motherDOBcheck").checked;
var fatherDoBcheck             =document.getElementById("fatherDoBcheck").checked;
var motherInLawDOBcheck        =document.getElementById("motherInLawDOBcheck").checked;
var fatherInLawDOBcheck        =document.getElementById("fatherInLawDOBcheck").checked;
var addtionalPersonscheck      =document.getElementById("addtionalPersonscheck").checked;

if(sumins.value=="selected"){
alert("Please Select Sum Insured");
sumins.focus();
return false;
}


if(primeryPersonDOB.value==""){
alert("Please enter Primary Person's Date Of Birth");
primeryPersonDOB.focus();
primeryPersonDOB.select();
return false;
}

if(primeryPersonDOB.value.length >10){
alert("Please enter Valid Primary Person's Date of Birth (dd/mm/yyyy)");
primeryPersonDOB.focus();
primeryPersonDOB.select();
return false;
}
if(isDate(primeryPersonDOB.value)==false){
alert("Please enter Valid Primary Person's Date of Birth (dd/mm/yyyy)");
primeryPersonDOB.focus();
primeryPersonDOB.select();
return false;
}
if(isLessThenCurrentDate(primeryPersonDOB.value)==false){
alert("Primary  Person's Date of Birth should be greater than 18 years");
primeryPersonDOB.focus();
primeryPersonDOB.select();
return false;
}

if(SpouseDOBcheck==true){
if(SpouseDOB.value==""){
alert("Please enter Spouse's Date Of Birth");
SpouseDOB.focus();
SpouseDOB.select();
return false;
}
if(SpouseDOB.value.length >10){
alert("Please enter Valid Spouse's Date of Birth (dd/mm/yyyy)");
primeryPersonDOB.focus();
primeryPersonDOB.select();
return false;
}
if(isDate(SpouseDOB.value)==false){
alert("Please enter Valid Spouse's Date of Birth (dd/mm/yyyy)");
SpouseDOB.focus();
SpouseDOB.select();
return false;
}
if(isLessThenCurrentDate(SpouseDOB.value)==false){
alert("Spouse's Date of Birth  should be greater than 18 years");
SpouseDOB.focus();
SpouseDOB.select();
return false;
}
}

if(firstChildDOBcheck==true){
if(firstChildDOB.value==""){
alert("Please enter first child's Date Of Birth");
firstChildDOB.focus();
firstChildDOB.select();
return false;
}
if(firstChildDOB.value.length >10){
alert("Please enter Valid first child's Date of Birth (dd/mm/yyyy)");
firstChildDOB.focus();
firstChildDOB.select();
return false;
}
if(isDate(firstChildDOB.value)==false){
alert("Please enter Valid first child's Date of Birth (dd/mm/yyyy)");
firstChildDOB.focus();
firstChildDOB.select();
return false;
}
if(isLessThenCurrentDateForExtFamily(firstChildDOB.value)==false){
alert("First Child's Date of Birth should be greater than 3 months");
firstChildDOB.focus();
firstChildDOB.select();
return false;
}
if(isGraterThen18Years(firstChildDOB.value)==false){
alert("First Child's Date of Birth should be Less than 25 Years");
firstChildDOB.focus();
firstChildDOB.select();
return false;
}


var firstChildGanderMale   =document.getElementById("firstChildGanderMale").checked;
var firstChildGanderfemale   =document.getElementById("firstChildGanderfemale").checked;
if(firstChildGanderMale==false && firstChildGanderfemale==false){
alert("please Select first Child's Gender");
return false;
}

}

if(secondChildDOBcheck==true){
if(secondChildDOB.value==""){
alert("Please enter second child's Date Of Birth");
secondChildDOB.focus();
secondChildDOB.select();
return false;
}
if(secondChildDOB.value.length >10){
alert("Please enter Valid second child's Date of Birth (dd/mm/yyyy)");
secondChildDOB.focus();
secondChildDOB.select();
return false;
}
if(isDate(secondChildDOB.value)==false){
alert("Please enter Valid second child's Date of Birth (dd/mm/yyyy)");
secondChildDOB.focus();
secondChildDOB.select();
return false;
}
if(isLessThenCurrentDateForExtFamily(secondChildDOB.value)==false){
alert("Second child's Date of Birth should be greater than 3 months");
secondChildDOB.focus();
secondChildDOB.select();
return false;
}
if(isGraterThen18Years(secondChildDOB.value)==false){
alert("Second child's Date of Birth should be less than 25 years");
secondChildDOB.focus();
secondChildDOB.select();
return false;
}
var secondChildGanderMale   =document.getElementById("secondChildGanderMale").checked;
var secondChildGanderfemale   =document.getElementById("secondChildGanderfemale").checked;
if(secondChildGanderMale==false && secondChildGanderfemale==false){
alert("please Select second Child's Gender");
return false;
}


}

if(thirdChildDOBcheck==true){
if(thirdChildDOB.value==""){
alert("Please enter third child's Date Of Birth");
thirdChildDOB.focus();
thirdChildDOB.select();
return false;
}
if(thirdChildDOB.value.length >10){
alert("Please enter Valid third child's Date of Birth (dd/mm/yyyy)");
thirdChildDOB.focus();
thirdChildDOB.select();
return false;
}
if(isDate(thirdChildDOB.value)==false){
alert("Please enter Valid third child's Date of Birth (dd/mm/yyyy)");
thirdChildDOB.focus();
thirdChildDOB.select();
return false;
}
if(isLessThenCurrentDateForExtFamily(thirdChildDOB.value)==false){
alert("Third child's Date of Birth should be greater than 3 months");
thirdChildDOB.focus();
thirdChildDOB.select();
return false;
}
if(isGraterThen18Years(thirdChildDOB.value)==false){
alert("Third child's Date of Birth should be less than 25 years");
thirdChildDOB.focus();
thirdChildDOB.select();
return false;
}

var thirdChildGanderMale   =document.getElementById("thirdChildGanderMale").checked;
var thirdChildGanderfemale   =document.getElementById("thirdChildGanderfemale").checked;
if(thirdChildGanderMale==false && thirdChildGanderfemale==false){
alert("please Select third Child's Gender");
return false;
}

}

if(motherDOBcheck==true){
if(motherDOB.value==""){
alert("Please enter mother's Date Of Birth");
motherDOB.focus();
motherDOB.select();
return false;
}
if(motherDOB.value.length >10){
alert("Please enter Valid mother's Date of Birth (dd/mm/yyyy)");
motherDOB.focus();
motherDOB.select();
return false;
}
if(isDate(motherDOB.value)==false){
alert("Please enter Valid mother's Date of Birth (dd/mm/yyyy)");
motherDOB.focus();
motherDOB.select();
return false;
}
if(isLessThenCurrentDate(motherDOB.value)==false){
alert("Mother's Date of Birth should be less than 18 years");
motherDOB.focus();
motherDOB.select();
return false;
}
}

if(fatherDoBcheck==true){
if(fatherDoB.value==""){
alert("Please enter father's Date Of Birth");
fatherDoB.focus();
fatherDoB.select();
return false;
}
if(fatherDoB.value.length >10){
alert("Please enter Valid father's Date of Birth (dd/mm/yyyy)");
fatherDoB.focus();
fatherDoB.select();
return false;
}
if(isDate(fatherDoB.value)==false){
alert("Please enter Valid father's Date of Birth (dd/mm/yyyy)");
fatherDoB.focus();
fatherDoB.select();
return false;
}
if(isLessThenCurrentDate(fatherDoB.value)==false){
alert("Father's Date of Birth should be less than 18 years");
fatherDoB.focus();
fatherDoB.select();
return false;
}
}

if(motherInLawDOBcheck==true){
if(motherInLawDOB.value==""){
alert("Please enter mother In-Law's Date Of Birth");
motherInLawDOB.focus();
motherInLawDOB.select();
return false;
}
if(motherInLawDOB.value.length >10){
alert("Please enter Valid mother In-Law's Date of Birth (dd/mm/yyyy)");
motherInLawDOB.focus();
motherInLawDOB.select();
return false;
}
if(isDate(motherInLawDOB.value)==false){
alert("Please enter Valid mother In-Law's Date of Birth (dd/mm/yyyy)");
motherInLawDOB.focus();
motherInLawDOB.select();
return false;
}
if(isLessThenCurrentDate(motherInLawDOB.value)==false){
alert("Mother In-Law's Date of Birth should be less than 18 years");
motherInLawDOB.focus();
motherInLawDOB.select();
return false;
}
}

if(fatherInLawDOBcheck==true){
if(fatherInLawDOB.value==""){
alert("Please enter father In-Law's Date Of Birth");
fatherInLawDOB.focus();
fatherInLawDOB.select();
return false;
}
if(fatherInLawDOB.value.length >10){
alert("Please enter Valid father In-Law's Date of Birth (dd/mm/yyyy)");
fatherInLawDOB.focus();
fatherInLawDOB.select();
return false;
}
if(isDate(fatherInLawDOB.value)==false){
alert("Please enter Valid father In-Law's Date of Birth (dd/mm/yyyy)");
fatherInLawDOB.focus();
fatherInLawDOB.select();
return false;
}
if(isLessThenCurrentDate(fatherInLawDOB.value)==false){
alert("Father In-Law's Date of Birth should be less than 18 years");
fatherInLawDOB.focus();
fatherInLawDOB.select();
return false;
}
}

//if(motherDOB.value=="" && fatherDoB.value=="" && motherInLawDOB.value=="" && fatherInLawDOB.value=="" ){
	//alert("Please enter any one of parents or parents In-Law's Date of Birth");
//return false;
//}


if(addtionalPersonscheck==true){
if(addtionalPersons.value=="selected"){
	alert("Please select additional persons");
	addtionalPersons.focus();
	return false;
}
}


var FirstRelation  =document.getElementById("FirstRelation");
var FirstDOB       =document.getElementById("FirstDOB");
var secondRelation =document.getElementById("secondRelation");
var secondDOB      =document.getElementById("secondDOB");
var thirdRelation =document.getElementById("thirdRelation");
var thirdDOB      =document.getElementById("thirdDOB");
var fourthRelation =document.getElementById("fourthRelation");
var fourthDOB      =document.getElementById("fourthDOB");
var fifthRelation =document.getElementById("fifthRelation");
var fifthDOB      =document.getElementById("fifthDOB");
var sixthRelation =document.getElementById("sixthRelation");
var sixthDOB      =document.getElementById("sixthDOB");

var    x=parseInt(document.getElementById("addtionalPersons").value);
	
switch (x) {

case 6:
if(sixthRelation.value=="selected"){
alert("Please select sixth additional person relation.");
sixthRelation.focus();
return false;
}
if(sixthDOB.value==""){
alert("Please enter sixth additional person Date Of Birth");
sixthDOB.focus();
sixthDOB.select();
return false;
}
if(sixthDOB.value.length >10){
alert("Please enter Valid sixth additional person Date of Birth (dd/mm/yyyy)");
sixthDOB.focus();
sixthDOB.select();
return false;
}
if(isDate(sixthDOB.value)==false){
alert("Please enter Valid sixth additional person Date of Birth (dd/mm/yyyy)");s
sixthDOB.focus();
sixthDOB.select();
return false;
}
if(isLessThenCurrentDateForExtFamily(sixthDOB.value)==false){
alert("Sixth additional person Date of Birth should be greater than 3 months");
sixthDOB.focus();
sixthDOB.select();
return false;
}

case 5:
if(fifthRelation.value=="selected"){
alert("Please select fifth additional person relation.");
fifthRelation.focus();
return false;
}
if(fifthDOB.value==""){
alert("Please enter fifth additional person Date Of Birth");
fifthDOB.focus();
fifthDOB.select();
return false;
}
if(fifthDOB.value.length >10){
alert("Please enter Valid fifth additional person Date of Birth (dd/mm/yyyy)");
fifthDOB.focus();
fifthDOB.select();
return false;
}
if(isDate(fifthDOB.value)==false){
alert("Please enter Valid fifth additional person Date of Birth (dd/mm/yyyy)");s
fifthDOB.focus();
fifthDOB.select();
return false;
}
if(isLessThenCurrentDateForExtFamily(fifthDOB.value)==false){
alert("Fifth additional person Date of Birth should be greater than 3 months");
fifthDOB.focus();
fifthDOB.select();
return false;
}

case 4:
if(fourthRelation.value=="selected"){
alert("Please select fourth additional person relation.");
fourthRelation.focus();
return false;
}
if(fourthDOB.value==""){
alert("Please enter fourth additional person Date Of Birth");
fourthDOB.focus();
fourthDOB.select();
return false;
}
if(fourthDOB.value.length >10){
alert("Please enter Valid fourth additional person Date of Birth (dd/mm/yyyy)");
fourthDOB.focus();
fourthDOB.select();
return false;
}
if(isDate(fourthDOB.value)==false){
alert("Please enter Valid fourth additional person Date of Birth (dd/mm/yyyy)");s
fourthDOB.focus();
fourthDOB.select();
return false;
}
if(isLessThenCurrentDateForExtFamily(fourthDOB.value)==false){
alert("Fourth additional person Date of Birth should be greater than 3 months");
fourthDOB.focus();
fourthDOB.select();
return false;
}

case 3:
if(thirdRelation.value=="selected"){
alert("Please select third additional person relation.");
thirdRelation.focus();
return false;
}
if(thirdDOB.value==""){
alert("Please enter third additional person  Date Of Birth");
thirdDOB.focus();
thirdDOB.select();
return false;
}
if(thirdDOB.value.length >10){
alert("Please enter Valid third additional person Date of Birth (dd/mm/yyyy)");
thirdDOB.focus();
thirdDOB.select();
return false;
}
if(isDate(thirdDOB.value)==false){
alert("Please enter Valid third additional person Date of Birth (dd/mm/yyyy)");s
thirdDOB.focus();
thirdDOB.select();
return false;
}
if(isLessThenCurrentDateForExtFamily(thirdDOB.value)==false){
alert("Third additional person Date of Birth should be greater than 3 months");
thirdDOB.focus();
thirdDOB.select();
return false;
}


case 2:
if(secondRelation.value=="selected"){
 alert("Please select second additional person relation.");
secondRelation.focus();
return false;
}
if(secondDOB.value==""){
alert("Please enter second additional person Date Of Birth");
secondDOB.focus();
secondDOB.select();
return false;
}
if(secondDOB.value.length >10){
alert("Please enter Valid second additional person Date of Birth (dd/mm/yyyy)");
secondDOB.focus();
secondDOB.select();
return false;
}
if(isDate(secondDOB.value)==false){
alert("Please enter Valid second additional person Date of Birth (dd/mm/yyyy)");
secondDOB.focus();
secondDOB.select();
return false;
}
if(isLessThenCurrentDateForExtFamily(secondDOB.value)==false){
alert("Second additional person Date of Birth should be greater than 3 months");
secondDOB.focus();
secondDOB.select();
return false;
}


case 1:
if(FirstRelation.value=="selected"){
 alert("Please select first additional person relation.");
FirstRelation.focus();
return false;
}
if(FirstDOB.value==""){
alert("Please enter first additional person Date Of Birth");
FirstDOB.focus();
FirstDOB.select();
return false;
}
if(FirstDOB.value.length >10){
alert("Please enter Valid first additional person Date of Birth (dd/mm/yyyy)");
FirstDOB.focus();
FirstDOB.select();
return false;
}
if(isDate(FirstDOB.value)==false){
alert("Please enter Valid first additional person Date of Birth (dd/mm/yyyy)");
FirstDOB.focus();
FirstDOB.select();
return false;
}
if(isLessThenCurrentDateForExtFamily(FirstDOB.value)==false){
alert("First additional person Date of Birth should be greater than 3 months");
FirstDOB.focus();
FirstDOB.select();
return false;
}

break;

}

var maxBupaIndividualSI   =document.getElementById("maxBupaIndividualSI");
var maxBupaFloaterSI      =document.getElementById("maxBupaFloaterSI");

if(parseInt(addtionalPersons.value) > 0){
//if(maxBupaIndividualSI.value=="selected"){
//	alert("Please select Individual sum Insured for max Bupa Plans");
//	maxBupaIndividualSI.focus();
//	return false;
//}
if (maxBupaFloaterSI.value=="selected")
{
	alert("Please select Floater Sum Insured for max Bupa Plans");
	maxBupaFloaterSI.focus();
	return false;
}
}


return true;
}











function validationExtendedFamilyOLD(){ 

var YourAge = document.getElementById("YourAge");
	if(YourAge.value=="selected"){
		alert('Please select Your Age  from Drop Down');
		YourAge.focus();
		return false;	
	}

var YourSpouseAge = document.getElementById("YourSpouseAge");
var YourFirstChildAge = document.getElementById("YourFirstChildAge");
var YourSecondChildAge = document.getElementById("YourSecondChildAge");
var YourThirdChildAge = document.getElementById("YourThirdChildAge");
var YourMotherAge = document.getElementById("YourMotherAge");
var YourFatherAge = document.getElementById("YourFatherAge");

var parents = document.getElementById("parents").checked;
var parentsInLaws = document.getElementById("parentsInLaws").checked;
var none1 = document.getElementById("none1").checked;

if((parents==false)&&(parentsInLaws==false)&&(none1==false)){

alert('Please select Parents or  Parents In-Laws or None');
return false;
}


	if(
		
	((YourSpouseAge.value=="selected")||(YourSpouseAge.value=="NO"))&&
	((YourFirstChildAge.value=="selected")||(YourFirstChildAge.value=="NO"))&&
	((YourSecondChildAge.value=="selected")||(YourSecondChildAge.value=="NO"))&&
	((YourThirdChildAge.value=="selected")||(YourThirdChildAge.value=="NO"))&&
    ((YourMotherAge.value=="selected")||(YourMotherAge.value=="NO"))&&
	((YourFatherAge.value=="selected")||(YourMotherAge.value=="NO"))

	){
		alert('Please select atleast one of your family member Age from Drop Downs');
		YourSpouseAge.focus();
		return false;	
	}

    
    var suminsured = document.getElementById("suminsuredA");

	if(suminsured.value=="selected"){
				alert('Please select sum insured Range from Drop Down');
				suminsured.focus();
		return false;	
	}
	

return true;
}


//Validation for health search screen//
function validate(){ 
	var cover = document.getElementById('mediclaim').checked;
    var cover4 = document.getElementById('SeniorCitizen').checked;
    var cover1 = document.getElementById('criticalillness').checked;
	 var cover2 = document.getElementById('diabetes').checked;
     var cover3 = document.getElementById('HospitalCash').checked;
     var he = document.getElementById("ToCover").value;
if(he !="Family"){

if(cover==false && cover1==false && cover2==false && cover3==false && cover4== false){
	alert("Please select any one option");
	return false;
}

}

if(he =="Family"){

		var adults = document.getElementById("adults");
		var kids = document.getElementById("kids");

		if(adults.value==""){
			alert("Please select no of Adults");
			adults.focus();
			return false;
		}
		
		if(kids.value==""){
			alert("Please select no of Children");
			kids.focus();
			return false;
		}
		
		if(adults==1 && kids==0){
			alert('For Family, Adults Should be more than 1 or no of children Should be more than 0');
			kidsFoc.focus();
			return false;
		}
	}
var eldestage = document.getElementById("eldestage");
var SeniorCitizen = document.getElementById('SeniorCitizen').checked;
		if(isEmpty(eldestage.value)==true){
			alert("Please enter Date of Birth");
			eldestage.focus();
			eldestage.select();
			return false;
		}

		if(eldestage.value.length > 10){
			alert('Please Enter Valid Date of Birth (dd/mm/yyyy)');
			eldestage.focus();
			eldestage.select();
			return false;	
		}
		if(isDate(eldestage.value)==false){
			alert('Please Enter Valid Date of Birth (dd/mm/yyyy)');
			eldestage.focus();
			eldestage.select();
			return false;
		}

		if(SeniorCitizen==true){
          if(isLessThenCurrentDateSC(eldestage.value)==false){
			alert('Age should be greater than 60 years for Senior Citizen, So please choose the Basic Mediclaim Policies');
			eldestage.focus();
			eldestage.select();
			document.getElementById('mediclaim').checked=true;
			return false;
		}
		}else{
		if(isLessThenCurrentDate(eldestage.value)==false){
			alert('Date of Birth should be greater than 18 years');
			eldestage.focus();
			eldestage.select();
			return false;
		}}


if((cover == true)||(he =="Family") ||(cover4 == true)){
	var suminsured = document.getElementById("suminsuredIF");
	if(suminsured.value=="selected"){
		alert('Please select a Range from Drop Down');
		suminsured.focus();
		return false;	
	}

}

	
	return true;
}





function validationExtendedFamilyByCompanyWise(){ 
var sumins                     =document.getElementById("sumInsureda");
var primeryPersonDOB           =document.getElementById("primeryPersonDOB");
var SpouseDOB                  =document.getElementById("SpouseDOB");
var firstChildDOB              =document.getElementById("firstChildDOB");
var secondChildDOB             =document.getElementById("secondChildDOB");
var thirdChildDOB              =document.getElementById("thirdChildDOB");
var motherDOB                  =document.getElementById("motherDOBa");
var fatherDoB                  =document.getElementById("fatherDoBa");
var motherInLawDOB             =document.getElementById("motherInLawDOBa");
var fatherInLawDOB             =document.getElementById("fatherInLawDOBa");
var addtionalPersons           =document.getElementById("addtionalPersons");

var SpouseDOBcheck             =document.getElementById("SpouseDOBcheck").checked;
var firstChildDOBcheck         =document.getElementById("firstChildDOBcheck").checked;
var secondChildDOBcheck        =document.getElementById("secondChildDOBcheck").checked;
var thirdChildDOBcheck         =document.getElementById("thirdChildDOBcheck").checked;
var motherDOBcheck             =document.getElementById("motherDOBcheck").checked;
var fatherDoBcheck             =document.getElementById("fatherDoBcheck").checked;
var motherInLawDOBcheck        =document.getElementById("motherInLawDOBcheck").checked;
var fatherInLawDOBcheck        =document.getElementById("fatherInLawDOBcheck").checked;
var addtionalPersonscheck      =document.getElementById("addtionalPersonscheck").checked;
var CompanyId                  =document.getElementById("CompanyId").value;

var entryAgeMin                =document.getElementById("entryAgeMin").value;
var entryAgeMax                =document.getElementById("entryAgeMax").value;
var childMinAge                =document.getElementById("childMinAge").value;
var childMaxAge                =document.getElementById("childMaxAge").value;
var parentsMinAge              =document.getElementById("parentsMinAge").value;
var parentsMaxAge              =document.getElementById("parentsMaxAge").value;

var spouseMinAge               =document.getElementById("spouseMinAge").value;
var spouseMaxAge               =document.getElementById("spouseMaxAge").value;
var parentsInLawMinAge         =document.getElementById("parentsInLawMinAge").value;
var parentsInLawMaxAge         =document.getElementById("parentsInLawMaxAge").value;
var otherMinAge                =document.getElementById("otherMinAge").value;
var otherMaxAge                =document.getElementById("otherMaxAge").value;

//alert("CompanyId-->"+CompanyId);

if(primeryPersonDOB.value==""){
alert("Please enter Primary Person's Date Of Birth");
primeryPersonDOB.focus();
primeryPersonDOB.select();
return false;
}

if(primeryPersonDOB.value.length >10){
alert("Please enter Valid Primary Person's Date of Birth (dd/mm/yyyy)");
primeryPersonDOB.focus();
primeryPersonDOB.select();
return false;
}
if(isDate(primeryPersonDOB.value)==false){
alert("Please enter Valid Primary Person's Date of Birth (dd/mm/yyyy)");
primeryPersonDOB.focus();
primeryPersonDOB.select();
return false;
}

if(primeryPersonDOB.value!="")
		//alert("called");
	{
        var datedif=0;
		var monthdif=0;
		var yeardif=0;
		var i=0;
		var j=0;
		var cal_age=0;
		var term=0;
		var currentDate=new Date(commonServerDate.getFullYear(), commonServerDate.getMonth(), commonServerDate.getDate());
		
        var dob=primeryPersonDOB.value;
		var presentage=0;
		var calculatedob=dob.split("/");
        var agedate=calculatedob[0];
		var agemonth= calculatedob[1];
		var ageyear=calculatedob[2];
        		if(agedate!=0 && agemonth!=0 && ageyear!=0 ){
				if(isDate(dob)){
					datedif=currentDate.getDate()-agedate;
					monthdif = currentDate.getMonth()-agemonth;
					yeardif=currentDate.getFullYear()-ageyear;
				   if(datedif < 0) {
				                i = monthdif - 1; 
				        }
				        else {
				        	i = monthdif;
				        }
				        if(i < 0) {
				        	j=i + 12;
				        }
				        else {
				        	j = i;
				        }
				        if(i<0) {
				        	yeardif = yeardif - 1;
				        }

						cal_age = yeardif;

						//alert("calage"+cal_age);


						//alert("Min->"+agemin+"Max->"+agemax);
						if(cal_age < parseInt(entryAgeMin)) 
						{
							alert("Enter primary Person's Age Between "+entryAgeMin+"Yrs  and "+entryAgeMax+"Yrs");
							return false;
						}
						if(cal_age > parseInt(entryAgeMax)) 
						{
							alert("Enter primary Person's Age Between "+entryAgeMin+"Yrs and "+entryAgeMax+"Yrs");
							return false;
						}
						if(cal_age >= parseInt(entryAgeMin) && cal_age <= parseInt(entryAgeMax)){
							
						}
					}
				else{

					alert("Enter a valid Primary Person's date of birth in (dd/mm/yyyy) format");
					primeryPersonDOB.value="";
					
				}
			}

	}


if(SpouseDOBcheck==true){
if(SpouseDOB.value==""){
alert("Please enter Spouse's Date Of Birth");
SpouseDOB.focus();
SpouseDOB.select();
return false;
}
if(SpouseDOB.value.length >10){
alert("Please enter Valid Spouse's Date of Birth (dd/mm/yyyy)");
primeryPersonDOB.focus();
primeryPersonDOB.select();
return false;
}
if(isDate(SpouseDOB.value)==false){
alert("Please enter Valid Spouse's Date of Birth (dd/mm/yyyy)");
SpouseDOB.focus();
SpouseDOB.select();
return false;
}
	if(SpouseDOB.value!="")
		//alert("called");
	{
        var datedif=0;
		var monthdif=0;
		var yeardif=0;
		var i=0;
		var j=0;
		var cal_age=0;
		var term=0;
		var currentDate=new Date(commonServerDate.getFullYear(), commonServerDate.getMonth(), commonServerDate.getDate());
		
        var dob=SpouseDOB.value;
		var presentage=0;
		var calculatedob=dob.split("/");
        var agedate=calculatedob[0];
		var agemonth= calculatedob[1];
		var ageyear=calculatedob[2];
        		if(agedate!=0 && agemonth!=0 && ageyear!=0 ){
				if(isDate(dob)){
					datedif=currentDate.getDate()-agedate;
					monthdif = currentDate.getMonth()-agemonth;
					yeardif=currentDate.getFullYear()-ageyear;
				   if(datedif < 0) {
				                i = monthdif - 1; 
				        }
				        else {
				        	i = monthdif;
				        }
				        if(i < 0) {
				        	j=i + 12;
				        }
				        else {
				        	j = i;
				        }
				        if(i<0) {
				        	yeardif = yeardif - 1;
				        }

						cal_age = yeardif;

						//alert("calage"+cal_age);


						//alert("Min->"+agemin+"Max->"+agemax);
						if(cal_age < parseInt(spouseMinAge)) 
						{
							alert("Enter spouse's Age Between "+spouseMinAge+"Yrs and "+spouseMaxAge+"Yrs");
							return false;
						}
						if(cal_age > parseInt(spouseMaxAge)) 
						{
							alert("Enter spouse's Age Between "+spouseMinAge+"Yrs and "+spouseMaxAge+"Yrs");
							return false;
						}
						if(cal_age >= parseInt(spouseMinAge) && cal_age <= parseInt(spouseMaxAge)){
							
						}
					}
				else{

					alert("Enter a valid Spouse's date of birth in (dd/mm/yyyy) format");
					SpouseDOB.value="";
					
				}
			}

	}
}

if(firstChildDOBcheck==true){
if(firstChildDOB.value==""){
alert("Please enter first child's Date Of Birth");
firstChildDOB.focus();
firstChildDOB.select();
return false;
}
if(firstChildDOB.value.length >10){
alert("Please enter Valid first child's Date of Birth (dd/mm/yyyy)");
firstChildDOB.focus();
firstChildDOB.select();
return false;
}
if(isDate(firstChildDOB.value)==false){
alert("Please enter Valid first child's Date of Birth (dd/mm/yyyy)");
firstChildDOB.focus();
firstChildDOB.select();
return false;
}
if(firstChildDOB.value!="")
		//alert("called");
	{
        var datedif=0;
		var monthdif=0;
		var yeardif=0;
		var i=0;
		var j=0;
		var cal_age=0;
		var term=0;
		var currentDate=new Date(commonServerDate.getFullYear(), commonServerDate.getMonth(), commonServerDate.getDate());
		
        var dob=firstChildDOB.value;
		var presentage=0;
		var calculatedob=dob.split("/");
        var agedate=calculatedob[0];
		var agemonth= calculatedob[1];
		var ageyear=calculatedob[2];
        		if(agedate!=0 && agemonth!=0 && ageyear!=0 ){
				if(isDate(dob)){
					datedif=currentDate.getDate()-agedate;
					monthdif = currentDate.getMonth()-agemonth;
					yeardif=currentDate.getFullYear()-ageyear;
				   if(datedif < 0) {
				                i = monthdif - 1; 
				        }
				        else {
				        	i = monthdif;
				        }
				        if(i < 0) {
				        	j=i + 12;
				        }
				        else {
				        	j = i;
				        }
				        if(i<0) {
				        	yeardif = yeardif - 1;
				        }

						cal_age = yeardif;

						//alert("calage"+cal_age);


						//alert("Min->"+agemin+"Max->"+agemax);
						if(cal_age < parseInt(childMinAge)) 
						{
							alert("Enter first child's Age Between "+childMinAge+"Yrs and "+childMaxAge+"Yrs");
							return false;
						}
						if(cal_age > parseInt(childMaxAge)) 
						{
							alert("Enter first child's Age Between "+childMinAge+"Yrs and "+childMaxAge+"Yrs");
							return false;
						}
						if(cal_age >= parseInt(childMinAge) && cal_age <= parseInt(childMaxAge)){
							
						}
					}
				else{

					alert("Enter a valid first child's date of birth in (dd/mm/yyyy) format");
					firstChildDOB.value="";
					
				}
			}

	}


var firstChildGanderMale   =document.getElementById("firstChildGanderMale").checked;
var firstChildGanderfemale   =document.getElementById("firstChildGanderfemale").checked;
if(firstChildGanderMale==false && firstChildGanderfemale==false){
alert("please Select first Child's Gender");
return false;
}

}

if(secondChildDOBcheck==true){
if(secondChildDOB.value==""){
alert("Please enter second child's Date Of Birth");
secondChildDOB.focus();
secondChildDOB.select();
return false;
}
if(secondChildDOB.value.length >10){
alert("Please enter Valid second child's Date of Birth (dd/mm/yyyy)");
secondChildDOB.focus();
secondChildDOB.select();
return false;
}
if(isDate(secondChildDOB.value)==false){
alert("Please enter Valid second child's Date of Birth (dd/mm/yyyy)");
secondChildDOB.focus();
secondChildDOB.select();
return false;
}
if(secondChildDOB.value!="")
		//alert("called");
	{
        var datedif=0;
		var monthdif=0;
		var yeardif=0;
		var i=0;
		var j=0;
		var cal_age=0;
		var term=0;
		var currentDate=new Date(commonServerDate.getFullYear(), commonServerDate.getMonth(), commonServerDate.getDate());
		
        var dob=secondChildDOB.value;
		var presentage=0;
		var calculatedob=dob.split("/");
        var agedate=calculatedob[0];
		var agemonth= calculatedob[1];
		var ageyear=calculatedob[2];
        		if(agedate!=0 && agemonth!=0 && ageyear!=0 ){
				if(isDate(dob)){
					datedif=currentDate.getDate()-agedate;
					monthdif = currentDate.getMonth()-agemonth;
					yeardif=currentDate.getFullYear()-ageyear;
				   if(datedif < 0) {
				                i = monthdif - 1; 
				        }
				        else {
				        	i = monthdif;
				        }
				        if(i < 0) {
				        	j=i + 12;
				        }
				        else {
				        	j = i;
				        }
				        if(i<0) {
				        	yeardif = yeardif - 1;
				        }

						cal_age = yeardif;

						//alert("calage"+cal_age);


						//alert("Min->"+agemin+"Max->"+agemax);
						if(cal_age < parseInt(childMinAge)) 
						{
							alert("Enter second child's Age Between "+childMinAge+"Yrs and "+childMaxAge+"Yrs");
							return false;
						}
						if(cal_age > parseInt(childMaxAge)) 
						{
							alert("Enter second child's Age Between "+childMinAge+"Yrs and "+childMaxAge+"Yrs");
							return false;
						}
						if(cal_age >= parseInt(childMinAge) && cal_age <= parseInt(childMaxAge)){
							
						}
					}
				else{

					alert("Enter a valid second child's date of birth in (dd/mm/yyyy) format");
					secondChildDOB.value="";
					
				}
			}

	}

var secondChildGanderMale   =document.getElementById("secondChildGanderMale").checked;
var secondChildGanderfemale   =document.getElementById("secondChildGanderfemale").checked;
if(secondChildGanderMale==false && secondChildGanderfemale==false){
alert("please Select second Child's Gender");
return false;
}

}

if(thirdChildDOBcheck==true){
if(thirdChildDOB.value==""){
alert("Please enter third child's Date Of Birth");
thirdChildDOB.focus();
thirdChildDOB.select();
return false;
}
if(thirdChildDOB.value.length >10){
alert("Please enter Valid third child's Date of Birth (dd/mm/yyyy)");
thirdChildDOB.focus();
thirdChildDOB.select();
return false;
}
if(isDate(thirdChildDOB.value)==false){
alert("Please enter Valid third child's Date of Birth (dd/mm/yyyy)");
thirdChildDOB.focus();
thirdChildDOB.select();
return false;
}
if(thirdChildDOB.value!="")
		//alert("called");
	{
        var datedif=0;
		var monthdif=0;
		var yeardif=0;
		var i=0;
		var j=0;
		var cal_age=0;
		var term=0;
		var currentDate=new Date(commonServerDate.getFullYear(), commonServerDate.getMonth(), commonServerDate.getDate());
		
        var dob=thirdChildDOB.value;
		var presentage=0;
		var calculatedob=dob.split("/");
        var agedate=calculatedob[0];
		var agemonth= calculatedob[1];
		var ageyear=calculatedob[2];
        		if(agedate!=0 && agemonth!=0 && ageyear!=0 ){
				if(isDate(dob)){
					datedif=currentDate.getDate()-agedate;
					monthdif = currentDate.getMonth()-agemonth;
					yeardif=currentDate.getFullYear()-ageyear;
				   if(datedif < 0) {
				                i = monthdif - 1; 
				        }
				        else {
				        	i = monthdif;
				        }
				        if(i < 0) {
				        	j=i + 12;
				        }
				        else {
				        	j = i;
				        }
				        if(i<0) {
				        	yeardif = yeardif - 1;
				        }

						cal_age = yeardif;

						//alert("calage"+cal_age);


						//alert("Min->"+agemin+"Max->"+agemax);
						if(cal_age < parseInt(childMinAge)) 
						{
							alert("Enter third child's Age Between "+childMinAge+"Yrs and "+childMaxAge+"Yrs");
							return false;
						}
						if(cal_age > parseInt(childMaxAge)) 
						{
							alert("Enter third child's Age Between "+childMinAge+"Yrs and "+childMaxAge+"Yrs");
							return false;
						}
						if(cal_age >= parseInt(childMinAge) && cal_age <= parseInt(childMaxAge)){
							
						}
					}
				else{

					alert("Enter a valid date of birth in (dd/mm/yyyy) format");
					thirdChildDOB.value="";
					
				}
			}

	}
var thirdChildGanderMale   =document.getElementById("thirdChildGanderMale").checked;
var thirdChildGanderfemale   =document.getElementById("thirdChildGanderfemale").checked;
if(thirdChildGanderMale==false && thirdChildGanderfemale==false){
alert("please Select third Child's Gender");
return false;
}

}

if(motherDOBcheck==true){
if(motherDOB.value==""){
alert("Please enter mother's Date Of Birth");
motherDOB.focus();
motherDOB.select();
return false;
}
if(motherDOB.value.length >10){
alert("Please enter Valid mother's Date of Birth (dd/mm/yyyy)");
motherDOB.focus();
motherDOB.select();
return false;
}
if(isDate(motherDOB.value)==false){
alert("Please enter Valid mother's Date of Birth (dd/mm/yyyy)");
motherDOB.focus();
motherDOB.select();
return false;
}
if(thirdChildDOB.value!="")
		//alert("called");
	{
        var datedif=0;
		var monthdif=0;
		var yeardif=0;
		var i=0;
		var j=0;
		var cal_age=0;
		var term=0;
		var currentDate=new Date(commonServerDate.getFullYear(), commonServerDate.getMonth(), commonServerDate.getDate());
		
        var dob=motherDOB.value;
		var presentage=0;
		var calculatedob=dob.split("/");
        var agedate=calculatedob[0];
		var agemonth= calculatedob[1];
		var ageyear=calculatedob[2];
        		if(agedate!=0 && agemonth!=0 && ageyear!=0 ){
				if(isDate(dob)){
					datedif=currentDate.getDate()-agedate;
					monthdif = currentDate.getMonth()-agemonth;
					yeardif=currentDate.getFullYear()-ageyear;
				   if(datedif < 0) {
				                i = monthdif - 1; 
				        }
				        else {
				        	i = monthdif;
				        }
				        if(i < 0) {
				        	j=i + 12;
				        }
				        else {
				        	j = i;
				        }
				        if(i<0) {
				        	yeardif = yeardif - 1;
				        }

						cal_age = yeardif;

						//alert("calage"+cal_age);


						//alert("Min->"+agemin+"Max->"+agemax);
						if(cal_age < parseInt(parentsMinAge)) 
						{
							alert("Enter mother's Age Between "+parentsMinAge+"Yrs and "+parentsMaxAge+"Yrs");
							return false;
						}
						if(cal_age > parseInt(parentsMaxAge)) 
						{
							alert("Enter mother's Age Between "+parentsMinAge+"Yrs and "+parentsMaxAge+"Yrs");
							return false;
						}
						if(cal_age >= parseInt(parentsMinAge) && cal_age <= parseInt(parentsMaxAge)){
							
						}
					}
				else{

					alert("Enter a valid mother's date of birth in (dd/mm/yyyy) format");
					motherDOB.value="";
					
				}
			}

	}
}

if(fatherDoBcheck==true){
if(fatherDoB.value==""){
alert("Please enter father's Date Of Birth");
fatherDoB.focus();
fatherDoB.select();
return false;
}
if(fatherDoB.value.length >10){
alert("Please enter Valid father's Date of Birth (dd/mm/yyyy)");
fatherDoB.focus();
fatherDoB.select();
return false;
}
if(isDate(fatherDoB.value)==false){
alert("Please enter Valid father's Date of Birth (dd/mm/yyyy)");
fatherDoB.focus();
fatherDoB.select();
return false;
}
if(fatherDoB.value!="")
		//alert("called");
	{
        var datedif=0;
		var monthdif=0;
		var yeardif=0;
		var i=0;
		var j=0;
		var cal_age=0;
		var term=0;
		var currentDate=new Date(commonServerDate.getFullYear(), commonServerDate.getMonth(), commonServerDate.getDate());
		
        var dob=fatherDoB.value;
		var presentage=0;
		var calculatedob=dob.split("/");
        var agedate=calculatedob[0];
		var agemonth= calculatedob[1];
		var ageyear=calculatedob[2];
        		if(agedate!=0 && agemonth!=0 && ageyear!=0 ){
				if(isDate(dob)){
					datedif=currentDate.getDate()-agedate;
					monthdif = currentDate.getMonth()-agemonth;
					yeardif=currentDate.getFullYear()-ageyear;
				   if(datedif < 0) {
				                i = monthdif - 1; 
				        }
				        else {
				        	i = monthdif;
				        }
				        if(i < 0) {
				        	j=i + 12;
				        }
				        else {
				        	j = i;
				        }
				        if(i<0) {
				        	yeardif = yeardif - 1;
				        }

						cal_age = yeardif;

						//alert("calage"+cal_age);


						//alert("Min->"+agemin+"Max->"+agemax);
						if(cal_age < parseInt(parentsMinAge)) 
						{
							alert("Enter father's Age Between "+parentsMinAge+"Yrs and "+parentsMaxAge+"Yrs");
							return false;
						}
						if(cal_age > parseInt(parentsMaxAge)) 
						{
							alert("Enter father's Age Between "+parentsMinAge+"Yrs and "+parentsMaxAge+"Yrs");
							return false;
						}
						if(cal_age >= parseInt(parentsMinAge) && cal_age <= parseInt(parentsMaxAge)){
							
						}
					}
				else{

					alert("Enter a valid father's date of birth in (dd/mm/yyyy) format");
					fatherDoB.value="";
					
				}
			}

	}
}


if(motherInLawDOBcheck==true){
if(motherInLawDOB.value==""){
alert("Please enter mother In-Law's Date Of Birth");
motherInLawDOB.focus();
motherInLawDOB.select();
return false;
}
if(motherInLawDOB.value.length >10){
alert("Please enter Valid mother In-Law's Date of Birth (dd/mm/yyyy)");
motherInLawDOB.focus();
motherInLawDOB.select();
return false;
}
if(isDate(motherInLawDOB.value)==false){
alert("Please enter Valid mother In-Law's Date of Birth (dd/mm/yyyy)");
motherInLawDOB.focus();
motherInLawDOB.select();
return false;
}
if(motherInLawDOB.value!="")
		//alert("called");
	{
        var datedif=0;
		var monthdif=0;
		var yeardif=0;
		var i=0;
		var j=0;
		var cal_age=0;
		var term=0;
		var currentDate=new Date(commonServerDate.getFullYear(), commonServerDate.getMonth(), commonServerDate.getDate());
		
        var dob=motherInLawDOB.value;
		var presentage=0;
		var calculatedob=dob.split("/");
        var agedate=calculatedob[0];
		var agemonth= calculatedob[1];
		var ageyear=calculatedob[2];
        		if(agedate!=0 && agemonth!=0 && ageyear!=0 ){
				if(isDate(dob)){
					datedif=currentDate.getDate()-agedate;
					monthdif = currentDate.getMonth()-agemonth;
					yeardif=currentDate.getFullYear()-ageyear;
				   if(datedif < 0) {
				                i = monthdif - 1; 
				        }
				        else {
				        	i = monthdif;
				        }
				        if(i < 0) {
				        	j=i + 12;
				        }
				        else {
				        	j = i;
				        }
				        if(i<0) {
				        	yeardif = yeardif - 1;
				        }

						cal_age = yeardif;

						//alert("calage"+cal_age);


						//alert("Min->"+agemin+"Max->"+agemax);
						if(cal_age < parseInt(parentsInLawMinAge)) 
						{
							alert("Enter mother In-Law's Age Between "+parentsInLawMinAge+"Yrs and "+parentsInLawMaxAge+"Yrs");
							return false;
						}
						if(cal_age > parseInt(parentsInLawMaxAge)) 
						{
							alert("Enter mother In-Law's Age Between "+parentsInLawMinAge+"Yrs and "+parentsInLawMaxAge+"Yrs");
							return false;
						}
						if(cal_age >= parseInt(parentsInLawMinAge) && cal_age <= parseInt(parentsInLawMaxAge)){
							
						}
					}
				else{

					alert("Enter a valid mother In-Law's date of birth in (dd/mm/yyyy) format");
					motherInLawDOB.value="";
					
				}
			}

	}
}

if(fatherInLawDOBcheck==true){
if(fatherInLawDOB.value==""){
alert("Please enter father In-Law's Date Of Birth");
fatherInLawDOB.focus();
fatherInLawDOB.select();
return false;
}
if(fatherInLawDOB.value.length >10){
alert("Please enter Valid father In-Law's Date of Birth (dd/mm/yyyy)");
fatherInLawDOB.focus();
fatherInLawDOB.select();
return false;
}
if(isDate(fatherInLawDOB.value)==false){
alert("Please enter Valid father In-Law's Date of Birth (dd/mm/yyyy)");
fatherInLawDOB.focus();
fatherInLawDOB.select();
return false;
}
if(fatherInLawDOB.value!="")
		//alert("called");
	{
        var datedif=0;
		var monthdif=0;
		var yeardif=0;
		var i=0;
		var j=0;
		var cal_age=0;
		var term=0;
		var currentDate=new Date(commonServerDate.getFullYear(), commonServerDate.getMonth(), commonServerDate.getDate());
		
        var dob=fatherInLawDOB.value;
		var presentage=0;
		var calculatedob=dob.split("/");
        var agedate=calculatedob[0];
		var agemonth= calculatedob[1];
		var ageyear=calculatedob[2];
        		if(agedate!=0 && agemonth!=0 && ageyear!=0 ){
				if(isDate(dob)){
					datedif=currentDate.getDate()-agedate;
					monthdif = currentDate.getMonth()-agemonth;
					yeardif=currentDate.getFullYear()-ageyear;
				   if(datedif < 0) {
				                i = monthdif - 1; 
				        }
				        else {
				        	i = monthdif;
				        }
				        if(i < 0) {
				        	j=i + 12;
				        }
				        else {
				        	j = i;
				        }
				        if(i<0) {
				        	yeardif = yeardif - 1;
				        }

						cal_age = yeardif;

						//alert("calage"+cal_age);


						//alert("Min->"+agemin+"Max->"+agemax);
						if(cal_age < parseInt(parentsInLawMinAge)) 
						{
							alert("Enter father In-Law's Age Between "+parentsInLawMinAge+"Yrs and "+parentsInLawMaxAge+"Yrs");
							return false;
						}
						if(cal_age > parseInt(parentsInLawMaxAge)) 
						{
							alert("Enter father In-Law's Age Between "+parentsInLawMinAge+"Yrs and "+parentsInLawMaxAge+"Yrs");
							return false;
						}
						if(cal_age >= parseInt(parentsInLawMinAge) && cal_age <= parseInt(parentsInLawMaxAge)){
							
						}
					}
				else{

					alert("Enter a valid father In-Law's date of birth in (dd/mm/yyyy) format");
					fatherInLawDOB.value="";
					
				}
			}

	}
}
if(CompanyId=="25" || CompanyId=="11"){
if(motherDOB.value=="" && fatherDoB.value=="" ){
	alert("Please enter any one of parents");
return false;
}			
}else if(CompanyId =="16"){
if((motherDOB.value!="" && fatherDoB.value !="" && motherInLawDOB.value!="" && fatherInLawDOB.value!="")
    ||(motherDOB.value =="" && fatherDoB.value !="" && motherInLawDOB.value!="" && fatherInLawDOB.value!="")
	||(motherDOB.value !="" && fatherDoB.value =="" && motherInLawDOB.value!="" && fatherInLawDOB.value!="")
	||(motherDOB.value !="" && fatherDoB.value !="" && motherInLawDOB.value=="" && fatherInLawDOB.value!="")
	||(motherDOB.value !="" && fatherDoB.value !="" && motherInLawDOB.value!="" && fatherInLawDOB.value=="")
	||(motherDOB.value !="" && fatherDoB.value =="" && motherInLawDOB.value!="" && fatherInLawDOB.value=="")
	||(motherDOB.value =="" && fatherDoB.value !="" && motherInLawDOB.value =="" && fatherInLawDOB.value!="")){
	alert("Please enter any one of parents or parents In-Law's Date of Birth");
return false;
}
}else if(CompanyId !="16"){

	alert("Please enter any one of parents or parents In-Law's Date of Birth");
	return false;

}
/*
if(CompanyId=="16"){
	//alert("called asd sdfsdf");
if(!(((fatherDoB.value!="" || motherDOB.value!="") && (motherInLawDOB.value==""&& fatherInLawDOB.value==""))||
((fatherDoB.value=="" && motherDOB.value=="") && (motherInLawDOB.value!="" || fatherInLawDOB.value!="")))){
alert("This Plan is available for parents or parents In-Law, but not Both");
return false;
}
}
*/

if(addtionalPersonscheck==true){
if(addtionalPersons.value=="selected"){
	alert("Please select additional persons");
	addtionalPersons.focus();
	return false;
}
}


var FirstRelation  =document.getElementById("FirstRelation");
var FirstDOB       =document.getElementById("FirstDOB");
var secondRelation =document.getElementById("secondRelation");
var secondDOB      =document.getElementById("secondDOB");
var thirdRelation =document.getElementById("thirdRelation");
var thirdDOB      =document.getElementById("thirdDOB");
var fourthRelation =document.getElementById("fourthRelation");
var fourthDOB      =document.getElementById("fourthDOB");
var fifthRelation =document.getElementById("fifthRelation");
var fifthDOB      =document.getElementById("fifthDOB");
var sixthRelation =document.getElementById("sixthRelation");
var sixthDOB      =document.getElementById("sixthDOB");

var    x=parseInt(document.getElementById("addtionalPersons").value);
	
switch (x) {

case 6:
if(sixthRelation.value=="selected"){
alert("Please select sixth additional person relation.");
sixthRelation.focus();
return false;
}
if(sixthDOB.value==""){
alert("Please enter sixth additional person Date Of Birth");
sixthDOB.focus();
sixthDOB.select();
return false;
}
if(sixthDOB.value.length >10){
alert("Please enter Valid sixth additional person Date of Birth (dd/mm/yyyy)");
sixthDOB.focus();
sixthDOB.select();
return false;
}
if(isDate(sixthDOB.value)==false){
alert("Please enter Valid sixth additional person Date of Birth (dd/mm/yyyy)");s
sixthDOB.focus();
sixthDOB.select();
return false;
}
	if(sixthDOB.value!="")
		//alert("called");
	{
        var datedif=0;
		var monthdif=0;
		var yeardif=0;
		var i=0;
		var j=0;
		var cal_age=0;
		var term=0;
		var currentDate=new Date(commonServerDate.getFullYear(), commonServerDate.getMonth(), commonServerDate.getDate());
		
        var dob=sixthDOB.value;
		var presentage=0;
		var calculatedob=dob.split("/");
        var agedate=calculatedob[0];
		var agemonth= calculatedob[1];
		var ageyear=calculatedob[2];
        		if(agedate!=0 && agemonth!=0 && ageyear!=0 ){
				if(isDate(dob)){
					datedif=currentDate.getDate()-agedate;
					monthdif = currentDate.getMonth()-agemonth;
					yeardif=currentDate.getFullYear()-ageyear;
				   if(datedif < 0) {
				                i = monthdif - 1; 
				        }
				        else {
				        	i = monthdif;
				        }
				        if(i < 0) {
				        	j=i + 12;
				        }
				        else {
				        	j = i;
				        }
				        if(i<0) {
				        	yeardif = yeardif - 1;
				        }

						cal_age = yeardif;

						//alert("calage"+cal_age);


						//alert("Min->"+agemin+"Max->"+agemax);
						if(cal_age < parseInt(otherMinAge)) 
						{
							alert("Enter sixth additional person Age Between "+otherMinAge+"Yrs and "+otherMaxAge+"Yrs");
							return false;
						}
						if(cal_age > parseInt(otherMaxAge)) 
						{
							alert("Enter sixth additional person Age Between "+otherMinAge+"Yrs and "+otherMaxAge+"Yrs");
							return false;
						}
						if(cal_age >= parseInt(otherMinAge) && cal_age <= parseInt(otherMaxAge)){
							
						}
					}
				else{

					alert("Enter a valid sixth additional person date of birth in (dd/mm/yyyy) format");
					sixthDOB.value="";
					
				}
			}

	}

case 5:
if(fifthRelation.value=="selected"){
alert("Please select fifth additional person relation.");
fifthRelation.focus();
return false;
}
if(fifthDOB.value==""){
alert("Please enter fifth additional person Date Of Birth");
fifthDOB.focus();
fifthDOB.select();
return false;
}
if(fifthDOB.value.length >10){
alert("Please enter Valid fifth additional person Date of Birth (dd/mm/yyyy)");
fifthDOB.focus();
fifthDOB.select();
return false;
}
if(isDate(fifthDOB.value)==false){
alert("Please enter Valid fifth additional person Date of Birth (dd/mm/yyyy)");s
fifthDOB.focus();
fifthDOB.select();
return false;
}
	if(fifthDOB.value!="")
		//alert("called");
	{
        var datedif=0;
		var monthdif=0;
		var yeardif=0;
		var i=0;
		var j=0;
		var cal_age=0;
		var term=0;
		var currentDate=new Date(commonServerDate.getFullYear(), commonServerDate.getMonth(), commonServerDate.getDate());
		
        var dob=fifthDOB.value;
		var presentage=0;
		var calculatedob=dob.split("/");
        var agedate=calculatedob[0];
		var agemonth= calculatedob[1];
		var ageyear=calculatedob[2];
        		if(agedate!=0 && agemonth!=0 && ageyear!=0 ){
				if(isDate(dob)){
					datedif=currentDate.getDate()-agedate;
					monthdif = currentDate.getMonth()-agemonth;
					yeardif=currentDate.getFullYear()-ageyear;
				   if(datedif < 0) {
				                i = monthdif - 1; 
				        }
				        else {
				        	i = monthdif;
				        }
				        if(i < 0) {
				        	j=i + 12;
				        }
				        else {
				        	j = i;
				        }
				        if(i<0) {
				        	yeardif = yeardif - 1;
				        }

						cal_age = yeardif;

						//alert("calage"+cal_age);


						//alert("Min->"+agemin+"Max->"+agemax);
						if(cal_age < parseInt(otherMinAge)) 
						{
							alert("Enter fifth additional person Age Between "+otherMinAge+"Yrs and "+otherMaxAge+"Yrs");
							return false;
						}
						if(cal_age > parseInt(otherMaxAge)) 
						{
							alert("Enter fifth additional person Age Between "+otherMinAge+"Yrs and "+otherMaxAge+"Yrs");
							return false;
						}
						if(cal_age >= parseInt(otherMinAge) && cal_age <= parseInt(otherMaxAge)){
							
						}
					}
				else{

					alert("Enter a valid fifth additional person date of birth in (dd/mm/yyyy) format");
					fifthDOB.value="";
					
				}
			}

	}
case 4:
if(fourthRelation.value=="selected"){
alert("Please select fourth additional person relation.");
fourthRelation.focus();
return false;
}
if(fourthDOB.value==""){
alert("Please enter fourth additional person Date Of Birth");
fourthDOB.focus();
fourthDOB.select();
return false;
}
if(fourthDOB.value.length >10){
alert("Please enter Valid fourth additional person Date of Birth (dd/mm/yyyy)");
fourthDOB.focus();
fourthDOB.select();
return false;
}
if(isDate(fourthDOB.value)==false){
alert("Please enter Valid fourth additional person Date of Birth (dd/mm/yyyy)");s
fourthDOB.focus();
fourthDOB.select();
return false;
}
	if(fourthDOB.value!="")
		//alert("called");
	{
        var datedif=0;
		var monthdif=0;
		var yeardif=0;
		var i=0;
		var j=0;
		var cal_age=0;
		var term=0;
		var currentDate=new Date(commonServerDate.getFullYear(), commonServerDate.getMonth(), commonServerDate.getDate());
		
        var dob=fourthDOB.value;
		var presentage=0;
		var calculatedob=dob.split("/");
        var agedate=calculatedob[0];
		var agemonth= calculatedob[1];
		var ageyear=calculatedob[2];
        		if(agedate!=0 && agemonth!=0 && ageyear!=0 ){
				if(isDate(dob)){
					datedif=currentDate.getDate()-agedate;
					monthdif = currentDate.getMonth()-agemonth;
					yeardif=currentDate.getFullYear()-ageyear;
				   if(datedif < 0) {
				                i = monthdif - 1; 
				        }
				        else {
				        	i = monthdif;
				        }
				        if(i < 0) {
				        	j=i + 12;
				        }
				        else {
				        	j = i;
				        }
				        if(i<0) {
				        	yeardif = yeardif - 1;
				        }

						cal_age = yeardif;

						//alert("calage"+cal_age);


						//alert("Min->"+agemin+"Max->"+agemax);
						if(cal_age < parseInt(otherMinAge)) 
						{
							alert("Enter fourth additional person Age Between "+otherMinAge+"Yrs and "+otherMaxAge+"Yrs");
							return false;
						}
						if(cal_age > parseInt(otherMaxAge)) 
						{
							alert("Enter fourth additional person Age Between "+otherMinAge+"Yrs and "+otherMaxAge+"Yrs");
							return false;
						}
						if(cal_age >= parseInt(otherMinAge) && cal_age <= parseInt(otherMaxAge)){
							
						}
					}
				else{

					alert("Enter a valid fourth additional person date of birth in (dd/mm/yyyy) format");
					fourthDOB.value="";
					
				}
			}

	}

case 3:
if(thirdRelation.value=="selected"){
alert("Please select third additional person relation.");
thirdRelation.focus();
return false;
}
if(thirdDOB.value==""){
alert("Please enter third additional person  Date Of Birth");
thirdDOB.focus();
thirdDOB.select();
return false;
}
if(thirdDOB.value.length >10){
alert("Please enter Valid third additional person Date of Birth (dd/mm/yyyy)");
thirdDOB.focus();
thirdDOB.select();
return false;
}
if(isDate(thirdDOB.value)==false){
alert("Please enter Valid third additional person Date of Birth (dd/mm/yyyy)");s
thirdDOB.focus();
thirdDOB.select();
return false;
}
	if(thirdDOB.value!="")
		//alert("called");
	{
        var datedif=0;
		var monthdif=0;
		var yeardif=0;
		var i=0;
		var j=0;
		var cal_age=0;
		var term=0;
		var currentDate=new Date(commonServerDate.getFullYear(), commonServerDate.getMonth(), commonServerDate.getDate());
		
        var dob=thirdDOB.value;
		var presentage=0;
		var calculatedob=dob.split("/");
        var agedate=calculatedob[0];
		var agemonth= calculatedob[1];
		var ageyear=calculatedob[2];
        		if(agedate!=0 && agemonth!=0 && ageyear!=0 ){
				if(isDate(dob)){
					datedif=currentDate.getDate()-agedate;
					monthdif = currentDate.getMonth()-agemonth;
					yeardif=currentDate.getFullYear()-ageyear;
				   if(datedif < 0) {
				                i = monthdif - 1; 
				        }
				        else {
				        	i = monthdif;
				        }
				        if(i < 0) {
				        	j=i + 12;
				        }
				        else {
				        	j = i;
				        }
				        if(i<0) {
				        	yeardif = yeardif - 1;
				        }

						cal_age = yeardif;

						//alert("calage"+cal_age);


						//alert("Min->"+agemin+"Max->"+agemax);
						if(cal_age < parseInt(otherMinAge)) 
						{
							alert("Enter third additional person Age Between "+otherMinAge+"Yrs and "+otherMaxAge+"Yrs");
							return false;
						}
						if(cal_age > parseInt(otherMaxAge)) 
						{
							alert("Enter third additional person Age Between "+otherMinAge+"Yrs and "+otherMaxAge+"Yrs");
							return false;
						}
						if(cal_age >= parseInt(otherMinAge) && cal_age <= parseInt(otherMaxAge)){
							
						}
					}
				else{

					alert("Enter a valid third additional person date of birth in (dd/mm/yyyy) format");
					thirdDOB.value="";
					
				}
			}

	}


case 2:
if(secondRelation.value=="selected"){
 alert("Please select second additional person relation.");
secondRelation.focus();
return false;
}
if(secondDOB.value==""){
alert("Please enter second additional person Date Of Birth");
secondDOB.focus();
secondDOB.select();
return false;
}
if(secondDOB.value.length >10){
alert("Please enter Valid second additional person Date of Birth (dd/mm/yyyy)");
secondDOB.focus();
secondDOB.select();
return false;
}
if(isDate(secondDOB.value)==false){
alert("Please enter Valid second additional person Date of Birth (dd/mm/yyyy)");
secondDOB.focus();
secondDOB.select();
return false;
}
	if(secondDOB.value!="")
		//alert("called");
	{
        var datedif=0;
		var monthdif=0;
		var yeardif=0;
		var i=0;
		var j=0;
		var cal_age=0;
		var term=0;
		var currentDate=new Date(commonServerDate.getFullYear(), commonServerDate.getMonth(), commonServerDate.getDate());
		
        var dob=secondDOB.value;
		var presentage=0;
		var calculatedob=dob.split("/");
        var agedate=calculatedob[0];
		var agemonth= calculatedob[1];
		var ageyear=calculatedob[2];
        		if(agedate!=0 && agemonth!=0 && ageyear!=0 ){
				if(isDate(dob)){
					datedif=currentDate.getDate()-agedate;
					monthdif = currentDate.getMonth()-agemonth;
					yeardif=currentDate.getFullYear()-ageyear;
				   if(datedif < 0) {
				                i = monthdif - 1; 
				        }
				        else {
				        	i = monthdif;
				        }
				        if(i < 0) {
				        	j=i + 12;
				        }
				        else {
				        	j = i;
				        }
				        if(i<0) {
				        	yeardif = yeardif - 1;
				        }

						cal_age = yeardif;

						//alert("calage"+cal_age);


						//alert("Min->"+agemin+"Max->"+agemax);
						if(cal_age < parseInt(otherMinAge)) 
						{
							alert("Enter second additional person Age Between "+otherMinAge+"Yrs and "+otherMaxAge+"Yrs");
							return false;
						}
						if(cal_age > parseInt(otherMaxAge)) 
						{
							alert("Enter second additional person Age Between "+otherMinAge+"Yrs and "+otherMaxAge+"Yrs");
							return false;
						}
						if(cal_age >= parseInt(otherMinAge) && cal_age <= parseInt(otherMaxAge)){
							
						}
					}
				else{

					alert("Enter a valid second additional person date of birth in (dd/mm/yyyy) format");
					secondDOB.value="";
					
				}
			}

	}


case 1:
if(FirstRelation.value=="selected"){
 alert("Please select first additional person relation.");
FirstRelation.focus();
return false;
}
if(FirstDOB.value==""){
alert("Please enter first additional person Date Of Birth");
FirstDOB.focus();
FirstDOB.select();
return false;
}
if(FirstDOB.value.length >10){
alert("Please enter Valid first additional person Date of Birth (dd/mm/yyyy)");
FirstDOB.focus();
FirstDOB.select();
return false;
}
if(isDate(FirstDOB.value)==false){
alert("Please enter Valid first additional person Date of Birth (dd/mm/yyyy)");
FirstDOB.focus();
FirstDOB.select();
return false;
}
	if(FirstDOB.value!="")
		//alert("called");
	{
        var datedif=0;
		var monthdif=0;
		var yeardif=0;
		var i=0;
		var j=0;
		var cal_age=0;
		var term=0;
		var currentDate=new Date(commonServerDate.getFullYear(), commonServerDate.getMonth(), commonServerDate.getDate());
		
        var dob=FirstDOB.value;
		var presentage=0;
		var calculatedob=dob.split("/");
        var agedate=calculatedob[0];
		var agemonth= calculatedob[1];
		var ageyear=calculatedob[2];
        		if(agedate!=0 && agemonth!=0 && ageyear!=0 ){
				if(isDate(dob)){
					datedif=currentDate.getDate()-agedate;
					monthdif = currentDate.getMonth()-agemonth;
					yeardif=currentDate.getFullYear()-ageyear;
				   if(datedif < 0) {
				                i = monthdif - 1; 
				        }
				        else {
				        	i = monthdif;
				        }
				        if(i < 0) {
				        	j=i + 12;
				        }
				        else {
				        	j = i;
				        }
				        if(i<0) {
				        	yeardif = yeardif - 1;
				        }

						cal_age = yeardif;

						//alert("calage"+cal_age);


						//alert("Min->"+agemin+"Max->"+agemax);
						if(cal_age < parseInt(otherMinAge)) 
						{
							alert("Enter first additional person Age Between "+otherMinAge+"Yrs and "+otherMaxAge+"Yrs");
							return false;
						}
						if(cal_age > parseInt(otherMaxAge)) 
						{
							alert("Enter first additional person Age Between "+otherMinAge+"Yrs and "+otherMaxAge+"Yrs");
							return false;
						}
						if(cal_age >= parseInt(otherMinAge) && cal_age <= parseInt(otherMaxAge)){
							
						}
					}
				else{

					alert("Enter a valid first additional person date of birth in (dd/mm/yyyy) format");
					FirstDOB.value="";
					
				}
			}

	}

break;

}

var maxBupaIndividualSI   =document.getElementById("maxBupaIndividualSI");
var maxBupaFloaterSI      =document.getElementById("maxBupaFloaterSI");


//if(maxBupaIndividualSI.value=="selected"){
//	alert("Please select Individual sum Insured for max Bupa Plans");
//	maxBupaIndividualSI.focus();
//	return false;
//}
if(CompanyId=="50"){
if (maxBupaFloaterSI.value=="selected")
{
	alert("Please select Floater Sum Insured for max Bupa Plans");
	maxBupaFloaterSI.focus();
	return false;
}
}

return true;
}


//list of functions
function isEmpty(s){ 
	return ((s == null) || (s.length == 0))
}

var reInteger = /^\d+$/
function isInteger(s){
	var i;
    if (isEmpty(s)) 
       if (isInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isInteger.arguments[1] == true);

    return reInteger.test(s)
}

function isLessThenCurrentDate(dateStr){
	var mydate=new Date(commonServerDate.getFullYear(), commonServerDate.getMonth(), commonServerDate.getDate());
	var a1=new Array();
	a1=dateStr.split("/");
	var userdate=new Date(a1[2],a1[1]-1,a1[0]);
	var one_day=1000*60*60*24
	var noOfDays=Math.ceil((mydate.getTime()-userdate.getTime())/(one_day));
	if(noOfDays<=6574){
		return false;
	}
	return true;
}

function isLessThenCurrentDate(dateStr){
	var mydate=new Date(commonServerDate.getFullYear(), commonServerDate.getMonth(), commonServerDate.getDate());
	var a1=new Array();
	a1=dateStr.split("/");
	var userdate=new Date(a1[2],a1[1]-1,a1[0]);
	var one_day=1000*60*60*24
	var noOfDays=Math.ceil((mydate.getTime()-userdate.getTime())/(one_day));
	if(noOfDays<=6574){
		return false;
	}
	return true;
}
function isLessThenCurrentDateforPrimeryOrental(dateStr){
	var mydate=new Date(commonServerDate.getFullYear(), commonServerDate.getMonth(), commonServerDate.getDate());
	var a1=new Array();
	a1=dateStr.split("/");
	var userdate=new Date(a1[2],a1[1]-1,a1[0]);
	var one_day=1000*60*60*24
	var noOfDays=Math.ceil((mydate.getTime()-userdate.getTime())/(one_day));
	if(noOfDays<=7670){
		return false;
	}
	return true;
}
function isLessThenCurrentDateForExtFamily(dateStr){
	var mydate=new Date(commonServerDate.getFullYear(), commonServerDate.getMonth(), commonServerDate.getDate());
	var a1=new Array();
	a1=dateStr.split("/");
	var userdate=new Date(a1[2],a1[1]-1,a1[0]);
	var one_day=1000*60*60*24
	var noOfDays=Math.ceil((mydate.getTime()-userdate.getTime())/(one_day));
	if(noOfDays<=90){
		return false;
	}
	return true;
}

function isLessThenCurrentDateSC(dateStr){
	var mydate=new Date(commonServerDate.getFullYear(), commonServerDate.getMonth(), commonServerDate.getDate());
	var a1=new Array();
	a1=dateStr.split("/");
	var userdate=new Date(a1[2],a1[1]-1,a1[0]);
	var one_day=1000*60*60*24
	var noOfDays=Math.ceil((mydate.getTime()-userdate.getTime())/(one_day));
	if(noOfDays<=21915){
		return false;
	}
	return true;
}
function isGraterThen18Years(dateStr){
	var mydate=new Date(commonServerDate.getFullYear(), commonServerDate.getMonth(), commonServerDate.getDate());
	var a1=new Array();
	a1=dateStr.split("/");
	var userdate=new Date(a1[2],a1[1]-1,a1[0]);
	var one_day=1000*60*60*24
	var noOfDays=Math.ceil((mydate.getTime()-userdate.getTime())/(one_day));
	if(noOfDays>=9131){
		return false;
	}
	return true;
}

var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isIntegers(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 strDay=dtStr.substring(0,pos1)
	var strMonth=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("Please enter valid Date(dd/mm/yyyy)")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		//alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		//alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		//alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isIntegers(stripCharsInBag(dtStr, dtCh))==false){
		//alert("Please enter a valid date")
		return false
	}
   return true
}

//Trim function 
String.prototype.trim = function() {
// Strip leading and trailing white-space
return this.replace(/^\s*|\s*$/g, "");
}

