<!--
function IsNbrKey(key) {
   // Was key that was pressed a numeric character (0-9) (or a valid editing key)?
   if ( (key > 47 && key < 58) || IsEditKey(key) || key == 190 || key==110 || (key > 95 && key < 106) ) return(true); // if so, do nothing
   else return(false);     
}

function IsEditKey(key) {
   // Was key that was pressed a numeric character (0-9) (or a valid editing key)?
   //   enter      backspc   tab       shift       home       end        delete     insert     right      left        up        down      caps lock   ctrl 
   if ( key==13 || key==8 || key==9 || key==16 ||  key==36 || key==35 || key==46 || key==45 || key==39 || key==37 || key==38 || key==40 || key==20 || key==17) return(true); // if so, do nothing
   else return(false);   
}

function EatKey() {
   var key = window.event.keyCode;
	// let them hit the tab key!
	if(key == 9) window.event.returnValue = key;
	else window.event.returnValue = null;
}

function NbrsOnly(objthis) {
	try {
		var key = window.event.keyCode;
		// replace was done to pacify the MAC
		objthis.value = objthis.value.replace(/([^0-9.$])/g,"");
		if (IsNbrKey(key)) return(key);
		else window.event.returnValue = null;
	} catch (e) {}
}

function LimitFieldLgth(objthis,iMaxLgth) {
	var sFldValu = objthis.value;
	if(sFldValu.length >= iMaxLgth) {
		// Eat the keystroke if its not a tab key!
		if(IsEditKey(window.event.keyCode) == false) window.event.returnValue = null;
		objthis.value = objthis.value.substring(0, iMaxLgth);
	}
}


function toDate(sDt, sFmt) {
/* 
	Takes a date string and returns a Date object according to the format string provided
	Variables:
		sDt : the string representing the date you wish to use;
		sFmt : the string that supplies the format the sDt string was sent in
	
	Use:
		By passing in the date and the format, you may construct a JavaScript Date object
		for any valid date using any date format you want. The minimum (of course)
		is month, day and year.
		Example: var bday = toDate('3/9/1969 10:28 am', 'm/d/y h:i a');
	
	Legend - the following are the codes (case-sensitive!) passed in through the format string:
		a : Ante meridiem and Post meridiem (am or pm); case matters not
		m : Numeric representation of a month, with or without leading zeros
		M : A textual representation of a month, three letters or full name 
		d : Day of the month, with or without leading zeros 
		y : A full 4 digit numeric representation of a year (does NOT support 2 digit years)
		h : 12-hour format of an hour with or without leading zeros 
		H : 24-hour format of an hour with or without leading zeros 
		i : Minutes with leading zeros
		s : Seconds, with or without leading zeros
		l (lowercase 'L') : Milliseconds, with or without leading zeros
*/
	var rDt = null, // return value - will be null if there is an error
		aDtParts = new Array(), // array to hold the date parts of sDt
		aFmtParts = new Array(), // array to hold the format parts of sFmt
		aDtNums = new Array(), // array to collect date parts from sDt by sFmt
		aMonths = new Array("jan", "feb", "mar", "apr", "may", 
			"jun", "jul", "aug", "sep", "oct", "nov", "dec"), // month names array
	
	// split the date and format strings into their component parts
	sDt = sDt.replace(/[\s\/\.\-\:\;_,]+/gi, " ");
	aDtParts = sDt.split(" ");
	sFmt = sFmt.replace(/[\s\/\.\-\:\;_,]+/gi, " ");
	aFmtParts = sFmt.split(" ");
	
	//make sure we have arrays of the same size
	if (aDtParts.length == aFmtParts.length) {
		for (var x = 0; x < aFmtParts.length; x++) {
			if (aFmtParts[x] == "m") aDtNums["month"] = Number(aDtParts[x]) - 1; // remember, js months start at 0!
			if (aFmtParts[x] == "M") {
				for (var m = 0; m < aMonths.length; m++) {
					//we have to match the first three letters only
					var tmpM = aDtParts[x].toLowerCase().substr(0,3);
					if (tmpM == aMonths[m]) {
						aDtNums["month"] = Number(m);
						break;
					}
				}
			}
			if (aFmtParts[x] == "d") aDtNums["day"] = Number(aDtParts[x]);
			if (aFmtParts[x] == "y") aDtNums["year"] = Number(aDtParts[x]);
			if (aFmtParts[x] == "H") aDtNums["hour"] = Number(aDtParts[x]);
			if (aFmtParts[x] == "h") {
				// if pm was provided, make sure we convert our hour to the 24 hour format for accuracy
				aDtNums["hour"] = (sDt.toLowerCase().indexOf("pm") != -1) ? Number(aDtParts[x]) + 12 : Number(aDtParts[x]);
			}
			if (aFmtParts[x] == "i") aDtNums["min"] = Number(aDtParts[x]);
			if (aFmtParts[x] == "s") aDtNums["sec"] = Number(aDtParts[x]);
			if (aFmtParts[x] == "l") aDtNums["msec"] = Number(aDtParts[x]);
		}
		
		// we need at least month/day/year to construct a valid date
		if ((typeof aDtNums["month"] == "number") && aDtNums["day"] && aDtNums["year"]) {
			// construct the date depending on how many date parts were provided
			if (aDtNums["hour"] && aDtNums["min"] && aDtNums["sec"] && aDtNums["msec"]) {
				//alert("rDt = new Date(" + aDtNums["year"] + ", " + aDtNums["month"] + ", " + aDtNums["day"] + ", " + aDtNums["hour"] + ", " + aDtNums["min"] + ", " + aDtNums["sec"] + ", " + aDtNums["msec"] + ")");
				rDt = new Date(aDtNums["year"], aDtNums["month"], aDtNums["day"], aDtNums["hour"], aDtNums["min"], aDtNums["sec"], aDtNums["msec"]);
			} else if (aDtNums["hour"] && aDtNums["min"] && aDtNums["sec"]) {
				//alert("rDt = new Date(" + aDtNums["year"] + ", " + aDtNums["month"] + ", " + aDtNums["day"] + ", " + aDtNums["hour"] + ", " + aDtNums["min"] + ", " + aDtNums["sec"] + ")");
				rDt = new Date(aDtNums["year"], aDtNums["month"], aDtNums["day"], aDtNums["hour"], aDtNums["min"], aDtNums["sec"]);
			} else if (aDtNums["hour"] && aDtNums["min"]) {
				//alert("rDt = new Date(" + aDtNums["year"] + ", " + aDtNums["month"] + ", " + aDtNums["day"] + ", " + aDtNums["hour"] + ", " + aDtNums["min"] + ")");
				rDt = new Date(aDtNums["year"], aDtNums["month"], aDtNums["day"], aDtNums["hour"], aDtNums["min"]);
			} else {
				//alert("rDt = new Date(" + aDtNums["year"] + ", " + aDtNums["month"] + ", " + aDtNums["day"] + ")");
				rDt = new Date(aDtNums["year"], aDtNums["month"], aDtNums["day"]);
			}
		} //else alert("no matches!\nmonth:" + aDtNums["month"] + "\nday: " + aDtNums["day"] + "\nyear: " + aDtNums["year"] + "\nhour" + aDtNums["hour"] + "\nmin" + aDtNums["min"] + "\nsec" + aDtNums["sec"] + "\nmsec" + aDtNums["msec"]);
	}
	return rDt;
}


// -->
