	function toggleLayer( whichLayer ) {
  		var elem, vis;
  		if (document.getElementById) { // this is the way the standards work
			elem = document.getElementById(whichLayer);
		} else if (document.all) { // this is the way old msie versions work
			elem = document.all[whichLayer];
		} else if (document.layers) { // this is the way nn4 works
			elem = document.layers[whichLayer];
		} 
  		vis = elem.style;
  		
		// if the style.display value is blank we try to figure it out here
  		if (vis.display == '' && elem.offsetWidth != undefined && elem.offsetHeight != undefined) {
			vis.display = (elem.offsetWidth != 0 && elem.offsetHeight != 0) ? 'block' : 'none';
		}
  		vis.display = (vis.display==''||vis.display=='block')?'none':'block';		
	}

			
			function test() {
			}
				
			function show_comment(pkid) {
				$("shortfall_comment").show();
			}
			
			// this is the stuff for prototype
			function proToggle(name) {
				$(name).toggle();
			}
			// this is the stuff for prototype
			function proShow(name) {
				$(name).show();
			}

				function checkDelete(form) {
					//var alert;
					//var confirm;
					if (form.payroll !== null && form.payroll.value !== "" && form.match.value === "") {
						alert("Before Manual Matching you must use the \n 'search payroll' link");
						return false;
					}
					if (form.remove !== null && form.remove.value == "1") {
						if (!confirm("Are you sure you wish to delete. \nThis will be permanent")) {
							return false;
						}
					}
				}
				
				function calcChars(input, output, count) {
					//var alert;
					var i = count - input.value.length;
					if (i < 0) {
						input.value = input.value.substring(0, count);
						alert("You have reached the maximum size" + input.value.length);
						return false;
					}
					output.value = i;
					return true;
				}
				
				function openwin(pageurl, winname, winwidth, winheight, resizable, scrollbars) {
					var pointer = window.open(pageurl, winname, "width=" + winwidth + ",height=" + winheight + ",toolbar=no,directories=no,menubar=no,status=no,resizable=" + resizable + ",location=no,scrollbars=" + scrollbars + ",copyhistory=no");
					pointer.focus();
				}
				
				function tester() {
					alert("getting here");
				}

				function replace_value(field, value) {
					//alert(field);
					//alert(value);
					try {
						var el = document.getElementById(field);
						el.value = value;
					} catch (err) {
						// do nothing as this is sometimes expected
					}
				}
				
				function doPayroll(form) {
					form.match.value = "1";
				}
				
				function resetPayroll(form) {
					var el   = document.getElementById('payrollPop');
					el.href  = "payroll.pop.do?payroll=" + form.payroll.value;
				}
				
				function SetAllCheckBoxes(FormName, FieldName, CheckValue) {
					//alert(FieldName);
					if(!document.forms[FormName]){return;}
					var objCheckBoxes = document.forms[FormName].elements[FieldName];
					if(!objCheckBoxes) {return;}
					var countCheckBoxes = objCheckBoxes.length;
					if(!countCheckBoxes) {
						//alert("no loop : " + objCheckBoxes.name)
						objCheckBoxes.checked = CheckValue; 
					} else {// set the check value for all check boxes
						//alert("loop : " + countCheckBoxes);
						for(var i = 0; i < countCheckBoxes; i++) {
							objCheckBoxes[i].checked = CheckValue;
						}
					}
				}
				
				function SetAllChecks(IdName, CheckValue) {
					var objCheckBoxes = document.getElementsByTagName(IdName);
					if(!objCheckBoxes) {return;}
					var countCheckBoxes = objCheckBoxes.length;
					if(!countCheckBoxes) {
						objCheckBoxes.checked = CheckValue; 
					} else {// set the check value for all check boxes
						for(var i = 0; i < countCheckBoxes; i++) {
							objCheckBoxes[i].checked = CheckValue;
						}
					}
				}
				
			function Agency(){
				var data = document.getElementById("agent").value;
				//alert(data);
				if (data<=0) { 
					document.getElementById("form2a").style.display='inline'; 
				}
				if (data>0) { 
					document.getElementById("form2a").style.display='none'; 
				}
			}
				
				function checkAll(field, val, isChecked) {
					for (var i = 0; i < field.length; i++) {
						if (field[i].alt == val) {
							field[i].checked = isChecked;
						}
					}
				}
				
				function checkAllTitle(field, val, isChecked) {
					//alert('inside checkAllTitle');
					for (var i = 0; i < field.length; i++) {
						if (field[i].title == val) {
							field[i].checked = isChecked;
						}
					}
				}
				
				function checkAllPositive(field, val, isChecked) {
					for (var i = 0; i < field.length; i++) {
						if (field[i].alt == val && isChecked == true) {						
							field[i].checked = isChecked;
						}
					}
				}
				
				if (!document.getElementById) {
					if (document.all) {
						document.getElementById = function () {
							if (typeof document.all[arguments[0]] != "undefined") {
								return document.all[arguments[0]];
							} else {
								return null;
							}
						};
					} else {
						if (document.layers) {
							document.getElementById = function () {
								if (typeof document[arguments[0]] != "undefined") {
									return document[arguments[0]];
								} else {
									return null;
								}
							};
						}
					}
				}

