
<!--
//********************************************************
//* 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');
}
//********************************************************
//* 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,'F63:68');
	f.E81.value=xsum(f,'E74:80');
	f.F81.value=xsum(f,'F74:80');
	f.E91.value=xsum(f,'E86:90');
	f.F91.value=xsum(f,'F86:90');
	f.F102.value=xsum(f,'F96:101');
	f.E112.value=xsum(f,'E107:111');
	f.F112.value=xsum(f,'F107:111');
	f.E127.value=xsum(f,'E117:126');
	f.F127.value=xsum(f,'F117:126');
	f.E140.value=xsum(f,'E132:139');
	f.F140.value=xsum(f,'F132:139');
	f.D153.value=xsum(f,'E145:152');
	f.E153.value=xsum(f,'E145:152');
	f.F153.value=xsum(f,'F145:152');
	f.E166.value=xsum(f,'E158:165');
	f.F166.value=xsum(f,'F158:165');
	f.E186.value=xsum(f,'E176:185');
	f.F186.value=xsum(f,'F176:185');
	f.E199.value=xsum(f,'E191:198');
	f.F199.value=xsum(f,'F191:198');
	f.E213.value=xsum(f,'E204:212');
	f.F213.value=xsum(f,'F204:212');
	f.D224.value=xsum(f,'D218:223');
	f.E224.value=xsum(f,'E218:223');
	f.F224.value=xsum(f,'F218:223');
	f.D235.value=xsum(f,'D229:234');
	f.E235.value=xsum(f,'E229:234');
	f.F235.value=xsum(f,'F229:234');
	f.D244.value=xsum(f,'D240:243');
	f.E244.value=xsum(f,'E240:243');
	f.F244.value=xsum(f,'F240:243');
	f.F253.value=xsum(f,'F249:252');

	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,'F63:68')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'E74:80')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'F74:80')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'E86:90')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'F86:90')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'F96:101')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'E107:111')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'F107:111')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'E117:126')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'F117:126')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'E132:139')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'F132:139')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'D145:152')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'E145:152')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'F145:152')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'E158:165')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'F158:165')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'E176:185')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'F176:185')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'E191:198')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'F191:198')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'E204:212')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'F204:212')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'D218:223')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'E218:223')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'F218:223')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'D229:234')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'E229:234')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'F229:234')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'D240:243')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'E240:243')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'F240:243')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (isInRange(c,'F249:252')) { 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);
	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.D5) { f.B7.focus(); return; }
	return;
}
//-->
