//Product Validation
function getProducts()
{
	document.frmView.callType.value = "getQuote";
	document.frmView.submit();
}


//For All Products
var elBackDate ="BackDateforIllustration";
var elIsapplicantastaffmember="Isapplicantastaffmember";
var elPleaseentertheemployeecodenumber="Pleaseentertheemployeecodenumber";

function functionalityChange()
{

	var selectedElement = document.frmView.productId;
	var selectedName =	selectedElement.options[selectedElement.selectedIndex].text;
	
	//Validations for Homesurance Plan(Single Premium)
	if(selectedName=="Homesurance Plan (Single Premium)"){
		
		disableTopupWithdrawal();
		disableValidationParameter();

		callHomesuranceSinglePremiumValidation();	
	}
	
	//Validations for Homesurance Plan(Regular Premium)
	if(selectedName=="Homesurance Plan (Regular Premium)"){

		disableTopupWithdrawal();
		disableValidationParameter();
		
		document.getElementById("validationHomesurance").style.visiblity="visible"
		document.getElementById("validationHomesurance").style.display = "inline";
		
		callHomesuranceRegularValidation();
	}
	
	if(selectedName=="Homesurance Protection Plan"){

		disableTopupWithdrawal();
		disableValidationParameter();

		document.getElementById("validationHPP").style.visiblity="visible"
		document.getElementById("validationHPP").style.display = "inline";	
		
		callHomesuranceProtectionValidation();

	}
	
	if(selectedName=="Bondsurance Plan"){

		disableTopupWithdrawal();
		disableValidationParameter();
		
		callBondsurancePlanValidation();
	}
	
	if(selectedName=="Retiresurance Pension Plan"){
		document.getElementById(elRPPAttainedageagelastbirthday).readOnly=true;
		document.getElementById(elRPPAnnualPremium).readOnly=true;
		document.getElementById(elRPPVestingage).readOnly=true;

		disableValidationParameter();
		callRetiresurancePensionValidation();
	}

	//Validations for Wealthsurance foundation plan
	if(selectedName=="Wealthsurance Foundation Plan"){

		document.getElementById("headerExpandingBoxPremiumReductionOption").style.display = "none";
		document.getElementById("divExpandingBoxPremiumReductionOption").style.display = "none";

		disableValidationParameter();
		
		document.getElementById("validationWealthsurance").style.visiblity="visible"
		document.getElementById("validationWealthsurance").style.display = "inline";
			
		callWealthsuranceFoundationValidation();
	}
	
	if(selectedName=="Termsurance Protection Plan (Individual)"){

		disableTopupWithdrawal();
		disableValidationParameter();

		document.getElementById("validationTermsurance").style.visiblity="visible"
		document.getElementById("validationTermsurance").style.display = "inline";

		callTermsuranceValidation();
	}
	
	if(selectedName=="Incomesurance Endowment And Money Back Plan"){
	
		disableTopupWithdrawal();
		disableValidationParameter();

		document.getElementById("validationIncomesurance").style.visiblity="visible"
		document.getElementById("validationIncomesurance").style.display = "inline";
	
		callIncomeinsuranceValidation();
	}

	if(selectedName=="Wealthsurance (IRDA cap)"){
	
		document.getElementById("headerExpandingBoxPremiumReductionOption").style.display = "none";
		document.getElementById("divExpandingBoxPremiumReductionOption").style.display = "none";

		disableValidationParameter();
		
		document.getElementById("validationWealthsurance").style.visiblity="visible"
		document.getElementById("validationWealthsurance").style.display = "inline";
	
		callWealthsuranceIRDAValidation();
	}
	
	if(selectedName=="Retiresurance (IRDA Cap)"){
		disableValidationParameter();
		callRetiresuranceIRDAValidation();
	}


	if(selectedName=="Termsurance Grameen Bachat Yojana"){
		disableTopupWithdrawal();
		disableValidationParameter();
		
		document.getElementById("validationTermsuranceGBY").style.visiblity="visible"
		document.getElementById("validationTermsuranceGBY").style.display = "inline";
	
		callTermsuranceGareemBachatValidation();
	}

	if(selectedName=="Incomesurance Immediate Annuity"){
		disableTopupWithdrawal();
		disableValidationParameter();
		
		document.getElementById("validationIncomesuranceAnnuity").style.visiblity="visible"
		document.getElementById("validationIncomesuranceAnnuity").style.display = "inline";
		
		callIncomesuranceImmediateAnnuityValidation();
	}

	if(selectedName=="Retiresurance Mark III"){
		disableValidationParameter();
		callRetiresuranceIIIValidation();
	}	
	if(selectedName=="Wealthsurance Milestone Plan"){
		
		document.getElementById("headerExpandingBoxPremiumReductionOption").style.display = "none";
		document.getElementById("divExpandingBoxPremiumReductionOption").style.display = "none";

		disableValidationParameter();
		
		document.getElementById("validationWealthsurance").style.visiblity="visible"
		document.getElementById("validationWealthsurance").style.display = "inline";
	
		callWealthsuranceIIIValidation();
	}
	if(selectedName=="Loansurance"){
		disableTopupWithdrawal();
		disableValidationParameter();
		
		document.getElementById("validationLoansurance").style.visiblity="visible"
		document.getElementById("validationLoansurance").style.display = "inline";
		
		callLoansuranceValidation();
	}
	if(selectedName=="Bondsurance Advantage Insurance Plan"){
		disableTopupWithdrawal();
		disableValidationParameter();
		callBondsuranceAdvPlanValidation();
	}
	if(selectedName=="Group Termsurance ROP"){
		callGroupTermsuranceROPValidation()
		disableTopupWithdrawal();
		disableValidationParameter();
	}	
	if(selectedName=="Wealthsurance Premier Plan"){
		document.getElementById("headerExpandingBoxPremiumReductionOption").style.display = "none";
		document.getElementById("divExpandingBoxPremiumReductionOption").style.display = "none";

		disableValidationParameter();
		
		document.getElementById("validationWealthsurancePremier").style.visiblity="visible"
		document.getElementById("validationWealthsurancePremier").style.display = "inline";

		callWealthsurancePremierValidation();
	}
	if(selectedName=="Retiresurance Guaranteed Pension Plan"){
		disableTopupWithdrawal();
		disableValidationParameter();
		callRetiresuranceGuaranteedValidation();
	}	
	if(selectedName=="Termsurance Premier Plan"){
		disableTopupWithdrawal();
		
		disableValidationParameter();
		
		document.getElementById("validationTermsurancePremier").style.visiblity="visible"
		document.getElementById("validationTermsurancePremier").style.display = "inline";
		termsurancePremierValidation();
	}	
	if(selectedName=="Termsurance Senior Plan"){
		
		disableValidationParameter();
		document.getElementById("validationTermsuranceSeniors").style.visiblity="visible"
		document.getElementById("validationTermsuranceSeniors").style.display = "inline";
		disableTopupWithdrawal();
		
		callTermsuranceSeniorsPlanValidation();
	}
	if(selectedName=="Wealthsurance Dreamstart Plan"){
		disableValidationParameter();
		
		document.getElementById("headerExpandingBoxPremiumReductionOption").style.display = "none";
		document.getElementById("divExpandingBoxPremiumReductionOption").style.display = "none";
		
		document.getElementById("validationWealthsuranceDreamstart").style.visiblity="visible"
		document.getElementById("validationWealthsuranceDreamstart").style.display = "inline";
		
		wealthDreamstartValidation();		
	}
	
	if(selectedName=="Wealthsurance Dreambuilder Plan"){
		
		document.getElementById("headerExpandingBoxPremiumReductionOption").style.display = "none";
		document.getElementById("divExpandingBoxPremiumReductionOption").style.display = "none";
		
		disableValidationParameter();
		
		document.getElementById("validationWealthsuranceDreambuiler").style.visiblity="visible"
		document.getElementById("validationWealthsuranceDreambuiler").style.display = "inline";
	
		callWealthDreambuilderValidation();
	}
	//Modified By DURGAVATHI CH ON Date:25-02-2011
	if(selectedName=="Retiresurance Milestone Pension Plan"){
		disableValidationParameter();
		callRetiresuranceMilestoneValidation();
		document.getElementById("validateRetiresuranceMilestonePlan").style.visiblity="visible"
		document.getElementById("validateRetiresuranceMilestonePlan").style.display = "inline";
	}

	
	if(selectedName=="Wealthsurance Maxigain Plan"){

		document.getElementById("headerExpandingBoxPremiumReductionOption").style.display = "none";
		document.getElementById("divExpandingBoxPremiumReductionOption").style.display = "none";
		
		disableValidationParameter();
		callWealthMaxiGainValidation();
		document.getElementById("validateWealthsuranceMaxiGainPlan").style.visiblity="visible"
		document.getElementById("validateWealthsuranceMaxiGainPlan").style.display = "inline";
	}
	
	if(selectedName=="Childsurance Dreambuilder Insurance Plan")
	{
		disableValidationParameter();
		document.getElementById("validateChildsuranceDreambuiler").style.visiblity="visible"
		document.getElementById("validateChildsuranceDreambuiler").style.display = "inline";
		document.getElementById("headerExpandingBoxPremiumReductionOption").style.display = "none";
		document.getElementById("divExpandingBoxPremiumReductionOption").style.display = "none";
		callChildDreambuilderValidation();
		
	}		
	
	//MODIFIED BY DURGAVATHI ON 04-08-2011
	
	if(selectedName=="Lifesurance Savings Insurance Plan"){
		disableTopupWithdrawal();		
		disableValidationParameter();		
		document.getElementById("validateLifesuranceSavings").style.visiblity="visible"
		document.getElementById("validateLifesuranceSavings").style.display = "inline";
		lifesuranceSavingsValidation();
	}
} // functionalityChange End 


