//	NOTE: this is a legacy version of the library for backward compatibility.
//	Please use the scripts in the folder /lib/ for new files.

	var BR = "<br />\n";
	var CR = "\n";
	var LF = "\r";
	var CRLF = "\n\r";
	var NBSP = "&nbsp;";
	var TAB = "\t";

//	COMMON FUNCTIONS SHORTENED
//	(most functions are named the same as the asp versions)
//------------------------------------------------------------------------------------------------------------------------------------------------------------

	function dw(str) { document.write(str); }
	function rw(str) { document.write(str); } // the asp version
	
	function rr(url) { window.location.href=url; }
	function go(url) { window.location.href=url; }
	
	function rq(varName) {
		var qs = window.location.search;
		var rexp = new RegExp("("+varName+"=)","i");
		if ( varName == 0 ) { return qs; } // returns entire query string starting with ?
		else if ( qs.search(rexp) == -1 ) { return false; } // can't find this variable name in query string
		else {
			rexp.compile("([\?|&]"+varName+"=)([^&]*)","gi");
			var arVal = qs.match(rexp); // returns an array of matching name=value pairs, i.e. ["test=1","test=2","test=3"]
			var thisStr = "";
			for (i in arVal) { // loop through previous compiled array
				arVal[i] = new String(arVal[i]);
				thisStr = arVal[i].split("="); // split each name=value pair at =
				arVal[i] = unescape(thisStr[1]); // reassign only the value to this spot in array
			}
			return arVal;
		}
	};
	
	function setCookie(cookieName, cookieValue, expireDays, cookiePath) {
		var exdate = new Date();
		exdate.setDate(expireDays);
		document.cookie = cookieName + "=" + escape(cookieValue) +
		(isNothing(expireDays) ? "" : ";expires=" + exdate) +
		";path=" + (isNothing(cookiePath) ? "/" : cookiePath);
	};
	
	function getCookie(cookieName){
		if(document.cookie.length > 0) {
			c_start=document.cookie.indexOf(cookieName + "=")
			if (c_start != -1) { 
				c_start=c_start + cookieName.length + 1;
				c_end=document.cookie.indexOf(";", c_start);
				if (c_end == -1) { c_end = document.cookie.length; }
				return unescape(document.cookie.substring(c_start, c_end));
			} 
		}
		return null;
	};
	
	//this function checks for null, undefined, or zero length string value
	function isNothing(v)		{ 
									v = new String(v);
									return ( v == 'undefined' || v == 'null' || v.length == 0 ? true : false );
								}
//------------------------------------------------------------------------------------------------------------------------------------------------------------
//The best Javascript feature ever!
	function objXMLHTTP() {
		var xmlhttp=false;
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (E) {
				xmlhttp = false;
			}
		}
		if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		  xmlhttp = new XMLHttpRequest();
		}
		return xmlhttp;
	}
//----------------------------------------------------------------------------------------------------------------------------------
function isEnterPress(evt) {
	/*
		this function is handy if you want a text field
		to do something other than submit the form
		when enter is pressed while focused
		
		USAGE EXAMPLE:
		document.forms.myTextField.onkeypress = function(event) {
			if(isEnterPress(event) {
				//do something
			}
		}
	
	*/
    var evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode :
        ((evt.which) ? evt.which : evt.keyCode);
    if (charCode == 13 || charCode == 3) {
        return true;
    } else {
        return false;
    }
};
	
//----------------------------------------------------------------------------------------------------------------------------------
	function IEforMacSucks() {
		//IE sucks period.
		var agt = navigator.userAgent.toLowerCase();
	    var appVer = navigator.appVersion.toLowerCase();
		var is_mac = (agt.indexOf("mac") != -1 ? true : false);
		var iePos  = appVer.indexOf('msie');
		if(is_mac & iePos != -1) {
			alert('Microsoft stopped supporting IE for Mac in 2001.\nPlease upgrade to Safari, Firefox or Netscape\nfor a better browsing experience.');
		}
	};

