<!--
/*************************************************************************
CONTENTS:
function isDigit()
function imgChg(name,imgURL)
function launch(url) 
function s_LaunchCustom(url,winName,features) 
function printWin(url)
function emailWin(url) 
function s_dp(val)
function s_formatPercentage(num)
function placeFocus()
function IsInvalid(field,description,minLen,maxLen)
function NotSelected(field,description)
function AnyCheck(field,description)
function isEmpty(s)
function isEmail(s)
function getRadioButtonValue(radio)
function s_NoRadioButton(field, description)
function s_CheckNumber(Field, Description, MinValue, MaxValue)
function s_NoSelections(theForm)
function s_SwitchStyle(Element)
function s_FormatTime(time, format)
function s_IsValidTime(timeStr)
function s_FormatDateTime(dt, format)
*************************************************************************/
function isDigit() {return ((event.keyCode >= 48) && (event.keyCode <= 57))}
function imgChg(name,imgURL) { document[name].src=imgURL; }
function s_ImgChg(imgID,imgURL) { document.getElementById(imgID).src=imgURL; }
function launch(url) {openWin=window.open(url, "launchWin", "width=800,height=600,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes");}
function s_LaunchCustom(url,winName,features) {window.open(url,winName,features);}
function printWin(url) {openWin=window.open(url, "printWin", "width=800,height=600,toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes");}
function emailWin(url) {openWin=window.open(url, "emailWin", "width=550,height=575,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no");}
function s_dp(val) { //formats a number to 2 decimal points
	val = "" + val;
	count = val.length - val.indexOf('.');
	if (val.indexOf('.') == -1) return val + '.00';
	if (count == 1) return val + '00';
	if (count == 2) return val + '0';
	if (count > 3) {
		val = eval(val)*100; val = Math.round(val)/100;
		val = "" + val; count = val.length - val.indexOf('.');
		if (val.indexOf('.') == -1) return val + '.00';
		if (count == 1) return val + '00';
		if (count == 2) return val + '0';
	}
	return val;
}
function s_formatPercentage(num) { //Formats a decimal value as a percentage rounded to 2 decimal points with a percent sign
	var val = parseFloat(num);
	if (isNaN(val)) { return "0.00%"; }
	if (val <= 0) { return "0.00%"; }
	else {val = (val*10000);val = Math.round(val)/100;}
	val = (val == Math.floor(val)) ? val + '.00' : ((val*10 == Math.floor(val*10)) ? val + '0' : val);
	return (val+'%');
}
function placeFocus() { //Places focus on first editable form field upon onLoad.
	if (document.forms.length > 0) {
		var field = document.forms[0];
		for (i = 0; i < field.length; i++) {
			if ((field.elements[i].type == "text") || (field.elements[i].type == "textarea")) 
				{ document.forms[0].elements[i].focus(); break; }
}	}	}
/******************* TEXT FIELD VALIDATION *******************/
function IsInvalid(field,description,minLen,maxLen) { //Checks if field is between minLen and maxLen; 
	//-1 for minLen will prompt to fill in, but not require a min length.
	//-1 for maxLen allow unlimited characters to be entered.
	if (!field) //If field does not exist, exit
		return false;
    if (minLen==-1 && field.value=="") { alert("Please enter " + description + " before proceeding."); field.focus(); return true; }
  	if (minLen>0 && field.value.length<minLen) { alert("Please enter at least " + minLen + " characters for " + description +"."); field.focus(); return true; }
	if (maxLen>0 && field.value.length>maxLen) { alert("Please enter at most " + maxLen + " characters for " + description +"."); field.focus(); return true; }
	return false;
}
/******************* MENU VALIDATION *******************/
function NotSelected(field,description) {
	if (field) {
		if (field.selectedIndex<1) { alert ("Please select one of the \"" + description + "\" options."); field.focus(); return true; }
	}
	return false;
}
/******************* CHECKBOX VALIDATION *******************/
function AnyCheck(field,description) {
	if (field){
		var total = 0;
		for (var i = 0; i < field.length; i++) {if (eval(field[i].checked) == true) {total += 1;}}
		if (total==0) {alert("Please choose at least one of the "+ description +" options."); field[0].focus(); return true;}
	}
	return false;
}
/******************** EMAIL VALIDATION ********************/
function isEmpty(s)	// Returns true if string s is Empty
	{ return ( (s == null) || (s.length == 0)) }
