<!--
//----------------------------------------------------
// function to spaces in the field
//----------------------------------------------------
function isEmpty(fieldValue){
	var len=fieldValue.length
	var i
	for(i=0;i<len;++i){
		if (fieldValue.charAt(i)!= " ") return false;
	}
 return true;
}

//----------------------------------------------------
// function to validate required field entry
//----------------------------------------------------

function chkReqFieldEntry(element,desc,type,minLength){
	if (isEmpty(element.value)){
		alert("Please enter a value in the \""+desc+"\" field.")
		element.value = ''
		element.focus()
		return false
	}
	if ((type == "number")|| (type == "alpha_numeric")){
		if (element.value.length < minLength){
			alert("Please enter at least \""+minLength+"\" characters in the \""+desc+"\" field.")
			element.focus()
			return false
		}		
		if (type == "number") {
			if (element.value < 0){
				alert("Please enter a positive number in the \""+desc+"\" field.")
				element.focus()
				return false
			}
		}
		if (type == "alpha_numeric") {
			return (chkCharacters(element,desc,type))
		}
		else{
			return (chkNumbers(element,desc))
		}
	}
	if (type == "email"){
			return (validate_email(element,desc))
	}
	else{
		if (element.value.length < minLength){
			alert("Please enter at least \""+minLength+"\" characters in the \""+desc+"\" field.")
			element.focus()
			return false
		}
		if 	(type == "alpha")
			return (chkCharacters(element,desc,type))
	}
	return true;
}	


//----------------------------------------------------
// function to validate display field entry
//----------------------------------------------------

function chkFieldEntry(element,desc,type,minLength){
	if (element.value.length > 0){
		if (isEmpty(element.value)){
			alert("Please enter a value in the \""+desc+"\" field.")
			element.focus()
			return false
		}
		if ((type == "number")|| (type == "alpha_numeric")){
			if (element.value.length < minLength){
				alert("Please enter a value in the \""+desc+"\" field.")
				element.focus()
				return false
			}		
			if (element.value < 1){
				alert("Please enter a positive number in the \""+desc+"\" field.")
				element.focus()
				return false
			}
			if (type == "alpha_numeric") {
				return (chkCharacters(element,desc,type))
			}
			else{
				return (chkNumbers(element,desc))
			}
		}
		if (type == "email"){
				return (validate_email(element,desc))
		}
		else{
			if (element.value.length < minLength){
				alert("Please enter a value in the \""+desc+"\" field.")
				element.focus()
				return false
			}
			if 	(type == "alpha")
				  return (chkCharacters(element,desc,type));
		}
	}
	return true;
}	



//----------------------------------------------------
// function to validate only numbers in a field
//----------------------------------------------------

function chkNumbers(element,desc){
	var checkOK = "0123456789";
	var checkStr = element.value;
	var allValid = true;
	var decPoints = 0;
	var allNum = "";
	for (i = 0;  i < checkStr.length;  i++)
	{
	  ch = checkStr.charAt(i);
	  for (j = 0;  j < checkOK.length;  j++)
	    if (ch == checkOK.charAt(j))
	      break;
	  if (j == checkOK.length)
	  {
	    allValid = false;
	    break;
	  }
	  allNum += ch;
	}
	if (!allValid)
	{
	  alert("Please enter only numeric characters in the \""+desc+"\" field.");
	  element.focus();
	  element.select();
	  return (false);
	}	
	return true
}

//--------------------------------------------------------------
// function to validate only numbers and alphabets in a field
//--------------------------------------------------------------

function chkCharacters(element,desc,type){
	  if (type == "alpha")
	  	  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
	  else if (type == "login")
		  var checkOK = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_";
	  else
		  var checkOK = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
	   
	  var checkStr = element.value;
	  var allValid = true;
	  var decPoints = 0;
	  var allNum = "";
	  for (i = 0;  i < checkStr.length;  i++)
	  {
	    ch = checkStr.charAt(i);
	    for (j = 0;  j < checkOK.length;  j++)
	      if (ch == checkOK.charAt(j))
	        break;
	    if (j == checkOK.length)
	    {
	      allValid = false;
	      break;
	    }
	    allNum += ch;
	  }
	  if (!allValid)
	  {
	    alert("Please enter only letters or numbers in the \""+desc+"\" field.");
	    element.focus();
	    element.select();
	    return (false);
	  }
	  return true
}

