	function PrintPage(text){
		text=document
		print(text)
	}

	function PopItUp(content,width,height) {
		if (width <= 0) width=300;
		if (height <= 0) height=150;
		newwindow=window.open('','popup1','height='+height+',width='+width);
		var tmp = newwindow.document;
		tmp.write('<html><head></head><body>');
		tmp.write(content);
		tmp.write('<center><p><a href="javascript:self.close()">close window</a></p></center>');
		tmp.write('</body></html>');
		tmp.close();
	}

	function PopUpFromId(id,width,height) {
		var content = '';
		if (document.getElementById) {
			content = document.getElementById(id).innerHTML;
			PopItUp(content,width,height);
			return true;
		}
		return false;
	}

	function ShowHelp(hid) {
		newwindow=window.open('/help.html#'+hid,'help1','height=500,width=700,resizable=yes,scrollbars=yes');
	}

	function HideElements(ids,hide) {
		var disp = (hide) ? 'none' : '';
		if (document.getElementById) {
			for (x in ids) {
				document.getElementById(ids[x]).style.display = disp;
			}
		}
	}

	function HideElementById(ids,hide) {
		var disp = (hide) ? 'none' : '';
		if (document.getElementById) {
			document.getElementById(ids).style.display = disp;
		}
	}

	function HideElementByName(nam,hide) {
		var disp = (hide) ? 'none' : '';
		if (document.getElementByName) {
			document.getElementsByName(nam).style.display = disp;
		}
	}

	function ToggleAllCheckboxes(myform, myname, myvalue) {
		var formblock = document.getElementById(myform);
		var forminputs = formblock.getElementsByTagName('input');

		for (i = 0; i < forminputs.length; i++) {
			// regex here to check name attribute
			var regex = new RegExp(myname, "i");
			if (regex.test(forminputs[i].getAttribute('name'))) {
				if (myvalue == '1') {
					forminputs[i].checked = true;
				}
				else if (myvalue == '0') {
					forminputs[i].checked = false;
				}
				else {
					forminputs[i].checked = !(forminputs[i].checked);
				}
			}
		}
	}

	function swapBGColor(elname,color1,color2) {
		var bgclr = document.getElementsByName(elname)[0].style.backgroundColor;
		alert(bgclr);
		if (bgclr == color1) {
			document.getElementsByName(elname)[0].style.backgroundColor = color2;
		}
		else {
			document.getElementsByName(elname)[0].style.backgroundColor = color1;
		}
	}

	function swapClass(elname,class1,class2) {
		var curcls = document.getElementsByName(elname)[0].className;
		alert(curcls);
		if (curcls == class1) {
			document.getElementsByName(elname)[0].className = class2;
		}
		else {
			document.getElementsByName(elname)[0].className = class1;
		}
	}

	function radioSwap(radioid,cellid,count0,class1,class2) {
		for (var i=1; i <= count0; i++) {
			var radid = radioid+i;
			var celid = cellid+i;
			var radio0 = document.getElementById(radid);
			var cell0 = document.getElementById(celid);

			if (radio0.checked) {
				cell0.className = class2;
			}
			else {
				cell0.className = class1;
			}
		}
	}

	/*
		Calls to htSubmitToId require prototype.js to be loaded
	*/
	function htSubmitToId(fid,tid,url,meth) {
		if (meth.empty()) meth = 'get';
		new Ajax.Updater(
			tid,url, {
				method: meth, parameters: $(fid).serialize(true)
			}
		);
	}

	function htSubmitToPopUp(fid,url,wid,hit,nam) {
		PopUpURL(url+'?'+$(fid).serialize(false),wid,hit,nam);
	}

	/*
		requires prototype.js
	*/
	function htAnchorTargetDiv(divid,url) {
		new Ajax.Updater(divid,url);
	}

	/*
		Updates content of item using id
	*/
	function htWriteToId(id, content) {
		document.getElementById(id).innerHTML = content;
	}


