// JavaScript Document
var description = new Array();
description[0] = "";
description[1] = "<p>Among final expenses are medical, hospital, and funeral expenses, attorney or executor fees, probate court costs (if you do not have a will), and any outstanding taxes that would need to be paid if you died. Experts recommend that you allocate 50 percent of the higher wage earner's salary for the final expenses.</p>";
description[2] = "<p><br><br><br><br>Among outstanding debts are credit card balances, auto loans, college loans, and all other outstanding bills.</p>";
description[3] = "<p><br><br><br><br><br><br><br>Emergency expenses should include a cash reserve for medical emergencies and repairs to your home or car. Experts recommend that you allocate three to six months worth of living expenses as your emergency expenses.</p>";
description[4] = "<p><br><br><br><br><br><br><br><br><br><br><br><br><br>Put down the mortgage balance.</p>";
description[5] = "<p><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>Calculating an education fund is tricky because you have no idea where your children will be going to college. Perhaps the best method is to use the present average college cost in the United States and the number of years away your children are from entering college. The average college costs for the 2002-2003 school year were $4,081 annually for a public, four-year institution, and $18,273 annually for a private, four-year institution, according to The College Board. Vance Grant, an education statistics specialist with the U.S. Department of Education, says that college costs traditionally have been rising at about 5 percent annually, so you need to figure out what the cost will be when your child goes to college.</p>";
description[6] = "<p><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>These include such necessities as child care, food, clothing, utility bills, entertainment, travel, and transportation. Calculate this figure based on a year's worth of expenses.</p>";
description[7] = "<p><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>Number of years for which you want to provide the income indicated above.</p>";
description[8] = "<p><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>Add all available savings, stocks, bonds, mutual funds, existing life insurance (such as group life through your employer), and Social Security. You and your spouse can find out how much you'll get through the Social Security Administration (SSA) by visiting the SSA's Web site , where you can get an estimate of how much you should have in Social Security benefits.</p>";
description[9] = "<p><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>Lump Sum Needs equal the total of the Short Term Needs and the Long Term Debts.</p>";
description[10] = "<p><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>Present Value of Income Needs is the amount of capital required today in order to provide the income you specified in Step 3, given the assumed inflation rate and anual return of investment.</p>";
description[11] = "<p><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>Total Capital Needs at Death is the sum of the Short Term Needs, the Long Term Debts, and the Family Maintenance Expenses.</p>";
description[12] = "<p><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>Same as in Step 4: Available Resources.</p>";
description[13] = "<p><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>This amount should represent the amount of life insurance coverage you should buy.</p>";
adImages = new Array("images_life/contactus_image_red.gif","images_life/contactus_image_white.gif")
thisAd = 0
function rotate_contactus() {
	imgCt = adImages.length
		if (document.images) {
			thisAd++
			if (thisAd == imgCt) {
				thisAd = 0
			}
			document.adBanner.src=adImages[thisAd]
		  	setTimeout("rotate_contactus()", .5 * 1000)
	  	}
}
	
CompanyImages = new Array("../brandlogos/fglife.gif","../brandlogos/mutualofomaha.gif","../brandlogos/northamericancompany.jpg","../brandlogos/pmplogobanner.jpg","../brandlogos/vistahealthplan.gif","../brandlogos/adi.jpg","../brandlogos/humana.gif","../brandlogos/celtic.jpg","../brandlogos/fortis_logo.gif","../brandlogos/pfg_logo.gif")
thisBnr = 0

function rotate_logoBnr() {
	imgCt = CompanyImages.length
		if (document.images) {
			thisBnr++
			if (thisBnr == imgCt) {
				thisBnr = 0
			}
			document.adBnr.src=CompanyImages[thisBnr]
		  	setTimeout("rotate_logoBnr()", 3 * 1000)
	  	}
}

adAds = new Array("images_life/animation/escena1.jpg","images_life/animation/escena2.jpg","images_life/animation/escena3.jpg","images_life/animation/escena4.jpg")
thisAd1 = 0	
function rotate_logoTermInsAd() {
	imgCt = adAds.length
		if (document.images) {
			document.adAdver.src=adAds[thisAd1]
			setTimeout("rotate_logoTermInsAd()", 7 * 1000)
			thisAd1++
			if (thisAd1 == imgCt) {
				thisAd1 = 0
			}
			
	  	}
}	

