
<!--
//********************************************************
//* Created for Orion Systems by Scott A. Caldwell
//* 2005-09-14
//* profit.js
//* page specific functions to match the behavior of
//* the profit.xls spreadsheet calculations and formulas
//********************************************************
window.onload = wonload;
function wonload() {
	sheetformat(document.profitloss.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;
	var tmp;
	if (c == f.D5) { c.value=gendiff(2,f.B3.value,f.B4.value); c=f.D19; }
	if (c == f.B16) {
		c.value=gensum(8,
						f.B7.value,f.B8.value,f.B9.value,f.B10.value,
						f.B11.value,f.B13.value,f.B14.value,f.B15.value
						); c=f.D18; }
	if (c == f.D18) {
		c.value=gendiff(2,
						f.B16.value,f.B17.value
						); c=f.D19; }
	if (c == f.D19) {
		c.value=gendiff(2,
						f.D5.value,f.D18.value
						); c=f.B54; }
	if (c == f.B52) {
		tmp=gensum(14,
						f.B21.value,f.B22.value,f.B23.value,f.B24.value,
						f.B25.value,f.B26.value,f.B27.value,f.B28.value,
						f.B29.value,f.B30.value,f.B31.value,f.B32.value,
						f.B33.value,f.B34.value);
		tmp=gensum(11,tmp,
						f.B35.value,f.B36.value,f.B37.value,f.B38.value,
						f.B39.value,f.B40.value,f.B41.value,f.B42.value,
						f.B43.value,f.B44.value);
		c.value=gensum(7,tmp,
						f.B46.value,f.B47.value,f.B48.value,f.B49.value,
						f.B50.value,f.B51.value);
	}
	c=f.B54;
	c.value=gendiff(2,f.D19.value,f.B52.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.B3) { computesum(f.D5); return; }
	if (c == f.B4) { computesum(f.D5); return; }
	if (c == f.B7) { computesum(f.B16); return; }
	if (c == f.B8) { computesum(f.B16); return; }
	if (c == f.B9) { computesum(f.B16); return; }
	if (c == f.B10) { computesum(f.B16); return; }
	if (c == f.B11) { computesum(f.B16); return; }
	if (c == f.B13) { computesum(f.B16); return; }
	if (c == f.B14) { computesum(f.B16); return; }
	if (c == f.B15) { computesum(f.B16); return; }
	if (c == f.B17) { computesum(f.D18); return; }
	if (c == f.B21) { computesum(f.B52); return; }
	if (c == f.B22) { computesum(f.B52); return; }
	if (c == f.B23) { computesum(f.B52); return; }
	if (c == f.B24) { computesum(f.B52); return; }
	if (c == f.B25) { computesum(f.B52); return; }
	if (c == f.B26) { computesum(f.B52); return; }
	if (c == f.B27) { computesum(f.B52); return; }
	if (c == f.B28) { computesum(f.B52); return; }
	if (c == f.B29) { computesum(f.B52); return; }
	if (c == f.B30) { computesum(f.B52); return; }
	if (c == f.B31) { computesum(f.B52); return; }
	if (c == f.B32) { computesum(f.B52); return; }
	if (c == f.B33) { computesum(f.B52); return; }
	if (c == f.B34) { computesum(f.B52); return; }
	if (c == f.B35) { computesum(f.B52); return; }
	if (c == f.B36) { computesum(f.B52); return; }
	if (c == f.B37) { computesum(f.B52); return; }
	if (c == f.B38) { computesum(f.B52); return; }
	if (c == f.B39) { computesum(f.B52); return; }
	if (c == f.B40) { computesum(f.B52); return; }
	if (c == f.B41) { computesum(f.B52); return; }
	if (c == f.B42) { computesum(f.B52); return; }
	if (c == f.B43) { computesum(f.B52); return; }
	if (c == f.B44) { computesum(f.B52); return; }
	if (c == f.B46) { computesum(f.B52); return; }
	if (c == f.B47) { computesum(f.B52); return; }
	if (c == f.B48) { computesum(f.B52); return; }
	if (c == f.B49) { computesum(f.B52); return; }
	if (c == f.B50) { computesum(f.B52); return; }
	if (c == f.B51) { computesum(f.B52); 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.B3);
	reformat(f.B4);
		reformat(f.D5);
	reformat(f.B7);
	reformat(f.B8);
	reformat(f.B9);
	reformat(f.B10);
	reformat(f.B11);
	reformat(f.B13);
	reformat(f.B14);
	reformat(f.B15);
	reformat(f.B16);
	reformat(f.B17);
		reformat(f.D18);
		reformat(f.D19);
	reformat(f.B21);
	reformat(f.B22);
	reformat(f.B23);
	reformat(f.B24);
	reformat(f.B25);
	reformat(f.B26);
	reformat(f.B27);
	reformat(f.B28);
	reformat(f.B29);
	reformat(f.B30);
	reformat(f.B31);
	reformat(f.B32);
	reformat(f.B33);
	reformat(f.B34);
	reformat(f.B35);
	reformat(f.B36);
	reformat(f.B37);
	reformat(f.B38);
	reformat(f.B39);
	reformat(f.B40);
	reformat(f.B41);
	reformat(f.B42);
	reformat(f.B43);
	reformat(f.B44);
	reformat(f.B46);
	reformat(f.B47);
	reformat(f.B48);
	reformat(f.B49);
	reformat(f.B50);
	reformat(f.B51);
	reformat(f.B52);
	reformat(f.B54);
	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; }
	if (c==f.B16) { f.B17.focus(); return; }
	if (c==f.D18) { f.B21.focus(); return; }
	if (c==f.D19) { f.B21.focus(); return; }
	if (c==f.B52) { f.B54.focus(); return; }
	return;
}
//-->