// DISABLE RIGHT (CTRL) CLICK----------------------------------------------------------------------------------------------------------------------------------
	function clickIE4(){
		if (event.button==2){
			return false;
		}
	};
	
	function clickNS4(e){
		if (document.layers||document.getElementById&&!document.all){
			if (e.which==2||e.which==3){
				return false;
			}
		}
	};
	
	function disableRightClick() {
		if (document.layers){
			document.captureEvents(Event.MOUSEDOWN);
			document.onmousedown=clickNS4;
		} else if (document.all&&!document.getElementById){
			document.onmousedown=clickIE4;
		}
		
		document.oncontextmenu = new Function("return false");
	};

// MISC NUMBER FUNCTIONS----------------------------------------------------------------------------------------------------------------------------------

	function getRandomNum(lbound, ubound) {
		return (Math.floor(Math.random() * (ubound - lbound)) + lbound);
	}

	//------------------------------------------------------------------------------------------------
	function round_decimals(original_number, decimals) {
	    var result1 = original_number * Math.pow(10, decimals)
	    var result2 = Math.round(result1)
	    var result3 = result2 / Math.pow(10, decimals)
	    return result3;
	}
	
	//------------------------------------------------------------------------------------------------
	function FormatNumber(num,decimalNum,useLeadingZero,useParens,useCommas) {
		/**********************************************************************
		num - the number to format
		decimalNum - the number of decimal places to format the number to
		useLeadingZero - true / false - display a leading zero for numbers between -1 and 1
		useParens - true / false - use parenthesis around negative numbers
		useCommas - put commas as number separators.
 		**********************************************************************/
 		num = num + "";
 		num = num.replace(/,|(|)|\s/gi, ""); //strip formatting characters
 		num = (isNaN(num) || isNothing(num) ? 0 : num-0);

		var tmpNum = num;
		var iSign = ( num < 0 ? -1 : 1 );		// Get sign of number
		
		// Adjust number so only the specified number of numbers after
		// the decimal point are shown.
		tmpNum = tmpNum.toFixed(decimalNum);
		//tmpNum = round_decimals(tmpNum, decimalNum);
		//tmpNum *= iSign;					// Readjust for sign
		
		// Create a string object to do our formatting on
		var tmpNumStr = new String(tmpNum);
		
		
		// Add zeros after decimal
		var tmpNumDec = tmpNumStr;
		if (tmpNumDec.indexOf(".") == -1 && decimalNum > 0) {
			tmpNumStr += "." + "0".repeat(decimalNum);
		} else if(decimalNum > 0) {
			tmpNumDec = tmpNumDec.substring(tmpNumDec.indexOf(".") + 1, tmpNumDec.length);
			tmpNumDec = (tmpNumDec.length < decimalNum ? "0".repeat(decimalNum - tmpNumDec.length) : "");
			tmpNumStr += tmpNumDec;
		}
			

		// See if we need to put in the commas
		if (useCommas && (num >= 1000 || num <= -1000)) {
			var iStart = tmpNumStr.indexOf(".");
			if (iStart < 0)
				iStart = tmpNumStr.length;
	
			iStart -= 3;
			var iEnd = (num < 0 ? 2 : 1);
			while (iStart >= iEnd) {
				tmpNumStr = tmpNumStr.substring(0,iStart) + "," + tmpNumStr.substring(iStart)
				iStart -= 3;
			}
		}
		// See if we need to strip out the leading zero or not.
		if (!useLeadingZero && num < 1 && num > -1 && tmpNumStr.indexOf(".") != -1) {
			if (num >= 0) {
				tmpNumStr = tmpNumStr.substring(1);
			} else {
				tmpNumStr = "-" + tmpNumStr.substring(2);
			}
		}
	
		// See if we need to use parenthesis
		if (useParens && num < 0) {
			tmpNumStr = "(" + tmpNumStr.substring(1) + ")";
		}
	
		return tmpNumStr;		// Return our formatted string!
	} /** end function FormatNumber **/

	

	//------------------------------------------------------------------------------------------------
	function FormatCurrency(num,decimalNum,bolLeadingZero,bolParens,bolCommas) {
		/**********************************************************************
		NUM - the number to format
		decimalNum - the number of decimal places to format the number to
		bolLeadingZero - true / false - display a leading zero for numbers between -1 and 1
		bolParens - true / false - use parenthesis around negative numbers
		bolCommas - put commas as number separators.											
		**********************************************************************/
		var tmpStr = new String(FormatNumber(num,decimalNum,bolLeadingZero,bolParens,bolCommas));
	
		if (tmpStr.indexOf("(") != -1 || tmpStr.indexOf("-") != -1) {
			// We know we have a negative number, so place '$' inside of '(' / after '-'
			if (tmpStr.charAt(0) == "(")
				tmpStr = "($"  + tmpStr.substring(1,tmpStr.length);
			else if (tmpStr.charAt(0) == "-")
				tmpStr = "-$" + tmpStr.substring(1,tmpStr.length);
				
			return tmpStr;
		}
		else
			return "$" + tmpStr;		// Return formatted string!
	} /** end function FormatCurrency **/

