<!--
function voidMe() { return; }
function trimString(sString) {
	// sString should be trimmed (ie: any leading or trailing spaces)
	sString = new String(sString); // cast just in case.
	sString = sString.replace(/^[\s]+/g,"");
	sString = sString.replace(/[\s]+$/g,"");
	return sString;
}
function formatString(sString) {
	// cast it just in case?
	sString = trimString(sString);
	if (sString == "undefined") return String("");
	if (sString == "null") return String("");
	return sString;
}
//=====================================
function doSpaceLink(e) {
	var key = null;
	if (document.all) {
		// MSIE
		e = window.event;
		key = e.keyCode;
	}

	if (key == null) return; // give up on non-MSIE browsers.

	switch (String.fromCharCode(key)) {
		case " " : {
			window.event.returnValue = false;
			var sURL = String(e.srcElement.href);
			if (sURL.indexOf("javascript:") == -1) {
				window.location.href = e.srcElement.href; 
			} else {
				sURL = sURL.replace("javascript:", "");
				sURL = sURL.replace(/%20/g, " ");
				eval(sURL);
			}
			break; 
		}
		default : { break; }
	}
	return;
}
//=====================================
function dateDiff( start, end, interval, rounding ) {
    var iOut = 0;

    var bufferA = Date.parse( start ) ;
    var bufferB = Date.parse( end ) ;
    	
    // check that the start parameter is a valid Date. 
    if ( isNaN (bufferA) || isNaN (bufferB) ) {
        return null ;
    }
	
    // check that an interval parameter was not numeric. 
    if ( interval.charAt == 'undefined' ) {
        // the user specified an incorrect interval, handle the error. 
        return null ;
    }
    
    var number = bufferB-bufferA ;
    
    // what kind of add to do? 
    switch (interval.charAt(0))
    {
        case 'd': case 'D': 
            iOut = parseInt(number / 86400000) ;
            if(rounding) iOut += parseInt((number % 86400000)/43200001) ;
            break ;
        case 'h': case 'H':
            iOut = parseInt(number / 3600000 ) ;
            if(rounding) iOut += parseInt((number % 3600000)/1800001) ;
            break ;
        case 'm': case 'M':
            iOut = parseInt(number / 60000 ) ;
            if(rounding) iOut += parseInt((number % 60000)/30001) ;
            break ;
        case 's': case 'S':
            iOut = parseInt(number / 1000 ) ;
            if(rounding) iOut += parseInt((number % 1000)/501) ;
            break ;
        default:
        // If we get to here then the interval parameter
        // didn't meet the d,h,m,s criteria.  Handle
        // the error. 		
        return null ;
    }
    
    return iOut ;
}
//=====================================
function dateAdd( start, interval, number ) {
		// get the milliseconds for this Date object. 
		var buffer = Date.parse( start ) ;
		switch (interval) {
				case "mo" : case "MO" :
						number *= (32 - new Date(start.getFullYear(), start.getMonth(), 32).getDate());
						// fall through!
				case 'd': case 'D': 
						number *= 24 ; // days to hours
						// fall through! 
				case 'h': case 'H':
						number *= 60 ; // hours to minutes
						// fall through! 
				case 'm': case 'M':
						number *= 60 ; // minutes to seconds
						// fall through! 
				case 's': case 'S':
						number *= 1000 ; // seconds to milliseconds
						break ;
				default:
				return null ;
		}
		return new Date( buffer + number ) ;
}
//=====================================
function nullValueInArray(aData, sValue) {
	for (var i=0; i<aData.length; i++) {
		if (String(aData[i]) == String(sValue)) {
			aData[i] = null;
			return aData;
		}
	}
	return aData;
}
//=====================================
// Data Validator v1.1 (stable)
function DataValidator() {
	this.Validate = DataValidator_ValidateCollectionAware;
	this.Reset = DataValidator_Reset;

	var _DATATYPE_EXAMPLES = new Array();
	_DATATYPE_EXAMPLES["time"] = "time (ex: hh:mm)";
	_DATATYPE_EXAMPLES["int"] = "a Number value no longer than nine digits (ex: 1)";
	_DATATYPE_EXAMPLES["int>0"] = "a Number value no longer than nine digits and greater than zero (ex: 1)";
	_DATATYPE_EXAMPLES["datetime"] = "a datetime formated value (ex: hh:mm mm/dd/yyyy)";
	_DATATYPE_EXAMPLES["date"] = "a date formated value (ex: mm/dd/yyyy)";
	_DATATYPE_EXAMPLES["date>"] = "a date formated value (ex: mm/dd/yyyy) greater than today";
	_DATATYPE_EXAMPLES["date>="] = "a date formated value (ex: mm/dd/yyyy) greater than or equal today";
	_DATATYPE_EXAMPLES["money"] = "a money formated value (ex: x.xx)";
	_DATATYPE_EXAMPLES["emailaddress"] = "an email address (ex: example@somewhere.com)";
	_DATATYPE_EXAMPLES["phonenumber"] = "a phone number formated value (ex: xxx-xxx-xxxxx)";
	_DATATYPE_EXAMPLES["tinyint"] = "x";
	_DATATYPE_EXAMPLES["smallint"] = "x";
	_DATATYPE_EXAMPLES["string"] = "a string value without single quotes, apostrophes, or commas";
	_DATATYPE_EXAMPLES["real"] = "a precision formated value (ex: x.xxxx)";
	_DATATYPE_EXAMPLES["boolean"] = "x";
	_DATATYPE_EXAMPLES["hexcolor"] = "a valid html hex color value (ex: FFFFFF)";
	_DATATYPE_EXAMPLES["cc"] = "a valid credit card number";
	_DATATYPE_EXAMPLES["emailaddressmulti;"] = "one or more valid email addresses (example@somewhere.com) seperated by a semi-colon";
	_DATATYPE_EXAMPLES["emailaddressmulti,"] = "one or more valid email addresses (example@somewhere.com) seperated by a comma";
	_DATATYPE_EXAMPLES["filename"] = "a filename without single quotes, double quotes, ampersands, greater than signs, less than signs, apostrophes, or commas";

	this._DATATYPE_EXAMPLES = _DATATYPE_EXAMPLES;
}
function DataValidator_Reset(oTargetForm) {
	// reset the styles from previous any errors
	for (var iIndex=0; iIndex < oTargetForm.elements.length; iIndex++) {
		var Elm = oTargetForm.elements[iIndex];
		if ((String(Elm.type).toUpperCase() != "TEXT") && (String(Elm.type).toUpperCase() != "TEXTAREA")) continue;
		var sElementName = Elm.name;
		if (sElementName == "") continue;

		if (oTargetForm.elements[sElementName].length)	{
			for (var iElementCount=0; iElementCount < oTargetForm.elements[sElementName].length; iElementCount++) {
				oTargetForm.elements[sElementName][iElementCount].className = "";
			}
		} else {
			Elm.className = "";
		}
	}
	clearCSWarning();
}
function DataValidator_ValidateCollectionAware(oTargetForm, aFormFieldDatatypes, aRequiredFormFields, aFieldDescriptions, minOneField) {
	this.Reset(oTargetForm);
	var _HAS_VALUE = false;
	// preforms validation on the supplied form fields.
	// init form error variables
	var aErrors = new Array();
	var aRequiredErrors = new Array();
	var aRequiredErrorFieldNames = new Array();
	var aDatatypeErrorFieldNames = new Array();
	var sErrorMsg = "The following warnings were generated: \n";
	var bError = false;
	var sFirstErrorField = null;

	// datatype validation
	for (sFormField in aFormFieldDatatypes) {
		if (!oTargetForm.elements[sFormField]) continue;
		if (oTargetForm.elements[sFormField].length) {
			// multi
			for (var iElementCount=0; iElementCount < oTargetForm.elements[sFormField].length; iElementCount++) {
				var Elm = oTargetForm.elements[sFormField][iElementCount]; 
				if (String(Elm.type).toUpperCase() == "HIDDEN") continue;
				if (Elm.disabled == true) continue;
				if (Elm.value == "") continue;
				_HAS_VALUE = true;
				if (Elm.tagName == "SELECT") continue;
				if (!validate(Elm.value, aFormFieldDatatypes[sFormField])) {
					aErrors[aErrors.length] = Elm;
					aDatatypeErrorFieldNames[aDatatypeErrorFieldNames.length] = sFormField + "." + String(iElementCount);
				}
			}
		} else {
			// single
			var Elm = oTargetForm.elements[sFormField];
			if (String(Elm.type).toUpperCase() == "HIDDEN") continue;
			if (Elm.value == "") continue;
			if (Elm.tagName == "SELECT") continue;
			if (Elm.disabled == true) continue;
			_HAS_VALUE = true;
			if (!validate(Elm.value, aFormFieldDatatypes[sFormField])) {
				aErrors[aErrors.length] = Elm;
				aDatatypeErrorFieldNames[aDatatypeErrorFieldNames.length] = sFormField;
			}
		}
	}
	for (var i=0; i<aErrors.length; i++) {
		var oElement = aErrors[i];
		if (oElement.type == "HIDDEN") continue;
		var sFormField = String(oElement.name);
		sErrorMsg += "- You must supply " + this._DATATYPE_EXAMPLES[aFormFieldDatatypes[sFormField]] + " for the "; 
		// use descriptions if available.
		if (aFieldDescriptions) {
			var sFormField = aDatatypeErrorFieldNames[i];
			if (!aFieldDescriptions[sFormField]) {
				if (sFormField.substr(sFormField.indexOf(".")+1).indexOf(".") > -1) {
					var sTemp = sFormField.substr(sFormField.indexOf(".")+1);
					sFormField = sFormField.replace(sTemp.substr(sTemp.indexOf(".")), "");
				}
			}
			sErrorMsg += aFieldDescriptions[sFormField];
		} else {
			sErrorMsg += sFormField.substr(sFormField.indexOf(".")+1);
		}
		sErrorMsg += " field.\n";

		oElement.className = "error";

		if (sFirstErrorField == null) sFirstErrorField = oElement;
		bError = true
	}
	// required field check
	for (var i=0; i<aRequiredFormFields.length; i++) {
		if (aRequiredFormFields[i] == null) continue;
		var sFieldName = String(aRequiredFormFields[i]);
		// collection aware required conditional
		if (sFieldName.indexOf(".") != sFieldName.lastIndexOf(".")) {
			// special case of optional required within a collection.
			var iIndex = parseInt(sFieldName.slice(sFieldName.lastIndexOf(".")+1, sFieldName.length));
			var sName = sFieldName.slice(0, sFieldName.lastIndexOf("."));
			if (String(oTargetForm.elements[sName][iIndex].value).replace(/\s/g, "").length == 0) {
				aRequiredErrors[aRequiredErrors.length] = oTargetForm.elements[sName][iIndex];
				aRequiredErrorFieldNames[aRequiredErrorFieldNames.length] = sFieldName;
			}
		} else {
			if (oTargetForm.elements[aRequiredFormFields[i]].length) {
				if (oTargetForm.elements[sFieldName].options) {
					// select list?
					if (String(oTargetForm.elements[aRequiredFormFields[i]].options[oTargetForm.elements[aRequiredFormFields[i]].selectedIndex].value).length == 0) {
						aRequiredErrors[aRequiredErrors.length] = oTargetForm.elements[aRequiredFormFields[i]];
						aRequiredErrorFieldNames[aRequiredErrorFieldNames.length] = sFieldName;
					}
				} else {
					// multi
					for (var iElementCount=0; iElementCount < oTargetForm.elements[aRequiredFormFields[i]].length; iElementCount++) {
						var Elm = oTargetForm.elements[aRequiredFormFields[i]][iElementCount];
						if (Elm.disabled == true) continue;

						if (formatString(Elm.value) == "") {
							aRequiredErrors[aRequiredErrors.length] = Elm;
							aRequiredErrorFieldNames[aRequiredErrorFieldNames.length] = sFieldName;
						}
					}
				}
			} else {
				// single element
				/* MISSING SELECT LIST VALIDATION? */
				var Elm = oTargetForm.elements[aRequiredFormFields[i]];
				if (Elm.disabled == true) continue;
				if (formatString(Elm.value) == "") {
					aRequiredErrors[aRequiredErrors.length] = Elm;
					aRequiredErrorFieldNames[aRequiredErrorFieldNames.length] = sFieldName;
				}
			}
		}
	}
	for (var i=0; i<aRequiredErrors.length; i++) {
		var oElement = aRequiredErrors[i];
		if (oElement == null) continue;
		if (oElement.type == "HIDDEN") continue;
		sErrorMsg += "- You must supply a value for the ";

		if (aFieldDescriptions) {
			var sFormField = String(aRequiredErrorFieldNames[i]);
			sErrorMsg += aFieldDescriptions[sFormField];
		} else {
			var sFormField = String(oElement.name);
			sErrorMsg += sFormField.substr(sFormField.indexOf('.')+1);
		}

		sErrorMsg += " field.\n";
		oElement.className = "error";
		if (sFirstErrorField == null) sFirstErrorField = oElement;
		bError = true
	}
	
	if (!bError) {
		if ( (minOneField) && (_HAS_VALUE == false) ) {
			bError = true;
			sErrorMsg = "You have attempted to preform a search without specifying any search criteria. Please provide at least one value before searching.";
		}
	}

	if (bError) {
		throwCSWarning(sErrorMsg);
		// *** THIS IS WHERE IT NEEDS TO CATCH ERROR AND FIND PARENT ELEMENT TO SHOW IF ERROR THROWN ***
		try {
			if (!minOneField) {
				sFirstErrorField.focus();
			} else {
				focusFirstField(oTargetForm, true);
			}
		} catch (e) {
			Elm = sFirstErrorField;
			while (Elm != null) {
				if (String(Elm.id).indexOf("jTabs_") > -1) {
					aNames = String(Elm.id).split("_");
					eval(aNames[2]+"Selected = showTab(null, "+aNames[1]+", "+aNames[2]+", "+aNames[2]+"Selected, '"+Elm.id+"');");
					break;
				}
				Elm = Elm.parentNode;
			}
		}
		delete sErrorMsg;
		delete aErrors;
		delete aRequiredErrors;
	}

	if (bError) {
		return false;
	} else {
		return true;
	}
}
function clearCSWarning() {
	var oWarningDiv = (document.all) ? document.all["warning"] : document.getElementById("warning");
	if (oWarningDiv) oWarningDiv.style.display = "none";
	return;
}
function throwCSWarning(sWarning) {
	var oSuccessDiv = (document.all) ? document.all["success"] : document.getElementById("success");
	var oWarningDiv = (document.all) ? document.all["warning"] : document.getElementById("warning");
	var oErrorDiv = (document.all) ? document.all["error"] : document.getElementById("error");
	if (oSuccessDiv) oSuccessDiv.style.display = "none";
	if (oErrorDiv) oErrorDiv.style.display = "none";
	if (oWarningDiv) { 
		oWarningDiv.style.display = "block";
		oWarningDiv.innerHTML = String(sWarning).replace(/\n/g, "<br />");
		window.scroll(0,0);
	} else {
		window.alert(sWarning);
	}
}
function throwCSInformation(sInformation) {
	var oInfoDiv = (document.all) ? document.all["information"] : document.getElementById("information");
	if (oInfoDiv) {
		oInfoDiv.style.display = "block";
		oInfoDiv.innerHTML = String(sInformation).replace(/\n/g, "<br />");
		window.location.href = "#Warning";
	}
}
function throwCASSUpdate(sWarning) {
	var oSuccessDiv = (document.all) ? document.all["success"] : document.getElementById("success");
	var oWarningDiv = (document.all) ? document.all["warning"] : document.getElementById("warning");
	var oErrorDiv = (document.all) ? document.all["error"] : document.getElementById("error");
	var oCASSDiv = (document.all) ? document.all["cassUpdate"] : document.getElementById("cassUpdate");
	if (oSuccessDiv) oSuccessDiv.style.display = "none";
	if (oErrorDiv) oErrorDiv.style.display = "none";
	if (oWarningDiv) oWarningDiv.style.display = "none";
	if (oCASSDiv) { 
		oCASSDiv.style.display = "block";
		document.getElementById("cassUpdateData").innerHTML = String(sWarning).replace(/\n/g, "<br />");
		window.scroll(0,0);
	} else {
		window.alert(sWarning);
	}
}