//------------------------------------------------------------
// Validate Email field
//------------------------------------------------------------
function validate_email(element,desc){
	if (element.value =="")
	{
		alert("Please enter your \""+desc+"\" address")
		element.focus();
		return false;
	}		
	if (element.value.length > 0){
		var invalidChars = " :,;"
		var checkStr = element.value;	
		for (i=0; i<invalidChars.length; i++) {	// does it contain any invalid characters?
			badChar = invalidChars.charAt(i)
			if (checkStr.indexOf(badChar,0) > -1) {
				alert("Please make sure your \""+desc+"\" address is correct.");
				element.focus();
				return false;
			}
		}
		atPos = checkStr.indexOf("@",1)		// there must be one "@" symbol
		if (atPos == -1) {
			alert("Please make sure your \""+desc+"\" address is correct.");
			element.focus();
			return false;
		}
		if (checkStr.indexOf("@",atPos+1) != -1) {	// and only one "@" symbol
			alert("Please make sure your \""+desc+"\" address is correct.");
			element.focus();
			return false;
		}
		periodPos = checkStr.indexOf(".",atPos)
		if (periodPos == -1) {		// and at least one "." after the "@"
			alert("Please make sure your \""+desc+"\" address is correct.");
			element.focus();
			return false;
		}
		if (periodPos+3 > checkStr.length)	{	// must be at least 2 characters after the "."
			alert("Please make sure your \""+desc+"\" address is correct.");
			element.focus();
			return false;
		}
	 }
	 return true
}
//------------------------------------------------------------
// Show pop-up window
//------------------------------------------------------------
	var mywindow;

	function openChild(strHTMLPage, iWidth, iHeight){
		// this function is used to open internal pages like specs;
	    mywindow = window.open(strHTMLPage,"Help","left=100,top=100,toolbar=0,menubar=0,resizable=no,location=0,directories=0,scrollbars=0,width="+ parseInt(iWidth)+ ",height="+ parseInt(iHeight));
		mywindow.focus();      
	}
	
//------------------------------------------------------------
// Show Help pop-up window
//------------------------------------------------------------
	var mywindow;

	function openHelp(strHTMLPage, iWidth, iHeight){
		// this function is used to open internal pages like specs;
	    mywindow = window.open(strHTMLPage,"Help","left=100,top=100,toolbar=1,menubar=0,resizable=yes,location=0,directories=0,scrollbars=1,width="+ parseInt(iWidth)+ ",height="+ parseInt(iHeight));
		mywindow.focus();      
	}
	

//-----------------------------------------------------
// function to open a window based on click event
//-----------------------------------------------------
function openWindow(ptype){
	var user_rcdt = document.forms[0].hidden_rcdt.value
	var user_school = document.forms[0].hidden_school.value
	if (ptype == 'rcdt'){
		var link = "find_entity.asp?typecode=RCDT&rcdt=" + user_rcdt+"&change=rcdt"
		openChild(link,'450','200')
	}
	else if (ptype == 'school'){
		var link = "find_entity.asp?typecode=School&rcdt=" + user_rcdt +"&school="+user_school+"&change=school"
		openChild(link,'450','200')
	}
}

//------------------------------------------------------------
// validate date
//------------------------------------------------------------
function verify_date(field,desc){
	//-------------------------------------------------------------
	// From and To Date Fields
	//-------------------------------------------------------------
		if (field.value == "")
		{
		  alert("Please enter a valid date - MM/DD/YYYY format in \""+desc+"\" field.");
		  field.focus();
		  return (false);
		}
		var dateStr=field.value 
		var datePat = /^(\d{2})(\/|-)(\d{2})\2(\d{4})$/;
		var matchArray = dateStr.match(datePat); 
		if (matchArray == null) {
			alert("Date entered is not in a valid format.")
			field.focus();
			return false;
		}
		month = matchArray[1]; 
		day = matchArray[3];
		year = matchArray[4];
		if (month < 1 || month > 12) { 
			alert("Month must be between 1 and 12.");
			field.focus();
			return false;
		}
		if (day < 1 || day > 31) {
			alert("Day must be between 1 and 31.");
			field.focus();
			return false;
		}
		//check for 30 days in certain months
		if ((month==4 || month==6 || month==9 || month==11) && day==31) {
			alert("Month "+month+" doesn't have 31 days!")
			field.focus();
			return false
		}
		// check for february 29th
		if (month == 2) { 
			var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
			if (day>29 || (day==29 && !isleap)) {
				alert("February " + year + " doesn't have " + day + " days!");
			field.focus();
			return false;
			}
		}
		return true;
}		


