//template.js

	sHeaderType = "default";  
	sBreadcrumbType = "none";   
	sSite = "sic";   
	sShowAcrobat = "true";	
   	sUtilitiesType= "none";
	sMastheadType = "sic";	
	
	wcMh.searchType = "none";
	wcEnterpriseMenuType = "none";
	
	sLocalGraphic = "pix/sass_logo.gif";
	sLocalGraphicHeight = "80";
	sLocalGraphicWidth = "97";
	   


// Life Needs Functions ------------------------------------------------------------
function add_needs_life() {
		var form = document.needs_calc_life;
		
		with (form) {
			var y1=i_1_y.value.replace(/,/g,'')-0;
			var s1=i_1_s.value.replace(/,/g,'')-0;
			var y2=i_2_y.value.replace(/,/g,'')-0;
			var s2=i_2_s.value.replace(/,/g,'')-0;
			var y3=i_3_y.value.replace(/,/g,'')-0;
			var s3=i_3_s.value.replace(/,/g,'')-0;
			var y4=t_1_y.value.replace(/,/g,'')-0;
			var s4=t_1_s.value.replace(/,/g,'')-0;
			var y5=t_2_y.value.replace(/,/g,'')-0;
			var s5=t_2_s.value.replace(/,/g,'')-0;
			var y6=t_3_y.value.replace(/,/g,'')-0;
			var s6=t_3_s.value.replace(/,/g,'')-0;
			var y7=l_1_y.value.replace(/,/g,'')-0;
			var s7=l_1_s.value.replace(/,/g,'')-0;
			var y8=l_2_y.value.replace(/,/g,'')-0;
			var s8=l_2_s.value.replace(/,/g,'')-0;
			var y9=l_3_y.value.replace(/,/g,'')-0;
			var s9=l_3_s.value.replace(/,/g,'')-0;
			var y10=l_4_y.value.replace(/,/g,'')-0;
			var s10=l_4_s.value.replace(/,/g,'')-0;
			var y11=l_5_y.value.replace(/,/g,'')-0;
			var s11=l_5_s.value.replace(/,/g,'')-0;
			var y12=r_1_y.value.replace(/,/g,'')-0;
			var s12=r_1_s.value.replace(/,/g,'')-0;
			
			youTotal = y1+y2+y3+y4+y5+y6+y7+y8+y9+y10+y11+y12;
			spouseTotal = s1+s2+s3+s4+s5+s6+s7+s8+s9+s10+s11+s12;
			
			if(isNaN(youTotal)) {
				//error("You");
				// do nothing
			}else {
				total_y.value = formatAsCurrency(youTotal);
			}
			if(isNaN(spouseTotal)) {
				//error("Spouse");
				// do nothing
			}else {
				total_s.value = formatAsCurrency(spouseTotal);
			}
			
		}
}


function add_resources_life() {
	var form = document.needs_calc_life;
	
	with (form) {
		var x1=a_1_y.value.replace(/,/g,'')-0;
		var z1=a_1_s.value.replace(/,/g,'')-0;
		var x2=a_2_y.value.replace(/,/g,'')-0;
		var z2=a_2_s.value.replace(/,/g,'')-0;
		
		yTotal = x1+x2;
		sTotal = z1+z2;
		
		if(isNaN(yTotal)) {
			// do nothing
		}else {
			tra_y.value = formatAsCurrency(yTotal);
		}
		if(isNaN(sTotal)) {
			// do nothing
		}else {
			tra_s.value = formatAsCurrency(sTotal);
		}
	}
}