function disableValidationParameter(){
		document.getElementById("validationWealthsurance").style.visiblity="hidden"
		document.getElementById("validationWealthsurance").style.display = "none";
		document.getElementById("validationHomesurance").style.visiblity="hidden"
		document.getElementById("validationHomesurance").style.display = "none";
		document.getElementById("validationHPP").style.visiblity="hidden";
		document.getElementById("validationHPP").style.display = "none";
		document.getElementById("validationTermsurance").style.visiblity="hidden"
		document.getElementById("validationTermsurance").style.display = "none";
		document.getElementById("validationIncomesurance").style.visiblity="hidden"
		document.getElementById("validationIncomesurance").style.display = "none";
		document.getElementById("validationTermsuranceGBY").style.visiblity="hidden"
		document.getElementById("validationTermsuranceGBY").style.display = "none";
		document.getElementById("validationIncomesuranceAnnuity").style.visiblity="hidden"
		document.getElementById("validationIncomesuranceAnnuity").style.display = "none";
		document.getElementById("validationLoansurance").style.visiblity="hidden"
		document.getElementById("validationLoansurance").style.display = "none";
		document.getElementById("validationWealthsurancePremier").style.visiblity="hidden"
		document.getElementById("validationWealthsurancePremier").style.display = "none";
		document.getElementById("validationTermsurancePremier").style.visiblity="hidden"
		document.getElementById("validationTermsurancePremier").style.display = "none";
		document.getElementById("validationTermsuranceSeniors").style.visiblity="hidden"
		document.getElementById("validationTermsuranceSeniors").style.display = "none";
		document.getElementById("validationWealthsuranceDreamstart").style.visiblity="hidden"
		document.getElementById("validationWealthsuranceDreamstart").style.display = "none";
		document.getElementById("validationWealthsuranceDreambuiler").style.visiblity="hidden";
		document.getElementById("validationWealthsuranceDreambuiler").style.display = "none";
		document.getElementById("validateRetiresuranceMilestonePlan").style.visiblity="hidden";
		document.getElementById("validateRetiresuranceMilestonePlan").style.display = "none";
		document.getElementById("validateWealthsuranceMaxiGainPlan").style.visiblity="hidden";
		document.getElementById("validateWealthsuranceMaxiGainPlan").style.display = "none";
		document.getElementById("validateChildsuranceDreambuiler").style.visiblity="hidden";
		document.getElementById("validateChildsuranceDreambuiler").style.display = "none";
		document.getElementById("validateLifesuranceSavings").style.visiblity="hidden";
		document.getElementById("validateLifesuranceSavings").style.display = "none";
		
}

function disableTopupWithdrawal(){
	document.getElementById("headerExpandingBoxPremiumReductionOption").style.display = "none";
	document.getElementById("divExpandingBoxPremiumReductionOption").style.display = "none";
	document.getElementById("headerExpandingBoxTopupDetails").style.display = "none";
	document.getElementById("divExpandingBoxTopupDetails").style.display = "none";
	document.getElementById("headerExpandingBoxWithdrawalDetails").style.display = "none";
	document.getElementById("divExpandingBoxWithdrawalDetailsTable").style.display = "none";
}


function checkIsStaff(elIsStaff,elEmployeeCode){
	
	 if(document.getElementById(elIsStaff).value=="Yes"){
		 document.getElementById("headerExpandingBoxStaffDetails").style.visibility="visible";
		 document.getElementById("divExpandingBoxStaffDetails").style.visibility = "visible";
		 document.getElementById("headerExpandingBoxStaffDetails").style.display = "";
		 document.getElementById("divExpandingBoxStaffDetails").style.display = "";
	 }
	 else{
		 	document.getElementById("headerExpandingBoxStaffDetails").style.display = "none";
	    	document.getElementById("headerExpandingBoxStaffDetails").style.visibility="hidden";
	  	    document.getElementById("divExpandingBoxStaffDetails").style.display = "none";
	  	    document.getElementById("divExpandingBoxStaffDetails").style.visibility="hidden";
	  	    document.getElementById(elEmployeeCode).value="";
	 }
}

function checkEmployeeCode(elIsStaff,elEmployeeCode){
	if(document.getElementById(elIsStaff).value=="Yes"){
      	   if(document.getElementById(elEmployeeCode).value==""){
      			alert("Enter employee code");
  	 			document.getElementById(elEmployeeCode).focus();
  	 			return true;
      	   }
      		   alert("This is a Staff Proposal and no commission is payable on sourcing of this Proposal/Policy");
      		   return false;
         }
}

