
<!--
//********************************************************
//* Created for Orion Systems by Scott A. Caldwell
//* 2005-09-14
//* balance.js
//* page specific functions to match the behavior of
//* the balance.xls spreadsheet calculations and formulas
//********************************************************
window.onload = wonload;
function wonload() {
	// default everything to 0.00
	sheetformat(document.balancesheet.wholedollars);
}
//********************************************************
//* computesum
//* 	compare the excel named cells to the argument
//*		and performs the appropriate formula
//*		for dependent section, c is reassigned
//********************************************************
function computesum(c) {
	var f=c.form;
	if (c == f.D8) { c.value=gensum(2,f.B6.value,f.B7.value); c=f.D32; }
	if (c == f.B15) { c.value=gensum(4,f.B11.value,f.B12.value,f.B13.value,f.B14.value); c=f.D17; }
	if (c == f.D17) { c.value=gendiff(2,f.B15.value,f.B16.value);  c=f.D32; }
	if (c == f.D24) { c.value=gensum(5,f.B19.value,f.B20.value,f.B21.value,f.B22.value,f.B23.value); c=f.D32; }
	if (c == f.D32) { c.value=gensum(9,f.D8.value,f.D17.value,f.D24.value,f.D25.value,f.D26.value,f.D27.value,f.D29.value,f.D30.value,f.D31.value); c=f.D44; }
	if (c == f.B42) { c.value=gensum(7,f.B34.value,f.B35.value,f.B36.value,f.B37.value,f.B39.value,f.B40.value,f.B41.value); c=f.D44; }
	if (c == f.D44) { c.value=gendiff(2,f.B42.value,f.B43.value); c=f.D61; }
	if (c == f.D61) {
		c.value=gensum(14,
						f.D32.value,f.D44.value,f.D47.value,f.D48.value,
						f.D49.value,f.D50.value,f.D51.value,f.D52.value,
						f.D53.value,f.D55.value,f.D56.value,f.D57.value,
						f.D58.value,f.D59.value); return;}

	if (c == f.I23) {
		c.value=gensum(17,
						f.I6.value,f.I7.value,f.I8.value,f.I9.value,
						f.I10.value,f.I11.value,f.I12.value,f.I13.value,
						f.I14.value,f.I15.value,f.I16.value,f.I17.value,
						f.I18.value,f.I19.value,f.I20.value,f.I21.value,
						f.I22.value); c=f.I37;}
	if (c == f.I37) {
		c.value=gensum(4,f.I32.value,f.I33.value,f.I35.value,f.I36.value); c=f.I38;}
	if (c == f.I38) {
		c.value=gensum(2,f.I23.value,f.I37.value); c=f.I51;}
	if (c == f.I51) {
		c.value=gensum(2,f.I49.value,f.I50.value); c=f.I58;}
	if (c == f.H55) {
		c.value=gensum(2,f.H53.value,f.H54.value); c=f.I58;}
	if (c == f.I58) {
		c.value=gensum(3,f.H57.value,f.H55.value,f.I51.value);
	}
	c=f.I60;
	c.value=gensum(2,f.I38.value,f.I58.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;
	c.value = gensum(1,c.value);
	if ((c == f.B6) || (c == f.B7)) { computesum(f.D8); return; }
	if ((c == f.B11) || (c == f.B12) || (c == f.B13) || (c == f.B14)) { computesum(f.B15); return; }
	if ((c == f.B15) || (c == f.B16)) { computesum(f.D17); return; }
	if ((c == f.B19) || (c == f.B20) || (c == f.B21) || (c == f.B22) || (c == f.B23)) { computesum(f.D24); return; }
	if ((c == f.D25) || (c == f.D26) || (c == f.D27)
		 || (c == f.D29) || (c == f.D32) || (c == f.D31)) { computesum(f.D32); return; }
	if ((c == f.B34) || (c == f.B35) || (c == f.B36) || (c == f.B37) 
		 || (c == f.B39) || (c == f.B40) || (c == f.B41) ) { computesum(f.B42); return; }
	if ((c == f.B43)) { computesum(f.D44); return; }
	if ((c == f.D32) || (c == f.D44) || (c == f.D47) || (c == f.D48) 
		|| (c == f.D49) || (c == f.D50) || (c == f.D51) || (c == f.D52)
		|| (c == f.D53) || (c == f.D55) || (c == f.D56) || (c == f.D57)
		|| (c == f.D58) || (c == f.D59) ) { computesum(f.D61); return; }

	if ((c == f.I6) || (c == f.I7) || (c == f.I8) || (c == f.I9) 
		|| (c == f.I10) || (c == f.I11) || (c == f.I12) || (c == f.I13)
		|| (c == f.I14) || (c == f.I15) || (c == f.I16) || (c == f.I17)
		|| (c == f.I18) || (c == f.I19) || (c == f.I20) || (c == f.I21)
		|| (c == f.I22) ) { computesum(f.I23); return; }
	if ((c == f.I32) || (c == f.I33) || (c == f.I35) || (c == f.I36)) { computesum(f.I37); return; }
	if ((c == f.I49) || (c == f.I50) ) { computesum(f.I51); return; }
	if ((c == f.H53) || (c == f.H54) ) { computesum(f.H55); return; }
	if (c == f.H57) { computesum(f.I58); 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 = c.checked;
	reformat(f.B6);
	reformat(f.B7);
		reformat(f.D8);
	reformat(f.B11);
	reformat(f.B12);
	reformat(f.B13);
	reformat(f.B14);
	reformat(f.B15);
	reformat(f.B16);
		reformat(f.D17);
	reformat(f.B19);
	reformat(f.B20);
	reformat(f.B21);
	reformat(f.B22);
	reformat(f.B23);
		reformat(f.D24);
		reformat(f.D25);
		reformat(f.D26);
		reformat(f.D27);
		reformat(f.D29);
		reformat(f.D30);
		reformat(f.D31);
		reformat(f.D32);
	reformat(f.B34);
	reformat(f.B35);
	reformat(f.B36);
	reformat(f.B37);
	reformat(f.B39);
	reformat(f.B40);
	reformat(f.B41);
	reformat(f.B42);
	reformat(f.B43);
		reformat(f.D44);
		reformat(f.D47);
		reformat(f.D48);
		reformat(f.D49);
		reformat(f.D50);
		reformat(f.D51);
		reformat(f.D52);
		reformat(f.D53);
		reformat(f.D55);
		reformat(f.D56);
		reformat(f.D57);
		reformat(f.D58);
		reformat(f.D59);
		reformat(f.D61);

		reformat(f.I6);
		reformat(f.I7);
		reformat(f.I8);
		reformat(f.I9);
		reformat(f.I10);
		reformat(f.I11);
		reformat(f.I12);
		reformat(f.I13);
		reformat(f.I14);
		reformat(f.I15);
		reformat(f.I16);
		reformat(f.I17);
		reformat(f.I18);
		reformat(f.I19);
		reformat(f.I20);
		reformat(f.I21);
		reformat(f.I22);
		reformat(f.I23);

		reformat(f.I32);
		reformat(f.I33);
		reformat(f.I35);
		reformat(f.I36);
		reformat(f.I37);
		reformat(f.I38);

		reformat(f.I49);
		reformat(f.I50);
		reformat(f.I51);
	reformat(f.H53);
	reformat(f.H54);
	reformat(f.H55);
	reformat(f.H57);
		reformat(f.I58);
		reformat(f.I60);
	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.D8) { f.B11.focus(); return; }
	if (c==f.B15) { f.B16.focus(); return; }
	if (c==f.D17) { f.B19.focus(); return; }
	if (c==f.D24) { f.D25.focus(); return; }
	if (c==f.D32) { f.B34.focus(); return; }
	if (c==f.B42) { f.B43.focus(); return; }
	if (c==f.D44) { f.D47.focus(); return; }
	if (c==f.D61) { f.I6.focus(); return; }
	if (c==f.I23) { f.I32.focus(); return; }
	if (c==f.I37) { f.I49.focus(); return; }
	if (c==f.I38) { f.I49.focus(); return; }
	if (c==f.I51) { f.H53.focus(); return; }
	if (c==f.H55) { f.H57.focus(); return; }
	if (c==f.I58) { f.I60.focus(); return; }
	return;
}
//-->