function find_dif_life() {
	var form = document.needs_calc_life;
	add_needs_life();
	add_resources_life();
	with (form) {	// error handling moved here
		if(isNaN(youTotal-yTotal)) {
			total_y.value = "";
			tra_y.value = "";
			total_vol_y.value = "";
			error("You");
		}else {
			if(youTotal-yTotal <= 0) {
				total_vol_y.value=0;
			}else {
				total_vol_y.value=formatAsCurrency(youTotal-yTotal);
			}
		}
		if(isNaN(spouseTotal-sTotal)) {
			total_s.value = "";
			tra_s.value = "";
			total_vol_s.value = "";
			error("Spouse");
		}else {
			if(spouseTotal-sTotal <= 0) {
				total_vol_s.value=0;
			}else {
				total_vol_s.value=formatAsCurrency(spouseTotal-sTotal);
			}
		}
	}
	
}


function error(column) {	//pass the name of column, "you" or "spouse"
	alert("The calculator has encountered a non-numerical value\nin the "+column+" column.\n\nPlease verify that all fields contain only numerical values.\n\nThank you.");
}


// LTD Needs Functions ---------------------------------------------------------------------

	var ltdtmp = new Array();
	var ltdinc = new Array();
	
	function add_needs() {
		var form = document.needs_calc;
			
		ltdtmp[0] = form.m_1.value.replace(/,/g,'')-0;
		ltdtmp[1] = form.m_2.value.replace(/,/g,'')-0;
		ltdtmp[2] = form.m_3.value.replace(/,/g,'')-0;
		ltdtmp[3] = form.m_4.value.replace(/,/g,'')-0;
		ltdtmp[4] = form.m_5.value.replace(/,/g,'')-0;
		ltdtmp[5] = form.m_6.value.replace(/,/g,'')-0;
		ltdtmp[6] = form.m_7.value.replace(/,/g,'')-0;
		ltdtmp[7] = form.m_8.value.replace(/,/g,'')-0;
		ltdtmp[8] = form.m_9.value.replace(/,/g,'')-0;
				
		// add each item in tmp array to total
		ltdtmpTotal = ltdtmp[0]+ltdtmp[1]+ltdtmp[2]+ltdtmp[3]+ltdtmp[4]+ltdtmp[5]+ltdtmp[6]+ltdtmp[7]+ltdtmp[8];
		
		// display the total expenses
		form.total_m.value = formatAsCurrency(ltdtmpTotal);
		form.total_me.value = formatAsCurrency(ltdtmpTotal);
		if(isNaN(ltdtmpTotal)) {form.total_m.value = "";}
		
	}
	
	function add_income() {
		var form = document.needs_calc;
		
		ltdinc[0] = form.i_1.value.replace(/,/g,'')-0;
		ltdinc[1] = form.i_2.value.replace(/,/g,'')-0;
		ltdinc[2] = form.i_3.value.replace(/,/g,'')-0;
		
		// add each item in tmp array to total
		ltdincTotal = ltdinc[0]+ltdinc[1]+ltdinc[2];
        // leave out "take home pay" from total
        ltdincPostDisability = ltdinc[1] + ltdinc[2];
		
		// display the total income
		form.total_i.value = formatAsCurrency(ltdincTotal);
		form.total_mi.value = formatAsCurrency(ltdincPostDisability);
		if(isNaN(ltdincTotal)) {form.total_i.value = "";}
		find_diff();
	}
	
	function find_diff() {
		var form = document.needs_calc;
		
        if(form.total_i.value=="" || form.total_m.value=="") {
            alert("Please enter your expenses and income.");
        } 
		else {
            var difTotal = ltdtmpTotal - ltdincPostDisability;
            
			if(difTotal <= 0) {
				form.total_vol.value = 0;
			} 
			else {
				form.total_vol.value = formatAsCurrency(difTotal);
			}
		}
       
	}


	
// Premium Functions ----------------------------------------------------------
	