function calculateAge(chosenProduct,elementDOB,elementAge)
{
  if(checkDateFormat(document.getElementById(elementDOB))) {
	 if(document.getElementById(elementDOB)!=null && document.getElementById(elementDOB)!="")
	 {
		  var str = document.getElementById(elementDOB).value;
		  if(str.length>0)
		   {
				  var d = new Date();
				  var bits = str.split('-')
				  d.setHours(0,0,0,0); 
				  d.setFullYear(bits[0])
				  d.setMonth(bits[1]-1)
				  d.setDate(bits[2])

				  var now = new Date();
				  now.setHours(0,0,0,0); 
				  var years = now.getFullYear()-d.getFullYear();
				  d.setFullYear(now.getFullYear())
				  var diff = now.getTime()-d.getTime()
				  if ( diff <0) years--;
				
				if(document.getElementById(elementAge)!=null){
					document.getElementById(elementAge).value = years;
				}

		   }
	 }else{
		 document.getElementById(elementAge).value =""; 
	 } 	 
  }
}

function checkDateFormat(input)
{ 
   if(input.value.length>0){
	var validformat=/^\d{4}\-\d{2}\-\d{2}$/ //Basic check for format validity 
	var returnval=false; 
	
	if (!validformat.test(input.value)){ 
		 alert("Invalid Date Format. Please correct and submit again.") ;
		}
		else
		  {
		    var yearfield=input.value.split("-")[0] 
		    var monthfield=input.value.split("-")[1] 
		    var dayfield=input.value.split("-")[2] 
		    var dayobj = new Date(yearfield, monthfield-1, dayfield) 
		    if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield))
		       alert("Invalid Day, Month, or Year range detected. Please correct and submit again.") ;
		    else 
		    { 
		       returnval=true; 
		    } 
		 } 
		 if (returnval==false) input.select() 
		  return returnval; 
	  }
}

function getDateObject(dateString,dateSeperator){
	var values = dateString.split(dateSeperator);
	//alert("values::::::::::::::::::::::::::::"+values);
	var date="";
	values[1] = values[1] ;
	date=values[0]+"/"+values[1]+"/"+values[2];
	return date;
}