//	VARIABLES TO USE WITH DHTML OBJECTS
//------------------------------------------------------------------------------------------------------------------------------------------------------------
	var isDOM = (document.getElementById ? true : false); 
	var isIE4 = ((document.all && !isDOM) ? true : false);
	var isNS4 = (document.layers ? true : false);

	function getRef(id) {
		if (isDOM) return document.getElementById(id);
		if (isIE4) return document.all[id];
		if (isNS4) return document.layers[id];
	}
	function getSty(id) {
		return (isNS4 ? getRef(id) : getRef(id).style);
	}

// STRING PROTOTYPE FUNCTIONS------------------------------------------------------------------------------------------------------------------------------------------------------------
	function strltrim() {
	return this.replace(/^\s+/,'');
	}
	function strrtrim() {
	return this.replace(/\s+$/,'');
	}
	function strtrim() {
	return this.replace(/^\s+/,'').replace(/\s+$/,'');
	}
	
	String.prototype.ltrim = strltrim;
	String.prototype.rtrim = strrtrim;
	String.prototype.trim = strtrim;
	
	/**** the above functions used like their VBScript counterparts ****/
	function lTrim(str) {
	return str.replace(/^\s+/,'');
	}
	function rTrim(str) {
	return str.replace(/\s+$/,'');
	}
	function trim(str) {
	return str.replace(/^\s+/,'').replace(/\s+$/,'');
	}
	
	//a little update to the link method
	String.prototype.link = function(strHref, strTitle, strClass, strStyle) {
		var strLink = '<a href="' + strHref + '" ';
		strLink += (!isNothing(strTitle) ? 'title="' + strTitle + '" ' : '');
		strLink += (!isNothing(strClass) ? 'class="' + strClass + '" ' : '');
		strLink += (!isNothing(strStyle) ? 'style="' + strStyle + '" ' : '');
		strLink += '>' + this + '</a>';
		return strLink;
	}
	
	String.prototype.repeat = function(num) {
		var tmpstr = this;
		var newstr = ""
			for(var i = 1; i <= num; i++) {
				newstr += tmpstr;
			}
		return newstr;
	}