var period;
function roundAccuracy2(num, acc){
	var factor=Math.pow(10,acc);
	return Math.floor(num*factor)/factor;
	}
	
	function wants_check(who) {
		var form = document.prem_calc;
		with (form) {
			if(who=="act" || who=="ret") {
				myAmt = document.prem_calc.wants[document.prem_calc.wants.selectedIndex].value -0;
				//alert(myAmt);
			}
			
		}
	}
	
	function validate_age(who) {
		var form = document.prem_calc;
		if((who=="ltd")||(who=="em")||(who=="supplife")) {
			if(!form.age.value.match(/\d/g)){
				alert("Please enter your age.");
				form.age.focus();
				return false;
			}
		}
	return true;
	}
	
	//life premium calc
	function calc_prem_life(who) {
		//alert('life calculator');
		var form = document.prem_calc;	
		myAmt = document.prem_calc.wants[document.prem_calc.wants.selectedIndex].value -0;
		if(who=="em" && validate_age(who)) {
			with (form) {
				monthlyPrema = (myAmt/1000) * rate_lookup(age.value);
				myPrema.value = formatAsCurrency(monthlyPrema);
			}
		}
	}
	
	//ltd premium calc
	function calc_prem(who) {
		resetSalary();
		var annualben = document.getElementById('myAmt').value;
		var monthly = (annualben / 12);		
		document.getElementById('myAmt_hold').value = roundAccuracy2(monthly, -3);
		
		var form = document.prem_calc;			
			
		if(who=="ltd" && validate_age(who) && formatAsCurrency(monthly)) {
			//alert('validation returns true');
			
			with (form) {
				if(document.prem_calc.ltd_option.options[0].selected){
				monthlyPrem = (document.getElementById('myAmt_hold').value) * rate_lookup_ltd_A(age.value)/1000;
				}
				if(document.prem_calc.ltd_option.options[1].selected){
				monthlyPrem = (document.getElementById('myAmt_hold').value) * rate_lookup_ltd_B(age.value)/1000;
				}
				if(document.prem_calc.ltd_option.options[2].selected){
				monthlyPrem = (document.getElementById('myAmt_hold').value) * rate_lookup_ltd_C(age.value)/1000;
				}
				if(document.prem_calc.ltd_option.options[3].selected){
				monthlyPrem = (document.getElementById('myAmt_hold').value) * rate_lookup_ltd_D(age.value)/1000;
				}
				myPrem2 = (monthlyPrem)*12;
				myPrem3 = (myPrem2)/26
				
			}
		}
		
		document.getElementById('myAmt').value = formatAsCurrency(document.getElementById('myAmt').value);
		form.planperiod.value = formatAsCurrency(myPrem3);
		}
		
		//supp life premium calc
		function calc_prem_supp(who) {
		resetSalary();
		var annualben = document.getElementById('myAmt').value;
		var annualben_rounded = roundAccuracy2(annualben, -3);		
		document.getElementById('myAmt_hold').value = annualben_rounded * document.prem_calc.cov_level.options[document.prem_calc.cov_level.selectedIndex].value;
		
		var form = document.prem_calc;			
			
		if(who=="supplife" && validate_age(who) && formatAsCurrency(annualben)) {
			//alert('validation returns true');
			
			with (form) {
				monthlyPrem = (document.getElementById('myAmt_hold').value) * rate_lookup_supp(age.value)/1000;
				//myPrem2 = (monthlyPrem)*12;
				//myPrem3 = (myPrem2)/26
				
			}
		}
		
		document.getElementById('myAmt').value = formatAsCurrency(document.getElementById('myAmt').value);
		form.planperiod.value = formatAsCurrency(monthlyPrem);
		}
	
	//option A
	function rate_lookup_ltd_A(myAge) {
		//if(myAge < 30){rate=.00084}
		if(myAge <=40){rate=.58}
		if(myAge >=40 && myAge <=44){rate=1.42}
		if(myAge >=45 && myAge <=49){rate=2.38}
		if(myAge >=50 && myAge <=54){rate=3.83}
		if(myAge >=55 && myAge <=69){rate=4.69}
		if(myAge >=70){rate=7.01}
		return rate;
	}
	
	//option B
	function rate_lookup_ltd_B(myAge) {
		//if(myAge < 30){rate=.00084}
		if(myAge <=40){rate=.68}
		if(myAge >=40 && myAge <=44){rate=1.84}
		if(myAge >=45 && myAge <=49){rate=3.06}
		if(myAge >=50 && myAge <=54){rate=4.93}
		if(myAge >=55 && myAge <=69){rate=6.09}
		if(myAge >=70){rate=9.04}
		return rate;
	}
	
	//option C
	function rate_lookup_ltd_C(myAge) {
		//if(myAge < 30){rate=.00084}
		if(myAge <=40){rate=.73}
		if(myAge >=40 && myAge <=44){rate=1.69}
		if(myAge >=45 && myAge <=49){rate=2.74}
		if(myAge >=50 && myAge <=54){rate=4.41}
		if(myAge >=55 && myAge <=69){rate=5.43}
		if(myAge >=70){rate=8.12}
		return rate;
	}
	//option D
	function rate_lookup_ltd_D(myAge) {
		//if(myAge < 30){rate=.00084}
		if(myAge <=40){rate=.88}
		if(myAge >=40 && myAge <=44){rate=2.19}
		if(myAge >=45 && myAge <=49){rate=3.53}
		if(myAge >=50 && myAge <=54){rate=5.68}
		if(myAge >=55 && myAge <=69){rate=7.04}
		if(myAge >=70){rate=10.47}
		return rate;
	}
	
	function rate_lookup_supp(myAge) {
		//if(myAge < 30){rate=.00084}
		if(myAge <=30){rate=.04}
		if(myAge >=30 && myAge <=34){rate=.06}
		if(myAge >=35 && myAge <=39){rate=.07}
		if(myAge >=40 && myAge <=44){rate=.09}
		if(myAge >=45 && myAge <=49){rate=.14}
		if(myAge >=50 && myAge <=54){rate=.21}
		if(myAge >=55 && myAge <=59){rate=.35}
		if(myAge >=60 && myAge <=64){rate=.55}
		if(myAge >=65 && myAge <=69){rate=1.00}
		if(myAge >=70){rate=1.75}
		return rate;
	}
	
	function rate_lookup(myAge) {
		if(myAge < 35){rate=.09}
		if(myAge >=35 && myAge <=39){rate=.10}
		if(myAge >=40 && myAge <=44){rate=.13}
		if(myAge >=45 && myAge <=49){rate=.17}
		if(myAge >=50 && myAge <=54){rate=.27}
		if(myAge >=55 && myAge <=59){rate=.32}
		if(myAge >=60 && myAge <=64){rate=.39}
		if(myAge >=65 && myAge <=69){rate=.73}
		if(myAge >=70){rate=1.02}
		return rate;
	}
	
	function resetSalary() {
		if(document.getElementById('myAmt').value != ""){
			document.getElementById('myAmt').value=document.getElementById('myAmt').value.replace(/,/g,"");
			document.getElementById('myAmt').value=document.getElementById('myAmt').value.replace(/[$]/g,"");
			document.getElementById('myAmt').value=document.getElementById('myAmt').value.split(".",1)
		}
	}
	
// added 04/17/08....mf
	function stripInput(a) {
		var modAmt = a;
		var empty = "";		
		modAmt = modAmt.replace(/,/g,empty);
		modAmt = modAmt.replace(/\$/g,empty);
		//alert(modAmt);
		return modAmt;
	}	
	
function popup(page,width,height,scroll,menu) {
		// the next 2 vars get the center screen position 
		//var winl = 45; //(screen.width - width) / 2;
		var winl = (screen.width - width) / 2;
		var wint = (screen.height - height) / 2;
		//alert("left: " + winl + "\ntop: " + wint);
		// the list of window properties
		winprops = 'height='+height+',width='+width+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=yes,status=yes';
		// if menu is requested, add all the nesessary parts
		if (menu=='yes')
			winprops += ',menubar=yes,toolbar=yes,locationbar=yes';
		// open the new window
		window.open(page, 'newWindow', winprops);
}	