function getFormValues(crntForm, functionRequested){
		var formList = "";
		var fldName = "";
		var fldValue = "";
		var tmpField = "";

		var currentForm = "";
		 
	
		for (var i=0; i<crntForm.elements.length; i++) {
			currentForm = crntForm.elements[i];	 

			fldName = currentForm.name;
	
			var sectionName = currentForm.getAttribute("sectionName");

			//alert(" Section Name " + sectionName);
			//alert(" currentForm.type " + currentForm.type);

			if(currentForm.type == "radio"){
				//alert(" It is a radio button selection ");
				if(tmpField != fldName){
				var colRadio = document.getElementsByName(fldName);
				var len = colRadio.length;

				for(var j=0; j<len; j++){
					if(colRadio[j].checked){
						fldValue = colRadio[j].value;
					}
				}

					formList = formList + sectionName +"|"+ fldName + "|" + fldValue +"|alphaNumeric~";	
				}

				tmpField = fldName;
				
			}else if(currentForm.type == "checkbox"){
				//alert(" Flow inside the checkbox if ");
				var selectFldName = fldName;
				var checkedFld = currentForm.checked;
				//alert(" selectFldName " + selectFldName);
				//alert(" selectFldName.checked " + selectFldName.checked );

				if(checkedFld){
					fldValue = "Yes"
				}
				else{
					fldValue = "No"
					
				}
				formList = formList + sectionName +"|"+ fldName + "|" + fldValue +"|alphaNumeric~";
				
			}else if(currentForm.type == "select-one"){
				//alert( " fldName inside select-one " + fldName);
				fldNameSelectedIndex = currentForm.selectedIndex;
				//alert(" fldNameSelectedIndex " + fldNameSelectedIndex);
				var selectedElement = crntForm.elements[i];
				//alert("selectedElement.selectedIndex " + selectedElement.selectedIndex);

				if(fldNameSelectedIndex>=0)
				{
					//alert("fldNameSelectedIndex " + fldNameSelectedIndex);
					fldValue = selectedElement.options[fldNameSelectedIndex].text;
					//alert("fldValue" + fldValue);
					formList = formList + sectionName +"|"+ fldName + "|" + fldValue +"|alphaNumeric~";	
				}
			}else if(currentForm.type != "radio" && currentForm.type != "hidden" && 
														currentForm.type != "button" ){
				var functionName = currentForm.getAttribute("functionName");

				var dataType = "";
				if(functionName == "isAlphabetic"){
					dataType = 	"alphabetic";			
				}else if(functionName == "isNumeric"){
					dataType = 	"numeric";			
				}else if(functionName == "isAlphaNumeric"){
					dataType = 	"alphaNumeric";			
				}else if(functionName == "isValidDate"){
					dataType = 	"date";			
				}else {
					dataType = 	"alphaNumeric";			
				}
				
				formList = formList +  sectionName +"|"+ currentForm.id + "|" + currentForm.value +"|"+ dataType +"~";
			}
		}

		
		formList = formList.substring(0,formList.length-1);
		// alert("formList ::::::: "+formList);

		document.frmView.callType.value = functionRequested;
		
		document.frmView.formValues.value = formList;
		
	    var prodId = document.frmView.productId;
	    prodId = prodId.options[prodId.selectedIndex].text;

	    if(prodId== "Termsurance Protection Plan (Individual)" || prodId== "Incomesurance Endowment And Money Back Plan" || prodId=="Homesurance Plan (Single Premium)" ||
	    	prodId== "Retiresurance Pension Plan" || prodId=="Homesurance Protection Plan")
	    {
	    	if(checkEmployeeCode(elIsapplicantastaffmember,elPleaseentertheemployeecodenumber))
			{
				return;
			}
	    }
	    	
		if(prodId== "Wealthsurance Foundation Plan" || prodId=="Wealthsurance (IRDA cap)" 
			|| prodId=="Wealthsurance Milestone Plan" )
		{
			//////////////////////
			if(document.getElementById(elWSMDB).checked){
			  if(document.getElementById(elWSMDBSA).value.length==0){
				  alert("Please enter MDB Sum Assured");
				  document.getElementById(elWSMDBSA).focus();
				  return;
			  }
			  if(document.getElementById(elWSMDBTerm).value.length==0){
				 alert("Please enter MDB Term");
				 document.getElementById(elWSMDBTerm).focus();
				  return;	
			  }
				
			}

			
			if(document.getElementById(elWSHCB).checked){
			  if(document.getElementById(elWSHCBSA).value==0){
				  alert("Please select HCB Sum Assured");
				  document.getElementById(elWSHCBSA).focus;
				  return;
			  }
			   if(document.getElementById(elWSHCBTerm).value.length==0){
				   alert("Please enter HCB Term");
				   document.getElementById(elWSHCBTerm).focus();
				   return;
			   }
				
			}

			if(document.getElementById(elWSADDB).checked){
			   if(document.getElementById(elWSADDBSA).value.length==0){
				   alert("Please enter ADDB Sum Assured");
				   document.getElementById(elWSADDBSA).focus();
				   return;
			   }
				
				if(document.getElementById(elWSADDBTerm).value.length==0){
					alert("Please enter ADDB Term");
					document.getElementById(elWSADDBTerm).focus();
					return;
				}
				
			}

			if(document.getElementById(elWSADB).checked){
			   if(document.getElementById(elWSADBSA).value.length==0){
				   alert("Please enter ADB Sum Assured");
				   document.getElementById(elWSADBSA).focus();
				   return;
			   }
				if(document.getElementById(elWSADBTerm).value.length==0){
					alert("Please enter ADB Term");
					document.getElementById(elWSADBTerm).focus();
					return;
				}
				
			}

			if(prodId=="Wealthsurance Milestone Plan"){
				document.getElementById("paymentFrequencyValidate").value=document.getElementById(elWSIIIBasePremFreq).value;
			}else{
				document.getElementById("paymentFrequencyValidate").value=document.getElementById(elWSBasePremFreq).value;
			}	

			if(document.getElementById(elWSMDB).disabled){
				document.getElementById("mdbHidden").value="disabled";
			}

			if(document.getElementById(elWSHCB).disabled){
				document.getElementById("hcbHidden").value="disabled";
			}

			if(document.getElementById(elWSWOPTPD).disabled){
				document.getElementById("wopTPDHidden").value="disabled";
			}

			if(document.getElementById(elWSADDB).disabled){
				document.getElementById("addbHidden").value="disabled";
			}

			if(document.getElementById(elWSADB).disabled){
				document.getElementById("adbHidden").value="disabled";
			}
			if(checkEmployeeCode(elIsapplicantastaffmember,elPleaseentertheemployeecodenumber)){
				return;
			}
			
			
		}
		
		if( prodId == "Homesurance Plan (Regular Premium)" )
	    {
			if(document.getElementById(elHRMDB).checked){
			  if(document.getElementById(elHRMDBSI).value.length==0){
				  alert("Please enter MDB Sum Insured");
				  document.getElementById(elHRMDBSI).focus();
				  return;
			  }
			  if(document.getElementById(elHRMDBTerm).value.length==0){
				 alert("Please enter MDB Term");
				 document.getElementById(elHRMDBTerm).focus();
				  return;	
			  }
				
			}
			
			if(document.getElementById(elHRHCB).checked){
			  if(document.getElementById(elHRHCBSI).value==0){
				  alert("Please select HCB Sum Insured");
				  document.getElementById(elHRHCBSI).focus;
				  return;
			  }
			   if(document.getElementById(elHRHCBTerm).value.length==0){
				   alert("Please enter HCB Term");
				   document.getElementById(elHRHCBTerm).focus();
				   return;
			   }
				
			}

			if(document.getElementById(elHRADDB).checked){
			   if(document.getElementById(elHRADDBSI).value.length==0){
				   alert("Please enter ADDB Sum Insured");
				   document.getElementById(elHRADDBSI).focus();
				   return;
			   }
				
				if(document.getElementById(elHRADDBTerm).value.length==0){
					alert("Please enter ADDB Term");
					document.getElementById(elHRADDBTerm).focus();
					return;
				}
				
			}

			if(document.getElementById(elHRADB).checked){
			   if(document.getElementById(elHRADBSI).value.length==0){
				   alert("Please enter ADB Sum Insured");
				   document.getElementById(elHRADBSI).focus();
				   return;
			   }
				if(document.getElementById(elHRADBTerm).value.length==0){
					alert("Please enter ADB Term");
					document.getElementById(elHRADBTerm).focus();
					return;
				}
				
			}

			document.getElementById("paymentFrequencyValidate").value=document.getElementById(elHRBasePremFreq).value;

			if(document.getElementById(elHRMDB).disabled){
				document.getElementById("mdbHidden").value="disabled";
			}

			if(document.getElementById(elHRHCB).disabled){
				document.getElementById("hcbHidden").value="disabled";
			}

			if(document.getElementById(elHRWOPTPDYN).disabled){
				document.getElementById("wopTPDHidden").value="disabled";
			}

			if(document.getElementById(elHRADDB).disabled){
				document.getElementById("addbHidden").value="disabled";
			}

			if(document.getElementById(elHRADB).disabled){
				document.getElementById("adbHidden").value="disabled";
			}
			if(checkEmployeeCode(elIsapplicantastaffmember,elPleaseentertheemployeecodenumber)){
				return;
			}
		}

	    if( prodId == "Wealthsurance Foundation Plan" )
	    {
			if( ! atleastOneFundOptionDetailGiven() ){
			    alert("Atleast one FundOptionDetail should be given.");
				return;
			}			
			if ( getSumOfFundOptions() < 100 ){
		       alert("FundOptionValue should not be Lesser than 100%");
		       return;
		    }
		    if ( getSumOfFundOptions() > 100 ){
		       alert("FundOptionValue should not be Greater than 100%");
		       return;
		    }

			if(document.getElementById(elWSWOPDeath).disabled){
				document.getElementById("wopDeathHidden").value="disabled";
			}

			document.getElementById("premiumPaymentTermValidate").value=document.getElementById(elWSBasePremPayTerm).value;
			document.getElementById("innerTopUpText").value=document.getElementById('divExpandingBoxTopupDetails').innerHTML;
			document.getElementById("innerWithdrawalText").value=document.getElementById('divExpandingBoxWithdrawalDetails').innerHTML;

		}

		if( prodId == "Retiresurance Pension Plan" )
	    {
			if( ! atleastOneRPPFundOptionDetailGiven() ){
			    alert("Atleast one FundOptionDetail should be given.");
				return;
			}			
			if ( getRPPSumOfFundOptions() < 100 ){
		       alert("FundOptionValue should not be Lesser than 100%");
		       return;
		    }
		    if ( getRPPSumOfFundOptions() > 100 ){
		       alert("FundOptionValue should not be Greater than 100%");
		       return;
		    }
			
			document.getElementById("paymentFrequencyValidate").value=document.getElementById(elRPPModeofPremiumPayment).value;
			document.getElementById("innerRetireTopUpText").value=document.getElementById('divExpandingBoxTopupDetails').innerHTML;
			document.getElementById("innerRetireWithdrawalText").value=document.getElementById('divExpandingBoxWithdrawalDetails').innerHTML;
			document.getElementById("innerRetirePremiumReductionText").value=document.getElementById('divExpandingBoxPremiumReductionOption').innerHTML;
		}

		if(prodId == "Bondsurance Plan"){

			if(document.getElementById(elBondPlanSelection).value == "Premium Input (in Rs)"){
				if(document.getElementById(elBondPlanPremInclST).value ==""){
					alert("Enter Single Premium incl Service tax and Education Cess");
					return;
				}
				document.getElementById("valuePremiumInput").value = "true";
			}
			else{
				if(document.getElementById(elBondPlanMaturityBenefit).value ==""){
					alert("Enter Maturity Benefit");
					return;
				}
				document.getElementById("valuePremiumInput").value = "false";
			}
			
			if(checkEmployeeCode(elIsapplicantastaffmember,elPleaseentertheemployeecodenumber)){
				return;
			}
		}

		if(prodId == "Bondsurance Advantage Insurance Plan"){

			if(document.getElementById(elBondAdvPlanPlanselection).value == "Enter premium amount (in Rs)"){
				if(document.getElementById(elBondAdvPlanSinglepremiumWithTax).value ==""){
					alert("Please enter single premium incl service tax and education Cess");
					return;
				}
				document.getElementById("valuePremiumInput").value = "true";
			}
			else{
				if(document.getElementById(elBondAdvPlanMaturitybenefitinRs).value ==""){
					alert("Please enter maturity benefit");
					return;
				}
				document.getElementById("valuePremiumInput").value = "false";
			}
			
			if(document.getElementById(elBondAdvPlanCovertype).value =='Joint life'){
				if(document.getElementById(elBondAdvPlanJointInsuredName).value==''){
					document.getElementById(elBondAdvPlanJointInsuredName).focus();
					alert("Please enter name of the person to be joint life insured");
					return;
				}
				if(document.getElementById(elBondAdvPlanJointInsuredDOB).value==''){
					document.getElementById(elBondAdvPlanJointInsuredDOB).focus();
					alert("Please enter date of birth of the person to be joint life insured");
					return;
				}
			}
			
			if(checkEmployeeCode(elBondAdvPlanIsapplicantastaffmember,elBondAdvPlanEmployeecode)){
				return;
			}
		}
		
		if(prodId == "Wealthsurance (IRDA cap)"){
			
			if(checkEmployeeCode(elIsapplicantastaffmember,elPleaseentertheemployeecodenumber)){
				return;
			}
			if( ! wealthIRDAatleastOneFundOptionDetailGiven() ){
			    alert("Atleast one FundOptionDetail should be given.");
				return;
			}			
			if ( getSumOfWealthIRDAFundOptions() < 100 ){
		       alert("FundOptionValue should not be Lesser than 100%");
		       return;
		    }
		    if ( getSumOfWealthIRDAFundOptions() > 100 ){
		       alert("FundOptionValue should not be Greater than 100%");
		       return;
		    }
			
			document.getElementById("paymentFrequencyValidate").value=document.getElementById(elWSBasePremFreq).value;
			document.getElementById("premiumPaymentTermValidate").value=document.getElementById(elWSBasePremPayTerm).value;
			document.getElementById("innerIRDATopUpText").value=document.getElementById('divExpandingBoxTopupDetails').innerHTML;
			document.getElementById("innerIRDAWithdrawalText").value=document.getElementById('divExpandingBoxWithdrawalDetails').innerHTML;
			
		}

		if(prodId == "Retiresurance (IRDA Cap)"){
			if(checkEmployeeCode(elIsapplicantastaffmember,elPleaseentertheemployeecodenumber)){
				return;
			}
			if( ! retireIRDAatleastOneRPPFundOptionDetailGiven() ){
			    alert("Atleast one FundOptionDetail should be given.");
				return;
			}			
			if ( getRPPIRDASumOfFundOptions() < 100 ){
		       alert("FundOptionValue should not be Lesser than 100%");
		       return;
		    }
		    if ( getRPPIRDASumOfFundOptions() > 100 ){
		       alert("FundOptionValue should not be Greater than 100%");
		       return;
		    }
			
			document.getElementById("paymentFrequencyValidate").value=document.getElementById(elRPPModeofPremiumPayment).value;
			document.getElementById("innerIRDARetireTopUpText").value=document.getElementById('divExpandingBoxTopupDetails').innerHTML;
			document.getElementById("innerIRDARetireWithdrawalText").value=document.getElementById('divExpandingBoxWithdrawalDetails').innerHTML;
			document.getElementById("innerRetirePremiumReductionText").value=document.getElementById('divExpandingBoxPremiumReductionOption').innerHTML;
		}
		
		if(prodId == "Retiresurance Mark III"){
			if(checkEmployeeCode(elIsapplicantastaffmember,elPleaseentertheemployeecodenumber)){
				return;
			}
			if( ! retireIIIatleastOneRPPFundOptionDetailGiven() ){
			    alert("Atleast one FundOptionDetail should be given.");
				return;
			}			
			if ( getRPPIIISumOfFundOptions() < 100 ){
		       alert("FundOptionValue should not be Lesser than 100%");
		       return;
		    }
		    if ( getRPPIIISumOfFundOptions() > 100 ){
		       alert("FundOptionValue should not be Greater than 100%");
		       return;
		    }
			
			document.getElementById("paymentFrequencyValidate").value=document.getElementById(elRPPModeofPremiumPayment).value;
			document.getElementById("innerRetireIIITopUpText").value=document.getElementById('divExpandingBoxTopupDetails').innerHTML;
			document.getElementById("innerRetireIIIWithdrawalText").value=document.getElementById('divExpandingBoxWithdrawalDetails').innerHTML;
			document.getElementById("innerRetirePremiumReductionText").value=document.getElementById('divExpandingBoxPremiumReductionOption').innerHTML;
		}
		
		if(prodId == "Wealthsurance Milestone Plan"){
			
			if(checkEmployeeCode(elIsapplicantastaffmember,elPleaseentertheemployeecodenumber)){
				return;
			}
			if( ! wealthIIIatleastOneFundOptionDetailGiven() ){
			    alert("Atleast one FundOptionDetail should be given.");
				return;
			}			
			if ( getSumOfWealthIIIFundOptions() < 100 ){
		       alert("FundOptionValue should not be Lesser than 100%");
		       return;
		    }
		    if ( getSumOfWealthIIIFundOptions() > 100 ){
		       alert("FundOptionValue should not be Greater than 100%");
		       return;
		    }
			
		    if(document.getElementById(elWSWOPDeath).disabled){
				document.getElementById("wopDeathHidden").value="disabled";
			}
		    
			document.getElementById("paymentFrequencyValidate").value=document.getElementById(elWSIIIBasePremFreq).value;
			document.getElementById("premiumPaymentTermValidate").value=document.getElementById(elWSBasePremPayTerm).value;
			document.getElementById("innerWealthIIITopUpText").value=document.getElementById('divExpandingBoxTopupDetails').innerHTML;
			document.getElementById("innerWealthIIIWithdrawalText").value=document.getElementById('divExpandingBoxWithdrawalDetails').innerHTML;
			
		}
		
		if(prodId == "Loansurance"){
			if(document.getElementById("Coverbenefit").value=="Proportionate cover"){
				if(getLoanCoInsuredTotalSharePercent()<100){
					alert("Total co-insured share of loan should not be less than 100%");
					document.getElementById("Shareofloan").focus();
					return;
				}
				if(getLoanCoInsuredTotalSharePercent()>100){
					alert("Total co-insured share of loan should not be greater than 100%");
					document.getElementById("Shareofloan").focus();
					return;
				}
			}
			if(parseInt(document.getElementById(elLoanTotalPremium).value)==0){
				alert("Invalid information.Please check the field inputs");
				return;
			}	
		}
		
		if(prodId == "Wealthsurance Premier Plan"){
			if(checkEmployeeCode(elWSPremierIsapplicantastaffmember,elWSPremierEmployeecode)){
				return;
			}
			if( ! wealthPremieratleastOneFundOptionDetailGiven() ){
			    alert("Atleast one FundOptionDetail should be given.");
				return;
			}			
			if ( getSumOfWealthPremierFundOptions() < 100 ){
		       alert("FundOptionValue should not be Lesser than 100%");
		       return;
		    }
		    if ( getSumOfWealthPremierFundOptions() > 100 ){
		       alert("FundOptionValue should not be Greater than 100%");
		       return;
		    }
		    
			document.getElementById("premiumPaymentTermValidate").value=document.getElementById(elWSPremierBasePremPayTerm).value;
			document.getElementById("innerWealthPremierTopUpText").value=document.getElementById('divExpandingBoxTopupDetails').innerHTML;
			document.getElementById("innerWealthPremierWithdrawalText").value=document.getElementById('divExpandingBoxWithdrawalDetails').innerHTML;
		}
		
		if(prodId == "Retiresurance Guaranteed Pension Plan"){
			document.getElementById("innerRetireGuarantTopUpText").value=document.getElementById('divExpandingBoxTopupDetails').innerHTML;
		}	
		if(prodId== "Termsurance Premier Plan"){
			if(checkEmployeeCode(elTermPremierIsapplicantastaffmember,elTermPremierEmployeecode)){
				return;
			}
		}	
		if(prodId == "Wealthsurance Dreamstart Plan"){
			if(checkEmployeeCode(elWSDsIsapplicantastaffmember,elWSDsemployeecodenumber)){
				return;
			}
			if( ! wealthDsAtleastOneFundOptionDetailGiven() ){
			    alert("Atleast one FundOptionDetail should be given.");
				return;
			}			
			if ( getSumOfWealthDsFundOptions() < 100 ){
		       alert("FundOptionValue should not be Lesser than 100%");
		       return;
		    }
		    if ( getSumOfWealthDsFundOptions() > 100 ){
		       alert("FundOptionValue should not be Greater than 100%");
		       return;
		    }
		    
			document.getElementById("premiumPaymentTermValidate").value=document.getElementById(elWSDsPremPaymentTerm).value;
			document.getElementById("innerWealthDreamStartTopUpText").value=document.getElementById('divExpandingBoxTopupDetails').innerHTML;
			document.getElementById("innerWealthDreamStartWithdrawalText").value=document.getElementById('divExpandingBoxWithdrawalDetails').innerHTML;
		}
		
		if(prodId == "Wealthsurance Dreambuilder Plan"){
			
			if(checkEmployeeCode(elWSDbIsapplicantastaffmember,elPleaseentertheemployeecodenumber)){
				return;
			}
			if( ! wealthDreambuilderatleastOneFundOptionDetailGiven() ){
			    alert("Atleast one FundOptionDetail should be given.");
				return;
			}			
			if ( getSumOfWealthDreambuilderFundOptions() < 100 ){
		       alert("FundOptionValue should not be Lesser than 100%");
		       return;
		    }
		    if ( getSumOfWealthDreambuilderFundOptions() > 100 ){
		       alert("FundOptionValue should not be Greater than 100%");
		       return;
		    }
			
		    if(document.getElementById(elWSWOPDeath).disabled){
				document.getElementById("wopDeathHidden").value="disabled";
			}
		    
		
			document.getElementById("premiumPaymentTermValidate").value=document.getElementById(elWSBasePremPayTerm).value;
			document.getElementById("innerWealthDreambuilderTopUpText").value=document.getElementById('divExpandingBoxTopupDetails').innerHTML;
			document.getElementById("innerWealthDreambuilderWithdrawalText").value=document.getElementById('divExpandingBoxWithdrawalDetails').innerHTML;
			
		}
		//Code added by Durgavathi Ch on 25-02-2011 
		//Retiresurance Milestone Pension Plan
		if(prodId == "Retiresurance Milestone Pension Plan"){
			if( ! retireMPPatleastOneRPPFundOptionDetailGiven() ){
			    alert("Atleast one FundOptionDetail should be given.");
				return;
			}			
			if ( getRMPPSumOfFundOptions() < 100 ){
		       alert("FundOptionValue should not be Lesser than 100%");
		       return;
		    }
		    if ( getRMPPSumOfFundOptions() > 100 ){
		       alert("FundOptionValue should not be Greater than 100%");
		       return;
		    }
						
		}
		if(prodId == "Wealthsurance Maxigain Plan"){
			
			if(checkEmployeeCode(elWSMGIsapplicantastaffmember,elWSMGPleaseentertheemployeecodenumber)){
				return;
			}
			if( !wealthMaxiGainatleastOneFundOptionDetailGiven() ){
			    alert("Atleast one FundOptionDetail should be given.");
				return;
			}			
			if ( getSumOfWealthMaxiGainFundOptions() < 100 ){
		       alert("FundOptionValue should not be Lesser than 100%");
		       return;
		    }
		    if ( getSumOfWealthMaxiGainFundOptions() > 100 ){
		       alert("FundOptionValue should not be Greater than 100%");
		       return;
		    }
			document.getElementById("premiumPaymentTermValidate").value=document.getElementById(elWSMGBasePremPayTerm).value;
			document.getElementById("innerWealthMaxiGainTopUpText").value=document.getElementById('divExpandingBoxTopupDetails').innerHTML;
			document.getElementById("innerWealthMaxiGainWithdrawalText").value=document.getElementById('divExpandingBoxWithdrawalDetails').innerHTML;
			
		}
		
		if(prodId == "Childsurance Dreambuilder Insurance Plan")
		{
			if(checkEmployeeCode(elCSDbIsapplicantastaffmember,elCSDbemployeecodenumber))
			{
				return;
			}
			if (document.getElementById(elCSDbSystematicallocator).value == 'No')
			{
				
				if(!childDreambuilderatleastOneFundOptionDetailGiven())
				{
					alert("Atleast one FundOptionDetail should be given.");
					return;
				}
				if (getSumOfChildDreambuilderFundOptions() < 100 )
				{
					alert("FundOptionValue should not be Lesser than 100%");
					return;
				}
				if ( getSumOfChildDreambuilderFundOptions() > 100 )
				{
					alert("FundOptionValue should not be Greater than 100%");
					return;
				}
			}
			document.getElementById("premiumPaymentTermValidate").value=document.getElementById(elWSBasePremPayTerm).value;
			document.getElementById("innerChildDreambuilderTopUpText").value=document.getElementById('divExpandingBoxTopupDetails').innerHTML;
			document.getElementById("innerChildDreambuilderWithdrawalText").value=document.getElementById('divExpandingBoxWithdrawalDetails').innerHTML;
			
		}

		if(prodId == "Incomesurance Endowment And Money Back Plan" )
		{
			var elIncomeInstalmentPrem="InstalmentPremiuminRs";
			var IncomeInstalmentPrem = document.getElementById(elIncomeInstalmentPrem).value;
			var elIncomePlanOption = "IncomesurancePlanOption";
			 
			if (document.getElementById(elIncomePlanOption).value == 'Waiver of Premium Option')
			{
				if (IncomeInstalmentPrem == "")
				{
					ajaxIncomeInstalPremium();
					return;
				}
			}
		}
		if(prodId== "Lifesurance Savings Insurance Plan"){			
			if(checkEmployeeCode(elLifeSavingIsapplicantastaffmember,elLifeSavingEmployeecode)){
				return;
			}
		}
			document.frmView.submit();
	}
	

