	function gebi(s) {return document.getElementById(s);}
	function isNumeric(s) {var vc="0123456789.,"; for (i=0;i<s.length;i++) {if (vc.indexOf(s.charAt(i))==-1) {return false;}} return true;}
	function checkFldNum(s) {return isNumeric(gebi(s).value);}
	function getFldVal(s)  {var f=gebi(s); return new Number(f.value.replace(',',''));}
	function castIntFld(s) {var f=gebi(s); var v=f.value.replace(',',''); if (v=="" || !isNumeric(v) || v<0) {f.value="0";}    else {f.value=addCommas((new Number(v)).toFixed(0));}}
	function castDblFld(s) {var f=gebi(s); var v=f.value.replace(',',''); if (v=="" || !isNumeric(v) || v<0) {f.value="0.00";} else {f.value=addCommas((new Number(v)).toFixed(2));}}
	function addCommas(s) {s += ''; x=s.split('.'); x1=x[0]; x2=(x.length>1 ? '.'+x[1]:''); var rgx=/(\d+)(\d{3})/; while (rgx.test(x1)) {x1=x1.replace(rgx,'$1'+','+'$2');} return x1+x2;}

	function popup(s)      {w=window.open(s,'popup',      'titlebar=no,toolbar=no,scrollbars=yes,resizable=yes,location=no,statusbar=yes,address=no,width=800,height=600'); w.focus();}
	function popupPrint(s) {w=window.open(s,'popup_print','titlebar=no,toolbar=no,scrollbars=yes,resizable=yes,location=no,statusbar=yes,address=no,width=800,height=600'); w.focus(); w.print();}

	function rewriteChk(pfx,outfld){
		var sval = "";
		for(i=0; i<document.f.elements.length; i++) {
			var fld = document.f.elements[i];
			if(fld.type=="checkbox" && fld.name.substring(0,pfx.length)==pfx && fld.checked){
				sval+=(","+fld.name.substring(pfx.length));
			}
		}
		if (sval!="") {sval=sval.substring(1);}
		outfld.value=sval;
	}

	function checkAll(pfx,v){
		for(i=0; i<document.f.elements.length; i++) {
			var fld = document.f.elements[i];
			if(fld.type=="checkbox" && fld.name.substring(0,pfx.length)==pfx) {fld.checked=v;}
		}
	}