
<!--
//********************************************************
//* Created for Orion Systems by Scott A. Caldwell
//* 2005-10-04
//* invoiceproducts.js
//* page specific functions to match the behavior of
//* the invoiceproducts.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() {
}
//********************************************************
//* 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.invoiceproducts.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.E22.value=genprod(f.B22,f.D22,1);
	f.E23.value=genprod(f.B23,f.D23,1);
	f.E24.value=genprod(f.B24,f.D24,1);
	f.E25.value=genprod(f.B25,f.D25,1);
	f.E26.value=genprod(f.B26,f.D26,1);
	f.E27.value=genprod(f.B27,f.D27,1);
	f.E28.value=genprod(f.B28,f.D28,1);
	f.E29.value=genprod(f.B29,f.D29,1);
	f.E30.value=genprod(f.B30,f.D30,1);
	f.E31.value=genprod(f.B31,f.D31,1);
	f.E32.value=genprod(f.B32,f.D32,1);
	f.E33.value=genprod(f.B33,f.D33,1);
	f.E34.value=genprod(f.B34,f.D34,1);
	f.E35.value=genprod(f.B35,f.D35,1);
	f.E36.value=genprod(f.B36,f.D36,1);
	f.E37.value=genprod(f.B37,f.D37,1);
	f.E38.value=genprod(f.B38,f.D38,1);
	f.E39.value=genprod(f.B39,f.D39,1);
	f.E40.value=genprod(f.B40,f.D40,1);
	f.E42.value=xsum(f,'E22:40');
	reformat(f.E44);
	f.E46.value=genprod(f.E42,f.D46,100);
	f.E48.value=gensum(3,f.E42.value,f.E44.value,f.E46.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,'B22:40')) {
		if (c.value!='') {
			c.value = parseInt(gensum(1,c.value));
			computesum(f);
			return;
		} else {
			f.E44.focus();
			return;
		}
	}
	if (isInRange(c,'C22:40')) {
		if (c.value=='') {
			f.E44.focus();
		} else {
			divexpand(c);
		}
		return;
	}
	if (isInRange(c,'D22:40')) { c.value = gensum(1,c.value);computesum(f); return; }
	if (c==f.E44) { c.value = gensum(1,c.value);computesum(f); return; }
	if (c==f.D46) { c.value = gensum(1,c.value);computesum(f); return; }
	return;
}
//********************************************************
//* divexpand
//*		generic function added to all line input boxes
//* 	checks to see if the next line is visible
//********************************************************
function divexpand(c) {
	var f=c.form;
	if (isInRange(c,'C32:40')) {
		var s=c.name;
		var i=parseInt((s.substring(1,3)))+1;
		if ((i<41) && (c.value != '')) {
			var s='invline'+i;
			display(s,1);
		}
	}
	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.D24);
	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.E22) { f.B23.focus(); return; }
	if (c==f.E23) { f.B24.focus(); return; }
	if (c==f.E24) { f.B25.focus(); return; }
	if (c==f.E25) { f.B26.focus(); return; }
	if (c==f.E26) { f.B27.focus(); return; }
	if (c==f.E27) { f.B28.focus(); return; }
	if (c==f.E28) { f.B29.focus(); return; }
	if (c==f.E29) { f.B30.focus(); return; }
	if (c==f.E30) { f.B31.focus(); return; }
	if (c==f.E31) { f.B32.focus(); return; }
	if (c==f.E32) { f.B33.focus(); return; }
	if (c==f.E33) { f.B34.focus(); return; }
	if (c==f.E34) { f.B35.focus(); return; }
	if (c==f.E35) { f.B36.focus(); return; }
	if (c==f.E36) { f.B37.focus(); return; }
	if (c==f.E37) { f.B38.focus(); return; }
	if (c==f.E38) { f.B39.focus(); return; }
	if (c==f.E39) { f.B40.focus(); return; }
	if (c==f.E40) { f.E44.focus(); return; }
	if (c==f.E42) { f.E44.focus(); return; }
	if (c==f.E46) { f.A45.focus(); return; }
	return;
}
//********************************************************
//* click one
//*		generic function for not allowing more than
//* 	one payment boxed to be checked
//********************************************************
function checkone(c) {
	var f=c.form;
	if (c.checked){
		if (c==f.A45) { 
			f.B45.checked=false;
			f.C45.checked=false;
			f.D45.checked=false;
		}
		if (c==f.B45) { 
			f.A45.checked=false;
			f.C45.checked=false;
			f.D45.checked=false;
		}
		if (c==f.C45) { 
			f.A45.checked=false;
			f.B45.checked=false;
			f.D45.checked=false;
		}
		if (c==f.D45) { 
			f.A45.checked=false;
			f.B45.checked=false;
			f.C45.checked=false;
		}
	}
}
//-->