function validateForm(crntForm, functionRequested){
		
		var isFlag = 0;
		
		for (var i=0; i<crntForm.elements.length; i++) {
			fldName = crntForm.elements[i].name;
			//alert(" fldName " + fldName);
		
			var currForm = crntForm.elements[i];
			
			var colRadioUsage = currForm.getAttribute("usage");
			
			var validationMessage = currForm.getAttribute("validationMessage");
			
				if (colRadioUsage=='Required' && colRadioUsage != null) {
				//alert(" colRadioUsage is not null ");
				
				if(currForm.type == "radio" && tmpField != fldName)
				{
					isFlag = 1;
					var colRadio = document.getElementsByName(currForm.name);
					
					
					var len = colRadio.length;
					for(var j=0; j<len; j++)
						if(colRadio[j].checked)
						{
							fldValue = colRadio[j].value;
							isFlag = 0;
							break;
						}
					if (isFlag == 1)
					{
						alert("Please select an option for "+fldName);
						break;
					}
				}
				else if(! isNotNull(currForm.name,validationMessage)){
					
					isFlag = 1;
					break;
				}
				tmpField = fldName;
			
			}

				if (currForm.getAttribute("functionName") != null 
					&& ((currForm.value != null) || (currForm.value != ""))
				) {

				var functionName = currForm.getAttribute("functionName");
				//alert(" Field Name : " + fldName + "\n" +" Function Name : " + functionName);
				
				
				if(functionName == "isAlphabetic"){
					
					if(! isAlphabetic(currForm.name,validationMessage)){
						
						isFlag = 1;
						break;
					}
				}
				else if(functionName == "isNumeric"){
					if(! isNumeric(currForm.name,validationMessage)){
						isFlag = 1;
						break;
					}
				}
				else if(functionName == "isAlphaNumeric"){
					if(! isAlphaNumeric(currForm.name,validationMessage)){
						isFlag = 1;
						break;
					}
				}
				else if(functionName == "isValidDate"){
					if( !checkdate(currForm)){
						isFlag = 1;
						//alert(" currForm.name " + currForm.name);
						alert("Please enter valid "+currForm.name);
						document.getElementById(currForm.name).focus();
						break;
					}
				}
				
			}
		}
		
		if(isFlag == 0)
		{
			getFormValues(crntForm, functionRequested);
		}
		var prodId = document.frmView.productId;
	    prodId = prodId.options[prodId.selectedIndex].text;
	    
	    if( prodId == "Homesurance Plan (Regular Premium)" ){
	    	var hospCashBenefit = document.getElementById(elHRHCB);
	    	var accDeathAndDisableBenefit = document.getElementById(elHRADDB);
	    	var accDeathBenefit = document.getElementById(elHRADB);
	    	var majDiseaseBenefit = document.getElementById(elHRMDB);
	    	if(!hospCashBenefit.checked && !accDeathAndDisableBenefit.checked && !accDeathBenefit.checked && !majDiseaseBenefit.checked){
	    		alert("You have not entered any Rider Details!!");
	    		return true;
	    	}
	    }
		else if(prodId == "Wealthsurance Foundation Plan" || prodId=="Wealthsurance (IRDA cap)" ){
			var hospCashBenefit = document.getElementById(elWSHCB);
	    	var accDeathAndDisableBenefit = document.getElementById(elWSADDB);
	    	var accDeathBenefit = document.getElementById(elWSADB);
	    	var majDiseaseBenefit = document.getElementById(elWSMDB);
	    	if(!hospCashBenefit.checked && !accDeathAndDisableBenefit.checked && !accDeathBenefit.checked && !majDiseaseBenefit.checked){
	    		alert("You have not entered any Rider Details!!");
	    		return true;
	    	}
		}	    
}