function newWindow(formvar) {
leftPos = 0;
if (screen) {
	leftPos = screen.width-900;
}
	if (formvar==1) {
	formWindow = window.open("terminsform.html","formWindow", "width=765,height=685,scrollbars=yes,left="+leftPos+",top=0");
	}
			if (formvar==2) {
			formWindow = window.open("ULinsform.html","formWindow", "width=765,height=685,scrollbars=yes,left="+leftPos+",top=0");
			}
					if (formvar==3) {
					formWindow = window.open("disabilityinsform.html","formWindow", "width=765,height=685,scrollbars=yes,left="+leftPos+",top=0");
					}
						if (formvar==4) {
						formWindow = window.open("contact_me_form.html","formWindow", "width=765,height=550,scrollbars=yes,left="+leftPos+",top=0");
						}
}

function CheckField (passedinput) {
  if (passedinput.value == "") {
    //alert("Please enter all required information.");
    passedinput.value = "0";
  } else {
     if (passedinput.value.indexOf(",") >= 0) {
       alert ("Please do not use thousand separtors i.e. comma or space.");
       passedinput.focus();
     }
     if (passedinput.value.indexOf(" ") >= 0) {
       alert ("Please do not use thousand separtors i.e. space or comma.");
       passedinput.focus();
     }
  }
}

function CheckField2 (passedinput) {
  if (passedinput.value == "") {
    //alert("Please enter all required information.");
    passedinput.value = "0";
  } 
}

function Format (number) {
  var thousand = 0;
  var hundred = 0;
  var tmp = "";
  var million = 0;
  million = Math.floor(number/1000000);
  if (million > 0) {
  			thousand = Math.floor(number / 1000) % 1000;
						if (thousand < 10) {
						thousand = million + ",00" + thousand;
					  	} else {
							if (thousand < 100) { 
							  thousand = million + ",0" + thousand;
							} else {
									thousand = million + "," + thousand;
							}
						}
  } else {
  thousand = Math.floor(number / 1000);
  }

  hundred = number % 1000;
 
  	if (hundred < 10) {
  
    	tmp = thousand + ",00" + hundred;
	
  	} else {
				if (hundred < 100) { 
			   
				  	tmp = thousand + ",0" + hundred;
			
				} else {
						
      				tmp = thousand + "," + hundred;

				}
	}
    
  tmp = tmp + ".00";
  return tmp;
}

function Calculate() {
  var ann_income = 0;
  var inf_rate = 0;
  var ann_roi = 0; 
  var period = 0;

  var lump_sum = 0;
  var pres_value = 0;
  var cap_need = 0;
  var ins_exist = 0;
  var ins_need = 0;
  var r = 0;
  var k = 0;
  var tmp = 0;
  
  ann_income = parseFloat(document.forms[0].ann_income.value);
  inf_rate = parseFloat(document.forms[0].inf_rate.value) / 100;
  ann_roi = parseFloat(document.forms[0].ann_roi.value) / 100;
  period = parseInt(document.forms[0].period.value);

  lump_sum += parseFloat(document.forms[0].final_exp.value);
  lump_sum += parseFloat(document.forms[0].outsting_mrtgage.value);
  lump_sum += parseFloat(document.forms[0].outsting_debts.value);
  lump_sum += parseFloat(document.forms[0].emerg_exp.value);
  lump_sum += parseFloat(document.forms[0].collg_funds.value);

  r = (1 + inf_rate) / (1 + ann_roi);
  k = (1 + ann_roi);

  pres_value += ann_income;
  if (r != 1) {
    pres_value = pres_value * ( (1 - Math.pow(r, period)) / (1 - r) );
  } else {
    pres_value = pres_value * period / (Math.pow((1 + ann_roi), 0.5));
  }

  cap_need = lump_sum + pres_value;
  ins_exist = parseFloat(document.forms[0].exist_rescs.value);
  ins_need = cap_need - ins_exist;
  if (ins_need < 0) {
     ins_need = 0;
  }

  //round to nearest dollar
  lump_sum = Math.ceil(lump_sum);
  pres_value = Math.ceil(pres_value);
  cap_need = Math.ceil(cap_need);
  ins_exist = Math.ceil(ins_exist);
  ins_need = Math.ceil(ins_need);

  //display results
  document.forms[0].tot_lump.value = Format(lump_sum);
  document.forms[0].tot_value.value = Format(pres_value);
  document.forms[0].tot_capit.value = Format(cap_need);
  document.forms[0].tot_rescs.value = Format(ins_exist);
  document.forms[0].add_ins.value = Format(ins_need);

  document.location = "#Results";
}