function parseBoolean(value) {
	if (String(value).toUpperCase()=="TRUE") return "1";
	if (String(value).toUpperCase()=="FALSE") return "0";
}
function validate(val, type) {
	var expInt = /\D/;
	var expDateTime = /^\d{1,2}\/\d{1,2}\/\d{4}$/;
	var expTime = /^\d{1,2}\:\d{1,2}$/;
	var expMoney = /\$?\d*\.\d{2,4}$/;
	var expEmail = /^[\w\.\-]+\@([(\w\.{0,1}\w)\-]|([\w\-]))+\.\w{2,3}$/;
	var expPhone = /^\d{3}\-\d{3}\-\d{4}$/;
	var expTinyint = /\d{1,3}/;
	var expSmallint = /\-?\d+/;
	var expString = /[\'\,]+/;
	var expReal = /\-?\d*\.\d{2,4}$/;
	var expBoolean = /\[0-1]/;
	var expHexColor = /^[a-fA-F0-9]{6}$/;
	var expFileName = /[\'\,&\"\>\<]+/;

	switch (type) {
		case 'time' :
			if (parseInt(String(val).replace(/\:/g, ""), 10) > 2359) return false;
			var aTemp = String(val).split(":");
			if (parseInt(aTemp[1], 10) > 59) return false;
			return expTime.test(val);
		case 'int' :
			if (String(val).length > 9) return false;
			return !expInt.test(val);
		case 'int>0' :
				if (String(val).length > 9) return false;
				return (val > 0) ? !expInt.test(val) : false;
		case 'datetime' :
			return expDateTime.test(val);
		case 'date' :
			var aTemp = String(val).split("/");
			if (aTemp.length < 3) return false;
			// fix leading zero problem with month.
			if (String(aTemp[0]).indexOf("0") == 0) aTemp[0] = String(aTemp[0]).substr(1, String(aTemp[0]).length);
			if (String(aTemp[1]).indexOf("0") == 0) aTemp[1] = String(aTemp[1]).substr(1, String(aTemp[1]).length);
			if ((parseInt(aTemp[0]) < 1) || (parseInt(aTemp[0]) > 12)) return false;
			if ((parseInt(aTemp[1]) < 1) || (parseInt(aTemp[1]) > 31)) return false;
			if ((parseInt(aTemp[2]) < 1753) || (parseInt(aTemp[2]) > 2100)) return false;
			var oDate = new Date(val);
			if ((parseInt(aTemp[0]) - 1) != oDate.getMonth()) return false;
			if (parseInt(aTemp[1]) != oDate.getDate()) return false;
			if (parseInt(aTemp[2]) != oDate.getFullYear()) return false;
			delete oDate;
			delete aTemp;
			return expDateTime.test(val);
		case 'date>' :
			var aTemp = String(val).split("/");
			if (aTemp.length < 3) return false;
			// fix leading zero problem with month.
			if (String(aTemp[0]).indexOf("0") == 0) aTemp[0] = String(aTemp[0]).substr(1, String(aTemp[0]).length);
			if (String(aTemp[1]).indexOf("0") == 0) aTemp[1] = String(aTemp[1]).substr(1, String(aTemp[1]).length);

			if ((parseInt(aTemp[0]) < 1) || (parseInt(aTemp[0]) > 12)) return false;
			if ((parseInt(aTemp[1]) < 1) || (parseInt(aTemp[1]) > 31)) return false;
			if ((parseInt(aTemp[2]) < 1753) || (parseInt(aTemp[2]) > 2100)) return false;
			var oDate = new Date(val);
			if ((parseInt(aTemp[0]) - 1) != oDate.getMonth()) return false;
			if (parseInt(aTemp[1]) != oDate.getDate()) return false;
			if (parseInt(aTemp[2]) != oDate.getFullYear()) return false;
			var oToday = new Date();
			if (oDate < oToday) return false;

			delete oDate;
			delete aTemp;
			return expDateTime.test(val);
		case 'date>=' :
			var aTemp = String(val).split("/");
			if (aTemp.length < 3) return false;
			// fix leading zero problem with month.
			if (String(aTemp[0]).indexOf("0") == 0) aTemp[0] = String(aTemp[0]).substr(1, String(aTemp[0]).length);
			if (String(aTemp[1]).indexOf("0") == 0) aTemp[1] = String(aTemp[1]).substr(1, String(aTemp[1]).length);

			if ((parseInt(aTemp[0]) < 1) || (parseInt(aTemp[0]) > 12)) return false;
			if ((parseInt(aTemp[1]) < 1) || (parseInt(aTemp[1]) > 31)) return false;
			if ((parseInt(aTemp[2]) < 1753) || (parseInt(aTemp[2]) > 2100)) return false;
			var oDate = new Date(val);
			if ((parseInt(aTemp[0]) - 1) != oDate.getMonth()) return false;
			if (parseInt(aTemp[1]) != oDate.getDate()) return false;
			if (parseInt(aTemp[2]) != oDate.getFullYear()) return false;
			var oToday = new Date();
			oToday =  new Date(String(oToday.getMonth()+1) +"/" + String(oToday.getDate()) +"/" + String(oToday.getFullYear()));
			if (oDate < oToday) return false;

			delete oDate;
			delete aTemp;
			return expDateTime.test(val);

		case 'money' : 
			return (val >= 0) ? expMoney.test(val) : false;
		case 'emailaddress' :
			return expEmail.test(val);
		case 'emailaddressmulti;' :
			var bValidEmail = true;
			var aEmails = String(val).split(";");
			for (var iIndex = 0; iIndex < aEmails.length; iIndex++) {
				if (expEmail.test(aEmails[iIndex]) == false) return false;
			}
			return true;
		case 'emailaddressmulti,' :
			var bValidEmail = true;
			var aEmails = String(val).split(",");
			for (var iIndex = 0; iIndex < aEmails.length; iIndex++) {
				if (expEmail.test(aEmails[iIndex]) == false) return false;
			}
			return true;
		case 'phonenumber' :
			return expPhone.test(val);
		case 'tinyint' :
			return (val >= 0 && val <= 255) ? expTinyint.test(val) : false;
		case 'smallint' :
			return (val >= -32768 && val <= 32767) ? expSmallint.test(val) : false;
		case 'string' :	
			return !expString.test(val);
		case 'real' :
			return expReal.test(val);
		case 'boolean' :
			return expBoolean.test(val);
		case 'hexcolor' : 
			return expHexColor.test(val);
		case 'cc' :
			return validateCCNumber(val);
		case 'filename':
			return !expFileName.test(val);
		default :
			return false
	}
}
// =======================================================================
function validateCCNumber(string) {
   // First we loop through the string, building a reversed copy of the
   // digits as we go.  We strip out any non-digits too, so it doesn't
   // matter if the user used spaces or dashes (or any other garbage).
   rstring = "";
   for( l = string.length - 1; l >= 0; l-- )
   {
      c = string.substr( l, 1 );
      if( c >= "0" && c <= "9" ) {
         rstring += c;
	  } else {
		  return false;
	  }
   }

   // Grab the last 4 digits...
   l4 = rstring.substr( rstring.length - 4, 4 );

   // Using the LUHN formula we calculate a checksum value.  All the other
   // cards we recognise must pass this test.
   sum = 0;
   for( l = 1; l <= rstring.length; l++ )
   {
      c = rstring.substr( l - 1, 1 );
      if( l % 2 == 0 )
      {
         n = 2 * parseInt( c );
         if( n > 9 )
         {
            sum += 1;
            n -= 10;
         }
         sum += n;
      }
      else
         sum += parseInt( c );
   }

   // If the sum is not an even multiple of 10 then it fails.
   if( sum % 10 )
      return false;

   // If the number is 16 digits long and starts with "6011" then it's
   // a Discover card.
   if( rstring.length == 16 && l4 == "1106" )
      return true;

   // Grab the right most digit...
   l1 = rstring.substr( rstring.length - 1, 1 );

   // If the number is 13 or 16 digits long and begins with "4" then it's
   // a VISA card.
   if( (rstring.length == 13 || rstring.length == 16) && l1 == "4" )
      //return "visa";
		return true;

   // Grab the last two digits...
   l2 = rstring.substr( rstring.length - 2, 2 );

   // If the number is 16 digits long and the first two digits are "51", "52",
   // "53", "54", or "55" then it's a MasterCard.
   if( rstring.length == 16 && (l2 == "15" || l2 == "25" || l2 == "35" || l2 == "45" || l2 == "55" ) )
      //return "mastercard";
		return true;

   // If the number is 15 digits long and it begins with either "34" or "37"
   // then it's an American Express card.
   if( rstring.length == 15 && (l2 == "43" || l2 == "73" ) )
      //return "amex";
		return true;

   // Grab the last 3 digits...
   l3 = rstring.substr( rstring.length - 3, 3 );

   // If it's none of those then it's false.
   return false;
}
// =======================================================================
function focusFirstField(oForm, ForceFocus) {
	if (!ForceFocus) {
		var bBailOut = false;
		// if the success display is present then don't focus.
		bBailOut = (document.all) ? document.all["success"] : document.getElementById("success");
		if (bBailOut) return;
		// if the error display is present then don't focus.
		bBailOut = (document.all) ? document.all["error"]: document.getElementById("error");
		if (bBailOut) return;
		// if the warning display is currently displayed then don't focus.
		bBailOut = (document.all) ? document.all["warning"].style.display == "block": document.getElementById("warning").style.display == "block";
		if (bBailOut) return;
	}

	for (var i = 0; i < oForm.elements.length; i++) {
		if (oForm.elements[i].name == "Query.rpp") continue;
		if (oForm.elements[i].type != "hidden") 
			if (oForm.elements[i].disabled == false) return oForm.elements[i].focus(); 
	}
	return;
}
// =======================================================================
function toggleDisplay(sElementId) {
	var Elm = (document.all) ? document.all[sElementId] : document.getElementById(sElementId);
	if (!Elm) return;
	if (document.all) if (window.event) window.event.cancelBubble = true;
	(Elm.style.display == "none") ? Elm.style.display = "" : Elm.style.display = "none" ;

	var Elm = (document.all) ? document.all["ShowHide"+sElementId] : document.getElementById("ShowHide"+sElementId);
	if (!Elm) return;
	(Elm.innerHTML == "Show") ? Elm.innerHTML = "Hide" : Elm.innerHTML = "Show";
}
function showDisplay(sElementId) {
	var Elm = (document.all) ? document.all[sElementId] : document.getElementById(sElementId);
	if (!Elm) return;
	if (document.all) if (window.event) window.event.cancelBubble = true;
	Elm.style.display = "";
}
function hideDisplay(sElementId) {
	var Elm = (document.all) ? document.all[sElementId] : document.getElementById(sElementId);
	if (!Elm) return;
	if (document.all) if (window.event) window.event.cancelBubble = true;
	Elm.style.display = "none";
}
// =======================================================================

function FormLoader(FormName, FieldName, Value) {
	if (!document.forms[FormName]) return; // no form
	if (!document.forms[FormName].elements[FieldName]) return; // no field
	var Elm = document.forms[FormName].elements[FieldName];
	// if (Elm.length) return; // ignore multi instances *DISABLED BECAUSE IT PICKS UP SELECTS*
	var Type = String(Elm.tagName).toLowerCase();
	if (Type == "input") Type = Elm.type;

	switch (Type) {
		case "select" : {
			for (var i=0; i < Elm.options.length; i++) {
				if (Elm.options[i].value == Value) {
					Elm.selectedIndex = i;
					// Run OnSelect?
					break;
				}
			}
			break;
		}
		case "checkbox" : {
			if (String(Value) == "1") Elm.checked = true;
			if (String(Elm.value) == String(Value)) Elm.checked = true;
			// Run OnCheck?
			break;
		}
		default : {
			Elm.value = Value;
			break;
		}
	}
	return;
}

-->