function isAlphabetic(fldName,validationMessage){
	
	var x = document.getElementById(fldName);
	var y = document.getElementById(fldName).value;
	
	if(y.length > 0){
		//alert("check fldName" + fldName );
		var anum=/^[a-z A-Z]+$/
		if (!anum.test(y)){
			alert("Enter a valid "+validationMessage);
			x.focus();
			return false;
		}
		return true;
	}
	return true;
}


function isNumeric(fldName,validationMessage){
	var x = document.getElementById(fldName);
	var y = document.getElementById(fldName).value;
	//alert("fldName "+ fldName);
	if(y.length > 0){
		if(fldName == "PerMile" || fldName == "BasePlanPerMile" || fldName == "ADBPerMile" 
			|| fldName == "ADDBPerMile" || fldName == "HCBPerMile" || fldName == "MajorDiseaseBenefitPerMile" 
			|| fldName == "WOPBenefitonTPDPerMile" || fldName == "WOPBenefitonDeathPerMile"  
			|| fldName == "PerMile" || fldName == "CurrentrateofinterestontheloanPercentage" ){
				var anum = /^-?\d*(\.\d+)?$/;
		}
		else{
			var anum=/^[0-9\s]+$/
		}
		//var anum=/^(0|[1-9]\d{0,2})(\.\d\d?)?$/;
		if (!anum.test(y)){
			alert("Enter a valid "+validationMessage);
			x.focus();
			return false;
		}
		return true;
	}
	return true;
}