function isEmail(s) { // Returns true if string s meets the basic format of an email address
	if (isEmpty(s))
		return false;
	var i = 1;											// Look for @ starting with the second character in s												
	var sLen = s.length;
	while( (i < sLen ) && ( s.charAt(i) != "@" ) ) { i++; }
	if( ( i >= sLen ) || (s.charAt(i) != "@")) 
		return false;
    else 
		i += 2;
	while ((i < sLen) && (s.charAt(i) != ".")) { i++; }	// Look for a dot starting with the second character after the @
	if ((i >= sLen - 1) || (s.charAt(i) != "."))		// There must be at least one character after the dot
		return false;
	else 
		return true;
}
/******************* RETURNS RADIO BUTTON VALUE *******************/
function getRadioButtonValue(radio) { 
	var Value = ""
	if (isNaN(radio.length)) {
		if (radio.checked) Value = radio.value;
	}
	else {
		for (var i = 0; i < radio.length; i++){
			if (radio[i].checked) Value = radio[i].value;
		}
	}
	return Value
}
/******************** RADIO BUTTON VALIDATION ********************/
function s_NoRadioButton(field, description){
	if (isEmpty(getRadioButtonValue(field))) {
		alert("Please choose at least one of the "+ description +" options."); 
		if (isNaN(field.length))
			field.focus(); 
		else 
			field[0].focus(); 
		return true;
	}
	else
		return false;
}
/******************* NUMERIC VALUE VALIDATION *******************/
function s_CheckNumber(Field, Description, MinValue, MaxValue) { // Checks a field to make sure it is numerical and b/t Min and Max values
	if (Field){
		floatValue = parseFloat(Field.value)
		// Min and Max value have been specified
		if ((MinValue > -1 && MaxValue > -1) && (isNaN(floatValue) || (eval(Field.value) < MinValue || eval(Field.value) > MaxValue)))
			{alert("Please enter a numerical value between "+ MinValue +" and "+ MaxValue +" for "+ Description +"."); Field.focus(); Field.select(); return true;}
		// Min value has been set but Max value is null (-1)
		if ((MinValue > -1 && MaxValue == -1) && (isNaN(floatValue) || Field.value < MinValue))
			{alert("Please enter a numerical value greater than "+ MinValue +" for "+ Description +"."); Field.focus(); Field.select(); return true;}
		// Max value has been set but Min value is null (-1)
		if ((MinValue == -1 && MaxValue > -1) && (isNaN(floatValue) || Field.value > MaxValue))
			{alert("Please enter a numerical value less than "+ MaxValue +" for "+ Description +"."); Field.focus(); Field.select(); return true;}
	}
	return false;
}
/******************* CHECK FOR CHECKBOX/RADIO BUTTON SELECTION *******************/
function s_NoSelections(theForm) { // Insures that at least one checkbox or radio button has been selected
	var blnSelection = false
	for (xx=0; xx < theForm.elements.length; xx++){
		if (theForm.elements[xx].checked == true)
			{blnSelection = true; break;}
	}
	if (blnSelection == false) 
		{alert("Please make a selection before proceeding."); return true;}
	return false;
}
/******************* MANIPULATE THE STYLE OF AN HTML ELEMENT *******************/
function s_SwitchStyle(Element){
	//This function can be used to alter the presentation of a specified HTML element.
	var oElement = document.getElementById(Element);
	arAttributes = new Array("","","",""); //arAttributes: className, backgroundColor, color, border
	for (var i=1; i<arguments.length; i++) {
		arAttributes[i-1] = arguments[i]
	}
	if (arAttributes[0].length!=0) oElement.className = arAttributes[0];
	if (arAttributes[1].length!=0) oElement.style.backgroundColor = arAttributes[1];
	if (arAttributes[2].length!=0) oElement.style.color = arAttributes[2];	
	if (arAttributes[3].length!=0) oElement.style.border = arAttributes[3];	
}

//-->