// DATE FUNCTIONS----------------------------------------------------------------------------------------------------------------------------------
	function secToMill(n) { return new Number(n * 1000);  }
	function minToMill(n) { return new Number(secToMill(n * 60)); }
	function hourToMill(n) { return new Number(secToMill(minToMill(n * 60))); }
	function dayToMill(n) { return new Number(secToMill(minToMill(hourToMill(n * 24)))); }
	
	//------------------------------------------------------------------------------------------------
	function isValidDate(dateStr, format) {
		// Checks for the following valid date formats:
		// MM/DD/YY   MM/DD/YYYY   MM-DD-YY   MM-DD-YYYY
		// Also separates date into month, day, and year variables
		
		//var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;
		
		// To require a 4 digit year entry, use this line instead:
		 var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;
		
		var matchArray = dateStr.match(datePat); // is the format ok?
		if (matchArray == null) {
			return false;
		}
		month = matchArray[1]; // parse date into variables
		day = matchArray[3];
		year = matchArray[4];
		if (month < 1 || month > 12) { // check month range
			return false;
		}
		if (day < 1 || day > 31) {
			return false;
		}
		if ((month==4 || month==6 || month==9 || month==11) && day==31) {
			return false;
		}
		if (month == 2) { // check for february 29th
			var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
			if (day>29 || (day==29 && !isleap)) {
				return false;
		   	}
		}
		return true;  // date is valid
	};

	function FormatDateTime(datetime, FormatType, abbr) {
		//**********************************************************************
		//	FormatType takes the following values
		//	1 - General Date = Friday, October 30, 1998
		//	2 - Typical Date = 10/30/1998
		//	2.5 - Typical Date = 10/30/98 (short yr)
		//	3 - Standard Time = 6:31 PM
		//	4 - Military Time = 18:31
		//	
		//	abbr (optional, default false) is boolean, 
		//	determines whether days and months are abbreviated

		//**********************************************************************

		var strDate = new String(datetime);
		var abbr = Boolean(abbr);
	
		if (strDate.toUpperCase() == "NOW") {
			var myDate = new Date();
			strDate = String(myDate);
		} else {
			var myDate = new Date(datetime);
			strDate = String(myDate);
		}
	
		// Get the date variable parts
		var dayName = myDate.getDayName(abbr);
		
		var monthName = myDate.getMonthName(abbr);
		
		var dayNum = new String(myDate.getDate());
			dayNum = (dayNum.length == 1 ? "0" + dayNum : dayNum + "");

		var Year = new String(myDate.getFullYear());	
		var Hour = myDate.getHours();
		var Min = myDate.getMinutes() + "";
			Min = (Min.length == 1 ? "0" + Min : Min);
		
			
		// Format Type decision time!
		switch (FormatType) {
			case 1 :
				strDate = dayName + ", " + monthName + " " + dayNum + ", " + Year;
				break;
			case 2 :
				strDate = (myDate.getMonth() + 1) + "/" + dayNum + "/" + Year;
				break;
			case 2.5 :
				strDate = (myDate.getMonth() + 1) + "/" + dayNum + "/" + Year.substring(2, 4);
				break;
			case 3 :
				var AMPM = ( Hour >= 12 ? "PM" : "AM" );
				switch(AMPM) {
					case "PM" :
						strDate = Hour - 12;
						strDate = (strDate == 0 ? 12 : strDate);
						break; 
					default :
						Hour = (Hour == 0 ? "12" : Hour+"");
						strDate = Hour + "";
				}
				strDate += ":" + Min + " " + AMPM;
				break;
			case 4 :
				Hour = Hour + "";
				Hour = (Hour.length == 1 ? "0" + Hour : Hour);
				strDate = Hour + ":" + Min;
		}
	
		return strDate;
	}; //end FormatDateTime
	
	// ----------------------------------------------------------------------------------------------------------------------------------
	
	function dateAdd( start, interval, number ) {
		
	    // Create 3 error messages, 1 for each argument. 
	    var startMsg = "Sorry the start parameter of the dateAdd function\n"
	        startMsg += "must be a valid date format.\n\n"
	        startMsg += "Please try again." ;
			
	    var intervalMsg = "Sorry the dateAdd function only accepts\n"
	        intervalMsg += "d, h, m OR s intervals.\n\n"
	        intervalMsg += "Please try again." ;
	
	    var numberMsg = "Sorry the number parameter of the dateAdd function\n"
	        numberMsg += "must be numeric.\n\n"
	        numberMsg += "Please try again." ;
			
	    // get the milliseconds for this Date object. 
	    var buffer = Date.parse( start ) ;
		
	    // check that the start parameter is a valid Date. 
	    if ( isNaN (buffer) ) {
	        alert( startMsg ) ;
	        return null ;
	    }
		
	    // check that an interval parameter was not numeric. 
	    if ( interval.charAt == 'undefined' ) {
	        // the user specified an incorrect interval, handle the error. 
	        alert( intervalMsg ) ;
	        return null ;
	    }
	
	    // check that the number parameter is numeric. 
	    if ( isNaN ( number ) )	{
	        alert( numberMsg ) ;
	        return null ;
	    }
	
	    // so far, so good...
	    //
	    // what kind of add to do? 
	    switch (interval.charAt(0))
	    {
	        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:
	        // If we get to here then the interval parameter
	        // didn't meet the d,h,m,s criteria.  Handle
	        // the error. 		
	        alert(intervalMsg) ;
	        return null ;
	    }
	    return new Date( buffer + number ) ;
	};