function isAlphaNumeric(fldName,validationMessage){
	
	var x = document.getElementById(fldName);
	var y = document.getElementById(fldName).value;
	if(y.length > 0){
		var anum=/^[a-zA-Z0-9+\s,\.\-\/]+$/

		if (!anum.test(x.value)){
			alert("Enter a valid "+validationMessage);
			x.focus();
			return false;
		}

		return true;
	}
	return true;
}

function isNotNull(fldName,validationMessage){
	
	//var x = eval("document.frmView."+fldName+".value");
	var x = document.getElementById(fldName);
	var y = document.getElementById(fldName).value;

	if(y.length == 0){
		alert("Enter " + validationMessage);
		x.focus();
		return false;
	}
	return true;
}

function isValidRadio(fldName,validationMessage){

	var len = document.getElementById(fldName).length;
	var isCheck = 0;

	for(var i=0; i<len; i++){
		if(document.getElementById(fldName+"[i]").checked){
			isCheck = 1;
		}
	}

	if(isCheck == 0){
		alert("Please select an option for "+validationMessage);
		return false;
	}
	else{
		return true;
	}
}

function checkdate(input){
	var validformat=/^\d{4}[-]\d{2}[-]\d{2}$/ //Basic check for format validity
	var returnval=false;
	//alert(" input.value " + input.value);
	var inputValue = input.value;
	if(inputValue.length>0){
		if (!(validformat.test(input.value)))
			return false;
		else{ //Detailed check for valid date ranges
			var dayfield=input.value.split("-")[2];
			var monthfield=input.value.split("-")[1];
			var yearfield=input.value.split("-")[0];
			var dayobj = new Date(yearfield, monthfield-1, dayfield);

			if((dayobj.getDate()!=dayfield)||(dayobj.getMonth()+1!=monthfield)||(dayobj.getFullYear()!=yearfield))
				return false;
			else
			return true;

			returnval="";
		}
	}
	else{
		return true;
	}
	
	if (returnval==false) input.select();
	return returnval;
}

function selectKeys(productId, policyId){
	document.frmView.productId.value = productId;
}

function viewErrors(){
	if(document.getElementById("errorDiv1")){
		var errObj = document.getElementById("errorDiv1");
		errObj.style.visibility = "visible";
		errObj.style.left = "170px";
	}
}
	
function closeError(){
	document.getElementById("errorDiv1").style.visibility = "hidden";
}
	

function giveInt(intval){
	  intval = trim(intval);
	  var regex = /^[0-9]+$/; //--> only numbers
	  if ( intval.match(regex) ) 
	  {
		  return parseInt(intval);
	  }
	  else
	  {
	      return 0;
	  }		 
}
		

