﻿// JScript File
function ChkNumericLen(id)
 {
    if(window.event.keyCode < 48  || window.event.keyCode > 57)
    {
     if (window.event.keyCode == 46)
        {
        }
      else
        {
        alert("Enter Digit Only");
        return false ;
        }
    } 
 }
  function isEmpty(s)
{   
return ((s == null) || (s.length == 0))
}

function isWhitespace (s)
{   
var i;
if (isEmpty(s)) return true;
for (i = 0; i < s.length; i++)
{   
	  var c = s.charAt(i);
    if (c != ' ') return false;
}

return true;
}
//calculation of EMI

function CalculateEMI()
{
var i = document.getElementById("interestrate").value;    
if (i> 1.0)
{
	i = i / 100.0;
}
i /= 12;
var pow = 1;
for (var j = 0; j <  document.getElementById("intnoofmonths").value; j++)
{
	pow = pow * (1 + i);
	//formTool.paymentAmt.value = Math.round((formTool.principalAmt.value * pow * i) / (pow - 1))
	document.getElementById("paymentAmt").value = (document.getElementById("principalAmt").value * pow * i) / (pow - 1)
	num = document.getElementById("paymentAmt").value;
	document.getElementById("paymentAmt").value = (parseFloat(num)).toFixed(2)
}
var paidTotalInterest;
paidTotalInterest = 0;
totInterest = 0;
principalAmt = document.getElementById("principalAmt").value;
emi = document.getElementById("paymentAmt").value;
int1 = (document.getElementById("interestrate").value/12)/100;
for (var j = 0; j < document.getElementById("intnoofmonths").value; j++)
{
	paidInterest = 0;
	paidPrincipal = 0;
	paidInterest = principalAmt * int1;
	paidPrincipal = emi - paidInterest;
	principal1 = principalAmt - paidPrincipal;
	if (principal1<0)
	{
		principal1 = 0;
	}
	paidTotalInterest = paidTotalInterest + paidInterest;
	principalAmt = principalAmt - paidPrincipal;
}

document.getElementById("totalinterestAmt").innerHTML = (parseFloat(paidTotalInterest)).toFixed(2)
}
function validateEMI()
{
var flag=0;
var msg="Please check/enter one or all of the following fields:\n\n";
if(isWhitespace(document.getElementById("principalAmt").value))
{
   msg = "Please Enter Amount of loan\n";
   alert(msg);
   document.getElementById("principalAmt").focus();
   return false;
}		
if(isWhitespace(document.getElementById("intnoofmonths").value))
{
   msg = "Please Enter Number of months\n";
   alert(msg);
   document.getElementById("intnoofmonths").focus();
   return false;
}

var checkOK = "0123456789- \t\r\n\f";
var checkStr = document.getElementById("intnoofmonths").value;
var allValid = true;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
  if (ch == checkOK.charAt(j))
    break;
if (j == checkOK.length)
{
  allValid = false;
  break;
}
}
if (!allValid)
{
alert("Please enter only digit in the \"Number of Months\" field.");
document.getElementById("intnoofmonths").value = ""
document.getElementById("intnoofmonths").focus();
return (false);
}

if(isWhitespace(document.getElementById("interestrate").value))
{
   msg = "Please Enter Rate of interestrate\n";
   alert(msg);
  document.getElementById("interestrate").focus();
   return false;
}


					

CalculateEMI();
}
function GetFinancialGoal()
{
  var inpFinancialG=document.getElementById("ctl00_ContentPlaceHolder1_inpFinancialG");
  
	if(inpFinancialG.value=="")
	{
	 	alert(" Please Fill Required Final Value");
		inpFinancialG.focus();
		return false;
	}
	if(isNaN(inpFinancialG.value))
	{
		alert("Final value should be in numbers");
		inpFinancialG.value ="";
		inpFinancialG.focus();
		return false;
	}

	if(document.getElementById("inpFYears").value=="")
	{
	 	alert(" Please Fill Years");
		document.getElementById("inpFYears").focus();
		return false;
	}
	if(isNaN(document.getElementById("inpFYears").value))
	{
		alert("Years should be in numbers");
		document.getElementById("inpFYears").value ="";
		document.getElementById("inpFYears").focus();
		return false;
	}

	if(document.getElementById("inpRateOfSaving").value=="")
	{
	 	alert(" Please Fill Interest");
		document.getElementById("inpRateOfSaving").focus();
		return false;
	}
	if(isNaN(document.getElementById("inpRateOfSaving").value))
	{
		alert("Interest should be in numbers");
		document.getElementById("inpRateOfSaving").value ="";
		document.getElementById("inpRateOfSaving").focus();
		return false;
	}

	var savings = document.getElementById("inpTSavings").value;
	var years = document.getElementById("inpFYears").value;
	var interest = document.getElementById("inpRateOfSaving").value/100;
	var finalvalue = inpFinancialG.value;
	if(savings!="")
	{
		finalvalue = finalvalue-savings;
	}
	var s1 =(1+interest);
	
	s = Math.pow(s1,years);
	
	//alert(s);
	//alert(finalvalue)
	
	finalvalue = finalvalue/s;
	finalvalue=Math.round(finalvalue)
	finalvalue = addCommas(finalvalue)
	document.getElementById("txtLumpsumSaving").innerHTML="Rs. " + finalvalue;
	
	lumpsum	= Math.round(finalvalue*100);
	lumpsum = lumpsum/100;
	lumpsum = addCommas(lumpsum);
	//getElementById("txtLumpsumSaving.value = lumpsum;

	var nSprod = 0
	var principal = 0
	var termy = 0
	var rrate = 0
	principal = parseFloat(inpFinancialG.value)
	if(savings!="")
	{
		principal = principal-savings;
	}
	termy = parseFloat(document.getElementById("inpFYears").value)*12
	rrate = parseFloat(document.getElementById("inpRateOfSaving").value)/12
	rrate = rrate/100
   	var TEMP1 = (1 + rrate)
   	var TEMP2 = Math.pow(TEMP1,termy)
	nSprod = principal*rrate/(TEMP2-1)
	nSprod	= Math.round(nSprod*100);
	nSprod = nSprod/100
	//nSprod = addCommas(nSprod)
	//alert(nSprod)
	nSprod = nSprod.toFixed(0)
	nSprod = addCommas(nSprod)
	document.getElementById("txtPerMonthSaving").innerHTML="Rs. " +  nSprod;
}
function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}
		
		
		function fn_Income()
																		{
																			if (document.getElementById('txtHRA').value!="" && document.getElementById('txtHRA').value!="0")
																			{
																			
																					if (document.getElementById('selhouseincome').value==1)
																					{
																					
																						document.getElementById('txtInterestOnHouseLoan').value=0;
																					}
																			}
																		}
																		function fn_calc()
																		{
																					
																			var txtBS,txtBS1,txtCity,txtRentpaid,txtHRAEmp;
																					
																			txtCity = document.getElementById('txtCity').value
																			if (document.getElementById('txtBS').value!="")
																			{
																				txtBS = document.getElementById('txtBS').value
																			}
																			else
																			{
																				txtBS = 0
																			}
																			if (document.getElementById('txtRentpaid').value!="")
																			{
																				txtRentpaid = document.getElementById('txtRentpaid').value
																			}
																			else
																			{
																				txtRentpaid = 0
																			}
																			if (document.getElementById('txtHRAEmp').value!="")
																			{
																				txtHRAEmp = document.getElementById('txtHRAEmp').value
																			}
																			else
																			{
																						
																				txtHRAEmp = 0
																			}
																					
																			if ((txtBS!="") && (txtRentpaid != "") && (txtHRAEmp!=""))
																			{
																						
																				if ((txtCity == "Mumbai") || (txtCity == "Kolkata") || (txtCity == "Delhi") || (txtCity == "Chennai")) 
																					{
																						txtBS1 = txtBS * 0.5
																					}
																				if (txtCity == "Other")
																					{ 
																						txtBS1 = txtBS * 0.4
																					}	
																			}
																					
																			txtRentpaid = txtRentpaid - (txtBS*0.1)
																					
																					
																			var leastvalue;
																			if ((txtBS1 < txtRentpaid) && (txtBS1 < txtHRAEmp))
																			{
																				leastvalue = txtBS1;
																			}
																			else if ((txtRentpaid < txtBS1) && (txtRentpaid < txtHRAEmp))
																			{
																				leastvalue = txtRentpaid;
																			}
																			else if ((txtHRAEmp < txtBS1) && (txtHRAEmp < txtRentpaid))
																			{
																				leastvalue = txtHRAEmp;
																			}
																			else
																			{
																				leastvalue = txtBS1;
																			}
																					
																			if (leastvalue == undefined)
																			{
																				document.getElementById('txtHRA').value = 0;
																			}
																			else
																			{
																				document.getElementById('txtHRA').value = leastvalue;
																			}
																					
																		}
																		function submit_onclick()
																		{	
																			
																			if(document.formTool.txtName.value=="")
																			{
																			 	alert(" Please Fill Name");
																				document.formTool.txtName.focus();
																				return false;
																			}
																			
																			if(document.formTool.txtSex.value=="")
																			{
																			 	alert("Please Fill Sex");
																				document.formTool.txtSex.focus();
																				return false;
																			}
																			
																			
																			if(document.formTool.txtEarning.value<0)
																			{
																			 	alert(" Earnings Cannot Be Negative");
																				document.formTool.txtEarning.focus();
																				return false;
																			}
																			
																			if (document.getElementById('txtBS').value=="" || document.getElementById('txtBS').value=="0")
																				{
																					alert("Please Fill Basic Salary Field")
																					document.getElementById('txtBS').focus();
																					return false;
																				}
																			//alert("sss");	
																			//document.formTool.submit();
																		}			
																		
																		