// ----------------------------------------------------------------------------------------------------------------------------------
	function dateDiff( start, end, interval, rounding ) {
	
	    var iOut = 0;
	    
	    // Create 2 error messages, 1 for each argument. 
	    var startMsg = "Check the Start Date and End Date\n"
	        startMsg += "must be a valid date format.\n\n"
	        startMsg += "Please try again." ;
			
	    var intervalMsg = "Sorry the dateAdd function only accepts\n"
	        intervalMsg += "d, h, m OR s intervals.\n\n"
	        intervalMsg += "Please try again." ;
	
	    var bufferA = Date.parse( start ) ;
	    var bufferB = Date.parse( end ) ;
	    	
	    // check that the start parameter is a valid Date. 
	    if ( isNaN (bufferA) || isNaN (bufferB) ) {
	        alert( startMsg ) ;
	        return null ;
	    }
		
	    // check that an interval parameter was not numeric. 
	    if ( interval.charAt == 'undefined' ) {
	        // the user specified an incorrect interval, handle the error. 
	        alert( intervalMsg ) ;
	        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. 		
	        alert(intervalMsg) ;
	        return null ;
	    }
	    
	    return iOut ;
	}; //end function dateDiff
	// ----------------------------------------------------------------------------------------------------------------------------------
	
	
// MONTH OBJECT----------------------------------------------------------------------------------------------------------------------------------
	function leapYear(year) {
	  if (year % 4 == 0) {// basic rule
	    return true; // is leap year
	  }
	  /* else */ // else not needed when statement is "return"
	  return false; // is not leap year
	}

	/**** month object ****/
	function Month() {	}
	Month.prototype.getDays = function (month, year) {
		 // create array to hold number of days in each month
		 var ar = new Array(12);
		 ar[0] = 31; // January
		 ar[1] = (leapYear(year)) ? 29 : 28; // February
		 ar[2] = 31; // March
		 ar[3] = 30; // April
		 ar[4] = 31; // May
		 ar[5] = 30; // June
		 ar[6] = 31; // July
		 ar[7] = 31; // August
		 ar[8] = 30; // September
		 ar[9] = 31; // October
		 ar[10] = 30; // November
		 ar[11] = 31; // December
		 return ar[month];
	}
	
	Month.prototype.name = function(month) {
		var ar = new Array(12);
		ar[0] = "January";
		ar[1] = "February";
		ar[2] = "March";
		ar[3] = "April";
		ar[4] = "May";
		ar[5] = "June";
		ar[6] = "July";
		ar[7] = "August";
		ar[8] = "September";
		ar[9] = "October";
		ar[10] = "November";
		ar[11] = "December";
		return ar[month];
	}
	
	Month.prototype.nameAbbr = function(month) {
		var ar = new Array(12);
		ar[0] = "Jan";
		ar[1] = "Feb";
		ar[2] = "Mar";
		ar[3] = "Apr";
		ar[4] = "May";
		ar[5] = "Jun";
		ar[6] = "Jul";
		ar[7] = "Aug";
		ar[8] = "Sep";
		ar[9] = "Oct";
		ar[10] = "Nov";
		ar[11] = "Dec";
		return ar[month];
	}
	
	// ----------------------------------------------------------------------------------------------------------------------------------
	/**** Day object *****************************/
	function Day() {}
	Day.prototype.name = function(weekday) {
		var ar = new Array(7);
		ar[0] = "Sunday";		ar[1] = "Monday";		ar[2] = "Tuesday";
		ar[3] = "Wednesday";	ar[4] = "Thursday";		ar[5] = "Friday";
		ar[6] = "Saturday";		return ar[weekday];
	}
	Day.prototype.nameAbbr = function(weekday) {
		var ar = new Array(7);
		ar[0] = "Sun";		ar[1] = "Mon";		ar[2] = "Tue";
		ar[3] = "Wed";		ar[4] = "Thu";		ar[5] = "Fri";
		ar[6] = "Sat";		return ar[weekday];	
	}
	
	/**** Date object prototypes *****************************/
	Date.prototype.getMonthName = function(isAbbr) {
		var oMonth = new Month();
			return ( !isAbbr ? oMonth.name(this.getMonth()) : oMonth.nameAbbr(this.getMonth()) );
	}
	Date.prototype.getDayName = function(isAbbr) {
		var oDay = new Day();
			return ( !isAbbr ? oDay.name(this.getDay()) : oDay.nameAbbr(this.getDay()) );
	}
	Date.prototype.toSQLstring = function(useSeconds) {
		var dStr = (this.getMonth()+1) + "/" + this.getDate() + "/" + this.getFullYear();
		var hStr = this.getHours();
		var mStr = new String(this.getMinutes());
			mStr = (mStr.length == 1 ? "0" + mStr : mStr);
		var secStr = ( useSeconds+"" == "undefined" || useSeconds == false ? "" : ":" + this.getSeconds() );
			setStr = (secStr.length == 2 ? "0" + secStr : secStr);
		return dStr + " " + hStr + ":" + mStr  + secStr;
	}