function getStartsWithCaps(value){
     return value.substring(0,1).toUpperCase() + value.substring(1, value.length);
}
   
   
function isPostDate(fieldId){
   var flag = true;
	if((fieldId.value.length > 0)&&(fieldId.value != ' '))
	{
	     var curDate = new Date();
		 var comingDate = new Date();
            
		 //alert(fieldId.value.substring(0,4)+ ":" + 
		 //fieldId.value.substring(5,7) + ":" + fieldId.value.substring(8,10) ); 

		 comingDate.setYear(fieldId.value.substring(0,4));				 
		 comingDate.setMonth( parseInt(fieldId.value.substring(5,7))-1);
		 comingDate.setDate(fieldId.value.substring(8,10));
		 
		 comingDate.setHours(0);//curDate.getHours() );
		 comingDate.setMinutes(0);// curDate.getMinutes() );
		 comingDate.setSeconds(59);

		 if ( curDate <= comingDate )
		 {			  
		   flag = false;
		 }
	 }
	 return flag;
}
	
function trim( data ){	
   if ( data == null )
   {
     return '';
   }

   var trim = '';
   for( var i=0; i<data.length; i++ )
   {
      if( data.substring(i, i+1) != ' ')
	  {			  
            trim += data.substring(i, i+1);
	  }
   }		   
   return trim;
}

function checkNumeric(elementInterestRate){
	 if (document.getElementById(elementInterestRate).value == parseInt(document.getElementById(elementInterestRate).value))
		  return true;
     else if(document.getElementById(elementInterestRate).value== parseFloat(document.getElementById(elementInterestRate).value))
		  return true;
	 else
	 {
		  alert("Enter a numeric Value")
		  document.getElementById(elementInterestRate).value="";
		  document.getElementById(elementInterestRate).focus();
		  return false;
	 }
}

function setTopupWithdrawal(){
	if(document.getElementById("innerTopUpText").value.length > 0){
		document.getElementById('divExpandingBoxTopupDetails').style.visibility = 'visible';
		document.getElementById('headerExpandingBoxTopupDetails').style.visibility = 'visible';
		document.getElementById('divExpandingBoxTopupDetails').innerHTML = document.getElementById("innerTopUpText").value;
		checkTopUpLoop(document.getElementById(elWSBaseTerm).value);
	}

	if(document.getElementById("innerWithdrawalText").value.length > 0){
		document.getElementById('divExpandingBoxWithdrawalDetails').style.visibility = 'visible';
		document.getElementById('headerExpandingBoxWithdrawalDetails').style.visibility = 'visible';
		document.getElementById('divExpandingBoxWithdrawalDetails').innerHTML = document.getElementById("innerWithdrawalText").value;

		checkWithdrawalLoop(document.getElementById(elWSBaseTerm).value);
		checkWithdrawal10Loop(document.getElementById(elWSBaseTerm).value);
	}
}

function setRetireTopupWithdrawal(){
	if(document.getElementById("innerRetireTopUpText").value.length > 0){
		document.getElementById('divExpandingBoxTopupDetails').style.visibility = 'visible';
		document.getElementById('headerExpandingBoxTopupDetails').style.visibility = 'visible';
		document.getElementById('divExpandingBoxTopupDetails').innerHTML = document.getElementById("innerRetireTopUpText").value;
		checkRetireTopUpLoop(document.getElementById(elRPPTerm).value);
	}

	if(document.getElementById("innerRetireWithdrawalText").value.length > 0){
		document.getElementById('divExpandingBoxWithdrawalDetails').style.visibility = 'visible';
		document.getElementById('headerExpandingBoxWithdrawalDetails').style.visibility = 'visible';
		document.getElementById('divExpandingBoxWithdrawalDetails').innerHTML = document.getElementById("innerRetireWithdrawalText").value;

		checkRetireWithdrawalLoop(document.getElementById(elRPPTerm).value);
		checkRetireWithdrawal10Loop(document.getElementById(elRPPTerm).value);
	}

	if(document.getElementById("innerRetirePremiumReductionText").value.length > 0){
		document.getElementById('divExpandingBoxPremiumReductionOption').style.visibility = 'visible';
		document.getElementById('headerExpandingBoxPremiumReductionOption').style.visibility = 'visible';
		document.getElementById('divExpandingBoxPremiumReductionOption').innerHTML = document.getElementById("innerRetirePremiumReductionText").value;
		checkRetirePremiumReduction(document.getElementById(elRPPTerm).value);
	}
}


function GoBack(){	
	history.go(-1);
}



function checkUnderWriter(){
	var finalroleName=document.frmView.hRoleName.value;
	//alert("finalroleName::::::::"+finalroleName);
	var finalProductId=document.frmView.hproductId.value;
	
	//newly Added for EMR on 04/03/2009 by Archana
	var selectedElement = document.frmView.productId;
	var selectedName =	selectedElement.options[selectedElement.selectedIndex].text;
	//alert("selectedName::::::::"+selectedName+"<<<<<<<<<");
	//
	if(finalProductId ==null || finalProductId ==" "  || finalProductId =="" || finalProductId=="null" ){
	
	//alert("inside first if loop::::::::");
	}
	else{
		var headerExpandingBoxForUnderwriting=document.getElementById('headerExpandingBoxForUnderwriting');
		var divExpandingBoxForUnderwriting=document.getElementById('divExpandingBoxForUnderwriting');
		if(finalroleName=="UnderWriter" || finalroleName=="Staff_UW" ){
			if(selectedName == "Homesurance Protection Plan" ){
				//document.getElementById(elHPPSumInsured).readOnly=false;
			}
		}
		else if(selectedName == "Wealthsurance Foundation Plan" 
			|| selectedName == "Homesurance Plan (Single Premium)" 
			|| selectedName == "Homesurance Plan (Regular Premium)"
			|| selectedName == "Homesurance Protection Plan"
			|| selectedName == "Bondsurance Plan" 
			|| selectedName == "Termsurance Protection Plan (Individual)"
			|| selectedName == "Incomesurance Endowment And Money Back Plan"
			|| selectedName == "Termsurance Grameen Bachat Yojana"
			|| selectedName == "Incomesurance Immediate Annuity"
			|| selectedName == "Wealthsurance (IRDA cap)"
			|| selectedName == "Wealthsurance Milestone Plan"	
			|| selectedName == "Loansurance"
			|| selectedName == "Bondsurance Advantage Insurance Plan"	
			|| selectedName == "Group Termsurance ROP"	
			|| selectedName == "Wealthsurance Premier Plan"	
			|| selectedName == "Termsurance Premier Plan"	
			|| selectedName == "Termsurance Senior Plan"	
			|| selectedName == "Wealthsurance Dreamstart Plan"
			|| selectedName == "Wealthsurance Dreambuilder Plan"	
			|| selectedName == "Wealthsurance Maxigain Plan"
			|| selectedName == "Childsurance Dreambuilder Insurance Plan"
			|| selectedName == "Lifesurance Savings Insurance Plan"
					
				) {
			
			headerExpandingBoxForUnderwriting.style.visibility="hidden";
			headerExpandingBoxForUnderwriting.style.display="none";
			divExpandingBoxForUnderwriting.style.visibility="hidden";
			divExpandingBoxForUnderwriting.style.display="none";
		}
		else{
		}
	}
}


