<!--
//used in:
//Academic/asp/faculty/updateinternetID.asp
//Application/landerapp...
//
//checkemail-form
//inputs: 
//	eform-form with field internet_id in order
//		to check the format 
//outputs:
//	message if not correct format for email address
//	returns true if correct, false if incorrect

//chkemail-string
//inputs:
//	strmail- string to check if valid email address
//outputs:
//	returns 0 if correct, 
//	returns 1-4 if not correct, various errors
//	1: blank
//	2: no @
//	3: @ at end
//	4: internal spaces

function checkemail(eform)
{
retcode=0;
retcode=chkemail(eform.internet_id.value);

if (retcode==1){
	alert("Invalid E-mail Address.");
	eform.internet_id.focus();
	return false;
}else if (retcode==2){
	alert("Invalid E-mail Address. No @ symbol included.");
	eform.internet_id.focus();
	return false;
}else if (retcode==3){
	alert("Invalid E-mail Address. @ symbol cannot be at the end.");
	eform.internet_id.focus();
	return false;
}else if (retcode==4){
	alert("Invalid E-mail Address. No internal spaces allowed.");
	eform.internet_id.focus();
	return false;
}

return true;
} 	


/**
 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

function checkemailstr(str) {

		var at="@"
		var dot="."

		if (str==null || str==""){
			return false
		}

		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)

		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true					
	}



function checkemailstrold2(email)
{
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

function checkemailstrold(strmail)
{
//check for blank string or internal spaces
if (strmail==""){
	return 1;	
}
else {
	a=strmail.charAt(0);
	max=strmail.length;
	atat=strmail.indexOf("@");
	if (atat==-1)
	{
		return 2;
	}
	if (atat== max-1 )
	{
		return 3;
	}
	for(i = 1 ; i < max ;i++){
		b=strmail.charAt(i);
		if (a==' ' && b!=' ')
		{
			return 4;
		}
		a = b;
	}
}
return 0;
} 	

//-->