//	COMMON FORM FUNCTIONS
//------------------------------------------------------------------------------------------------------------------------------------------------------------
			/**** deprecated ****/
					function returnFormRef(formRef) {
						if (isNaN(formRef)) { return eval("document.forms." + formRef); }
						else { return document.forms[formRef]; }
					}
				
				
					function focusInput(formRef,inputRef) {
						eval('document.forms['+formRef+'].'+inputRef+'.focus()');
					}
					
					function confirmAction(message) {
						if ( window.confirm(message) ) {
				
							return true;
						}
						else {
							return false;
							}
					}
			/**** deprecated ****/

	function hiliteInput(inputRef, color) {
		var clr = (!isNothing(color) ? color : "red");
		inputRef.style.borderColor = clr;
		inputRef.style.backgroundColor = "yellow";
		inputRef.style.color = "#b50000";
	};
	function clearHilite(inputRef) {
		inputRef.style.borderColor = '';
		inputRef.style.backgroundColor = '';
		inputRef.style.color = '';
	};
	function clearAllHilites(formRef) {
		for(var i = formRef.elements.length-1; i >= 0; i--) {
			formRef.elements[i].style.borderColor = '';
			formRef.elements[i].style.backgroundColor = '';
			formRef.elements[i].style.color = '';
		}
	};


	function encodeQuotes(formName,itemName) {
		var thisField = eval("document.forms." + formName + "." + itemName);
		var thisStr = thisField.value;
		var pattern1 = new RegExp("'","gi");
		var pattern2 = new RegExp("\"","gi");
		var pattern3 = new RegExp("<","gi");
		var pattern4 = new RegExp(">","gi");
		thisStr = thisStr.replace(pattern1,"&#146;");
		thisStr = thisStr.replace(pattern2,"&quot;");
		thisStr = thisStr.replace(pattern3,"&lt;");
		thisStr = thisStr.replace(pattern4,"&gt;");
		thisField.value = thisStr;
		
	};
	
	function validateField(strType, strVal) {
		switch(strType) {
			case 'phone_full' : //xxX-XXX-XXX-XXXX w/req country code digits
				var objRegExp  = /^\d{1,3}\-\d{3}\-\d{3}\-\d{4}$/;
				break;
			case 'phone_ac' :  //xxx-XXX-XXX-XXXX w/opt country code digits and req area code
				var objRegExp  = /^(\d{1,3}\-)?\d{3}\-\d{3}\-\d{4}$/;
				break;
			case 'phone_part' :  //xxx-XXX-XXXX w/opt area code
				var objRegExp  = /^(\d{3}\-)?\d{3}\-\d{4}$/;
				break;
			case 'email' :
				var objRegExp  = /^[a-z0-9]([a-z0-9_\-\.]*)@([a-z0-9_\-\.]*)(\.[a-z]{2,3}(\.[a-z]{2}){0,2})$/i;
				break;
			case 'state' :
				var objRegExp = /^(AK|AL|AR|AZ|CA|CO|CT|DC|DE|FL|GA|HI|IA|ID|IL|IN|KS|KY|LA|MA|MD|ME|MI|MN|MO|MS|MT|NB|NC|ND|NH|NJ|NM|NV|NY|OH|OK|OR|PA|RI|SC|SD|TN|TX|UT|VA|VT|WA|WI|WV|WY)$/i; 
				break;
			case 'zip' :
				var objRegExp  = /(^\d{5}$)|(^\d{5}-\d{4}$)/;
				break;
			case 'ssn' :
				var objRegExp  = /^\d{3}\-\d{2}\-\d{4}$/;
				break;
		};
		
		return (strVal.search(objRegExp) > -1 ? true : false);
	
	};
	
	//this function should be called from the onkeyup event
	//will finish the date string with the current year after the second slash (/)
	function completeDate(dateStr) {
		var objRegExp1 = /^\d{1,2}\/\d{1,2}\/\d{1,}$/;
		var objRegExp2 = /^\d{1,2}\/\d{1,2}\/$/;
		if(dateStr.search(objRegExp1) > -1) {
			return dateStr;
		} else if(dateStr.search(objRegExp2) > -1) {
			var yr = new Date(); yr = yr.getFullYear();
			return dateStr + yr;
		}
		return dateStr;
	
	};
	
	function checkOption(inputRef, optValue) {
		for(var i = inputRef.length-1; i >= 0; i--) {
			if(inputRef[i].value == optValue) {
				inputRef[i].checked = true;
				return true;
				break;
			}
		}
		return false;
	};


	function selectOption(inputRef, optValue) {
		for(var i = inputRef.length-1; i >= 0; i--) {
			if(inputRef[i].value == optValue) {
				inputRef.selectedIndex = i;
				return true;
				break;
			}
		}
		return false;
	};
	

