function checkNotNull(ctrl){
	//Make sure that the field is not empty (or in the case of a select box, not '-1')
	//The default value of text fields is an empty string, not null, so we need to use ''      
  //Note, when checking a select box, ctrl must be set to the selectedIndex object:
  //	using the following syntax: 
  //	document.form.selectObject[document.form.selectObject.selectedIndex]    if (ctrl.value == null || ctrl.value == '' || ctrl.value == '-1'){
      return(false);
  }
	return (true);
}


function checkNumeric(ctrl, required, minValue, maxValue){
	//Make sure the field contains only numeric data	if (required || (ctrl.value != '' && ctrl.value != null)){		var tempValue = '';
  
		//strip out any non-numeric characters
		for (var i=0; i < ctrl.value.length; i++){      
		  var ch = ctrl.value.substring(i, i+1);
		  if ((ch >= "0" && ch <= "9") || ch == "-" || ch == "."){
		      tempValue = tempValue + ch;
		  }
		}
		      
		ctrl.value = tempValue;
		      
		if (ctrl.value == '' || (ctrl.value < minValue || ctrl.value > maxValue)){
		    return (false);
		}	
	}
	return (true);
}


function checkEmail(ctrl, required){
	//Make sure the email address is valid
	if (required || (ctrl.value != '' && ctrl.value != null)){
		var valid = false;
		var tempValue = '';
	
		//Make sure the @ symbol is present once (and only once)
		for (var i=0; i < ctrl.value.length; i++){
			var ch = ctrl.value.substring(i, i+1);
			if (ch == "@" && i != 0){
				if (!valid){
					valid = true;
				}
				else{
					valid = false;
				}
			}
		}
	
		//Check for a valid suffix
		if (valid){
			var suffix = ctrl.value.substring(ctrl.value.length - 4, ctrl.value.length);
			if (suffix != ".com" && suffix != ".net" && suffix != ".edu" && suffix != ".gov" && suffix != ".us"){
				//It is not a valid U.S. address
				valid = false;
			}
		}
	
		if (!valid){
			return (false);		
		}	
	}
	return (true);
}


function checkDate(ctrl, required){
	//Make sure a valid date is entered
	if (required || (ctrl.value != '' && ctrl.value != null)){	
		if (!isNaN(Date.parse(ctrl.value))){
			//The date string is recognized, let's standardize the format
			var myDate = new Date(ctrl.value);
			var dateValue = (myDate.getMonth(ctrl.value) + 1) + '/' + myDate.getDate(ctrl.value) + '/' + myDate.getFullYear(ctrl.value);
			ctrl.value = dateValue	
		}
		else{
			return (false);
		}
	}
	return (true);
}


function checkLength(ctrl, required, minLength, maxLength){
	//Make sure the string is not shorter or longer than required
	if (required || (ctrl.value != '' && ctrl.value != null)){
		if (ctrl.value.length < minLength || ctrl.value.length > maxLength){
			return (false);
		}
	}
	return (true);
}


function checkRadioNull(ctrl, numberOfChoices){
  var buttonChecked = false;
  
  for (i=0; i <= numberOfChoices - 1; i++){
     if (ctrl[i].checked){
        buttonChecked = true;
     }
  }
  
  if (buttonChecked == false){
		return (false);
  }
	return(true)
}