
<!--
//********************************************************
//* Created for Orion Systems by Scott A. Caldwell
//* 2005-10-04
//* persfinc.js
//* page specific functions to match the behavior of
//* the persfinc.xls spreadsheet calculations and formulas
//********************************************************
//********************************************************
//* Variables for the popup window
//********************************************************
var popupwdw;					//  popup wizard window object
var usewizard=false;			//	popup wizard is open flag
window.onload = wonload;
function wonload() {
	sheetformat(document.persfinc.cbusewizard);
	showwizard('instructions-S');
}
//********************************************************
//* wonunload executes when the window is unloaded
//********************************************************
function wonunload() {
	closewizard();
}

//********************************************************
//* showwizard will load the popup wizard window and display it
//*		s = name of the wizard page to display
//********************************************************
function showwizard(s) {
	var features='toolbar=no,status=yes,height=50,width=50';
	var name='wizard';
	var url= s+'.htm';
	usewizard=true;
	popupwdw=window.open(url,name,features);
}

//
// closewizard will unload the popup wizard window if it is loaded
//
function closewizard() {
	document.persfinc.cbusewizard.checked = false;
	if (usewizard == true) {
		usewizard=false;
		popupwdw.close();
	}
}
//********************************************************
//* computesum
//* 	compare the excel named cells to the argument
//*		and performs the appropriate formula
//*		for dependent section, c is reassigned
//********************************************************
function computesum(f) {
	f.B16.value=gensum(2,(xsum(f,'B6:9')),(xsum(f,'B11:15')));
	f.F69.value=xsum(f,'F65:68');
	f.E81.value=xsum(f,'E79:80');
	f.F81.value=xsum(f,'F79:80');
	f.E91.value=xsum(f,'E89:89');
	f.F91.value=xsum(f,'F89:89');
	f.F102.value=xsum(f,'F100:101');
	f.E112.value=xsum(f,'E110:110');
	f.F112.value=xsum(f,'F110:110');
	f.E127.value=xsum(f,'E124:125');
	f.F127.value=xsum(f,'F124:125');
	f.D140.value=xsum(f,'D136:139');
	f.E140.value=xsum(f,'E136:139');
	f.F140.value=xsum(f,'F136:139');
	f.D153.value=xsum(f,'E147:150');
	f.E153.value=xsum(f,'E147:150');
	f.F153.value=xsum(f,'F147:150');
	f.E166.value=xsum(f,'E163:163');
	f.F166.value=xsum(f,'F163:163');
	f.E186.value=xsum(f,'E183:184');
	f.F186.value=xsum(f,'F183:184');
	f.E199.value=xsum(f,'E195:198');
	f.F199.value=xsum(f,'F195:198');
	f.E213.value=xsum(f,'E208:212');
	f.F213.value=xsum(f,'F208:212');
	f.D224.value=xsum(f,'D220:223');
	f.E224.value=xsum(f,'E220:223');
	f.F224.value=xsum(f,'F220:223');
	f.D235.value=xsum(f,'D231:234');
	f.E235.value=xsum(f,'E231:234');
	f.F235.value=xsum(f,'F231:234');
	f.D244.value=xsum(f,'D242:243');
	f.E244.value=xsum(f,'E242:243');
	f.F244.value=xsum(f,'F242:243');
	f.F253.value=xsum(f,'F251:251');

	f.D27.value=f.F69.value;
	f.D28.value=f.F81.value;
	f.D29.value=f.F91.value;
	f.D30.value=f.F102.value;
	f.D31.value=f.F112.value;
	f.D32.value=f.F127.value;
	f.D33.value=f.F140.value;
	f.D34.value=f.F153.value;
	f.D35.value=f.F166.value;

	f.D36.value=xsum(f,'D27:35');
	for (var i=27; i<36; i++) eval('f.E'+i+'.value=genratio(f.D'+i+',f.D36,1);');
	f.E36.value=xsum(f,'E27:35');

	f.D42.value=f.F186.value;
	f.D43.value=f.F199.value;
	f.D44.value=f.F213.value;
	f.D45.value=f.F224.value;
	f.D46.value=f.F235.value;
	f.D47.value=f.F244.value;
	f.D48.value=f.F253.value;

	f.D49.value=xsum(f,'D42:48');
	for (var i=42; i<49; i++) eval('f.E'+i+'.value=genratio(f.D'+i+',f.D49,1);');
	f.E49.value=xsum(f,'E42:48');

	f.D52.value=gendiff(2,f.D36.value,f.D49.value);

	return;
}
//********************************************************
//* cellchange
//*		generic function added to all excel type input boxes
//* 	calls the appropriate sum function based on
//*		which cell changed.
//********************************************************
function cellchange(c) {
	var f=c.form;
	if (isInRange(c,'B6:9')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'B11:15')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'F65:68')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'E79:80')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'F79:80')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'E89:89')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'F89:89')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'F100:101')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'E110:110')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'F110:110')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'E124:125')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'F124:125')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'E136:139')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'F136:139')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'D147:150')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'E147:150')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'F147:150')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'E163:163')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'F163:163')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'E183:184')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'F183:184')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'E195:198')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'F195:198')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'E208:212')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'F208:212')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'D220:223')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'E220:223')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'F220:223')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'D231:234')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'E231:234')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'F231:234')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'D242:243')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'E242:243')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'F242:243')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'F251:251')) { c.value = gensum(1,c.value);computesum(f); return; }
	return;
}
//********************************************************
//* sheetformat
//*		generic function for setting the global
//* 	format of the displayed page in dollars
//*		with or without cents.
//*		called as the onclick event of a checkbox control
//********************************************************
function sheetformat(c) {
	var f=c.form;
	whdol = true;
	reformat(f.B6);
	reformat(f.B7);
	reformat(f.B8);
	reformat(f.B9);
	reformat(f.B11);
	reformat(f.B12);
	reformat(f.B13);
	reformat(f.B14);
	reformat(f.B15);
		reformat(f.B16);
	reformat(f.D27);
	reformat(f.D28);
	reformat(f.D29);
	reformat(f.D30);
	reformat(f.D31);
	reformat(f.D32);
	reformat(f.D33);
	reformat(f.D34);
	reformat(f.D35);
		reformat(f.D36);
	reformat(f.D42);
	reformat(f.D43);
	reformat(f.D44);
	reformat(f.D45);
	reformat(f.D46);
	reformat(f.D47);
	reformat(f.D48);
		reformat(f.D49);
		reformat(f.D52);
	reformat(f.F65);
	reformat(f.F66);
	reformat(f.F67);
	reformat(f.F68);
		reformat(f.F69);
	reformat(f.E79);
	reformat(f.F79);
	reformat(f.E80);
	reformat(f.F80);
		reformat(f.E81);
		reformat(f.F81);
	reformat(f.E89);
	reformat(f.F89);
//	reformat(f.E90);
//	reformat(f.F90);
		reformat(f.E91);
		reformat(f.F91);
	reformat(f.F100);
	reformat(f.F101);
		reformat(f.F102);
	reformat(f.E110);
	reformat(f.F110);
//	reformat(f.E111);
//	reformat(f.F111);
		reformat(f.E112);
		reformat(f.F112);
	reformat(f.D124);
	reformat(f.E124);
	reformat(f.F124);
	reformat(f.D125);
	reformat(f.E125);
	reformat(f.F125);
//	reformat(f.D126);
//	reformat(f.E126);
//	reformat(f.F126);
		reformat(f.E127);
		reformat(f.F127);
	reformat(f.D136);
	reformat(f.E136);
	reformat(f.F136);
	reformat(f.D137);
	reformat(f.E137);
	reformat(f.F137);
	reformat(f.D138);
	reformat(f.E138);
	reformat(f.F138);
	reformat(f.D139);
	reformat(f.E139);
	reformat(f.F139);
		reformat(f.D140);
		reformat(f.E140);
		reformat(f.F140);
	reformat(f.D147);
	reformat(f.E147);
	reformat(f.F147);
	reformat(f.D148);
	reformat(f.E148);
	reformat(f.F148);
	reformat(f.D149);
	reformat(f.E149);
	reformat(f.F149);
	reformat(f.D150);
	reformat(f.E150);
	reformat(f.F150);
//	reformat(f.D151);
//	reformat(f.E151);
//	reformat(f.F151);
//	reformat(f.D152);
//	reformat(f.E152);
//	reformat(f.F152);
		reformat(f.D153);
		reformat(f.E153);
		reformat(f.F153);
	reformat(f.E163);
	reformat(f.F163);
//	reformat(f.E164);
//	reformat(f.F164);
//	reformat(f.E165);
//	reformat(f.F165);
		reformat(f.E166);
		reformat(f.F166);
	reformat(f.E183);
	reformat(f.F183);
	reformat(f.E184);
	reformat(f.F184);
//	reformat(f.E185);
//	reformat(f.F185);
		reformat(f.E186);
		reformat(f.F186);
	reformat(f.E195);
	reformat(f.F195);
	reformat(f.E196);
	reformat(f.F196);
	reformat(f.E197);
	reformat(f.F197);
	reformat(f.E198);
	reformat(f.F198);
		reformat(f.E199);
		reformat(f.F199);
	reformat(f.E208);
	reformat(f.F208);
	reformat(f.E209);
	reformat(f.F209);
	reformat(f.E210);
	reformat(f.F210);
	reformat(f.E211);
	reformat(f.F211);
	reformat(f.E212);
	reformat(f.F212);
		reformat(f.E213);
		reformat(f.F213);
	reformat(f.D220);
	reformat(f.E220);
	reformat(f.F220);
	reformat(f.D221);
	reformat(f.E221);
	reformat(f.F221);
	reformat(f.D222);
	reformat(f.E222);
	reformat(f.F222);
	reformat(f.D223);
	reformat(f.E223);
	reformat(f.F223);
		reformat(f.D224);
		reformat(f.E224);
		reformat(f.F224);
	reformat(f.D231);
	reformat(f.E231);
	reformat(f.F231);
	reformat(f.D232);
	reformat(f.E232);
	reformat(f.F232);
	reformat(f.D233);
	reformat(f.E233);
	reformat(f.F233);
	reformat(f.D234);
	reformat(f.E234);
	reformat(f.F234);
		reformat(f.D235);
		reformat(f.E235);
		reformat(f.F235);
	reformat(f.D242);
	reformat(f.E242);
	reformat(f.F242);
	reformat(f.D243);
	reformat(f.E243);
	reformat(f.F243);
		reformat(f.D244);
		reformat(f.E244);
		reformat(f.F244);
	reformat(f.F251);
//	reformat(f.F252);
		reformat(f.F253);
	return;
}
//********************************************************
//* shiftfocus
//*		generic function for moving focus from a
//* 	computed cell to the next input cell
//********************************************************
function shiftfocus(c) {
	var f=c.form;
	if (c==f.B16) { f.B19.focus(); return; }
	if (c==f.D27) { f.A63.focus(); return; }
	if (c==f.E27) { f.A63.focus(); return; }
	if (c==f.D28) { f.A63.focus(); return; }
	if (c==f.E28) { f.A63.focus(); return; }
	if (c==f.D29) { f.A63.focus(); return; }
	if (c==f.E29) { f.A63.focus(); return; }
	if (c==f.D30) { f.A63.focus(); return; }
	if (c==f.E30) { f.A63.focus(); return; }
	if (c==f.D31) { f.A63.focus(); return; }
	if (c==f.E31) { f.A63.focus(); return; }
	if (c==f.D32) { f.A63.focus(); return; }
	if (c==f.E32) { f.A63.focus(); return; }
	if (c==f.D33) { f.A63.focus(); return; }
	if (c==f.E33) { f.A63.focus(); return; }
	if (c==f.D34) { f.A63.focus(); return; }
	if (c==f.E34) { f.A63.focus(); return; }
	if (c==f.D35) { f.A63.focus(); return; }
	if (c==f.E35) { f.A63.focus(); return; }
	if (c==f.D36) { f.A63.focus(); return; }
	if (c==f.E36) { f.A63.focus(); return; }
	if (c==f.D42) { f.A63.focus(); return; }
	if (c==f.E42) { f.A63.focus(); return; }
	if (c==f.D43) { f.A63.focus(); return; }
	if (c==f.E43) { f.A63.focus(); return; }
	if (c==f.D44) { f.A63.focus(); return; }
	if (c==f.E44) { f.A63.focus(); return; }
	if (c==f.D45) { f.A63.focus(); return; }
	if (c==f.E45) { f.A63.focus(); return; }
	if (c==f.D46) { f.A63.focus(); return; }
	if (c==f.E46) { f.A63.focus(); return; }
	if (c==f.D47) { f.A63.focus(); return; }
	if (c==f.E47) { f.A63.focus(); return; }
	if (c==f.D48) { f.A63.focus(); return; }
	if (c==f.E48) { f.A63.focus(); return; }
	if (c==f.D49) { f.A63.focus(); return; }
	if (c==f.E49) { f.A63.focus(); return; }
	if (c==f.D52) { f.A63.focus(); return; }

	if (c==f.F69) { f.A74.focus(); return; }
	if (c==f.E81) { f.A86.focus(); return; }
	if (c==f.F81) { f.A86.focus(); return; }
	if (c==f.E91) { f.A96.focus(); return; }
	if (c==f.F91) { f.A96.focus(); return; }
	if (c==f.F102) { f.A107.focus(); return; }
	if (c==f.E112) { f.A117.focus(); return; }
	if (c==f.F112) { f.A117.focus(); return; }
	if (c==f.E127) { f.A132.focus(); return; }
	if (c==f.F127) { f.A132.focus(); return; }
	if (c==f.D140) { f.A145.focus(); return; }
	if (c==f.E140) { f.A145.focus(); return; }
	if (c==f.F140) { f.A145.focus(); return; }
	if (c==f.D153) { f.A158.focus(); return; }
	if (c==f.E153) { f.A158.focus(); return; }
	if (c==f.F153) { f.A158.focus(); return; }
	if (c==f.E166) { f.A176.focus(); return; }
	if (c==f.F166) { f.A176.focus(); return; }

	if (c==f.E186) { f.A191.focus(); return; }
	if (c==f.F186) { f.A191.focus(); return; }
	if (c==f.E199) { f.A204.focus(); return; }
	if (c==f.F199) { f.A204.focus(); return; }
	if (c==f.E213) { f.A218.focus(); return; }
	if (c==f.F213) { f.A218.focus(); return; }
	if (c==f.D224) { f.A229.focus(); return; }
	if (c==f.E224) { f.A229.focus(); return; }
	if (c==f.F224) { f.A229.focus(); return; }
	if (c==f.D235) { f.A240.focus(); return; }
	if (c==f.E235) { f.A240.focus(); return; }
	if (c==f.F235) { f.A240.focus(); return; }
	if (c==f.D244) { f.A249.focus(); return; }
	if (c==f.E244) { f.A249.focus(); return; }
	if (c==f.F244) { f.A249.focus(); return; }
	if (c==f.F253) { f.A257.focus(); return; }

	return;
}
//-->