//------------------------------------------------------------------------------------------------------------------------------------------------------------



//	FUNCTION GROUP TO DEAL WITH MULTIPLE CHECK BOXES
//------------------------------------------------------------------------------------------------------------------------------------------------------------

	/**** RETURNS FALSE IF NO BOXES ARE CHECKED, TRUE OTHERWISE ****/
	function checkAny(formName, itemName) {
		var thisItem = eval("document.forms." + formName + "." + itemName);
		var checkedFlag = false;
		if( thisItem.length == "undefined" || isNaN(thisItem.length) && thisItem.checked ) {
			checkedFlag = true;
		}
		else {
			for(var i = 0; i <= thisItem.length-1; i++) {
				if( thisItem[i].checked == true ) {
					checkedFlag = true;
					break;
				}
			}
		}
		return checkedFlag;
	};

	/**** SELECTS ALL CHECK BOXES ****/
	var checkToggle = false;
	/**** SELECTS ALL CHECK BOXES ****/
	function checkAll(formName,itemName) {
		if (checkToggle == true) {
			checkNone(formName,itemName);
			checkToggle = false;
		}
		else {
			var thisItem = eval("document.forms." + formName + ".elements['" + itemName + "']");
			checkToggle = true;
			if( thisItem.length == "undefined" || isNaN(thisItem.length) && !thisItem.checked ) {
				thisItem.checked = true;
			}
			else {
				for(var i = 0; i <= thisItem.length-1; i++) {
					thisItem[i].checked = true;
				}
			}
			
		}
	};

	/**** DESELECTS ALL CHECK BOXES ****/
	function checkNone(formName,itemName) {
		var thisItem = eval("document.forms." + formName + "." + itemName);
		if( thisItem.length == "undefined" || isNaN(thisItem.length) && thisItem.checked ) {
			thisItem.checked = false;
		}
		else {
			for(var i = 0; i <= thisItem.length-1; i++) {
				thisItem[i].checked = false;
			}
		}
	};
	
	//return select index for an array of Radios or Checkboxes
	function getSelectedIndex(formItem) {
		for(var i = 0; i <= formItem.length - 1; i++) {
			if(formItem[i].checked == true) {
				return i;
			}
		}
		return -1;
	};	
