

function isNumeric(callingElement, check) 
{  

	//Check to make sure that a field has a valid number
	//Use in a fields onBlur event: e.gl onBlur="isNumeric(this)"
	badNumber=0
		for (var i=0; i < callingElement.value.length; i++) 
		{
			var ch = callingElement.value.substring(i, i+1);
			if (ch!=".")
			{
			if( ch < "0" || ch>"9" || callingElement.value.length == null) 
			{
				badNumber = 1
			}
			}
		}
		if ((callingElement.value<=0) && (callingElement.value.length>0)) {
			badNumber=1
			}
		if (badNumber==1)
		{
			if (check==1) {alert("Please enter a valid number above zero.");}
			callingElement.focus();
			return false;
		}
		return true
}


function notNull(str) {
if (str.length == 0)
  return false
else
	return true
}

function notBlank(str) {
for (var i=0; i<str.length; i++) {
if (str.charAt(i) != " ")
return true
}
return false
}

function isSize(str, size) {
if (str.length==size)
	return true
else
	return false
}

function isDigits(str) {
var i
for (i=0; i<str.length; i++) {
mychar=str.charAt(i)
if (mychar<"0" || mychar>"9")
	return false
}
return true
}

function stripNonDigits(str) {
var i
var newstring=""
for (i=0; i<str.length; i++ ) {
	mychar=str.charAt(i)
	if (isDigits(mychar))
		newstring+=mychar
	}
return newstring
}



function validateNumFields(myfield, size1, size2, fieldname, format) {

if (notNull(myfield.value)) {
	newstring=stripNonDigits(myfield.value)	
	if (isSize(newstring,size1) || isSize(newstring, size2))
		return true
}
	myfield.focus()
	myfield.select()
	alert("Invalid " + fieldname + ".  Please enter numeric values in the format of " + format + ".")
	return false
}


var emptyString=" field is blank.  Please enter a "

function validateString(myfield, s) {

if (notNull(myfield.value) && notBlank(myfield.value))
	return true
else {
	myfield.focus()
	alert("The " + s + emptyString + s)
	return false
	}
}

function validateCombo(myfield, s) {
if (myfield.options[myfield.selectedIndex].value>0) {

return true
	} else {
	myfield.focus
	alert("Please select a " + s + ".")
	return false
	
	}

}

function validateState(myfield, s) {
if (myfield.options[myfield.selectedIndex].value!=-1) {

return true
	} else {
	myfield.focus
	alert("Please select a " + s + ".")
	return false
	
	}

}

function isEmail(callingElement) 
{
	//Check to make sure that a field has a valid Email
	//Use in a fields onBlur event: e.gl onBlur="isEmail(this)"
	if (callingElement =="") 
	{
		alert("Please enter a valid e-mail address!");
	    callingElement.focus();
	    return false;         
	} 
	else 
	{
		var Temp     = callingElement
		var AtSym    = Temp.value.indexOf("@")
		var Period   = Temp.value.lastIndexOf(".")
		var Space    = Temp.value.indexOf(" ")
		var Length   = Temp.value.length - 1   // Array is from 0 to length-1

		if ((AtSym < 1) ||                     // "@" cannot be in first position
	    	(Period <= AtSym+1) ||             // Must be atleast one valid char btwn "@" and "."
		   	(Period == Length ) ||             // Must be atleast one valid char after "."
	    	(Space  != -1))                    // No empty spaces permitted
		{  
			
			alert("Please enter a valid e-mail address!");
			callingElement.focus();
			callingElement.select();
			return false;
		}   
	} return true 
}
function checkYear(myfield) {
if ((myfield.value<1900) || (myfield.value>2000)) {
	alert("Please enter a valid year.")
	myfield.focus()
	myfield.select()
	return false
} else {
	return true
}


}
function checkMonth(myfield) {
if (myfield.value>0 && myfield.value<13) {
		return true
	} else {

	alert("Invalid month.  Must be between 1 and 12")
	myfield.focus()
	myfield.select()
	return false
	} 
	
	
}

function checkDay(myfield) {
if (myfield.value>0 && myfield.value<32) {
		return true
	} else {

	alert("Invalid day. Please enter a valid day")
	myfield.focus()
	myfield.select()
	return false
	} 
	
	
}