//-----------------------------------------------------
// function for auto tab of phone and fax fields
//-----------------------------------------------------

var isNN = (navigator.appName.indexOf("Netscape")!=-1);

function tabControl(input,len, e)
{
	var keyCode = (isNN) ? e.which : e.keyCode;
	var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
	if(input.value.length >= len && !containsElement(filter,keyCode))
	{
		input.value = input.value.slice(0, len);
		input.form[(getIndex(input)+1) % input.form.length].focus();
	}

	function containsElement(arr, ele) 
	{
		var found = false, index = 0;
		while(!found && index < arr.length)
		if(arr[index] == ele)
		found = true;
		else
		index++;
		return found;
	}

	function getIndex(input) 
	{	
		var index = -1, i = 0, found = false;
		while (i < input.form.length && index == -1)
		if (input.form[i] == input)index = i;
		else i++;
		return index;
	}
return true;
}
//-----------------------------------------------------
// function to verify the password with user ID
//-----------------------------------------------------
function verifyPass(uElement,pElement){
	if (uElement.value == pElement.value){
		alert("Please verify, the user name and passwords should be different.");
		uElement.focus();
		return (false);
	  }
  return true;
}		 

//-----------------------------------------------------
// function to verify the old password with new password
//-----------------------------------------------------
function comparePass(uElement,pElement){
	if (uElement.value == pElement.value){
		alert("Please verify, the old password and new passwords should be different.");
		uElement.focus();
		return (false);
	  }
  return true;
}		 

//-----------------------------------------------------
// function to confirm the password
//-----------------------------------------------------
function confirmPass(pElement,pcElement){
	if (pElement.value != pcElement.value){
		alert("Please verify, the passwords entered are not similar.");
		pElement.focus();
		return (false);
	  }
  return true;
}	

//-----------------------------------------------------
// function to confirm the new password
//-----------------------------------------------------
function confirmNewPass(pElement,pcElement){
	if (pElement.value != pcElement.value){
		alert("Please verify, the New Password and Confirm Password entered are not similar.");
		pElement.focus();
		return (false);
	  }
  return true;
}

//-----------------------------------------------------
// function to confirm the phone or fax entry
//-----------------------------------------------------
function chkPhoneEntry(field1,field2,field3,desc,type){
	if ((!isEmpty(field1.value)) || (!isEmpty(field2.value)) || (!isEmpty(field3.value))){
		
		if (field1.value.length < 3){
			alert("Please enter at least \"3\" digits in \""+desc+" Area Code\" field.")
			field1.focus()
			return false
		}
		
		if (field2.value.length < 3){
			alert("Please enter at least \"3\" digits in \""+desc+" Prefix\" field.")
			field2.focus()
			return false
		}
		
		if (field3.value.length < 4){
			alert("Please enter at least \"4\" digits in \""+desc+" Suffix\" field.")
			field3.focus()
			return false
		}
		
		if (type == "number") {
			return (chkNumbers(field1,desc+" Area Code")&&
						chkNumbers(field2,desc+" Prefix")&&
						chkNumbers(field3,desc+" Suffix"))
		}
	}
return true;
}

//-----------------------------------------------------
// function to confirm the broadcast email entry
//-----------------------------------------------------

function chkEmailEdit(field1, field2, desc1)
{
	if (field2[field2.selectedIndex].value == "1"){
		return (validate_email(field1,desc1))
	}
return true
}


//  End -->