//EMI CALCULATOR 
  function isEmpty(s)
{   
return ((s == null) || (s.length == 0))
}

function isWhitespace (s)
{   
var i;
if (isEmpty(s)) return true;
for (i = 0; i < s.length; i++)
{   
	  var c = s.charAt(i);
    if (c != ' ') return false;
}

return true;
}
//calculation of EMI

function CalculateEMI()
{
var i = document.getElementById("interestrate").value;    
if (i> 1.0)
{
	i = i / 100.0;
}
i /= 12;
var pow = 1;
var paymentAmt;
for (var j = 0; j <  document.getElementById("intnoofmonths").value; j++)
{
	pow = pow * (1 + i);
	//formTool.paymentAmt.value = Math.round((formTool.principalAmt.value * pow * i) / (pow - 1))
	num = (document.getElementById("principalAmt").value * pow * i) / (pow - 1)
	paymentAmt = (parseFloat(num)).toFixed(2)
}
document.getElementById("paymentAmt").innerHTML =paymentAmt;
var paidTotalInterest;
paidTotalInterest = 0;
totInterest = 0;
principalAmt = document.getElementById("principalAmt").value;
emi = paymentAmt;
int1 = (document.getElementById("interestrate").value/12)/100;
for (var j = 0; j < document.getElementById("intnoofmonths").value; j++)
{
	paidInterest = 0;
	paidPrincipal = 0;
	paidInterest = principalAmt * int1;
	paidPrincipal = emi - paidInterest;
	principal1 = principalAmt - paidPrincipal;
	if (principal1<0)
	{
		principal1 = 0;
	}
	paidTotalInterest = paidTotalInterest + paidInterest;
	principalAmt = principalAmt - paidPrincipal;
}
document.getElementById("totalinterestAmt").innerHTML = (parseFloat(paidTotalInterest)).toFixed(2)
}
function validateEMI()
{
var flag=0;
var msg="Please check/enter one or all of the following fields:\n\n";
if(isWhitespace(document.getElementById("intnoofmonths").value))
{
   msg = "Please Enter Number of months\n";
   alert(msg);
   document.getElementById("intnoofmonths").focus();
   return false;
}

var checkOK = "0123456789- \t\r\n\f";
var checkStr = document.getElementById("intnoofmonths").value;
var allValid = true;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
  if (ch == checkOK.charAt(j))
    break;
if (j == checkOK.length)
{
  allValid = false;
  break;
}
}
if(isWhitespace(document.getElementById("principalAmt").value))
{
   msg = "Please Enter Amount of loan\n";
   alert(msg);
   document.getElementById("principalAmt").focus();
   return false;
}
if (!allValid)
{
alert("Please enter only digit in the \"Number of Months\" field.");
document.getElementById("intnoofmonths").value = ""
document.getElementById("intnoofmonths").focus();
return (false);
}

if(isWhitespace(document.getElementById("interestrate").value))
{
   msg = "Please Enter Rate of interestrate\n";
   alert(msg);
  document.getElementById("interestrate").focus();
   return false;
}



function ClearEMIResult(){
//	document.frmPortfolioValuer.txtSchemeName.value="";
//	document.frmPortfolioValuer.txtDateFrom.value="";
//	document.frmPortfolioValuer.txtDateTo.value="";
//	document.frmPortfolioValuer.txtIndex.value="";
//	document.frmPortfolioValuer.txtSecurityCode.value="";
}								

CalculateEMI();
}
//END			


//SIP Calculator

 function calculateSip()
	{
	
	if(document.getElementById("amount").value == "")
	{
	alert("Enter the Amount");
	document.getElementById("amount").value	 ="";
	document.getElementById("amount").focus();
	return false;
	}
	if(isNaN(document.getElementById("amount").value))
	{
	alert("Amount should be in numbers");
	document.getElementById("amount").value	 ="";
	document.getElementById("amount").focus();
	return false;
	}
	if(document.getElementById("interest").value == "")
	{
	alert("Enter the rate of return");
	document.getElementById("interest").value	 ="";
	document.getElementById("interest").focus();
	return false;
	}
	if(isNaN(document.getElementById("interest").value))
	{
	alert("Rate of return should be in numbers");
	document.getElementById("interest").value	 ="";
	document.getElementById("interest").focus();
	return false;
	}
	if(document.getElementById("months").value	 == "")
	{
	alert("Enter the Term of Investment (Months) ");
	document.getElementById("months").value	= "";
	document.getElementById("months").focus();
	return false;
	}
	if(isNaN(document.getElementById("months").value))
	{
	alert("Term of Investment (Months) should be in numbers");
	document.getElementById("months").value	= "";
	document.getElementById("months").focus();
	return false;
	}

	var amount	= document.getElementById("amount").value;
	var months	= document.getElementById("months").value;
	var interest = document.getElementById("interest").value;
	var finalamount	= 0.0;
	var rate	= interest/100;
	var i	= rate/12;
	var s1	=(1+i);
	s	=((Math.pow(s1,months))-1)/i;
	finalamount	= amount*s*s1;
	finalamount	= Math.round(finalamount*100);
	 document.getElementById("finalmount").value	= finalamount/100;
	return false;
	}
//END	

// Inflation

function CalInflation()
	{
	
		if(isNaN(document.getElementById("CurrentCost").value) || document.getElementById("CurrentCost").value=="")
		{
			alert("Current cost should be in numbers");
			document.getElementById("CurrentCost").value ="";
			document.getElementById("CurrentCost").focus();
			return false;
		}
		if(isNaN(document.getElementById("InfRateAmt").value) ||document.getElementById("InfRateAmt").value=="")
		{
			alert("Inflation Rate should be in numbers");
			document.getElementById("InfRateAmt").value ="";
			document.getElementById("InfRateAmt").focus();
			return false;
		}
		if(isNaN(document.getElementById("nofYears").value) || document.getElementById("nofYears").value=="")
		{
			alert("Years should be in numbers");
			document.getElementById("nofYears").value ="";
			document.getElementById("nofYears").focus();
			return false;
		}
		var InfAmt
		InfAmt = Math.pow( 1 + document.getElementById("InfRateAmt").value  / 100,  document.getElementById("nofYears").value );
		InfAmt =  document.getElementById("CurrentCost").value * InfAmt;
		InfAmt = InfAmt * 100;
		InfAmt = Math.round(InfAmt) / 100;
		document.getElementById("FCost").innerHTML="Rs. " +InfAmt; 
	}
//END						




//Insurance Calculator


errormsg = "The Following fields are left blank:";
fieldlist = "";
msg2=""
// pending:path has to be changed
//MM_preloadImages('../insurance_plan/images/apply.gif','images/redarrow.gif');
//MM_preloadImages('../../../../images/bsli/apply.gif','../../../../../images/bsli/redarrow.gif');
	  function blockOnline()
	  {
		alert("This facility will not be available till 29/12/2004.")
	  }	