//------------------------------------------------------------------------------------------------------------------------------------------------------------



// WINDOW & SCREEN FUNCTIONS
//------------------------------------------------------------------------------------------------------------------------------------------------------------
	function refresh() {
		window.location.href = window.location.href;
	};
	
	var thisWin;
	function popup(url, xWidth, yHeight, x, y, statusB) {
		var statbar = (isNothing(statusB) == true ? true : statusB); //statusB is a boolean value, optional, default true
			statbar = (statbar == false ? 'no' : 'yes');
		var attr = "width="+xWidth+",height="+yHeight+",toolbar=no,status="+statbar+",scrollbars";
		x = x - 0; y = y - 0; //convert to number
		if (x == -1 && y == -1) { attr += ",left=" + halfx(xWidth) + ",top=" + halfy(yHeight); }
		else if ( x == -1 ) { attr += ",left=" + halfx(xWidth) + ",top=" + y; }
		else if ( y == -1 ) { attr += ",left=" + x + ",top=" + halfy(yHeight); }
		else { attr += ",left=" + x + ",top=" + y; }
		if(thisWin !== undefined) { thisWin.close(); }
		thisWin = window.open(url,"popup",attr);
		thisWin.focus();
	};
	function getWinXpos(ref) {
		if ( ref == null ) { ref = 'window'; }
		if (window.left) { return eval(ref+'.left'); }
		else if (window.screenX) { return eval(ref+'.screenX'); }
		else { return 0 }
	}
	function getWinYpos(ref) {
		if ( ref == null ) { ref = 'window'; }
		if (window.top) { return eval(ref+'.top'); }
		else if (window.screenY) { return eval(ref+'.screenY'); }
		else { return 0 }
	}
	function getWinWidth(ref) {
		if ( ref == null ) { ref = 'window'; }
		if (window.outerWidth) { return eval(ref+'.outerWidth'); }
		else if (window.innerWidth) { return eval(ref+'.innerWidth'); }
		else if (window.width) { return eval(ref+'.width'); }
		else { return 0 }
	}
	function getWinHeight(ref) {
		if ( ref == null ) { ref = 'window'; }
		if (window.outerHeight) { return eval(ref+'.outerHeight'); }
		else if (window.innerHeight) { return eval(ref+'.innerHeight'); }
		else if (window.height) { return eval(ref+'.height'); }
		else { return 0 }
	}
	function setWinSize(x,y) {
		if (window.outerHeight) { window.outerHeight = y; window.outerWidth = x; }
		else if (window.innerHeight) { window.innerHeight = y; window.outerWidth = x; }
		else if (window.height) { window.height = y; window.width = x; }
		else {  }
	}
	function getScreenWidth() {
		if (screen.width) { return screen.width }
		else if (screen.availWidth) { return screen.availWidth }
		else { return 640 }
	}
	function getScreenHeight() {
		if (screen.height) { return screen.height }
		else if (screen.availHeight) { return screen.availHeight }
		else { return 480 }
	}
	function moveWindow(ref,x,y) {
			if (x == null || x == -1) { x = getWinXpos(ref); }
			if (y == null || y == -1) { y = getWinYPos(ref); }
			eval(ref+'.moveTo(x,y)');
			eval(ref+'.focus()');
	}
	function centerWin(ref,centerX,centerY) {
		// centerX and centerY are boolean values
		var halfx = -1 //default off for moveWindow
		var halfy = -1 //default off for moveWindow
		if (getWinWidth(ref) && centerX) {
			halfx = halfx(getWinWidth(ref));
		}
		if (getWinHeight() && centerY) {
			halfy = halfy(getWinHeight(ref));
			halfy -= 20; //visual balance to compensate for toolbar
		}
		window.moveTo(halfx,halfy);
		
	}
	function halfx(winWidth) {
		return Math.ceil( (getScreenWidth() / 2) - (winWidth / 2) );
	}
	function halfy(winHeight) {
		return Math.ceil( (getScreenHeight() / 2) - (winHeight / 2) );
	}
//------------------------------------------------------------------------------------------------------------------------------------------------------------