function isEmailAddr(email)
{
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
  if (index > 0)
  {
	var pindex = theStr.indexOf(".",index);
	if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function fnIsTextNull(r_strMsg,r_varCtrl)
{
	var flag="";
	//alert(r_strMsg+ "\t "+r_varCtrl.value + "\t"+r_varCtrl.length);
	if (r_varCtrl.value==0)
	{
		var l_strErr
		fieldlist += "\n\t" + r_strMsg 
		return true;
	}
	else if (r_varCtrl.length)
	{
		for (i=0;i< r_varCtrl.length;i++ )
		{
			if(r_varCtrl[i].checked)
				flag="YAP";
		}
		if(flag=="")
		{
			fieldlist += "\n\t" + r_strMsg;
		}
		return true
	}

	return false
}//end of function fnIsTextNull

function NumOnly()
{
  key = window.event.keyCode;
  if(key>57 || key<48)
	  window.event.keyCode = 0;	
  else
	;
}


function UpperCase()
{
  key = window.event.keyCode;
  if ((key > 0x60) && (key < 0x7B))
    window.event.keyCode = key-0x20;
}

function controls(cntrl,state)
{
	cntrl.disabled=state;
}

function DaysDelta(v1,v2) {
  var delta = 0;
  var a1 = v1;
  var a2 = v2;
  if (v1.getTime() < v2.getTime()) {
    a1 = v2;
	a2 = v1;
  }
  delta = a1.getTime() - a2.getTime(); // in msecs
  delta /= (1000 * 60 * 60 * 24); // days
  return delta;
}

function fnIsSelectNull(r_strMsg,r_varCtrl)
{
	var flag="";
	// the try catch block is used when the control is not rendered 
	// basically when the user doesnt select wht do i own & wht do i owe checkbox.
	try
	{
		if (r_varCtrl.value=="")
		{
			var l_strErr;
			fieldlist += "\n" + r_strMsg 
			return true;
		}
	}	
	catch (ex)
	{
	
	}
	
	/*
	else if (r_varCtrl.length)
	{
		for (i=0;i< r_varCtrl.length;i++ )
		{
			if(r_varCtrl[i].checked)
				flag="YAP";
		}
		if(flag=="")
		{
			fieldlist += "\n\t" + r_strMsg;
		}
		return true
	}*/

}

////////////////////////////////////////////////////////////////////////
// Customize functions are below																	//				
//																	//				
////////////////////////////////////////////////////////////////////////
function validateInput()
{

	
	var f = document.aspnetForm;
	var msg="";
	if(fnIsSelectNull("First Name",f.htxtFirstName))
	{
		alert("Please enter the First Name");
		f.htxtFirstName.focus();
		return false;
	}	
	if(fnIsSelectNull("Last Name",f.htxtLastName))
	{
		alert("Please enter the Last Name");
		f.htxtLastName.focus();
		return false;
	}
	if(f.hddnGender.selectedIndex == 0)
	{
		alert("Please select a gender");
		f.hddnGender.focus();
		return false;
	}
	if((f.hddndobDay.selectedIndex == 0) && (f.hddndobMonth.selectedIndex == 0) && (f.hddndobYear.selectedIndex == 0))
	{
		alert("Please Select the date of birth");
		f.hddndobDay.focus();
		return false;
	}
	if(fnIsSelectNull("Month",f.hddndobMonth))
	{
		alert("Please select a Month");
		f.hddndobMonth.focus();
		return false;
	}
	if(fnIsSelectNull("Day",f.hddndobDay))
	{
		alert("Please select a Day");
		f.hddndobDay.focus();
		return false;
	}
	if(fnIsSelectNull("Year",f.hddndobYear))
	{
		alert("Please select a year");
		f.hddndobYear.focus();
		return false;
	}
	//fnIsSelectNull("Gender",f.hddnGender)
	
	if(f.hddnMaritalStatus.selectedIndex == 0)
	{
		alert("Please select a Marital Status");
		f.hddnMaritalStatus.focus();
		return false;
	}
	//fnIsSelectNull("",f.hddnMaritalStatus);
	
	
	if(isInvalid(f.htxtFirstName.value)==false)
	{
		fieldlist=fieldlist+"\n Enter Valid Data for First Name"
		f.htxtFirstName.focus();
	//	return false;
	}
	if(isInvalidString(f.htxtFirstName.value)==false)
	{
		fieldlist=fieldlist+"\n Enter Valid Data for First Name"
		f.htxtFirstName.focus();
	}
	if(isInvalid(f.htxtLastName.value)==false)
	{
		fieldlist=fieldlist+"\n Enter Valid Data for Last Name"
		f.htxtLastName.focus();
	}
	if(isInvalidString(f.htxtLastName.value)==false)
	{
		fieldlist=fieldlist+"\n Enter Valid Data for Last Name"
		f.htxtLastName.focus();
	}
	if (f.htxtMonthlyIncome.value=="")
	{
		fieldlist=fieldlist+"\n Enter Numeric value for - Monthly Income"
		f.htxtMonthlyIncome.focus();
	}
	else if (parseInt(f.htxtMonthlyIncome.value)<0)
	{
			alert("Monthly Income can't be -ve");
	//		f.htxtMonthlyIncome.setfocus()
			f.htxtMonthlyIncome.focus();
	}

	/*if (f.htxtMonthlyExpense.value=="")
	{
		//f.htxtMonthlyExpense.value=defvalue;
		fieldlist=fieldlist+"Monthly Expense"
	}*/

	if (f.htxtOtherIncome.value=="")
	{
		//f.htxtOtherIncome.value=defvalue;
		fieldlist=fieldlist+"\n Enter Numeric value for - Income of the other members of family"
		f.htxtOtherIncome.focus();
	}
	if (f.htxtMonthlyExpense.value=="")
	{
		//f.htxtMonthlyExpense.value=defvalue;
		fieldlist=fieldlist+"\n Enter Numeric value for - Monthly Expense"
		f.htxtMonthlyExpense.focus();
	}
	if (f.htxtAnnualPremium.value=="")
	{
		//f.htxtAnnualPremium.value=defvalue;
		fieldlist=fieldlist+"\n Enter Numeric value for - Annual Premium"
		f.htxtAnnualPremium.focus();
	}
	try
	{
		if (f.htxtProperty.value=="")
		{
			//f.htxtProperty.value=defvalue;
			fieldlist=fieldlist+"\n Enter Numeric value for - Property"
			f.htxtProperty.focus();
		}
		if (f.htxtLia_House.value=="")
		{
			//f.htxtLia_House.value=defvalue;
			fieldlist=fieldlist+"\n Enter Numeric value for - Housing/ Property Loan"
			f.htxtLia_House.focus();
		}
		if (f.htxtExp_House.value=="")
		{
			//f.htxtExp_House.value=defvalue;
			fieldlist=fieldlist+"\n Enter Numeric value for - Housing/ Property Loan - Yearly Outflow"
			f.htxtExp_House.focus();
		}
		if (f.htxtCar.value=="")
		{
			//f.htxtCar.value=defvalue;
			fieldlist=fieldlist+"\n Enter Numeric value for - Car"
			f.htxtCar.focus();
		}
		if (f.htxtLia_CarLoan.value=="")
		{
			//f.htxtMonthlyExpense.value=defvalue;
			fieldlist=fieldlist+"\n Enter Numeric value for - Car loan (Amount) "
			f.htxtLia_CarLoan.focus();
		}
		if (f.htxtExp_CarLoan.value=="")
		{
			//f.htxtExp_CarLoan.value=defvalue;
			fieldlist=fieldlist+"\n Enter Numeric value for - Car loan (Yearly Outflow)"
			f.htxtExp_CarLoan.focus();
		}
		if (f.htxtOtherLoan.value=="")
		{
			//f.htxtMonthlyExpense.value=defvalue;
			fieldlist=fieldlist+"\n Enter Numeric value for - Other Loans"
			f.htxtOtherLoan.focus();
		}
		if (f.htxtinv_ShortTermAsset.value=="")
		{
			//f.htxtinv_ShortTermAsset.value=defvalue;
			fieldlist=fieldlist+"\n Enter Numeric value for - Short Term (FDs. Bonds)"
			f.htxtinv_ShortTermAsset.focus();
		}
		if (f.htxtinv_ShortTermIncome.value=="")
		{
			//f.insurance.value=defvalue;
			fieldlist=fieldlist+"\n Enter Numeric value for - Short Term (yearly inflow)"
			f.htxtinv_ShortTermIncome.focus();
		}
		/*
		if (f.maturityless.value=="")
		{
			f.maturityless.value=defvalue;
			_fieldlist=_fieldlist+"\n\t maturityless"
		}
		*/
		if (f.htxtAssest_LongTerm.value=="")
		{
			//f.htxtAssest_LongTerm.value=defvalue;
			fieldlist=fieldlist+"\n Enter Numeric value for - Long Term (Shares, Mutual Funds)"
			f.htxtAssest_LongTerm.focus();
		}
		if (f.htxtIns_LongTerm.value=="")
		{
			//f.htxtIns_LongTerm.value=defvalue;
			fieldlist=fieldlist+"\n Enter Numeric value for - Long Term (yearly inflow)"
			f.htxtIns_LongTerm.focus();
		}
		
		if (f.htxtInsurance.value=="")
		{
			//f.maturitymore.value=defvalue;
			fieldlist=fieldlist+"\n Enter Numeric value for - Insurance"
			f.htxtInsurance.focus();
		}
		if (f.htxtProvidentFund.value=="")
		{
			//f.htxtProvidentFund.value=defvalue;
			fieldlist=fieldlist+"\n Enter Numeric value for - Provident Fund"
			f.htxtProvidentFund.focus();
		}
		if (f.htxtOtherExpense.value=="")
		{
			//f.htxtOtherExpense.value=defvalue;
			fieldlist=fieldlist+"\n Enter Numeric value for - Other Expense"
			f.htxtOtherExpense.focus();
		}
		if (f.htxtSuperAnnuation.value=="")
		{
			//f.htxtSuperAnnuation.value=defvalue;
			fieldlist=fieldlist+"\n Enter Numeric value for - Superannuation"
			f.htxtSuperAnnuation.focus();
		}
		if (f.htxtGratuity.value=="")
		{
			//f.htxtGratuity.value=defvalue;
			fieldlist=fieldlist+"\n Enter Numeric value for - Gratuity"
			f.htxtGratuity.focus();
		}
	}
	catch (ex)
	{	}

	if(fieldlist=="")
		return true;
	else
		alert("Please tell us following - "+fieldlist);
		fieldlist="";
		return false;
}

function Insurancecalc()
{
	
	var f=document.aspnetForm;
	var need1="",need2="",need3="",imgsrc="",moreUrl="";
	var rate = "";
	needUrl="",y=0;
	var ann_factor = "";
	var str_rider = "";
	

	if(!validateInput())
		;
	else
	{
		var qstring="";
		//What do I own - variables. 
		var htxtProperty ;
		var htxtCar  ;
		var htxtinv_ShortTermAsset ;
		var htxtAssest_LongTerm ;
		var htxtInsurance ;
		var htxtProvidentFund ;
		var htxtSuperAnnuation ;
		var htxtGratuity ;
		var hddnAnnuity_Factor ;
		var htxtCar2 ;
		var htxtinv_ShortTermIncome ;
		var htxtIns_LongTerm ;
		try
		{
			//What do I own
			htxtProperty = f.htxtProperty.value;
		}
		catch (ex)
		{
			htxtProperty = 0;
		}
		try
		{
			htxtCar = f.htxtCar.value;
		}
		catch(ex)
		{
			htxtCar = 0 ;
		}
		try
		{
			htxtinv_ShortTermAsset = f.htxtinv_ShortTermAsset.value ;
		}
		catch(ex)
		{
			htxtinv_ShortTermAsset = 0;
		}
		try
		{
			htxtAssest_LongTerm = f.htxtAssest_LongTerm.value;
		}
		catch(ex)
		{
			htxtAssest_LongTerm = 0;
		}
		try
		{
			htxtInsurance = f.htxtInsurance.value ;
		}
		catch(ex)
		{
			htxtInsurance = 0;
		}
		try
		{
			htxtProvidentFund = f.htxtProvidentFund.value;
		}
		catch(ex)
		{
			htxtProvidentFund = 0;
		}
		try
		{
			htxtSuperAnnuation = f.htxtSuperAnnuation.value ;
		}
		catch(ex)
		{
			htxtSuperAnnuation = 0;
		}
		try
		{
			htxtGratuity = f.htxtGratuity.value ;
		}
		catch(ex)
		{
			htxtGratuity = 0;
		}
		try
		{
			hddnAnnuity_Factor = f.hddnAnnuity_Factor.value ;
		}
		catch(ex)
		{
			hddnAnnuity_Factor = 5 ;
		}
		try
		{
			htxtCar2 = f.htxtCar2.value ;
		}
		catch(ex)
		{
			htxtCar2 = 0;
		}
		try
		{
			htxtinv_ShortTermIncome = f.htxtinv_ShortTermIncome.value ;
		}
		catch(ex)
		{
			htxtinv_ShortTermIncome = 0;
		}
		try
		{
			htxtIns_LongTerm = f.htxtIns_LongTerm.value ;
		}
		catch(ex)
		{
			htxtIns_LongTerm = 0;
		}
		//What do I owe - variables
		try
		{
			htxtLia_House = f.htxtLia_House.value ;
		}
		catch(ex)
		{
			htxtLia_House = 0;
		}
		try
		{
			htxtLia_CarLoan = f.htxtLia_CarLoan.value;
		}
		catch(ex)
		{
			htxtLia_CarLoan = 0;
		}
		try
		{
			htxtOtherLoan = f.htxtOtherLoan.value ;
		}
		catch(ex)
		{
			htxtOtherLoan = 0;
		}
		try
		{
			htxtExp_House = f.htxtExp_House.value ;
		}
		catch(ex)
		{
			htxtExp_House = 0;
		}
		try
		{
			htxtExp_CarLoan = f.htxtExp_CarLoan.value ;
		}
		catch(ex)
		{
			htxtExp_CarLoan = 0;
		}
		try
		{
			htxtOtherLoan2 = f.htxtOtherLoan2.value;
		}
		catch(ex)
		{
			htxtOtherLoan2 = 0;
		}
		try
		{
			htxtOtherExpense = f.htxtOtherExpense.value ;
		}
		catch(ex)
		{
			htxtOtherExpense = 0;
		}
			
		//Defaultval('0');
		
		qstring="name="+f.htxtFirstName.value+"&lastname="+f.htxtLastName.value+"&dobMonth="+f.hddndobMonth.value+"&dobDay="+f.hddndobDay.value+"&dobYear="+f.hddndobYear.value+"&gender="+f.hddnGender.value+"&maritalstatus="+f.hddnMaritalStatus.value;

		var curDate = new Date(); 
		var age=parseInt(curDate.getYear())- parseInt(f.hddndobYear.value);
			
		var ageDiff=parseInt(f.htxtExpectedAge.value)-parseInt(f.hddnRetirementAge.value);
		
		
		//Insurance required to protect assets
		
		X=-parseInt(htxtinv_ShortTermAsset)-parseInt(htxtAssest_LongTerm) +
				parseInt(htxtLia_House)+parseInt(htxtLia_CarLoan)+
				parseInt(htxtOtherLoan)+parseInt(htxtOtherExpense);
		if (!isNaN(X))
			if (X>0)
				f.htxtins_ProtectAssets2.value=X - parseInt(htxtInsurance);
			else
				f.htxtins_ProtectAssets2.value=0;
		else
			f.htxtins_ProtectAssets2.value="Error: Please check you inputs";

		//Insurance required to protect lifestyle
		X=parseInt(f.htxtMonthlyExpense.value) * 12 * 
			(ageDiff)- parseInt(htxtProvidentFund) -
			parseInt(htxtSuperAnnuation) - parseInt(htxtGratuity)-
			parseInt(htxtinv_ShortTermAsset) - parseInt(htxtAssest_LongTerm);
		if (X<0)
		f.htxtins_ProtectLifestyle2.value=0
		else
		f.htxtins_ProtectLifestyle2.value=X;



// Insurance required to protect Wealth 
		//X= - parseInt(htxtinv_ShortTermAsset)-parseInt(htxtAssest_LongTerm) +
		//		parseInt(htxtLia_House)+parseInt(htxtOtherExpense);
	     // X = (- parseInt(htxtAssest_LongTerm) - parseInt(htxtinv_ShortTermAsset) - parseInt(htxtInsurance) )+  (parseInt(htxtLia_House) +  parseInt(htxtOtherExpense));
		//alert(- parseInt(htxtAssest_LongTerm));
		//alert(parseInt(htxtinv_ShortTermAsset));
		T = - parseInt(htxtAssest_LongTerm) - parseInt(htxtinv_ShortTermAsset) - parseInt(htxtInsurance) ;
		Y = parseInt(htxtLia_House) +  parseInt(htxtOtherExpense);
		X = T + Y
		//parseInt(htxtInsurance) +  parseInt(htxtLia_House) +  parseInt(htxtOtherExpense));
		
		if (!isNaN(X))
			if (X<0)
				f.htxtins_ProtectWealth2.value=-X
			else
				f.htxtins_ProtectWealth2.value=0;
		else
			f.htxtins_ProtectWealth2.value="Error: Please check you inputs";

// Insurance Required to protect earning capacity - changed done by Dinesh on 28/11/2003
						
			X = parseInt(f.hddnRetirementAge.value)-parseInt(age);
			X = X + "";
			y = X.substr(X.length-1,1);
			//alert(y);
			// setting the hddnAnnuity_Factor value to ann_factor variable.
			ann_factor = hddnAnnuity_Factor ;
			
			if (y == "0" || y=="5")
			{
				X = parseInt(X);
				
			}

			else if (y == "1" || y=="2")
			{
				X =  parseInt(X) - parseInt(y) ;
			}
			else if (y == "3" || y=="4")
			{
				X =  (parseInt(X) - parseInt(y)) + 5;
			}
			else if (y == "6" || y=="7")
			{
				X =  parseInt(X) - parseInt(y) +5 ;
			}
			else if (y == "8" || y=="9")
			{
				X =  (parseInt(X) + 10) - parseInt(y) ;
			}
			
			if (X == "5")
			{
				if (ann_factor == "5")
				{
					rate = "4.33";
				}
				if (ann_factor == "6")
				{
					rate = "4.21";
				}
				if (ann_factor == "7")
				{
					rate = "4.10";
				}
				if (ann_factor == "8")
				{
					rate = "3.99";
				}
				if (ann_factor == "9")
				{
					rate = "3.89";
				}
				if (ann_factor == "10")
				{
					rate = "3.79";
				}
				if (ann_factor == "11")
				{
					rate = "3.70";
				}
				if (ann_factor == "12")
				{
					rate = "3.60";
				}
				if (ann_factor == "13")
				{
					rate = "3.52";
				}
				if (ann_factor == "14")
				{
					rate = "3.43";
				}
			}	
			else if (X == "10")
			{
				if (ann_factor == "5")
				{
					rate = "7.72";
				}
				if (ann_factor == "6")
				{
					rate = "7.36";
				}
				if (ann_factor == "7")
				{
					rate = "7.02";
				}
				if (ann_factor == "8")
				{
					rate = "6.71";
				}
				if (ann_factor == "9")
				{
					rate = "6.42";
				}
				if (ann_factor == "10")
				{
					rate = "6.14";
				}
				if (ann_factor == "11")
				{
					rate = "5.89";
				}
				if (ann_factor == "12")
				{
					rate = "5.65";
				}
				if (ann_factor == "13")
				{
					rate = "5.43";
				}
				if (ann_factor == "14")
				{
					rate = "5.22";
				}
			}
			else if (X == "15")
			{
				if (ann_factor == "5")
				{
					rate = "10.38";
				}
				if (ann_factor == "6")
				{
					rate = "9.71";
				}
				if (ann_factor == "7")
				{
					rate = "9.11";
				}
				if (ann_factor == "8")
				{
					rate = "8.56";
				}
				if (ann_factor == "9")
				{
					rate = "8.06";
				}
				if (ann_factor == "10")
				{
					rate = "7.61";
				}
				if (ann_factor == "11")
				{
					rate = "7.19";
				}
				if (ann_factor == "12")
				{
					rate = "6.81";
				}
				if (ann_factor == "13")
				{
					rate = "6.46";
				}
				if (ann_factor == "14")
				{
					rate = "6.14";
				}
			}
			else if (X == "20")
			{
				if (ann_factor == "5")
				{
					rate = "12.46";
				}
				if (ann_factor == "6")
				{
					rate = "11.47";
				}
				if (ann_factor == "7")
				{
					rate = "10.59";
				}
				if (ann_factor == "8")
				{
					rate = "9.82";
				}
				if (ann_factor == "9")
				{
					rate = "9.13";
				}
				if (ann_factor == "10")
				{
					rate = "8.51";
				}
				if (ann_factor == "11")
				{
					rate = "7.96";
				}
				if (ann_factor == "12")
				{
					rate = "7.47";
				}
				if (ann_factor == "13")
				{
					rate = "7.02";
				}
				if (ann_factor == "14")
				{
					rate = "6.62";
				}
			}
			else if (X == "25")
			{
				if (ann_factor == "5")
				{
					rate = "14.09";
				}
				if (ann_factor == "6")
				{
					rate = "12.78";
				}
				if (ann_factor == "7")
				{
					rate = "11.65";
				}
				if (ann_factor == "8")
				{
					rate = "10.68";
				}
				if (ann_factor == "9")
				{
					rate = "9.82";
				}
				if (ann_factor == "10")
				{
					rate = "9.08";
				}
				if (ann_factor == "11")
				{
					rate = "8.42";
				}
				if (ann_factor == "12")
				{
					rate = "7.84";
				}
				if (ann_factor == "13")
				{
					rate = "7.33";
				}
				if (ann_factor == "14")
				{
					rate = "6.87";
				}
			}
			else if (X == "30")
			{
				if (ann_factor == "5")
				{
					rate = "15.37";
				}
				if (ann_factor == "6")
				{
					rate = "13.77";
				}
				if (ann_factor == "7")
				{
					rate = "12.41";
				}
				if (ann_factor == "8")
				{
					rate = "11.26";
				}
				if (ann_factor == "9")
				{
					rate = "10.27";
				}
				if (ann_factor == "10")
				{
					rate = "9.43";
				}
				if (ann_factor == "11")
				{
					rate = "8.69";
				}
				if (ann_factor == "12")
				{
					rate = "8.06";
				}
				if (ann_factor == "13")
				{
					rate = "7.50";
				}
				if (ann_factor == "14")
				{
					rate = "7.00";
				}
			}
			else if (X == "35")
			{
				if (ann_factor == "5")
				{
					rate = "15.37";
				}
				if (ann_factor == "6")
				{
					rate = "13.77";
				}
				if (ann_factor == "7")
				{
					rate = "12.41";
				}
				if (ann_factor == "8")
				{
					rate = "11.26";
				}
				if (ann_factor == "9")
				{
					rate = "10.27";
				}
				if (ann_factor == "10")
				{
					rate = "9.43";
				}
				if (ann_factor == "11")
				{
					rate = "8.69";
				}
				if (ann_factor == "12")
				{
					rate = "8.06";
				}
				if (ann_factor == "13")
				{
					rate = "7.50";
				}
				if (ann_factor == "14")
				{
					rate = "7.00";
				}
			}
			else if (X == "40")
			{
				if (ann_factor == "5")
				{
						
					rate = "17.16";
				}
				if (ann_factor == "6")
				{	
					rate = "15.05";
				}
				 if (ann_factor == "7")
				{	
					rate = "13.33";
				}
				if (ann_factor == "8")
				{
					rate = "11.93";
				}
				 if (ann_factor == "9")
				{
					rate = "10.76";
				}
				if (ann_factor == "10")
				{
					rate = "9.78";
				}
				if (ann_factor == "11")
				{
					rate = "8.95";
				}
				if (ann_factor == "12")
				{
					rate = "8.24";
				}
				if (ann_factor == "13")
				{
					rate = "7.63";
				}
				if (ann_factor == "14")
				{
					rate = "7.11";
				}
			}
			else if (X == "45")
			{
				if (ann_factor == "5")
				{
					rate = "17.16";
				}
				 if (ann_factor == "6")
				{
					rate = "15.05";
				}
				if (ann_factor == "7")
				{
					rate = "13.33";
				}
				if (ann_factor == "8")
				{
					rate = "11.93";
				}
				if (ann_factor == "9")
				{
					rate = "10.76";
				}
				if (ann_factor == "10")
				{
					rate = "9.78";
				}
				if (ann_factor == "11")
				{
					rate = "8.95";
				}
				if (ann_factor == "12")
				{
					rate = "8.24";
				}
				if (ann_factor == "13")
				{
					rate = "7.63";
				}
				if (ann_factor == "14")
				{
					rate = "7.11";
				}
			}
			else if (X >= "50")
			{
				if (ann_factor == "5")
				{
					rate = "18.26";
				}
				if (ann_factor == "6")
				{
					rate = "15.76";
				}
				if (ann_factor == "7")
				{
					rate = "13.80";
				}
				if (ann_factor == "8")
				{
					rate = "12.23";
				}
				if (ann_factor == "9")
				{
					rate = "10.96";
				}
				if (ann_factor == "10")
				{
					rate = "9.91";
				}
				if (ann_factor == "11")
				{
					rate = "9.04";
				}
				if (ann_factor == "12")
				{
					rate = "8.30";
				}
				if (ann_factor == "13")
				{
					rate = "7.68";
				}
				if (ann_factor == "14")
				{
					rate = "7.13";
				}
			}
			//alert(ann_factor);
			f.htxtins_ProtectEarning.value = parseInt((f.htxtMonthlyExpense.value) * (12 * (rate)));

		
//		alert(str_rider);
		
		need = "";


	
		if (parseInt(f.htxtins_ProtectWealth2.value) > 0)
		{
			
			//document.all.plan_wealth_image.innerHTML = str_imgP;
			document.all.plan_wealth_image.innerHTML = "";
		
			document.all.rider.innerHTML = str_rider ;
			
		}
		
		// else if (parseInt(f.ins_ProtectWealth.value)<= 0) //#Satyam#-16-Jan-2006: Giving same name for Id and name of the input tags whereever possible.
		 else if (parseInt(f.htxtins_ProtectWealth2.value)<= 0)
		{
		//	alert(f.htxtins_ProtectWealth2.value);
			document.all.plan_wealth.innerHTML = "";
			document.all.plan_wealth_image.innerHTML = "";
			document.all.arrow_assets_image.innerHTML = "";
			document.all.arrow_wealth_image.innerHTML = "";
			document.all.rider.innerHTML = str_rider ;
		}

		//if (parseInt(f.ins_ProtectLifestyle.value)>0) //#Satyam#-16-Jan-2006: Giving same name for Id and name of the input tags whereever possible.
		if (parseInt(f.htxtins_ProtectLifestyle2.value)>0) 
		{
		
		
			document.all.rider.innerHTML = str_rider ;
			
		}
		//else if (parseInt(f.ins_ProtectLifestyle.value)<=0) //#Satyam#-16-Jan-2006: Giving same name for Id and name of the input tags whereever possible.
		else if (parseInt(f.htxtins_ProtectLifestyle2.value)<=0)
		{
			document.all.plan_lifestyle.innerHTML= "";
			document.all.plan_lifestyle_image.innerHTML= "";
			document.all.arrow_lifestyle_image.innerHTML = "";
			document.all.rider.innerHTML = str_rider ;
		}
		if (parseInt(f.htxtins_ProtectAssets2.value) > 0)
				{
				document.all.plan_assets.innerHTML = str_assets;
				
				document.all.rider.innerHTML = str_rider ;
				}
		else if (parseInt(f.htxtins_ProtectAssets2.value) <= 0)
				{
				document.all.plan_assets.innerHTML = "";
				document.all.arrow_assets_image.innerHTML = "";
				document.all.rider.innerHTML = str_rider ;
				}

		if (parseInt(f.htxtins_ProtectEarning.value) > 0 )
				{
				
			
				document.all.rider.innerHTML = str_rider ;	
				
				
				}
		else if (parseInt(f.htxtins_ProtectEarning.value) <= 0 )
			{
				document.all.plan_capacity.innerHTML ="";
				document.all.arrow_earning_image.innerHTML = "";
				document.all.rider.innerHTML = str_rider ;		
				}
				MM_swapImage('btnImage','',imgsrc,1);
			} 

if (f.htxtins_ProtectLifestyle2.value < 0)
		{
			f.htxtins_ProtectLifestyle2.value = 0
		}
	

if (f.htxtins_ProtectEarning.value < 0)
			{
				f.htxtins_ProtectEarning.value = 0
		    }


	if (f.htxtins_ProtectAssets2.value < 0)
			{
				f.htxtins_ProtectAssets2.value = 0
			}

	if (f.htxtins_ProtectWealth2.value < 0)
			{
				f.htxtins_ProtectWealth2.value = 0
			}
	document.all.hdnFname.value=f.htxtFirstName.value;
	document.all.hdnLname.value=f.htxtLastName.value;
	document.all.hdnGender.value=f.hddnGender.value;
	//document.all.hdnDOB.value=f.htxtins_ProtectWealth2.value;
	//alert (document.all.hdnFname.value);
	//alert (document.all.hdnLname.value);
	//alert (document.all.hdnGender.value);

	//alert ("end of the function");

	return false;
}


function Defaultval(defvalue)
{	
	var f=document.aspnetForm;
	var _fieldlist=""
	if (f.htxtMonthlyIncome.value=="")
	{
		f.htxtMonthlyIncome.value=defvalue;
		_fieldlist=_fieldlist+"\n\t htxtMonthlyIncome"
	}
	else if (parseInt(f.htxtMonthlyIncome.value)<0){
			alert("Monthly Income can't be -ve");
	//		f.htxtMonthlyIncome.setfocus()
	}

	if (f.htxtMonthlyExpense.value=="")
	{
		f.htxtMonthlyExpense.value=defvalue;
		_fieldlist=_fieldlist+"\n\t htxtMonthlyExpense"
	}

	if (f.htxtOtherIncome.value=="")
	{
		f.htxtOtherIncome.value=defvalue;
		_fieldlist=_fieldlist+"\n\t htxtOtherIncome"
	}
	if (f.htxtMonthlyExpense.value=="")
	{
		f.htxtMonthlyExpense.value=defvalue;
		_fieldlist=_fieldlist+"\n\t htxtMonthlyExpense"
	}
	if (f.htxtProperty.value=="")
	{
		f.htxtProperty.value=defvalue;
		_fieldlist=_fieldlist+"\n\t htxtProperty"
	}
	if (f.htxtLia_House.value=="")
	{
		f.htxtLia_House.value=defvalue;
		_fieldlist=_fieldlist+"\n\t htxtLia_House"
	}
	if (f.htxtExp_House.value=="")
	{
		f.htxtExp_House.value=defvalue;
		_fieldlist=_fieldlist+"\n\t htxtExp_House"
	}
	if (f.htxtCar.value=="")
	{
		f.htxtCar.value=defvalue;
		_fieldlist=_fieldlist+"\n\t htxtCar"
	}
	if (f.htxtLia_CarLoan.value=="")
	{
		f.htxtMonthlyExpense.value=defvalue;
		_fieldlist=_fieldlist+"\n\t htxtLia_CarLoan"
	}
	if (f.htxtExp_CarLoan.value=="")
	{
		f.htxtExp_CarLoan.value=defvalue;
		_fieldlist=_fieldlist+"\n\t htxtExp_CarLoan"
	}
	if (f.htxtOtherLoan.value=="")
	{
		f.htxtMonthlyExpense.value=defvalue;
		_fieldlist=_fieldlist+"\n\t htxtOtherLoan"
	}
	if (f.htxtinv_ShortTermAsset.value=="")
	{
		f.htxtinv_ShortTermAsset.value=defvalue;
		_fieldlist=_fieldlist+"\n\t htxtinv_ShortTermAsset"
	}
	/*
	if (f.maturityless.value=="")
	{
		f.maturityless.value=defvalue;
		_fieldlist=_fieldlist+"\n\t maturityless"
	}
	*/
	if (f.htxtAssest_LongTerm.value=="")
	{
		f.htxtAssest_LongTerm.value=defvalue;
		_fieldlist=_fieldlist+"\n\t htxtAssest_LongTerm"
	}
	if (f.htxtIns_LongTerm.value=="")
	{
		f.htxtIns_LongTerm.value=defvalue;
		_fieldlist=_fieldlist+"\n\t htxtIns_LongTerm"
	}
	/*
	if (f.maturitymore.value=="")
	{
		f.maturitymore.value=defvalue;
		_fieldlist=_fieldlist+"\n\t maturitymore"
	}
	*/
	if (f.htxtinv_ShortTermIncome.value=="")
	{
		f.htxtInsurance.value=defvalue;
		_fieldlist=_fieldlist+"\n\t htxtInsurance"
	}
	if (f.htxtAnnualPremium.value=="")
	{
		f.htxtAnnualPremium.value=defvalue;
		_fieldlist=_fieldlist+"\n\t htxtAnnualPremium"
	}
	if (f.htxtProvidentFund.value=="")
	{
		f.htxtProvidentFund.value=defvalue;
		_fieldlist=_fieldlist+"\n\t htxtProvidentFund"
	}
	if (f.htxtOtherExpense.value=="")
	{
		f.htxtOtherExpense.value=defvalue;
		_fieldlist=_fieldlist+"\n\t htxtOtherExpense"
	}
	if (f.htxtSuperAnnuation.value=="")
	{
		f.htxtSuperAnnuation.value=defvalue;
		_fieldlist=_fieldlist+"\n\t htxtSuperAnnuation"
	}
	if (f.htxtGratuity.value=="")
	{
		f.htxtGratuity.value=defvalue;
		_fieldlist=_fieldlist+"\n\t htxtGratuity"
	}
	//return true;
}
function isInvalidString(str)
{
 var invalidChars = "0123456789";
 for(s=0;s<str.length;s++) //filter for invalid chars
	    {
	    	if(invalidChars.indexOf(str.charAt(s)) != -1) return false;
	    }
	   return true; 
}
function isInvalid(str)
{
 var invalidChars = "\t\n\r\\\"\'#$%^&*()+=!~`/;:<>?,[]{}";
 for(s=0;s<str.length;s++) //filter for invalid chars
	    {
	    	if(invalidChars.indexOf(str.charAt(s)) != -1) return false;
	    }
	   return true; 
}  
//END


//Compounding Tools
		function validateFields()
{
	 if(document.getElementById("startamt").value=="" && document.getElementById("monthly").value=="" )
	{
		alert("Please input non-zero values");
		return false;
	}
	 if(document.getElementById("returnVal").value==""||document.getElementById("returnVal").value=="0")
	 {
		alert("please input non-zero  value");
		document.getElementById("returnVal").focus();
		return false;
	 }
	if(document.getElementById("year").value=="")
	{
		alert("please enter year");
		document.getElementById("year").focus();
		return false;
	}
	frmobj=document.aspnetForm;
	
	K=frmobj.startamt.value*1;
	I=frmobj.monthly.value*1;
	R=frmobj.returnVal.value*0.01;
	n=frmobj.year.value*12;
	tempval=Math.pow((1+R),(n/12));
	tempval2=(tempval-1)/(Math.pow((1+R),(1/12))-1);
	ans=((K*tempval) +(I*tempval2));
	ans=Math.floor(ans)

	dispstr="<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" valign=\"0\" width=\"470\"><tr>";
	dispstr=dispstr+"<tr><td height=\"5\"></td></tr>";
	dispstr=dispstr+"<tr><td height=\"10\"><img src=\"../images/common/line.gif\" height=\"1\" width=\"150%\"></td></tr>";						
	dispstr=dispstr+"<tr><td class=\"link\" align=\"right\" valign=\"bottom\" style=\"padding-right:10;\"><b>Your computed amount is Rs."+ans+"</b></td></tr>";
	dispstr=dispstr+"</table>";
	
	
	
	document.getElementById("ansdiv").innerHTML=dispstr;
		//document.all.ansdiv.innerHTML=dispstr;
	//	document.all.mag2.style.visibility="visible";
	
}

function checkdata(val1)
{
//document.all.ansdiv.style.visibility='hidden';
  valid="1234567890";
  var ok = "yes";
  var temp;
  for (var i=0; i<=val1.value.length; i++)
  {
   //temp = "" + val1.value.substring(i, i+1);
   temp = "" + val1.value.substring(i, i+1);
   if (valid.indexOf(temp) == "-1") ok = "no";	
  }

  if (ok == "no") 
  {
    	alert("Please enter numeric non zero value")
		val1.value=""
	    val1.focus();
 }
 }

 function checkreturn(val1)
 {
	if(document.getElementById("returnVal").value >100)
	{
		alert("please enter value less than or equal to 100");
		document.getElementById("returnVal").value ="";
		document.getElementById("returnVal").focus();
		return false;
	}
 }
			

//END


//Current Expenses Calc

var gblValSum;
var gblValSum1;
var gblValSum2;
var gblValSum3;
var gblValSum4;
var gblValSum5;
var dispstr;
var dispstr1;
function check(val1,nX)
{
  valid="1234567890";
  var ok = "yes";
  var temp;
  var nX1=nX+1;
  for (var i=0; i< val1.value.length; i++)
  {
   temp = "" + val1.value.substring(i, i+1);
   if (valid.indexOf(temp) == "-1") ok = "no";	
   }

  if (ok == "no") 
  {
    	alert("Please enter numeric value")
	//	val1.value=""
		document.getElementById("annually"+nX).value=0;
		document.getElementById("monthly"+nX).value="";
	    val1.focus();
   }
	gblValSum="";
	gblValSum1="";
	gblValSum2="";
	gblValSum3="";
	gblValSum4="";
	gblValSum5="";
	dispstr="";
	dispstr1="";

if(nX<8)
{
	var a=document.getElementById("monthly"+nX).value;
	if (a!=0)
	{
		document.getElementById("annually"+nX).value=a *12;
	}
	else
	{
		document.getElementById("annually"+nX).value=0;
	}

}

if(nX>7)
{
	var b=document.getElementById("monthly"+nX).value;
	if (b!=0)
	{
		document.getElementById("annually"+nX).value=b *12;
	}
	else
	{
		document.getElementById("annually"+nX).value=0;
	}

}
	for(var i=0; i<8; i++)
 
		{			
			gblValSum=Number(gblValSum) + Number(document.getElementById("monthly"+i).value);				
			gblValSum1=Number(gblValSum1) + Number(document.getElementById("annually"+i).value);		
		}

		dispstr="<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" valign=\"0\" width=\"150\"><tr>";
		dispstr=dispstr+"<tr><td class=\"StoryHd\" align=\"right\" valign=\"bottom\" width=\"75\" style=\"padding-right:10\" ><b>"+gblValSum+"</b></td>";
		dispstr=dispstr+"<td class=\"StoryHd\" align=\"right\" valign=\"bottom\" width=\"75\" ><b>"+gblValSum1+"</b></td></tr>";
	
		dispstr=dispstr+"</table>";
	
			document.getElementById("total1").innerHTML=dispstr;
			document.getElementById("total1").style.visibility='visible';
		
	for(var i=8; i<13;i++)

		{	
			gblValSum2=Number(gblValSum2) + Number(document.getElementById("monthly"+i).value);			
			gblValSum3=Number(gblValSum3) + Number(document.getElementById("annually"+i).value);
		}
		
		dispstr1="<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" valign=\"0\" width=\"150\"><tr>";
		dispstr1=dispstr1+"<tr><td class=\"StoryHd\" align=\"right\" valign=\"bottom\" width=\"75\" style=\"padding-right:10\" ><b>"+gblValSum2+"</b></td>";
		dispstr1=dispstr1+"<td class=\"StoryHd\" align=\"right\" valign=\"bottom\" width=\"75\" ><b>"+gblValSum3+"</b></td></tr>";
		dispstr1=dispstr1+"</table>";
		
			document.getElementById("total2").innerHTML=dispstr1;
			document.getElementById("total2").style.visibility='visible';
		

		gblValSum4 = Number(gblValSum) + Number(gblValSum2)
		gblValSum5= Number(gblValSum1) + Number(gblValSum3)
	
		dispstr2="<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" valign=\"0\" width=\"150\"><tr>";
		dispstr2=dispstr2+"<tr><td class=\"StoryHd\" align=\"right\" valign=\"bottom\" width=\"75\" style=\"padding-right:10\" ><b>"+gblValSum4+"</b></td>";
		dispstr2=dispstr2+"<td class=\"StoryHd\" align=\"right\" valign=\"bottom\" width=\"75\"><b>"+gblValSum5+"</b></td></tr>";
		dispstr2=dispstr2+"</table>";

	document.getElementById("total3").innerHTML=dispstr2;
			document.getElementById("total3").style.visibility='visible';
		
 }

function validateCEXP(val1,nX)
{

	  valid="1234567890";
	  var ok = "yes";
	  var temp;
	  var nX1=nX+1;	
	  for (var i=0; i< val1.value.length; i++)
	  {
	   temp = "" + val1.value.substring(i, i+1);
	   if (valid.indexOf(temp) == "-1") ok = "no";	
	   }

	  if (ok == "no") 
	  {
			alert("Please enter numeric value")
//			val1.value=""
			document.getElementById("annually"+nX).value=0;
			document.getElementById("monthly"+nX).value="";
			val1.focus();
	   }

	gblValSum="";
	gblValSum1="";
	gblValSum2="";
	gblValSum3="";
	gblValSum4="";
	gblValSum5="";
	dispstr="";
	dispstr1="";

if(nX<8)
{
		var b=document.getElementById("annually"+nX).value
		if (b!=0)
		{
			document.getElementById("monthly"+nX).value=Math.floor(b/12);			
		}
		else
		{
			document.getElementById("monthly"+nX).value="";
		}
}
if(nX>7)
{
	var b=document.getElementById("annually"+nX).value;
	if (b!=0)
	{
		document.getElementById("monthly"+nX).value=Math.floor(b/12);
	}
	else
	{
		document.getElementById("monthly"+nX).value="";
	}
}
	
	for(var i=0; i<8; i++)
 
		{
			gblValSum1=Number(gblValSum1) + Number(document.getElementById("annually"+i).value);
			gblValSum=Number(gblValSum) + Number(document.getElementById("monthly"+i).value);				
		}
		dispstr="<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" valign=\"0\" width=\"150\"><tr>";
		dispstr=dispstr+"<tr><td class=\"StoryHd\" align=\"right\" valign=\"bottom\" width=\"75\" style=\"padding-right:10\" ><b>"+gblValSum+"</b></td>";
		dispstr=dispstr+"<td class=\"StoryHd\" align=\"right\" valign=\"bottom\" width=\"75\" ><b>"+gblValSum1+"</b></td></tr>";
	
		dispstr=dispstr+"</table>";
	
			document.all.total1.innerHTML=dispstr;
			document.all.total1.style.visibility='visible';
		

	for(var i=8; i<13;i++)
		{		
			gblValSum2=Number(gblValSum2) + Number(document.getElementById("monthly"+i).value);				
			gblValSum3=Number(gblValSum3) + Number(document.getElementById("annually"+i).value);
		}

		dispstr1="<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" valign=\"0\" width=\"150\"><tr>";
		dispstr1=dispstr1+"<tr><td class=\"StoryHd\" align=\"right\" valign=\"bottom\" width=\"75\" style=\"padding-right:10\" ><b>"+gblValSum2+"</b></td>";
		dispstr1=dispstr1+"<td class=\"StoryHd\" align=\"right\" valign=\"bottom\" width=\"75\" ><b>"+gblValSum3+"</b></td></tr>";
	
		dispstr1=dispstr1+"</table>";
		
			document.all.total2.innerHTML=dispstr1;
			document.all.total2.style.visibility='visible';
		

	gblValSum4 = Number(gblValSum) + Number(gblValSum2)
	gblValSum5= Number(gblValSum1) + Number(gblValSum3)

	dispstr2="<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" valign=\"0\" width=\"150\"><tr>";
	dispstr2=dispstr2+"<tr><td class=\"StoryHd\" align=\"right\" valign=\"bottom\" width=\"75\" style=\"padding-right:10\" ><b>"+gblValSum4+"</b></td>";
	dispstr2=dispstr2+"<td class=\"StoryHd\" align=\"right\" valign=\"bottom\" width=\"75\"><b>"+gblValSum5+"</b></td></tr>";

	dispstr2=dispstr2+"</table>";

	
		document.all.total3.innerHTML=dispstr2;
		document.all.total3.style.visibility='visible';
		

}

function validate1(i)
{		
	var numVal;
	numVal=document.getElementById("annually"+i).value;
	if((numVal<12)&&(numVal!=0))
	{
		alert("please enter value greater than or equal to 12");
		document.getElementById("annually"+i).value=0;
		document.getElementById("annually"+i).focus();
		validateCEXP(document.getElementById("annually"+i),i)
//		return false;
	}


}

//END


// Premium Calculator

function ConfirmChoice(url) 
{ 
answer = confirm("You are being redirected to Birla Sun Life Insurance Website")
if (answer !=0) 
{ 

//location = url;
window.open(url,"_blank")
} 

}

function ClickMe()
  {
  
  		StrMsg="You are being redirected to Birla Sun Life Insurance Website."
	
		if(document.getElementById("radOption1").checked)
		 {
			StrVal=document.getElementById("radOption1").value
		 	alert(StrMsg)
			window.open(StrVal)
		 }
	
		if(document.getElementById("radOption2").checked)
		 {
			StrVal=document.getElementById("radOption2").value
		 	alert(StrMsg)
			window.open(StrVal)
		 }
	
		if(document.getElementById("radOption3").checked)
		 {
			StrVal=document.getElementById("radOption3").value
		 	alert(StrMsg)
			window.open(StrVal)
		 }
	
		if(document.getElementById("radOption4").checked)
		 {
			StrVal=document.getElementById("radOption4").value
		 	alert(StrMsg)
			window.open(StrVal)
		 }
	
		if(document.getElementById("radOption5").checked)
		 {
			StrVal=document.getElementById("radOption5").value
		 	alert(StrMsg)
			window.open(StrVal)
		 }
	
		if(document.getElementById("radOption6").checked)
		 {
			StrVal=document.getElementById("radOption6").value
		 	alert(StrMsg)
			window.open(StrVal)
		 }
	
		if(document.getElementById("radOption7").checked)
		 {
			StrVal=document.getElementById("radOption7").value
		 	alert(StrMsg)
			window.open(StrVal)
		 }
	
		if(document.getElementById("radOption8").checked)
		 {
			StrVal=document.getElementById("radOption8").value
		 	alert(StrMsg)
			window.open(StrVal)
		 }
	
		if(document.getElementById("radOption9").checked)
		 {
			StrVal=document.getElementById("radOption9").value
		 	alert(StrMsg)
			window.open(StrVal)
		 }
	
		if(document.getElementById("radOption10").checked)
		 {
			
			if(!(document.getElementById("radOption101").checked || document.getElementById("radOption102").checked ))
			  {
					alert("select one option");
					return false;
					
			  }

			if(document.getElementById("radOption101").checked)
			  {
					StrVal=document.getElementById("radOption101").value
					window.open(StrVal)

			  }
			  
			if(document.getElementById("radOption102").checked )
			  {
					StrVal=document.getElementById("radOption102").value
					window.open(StrVal)

			  }
			
		 }
	
		if(document.getElementById("radOption11").checked)
		 {
			
			if(!(document.getElementById("radOption111").checked || document.getElementById("radOption112").checked ))
			  {
					alert("select one option");
					return false;
					
			  }

			if(document.getElementById("radOption111").checked)
			  {
					StrVal=document.getElementById("radOption111").value
					window.open(StrVal)

			  }
			  
			if(document.getElementById("radOption112").checked )
			  {
					StrVal=document.getElementById("radOption112").value
					window.open(StrVal)

			  }
		 }
	
		if(document.getElementById("radOption12").checked)
		 {
			StrVal=document.getElementById("radOption12").value
		 	alert(StrMsg)
			window.open(StrVal)
		 }
	
		if(document.getElementById("radOption13").checked)
		 {
			StrVal=document.getElementById("radOption13").value
		 	alert(StrMsg)
			window.open(StrVal)
		 }
	
		if(document.getElementById("radOption14").checked)
		 {
			StrVal=document.getElementById("radOption14").value
		 	alert(StrMsg)
			window.open(StrVal)
		 }
	
		if(document.getElementById("radOption15").checked)
		 {
			StrVal=document.getElementById("radOption15").value
		 	alert(StrMsg)
			window.open(StrVal)
		 }
	
  }
  
  
  
  function Check1() 
  {
	document.getElementById("radOption10").checked=true  

  }
  
  
  function Check2() 
  {
	document.getElementById("radOption11").checked=true  

  }
  
  
  function MCheck1() 
  {
	document.getElementById("radOption111").checked=false  
	document.getElementById("radOption112").checked=false  
	
  }
  
  
  function MCheck2() 
  {
	document.getElementById("radOption101").checked=false  
	document.getElementById("radOption102").checked=false  

  }
//END
