
			var iIndex = 0;
			var sErrorCode = new String("eChalkLoginErr=");
			var sURL = document.location.toString();
			iIndex = sURL.lastIndexOf(sErrorCode);
			
			if(iIndex != -1)
			{
				/*************Description of Error Codes
returned by eChalk Login Gateway**********
				1 -> User is running an older version of
browser that may not be supporting either
				     Frames, Cookies or Javascript
				     
				2 -> User does not belong to a valid eChalk
Group since user's group URL was not found
				     in eChalk Directory Servers
				     
				3 -> User has disabled cookies in his/er
browser.
				
				4 -> User has entered invalid logon
credentials.
				
				5 -> User has possibly tried to intrude the
eChalk Private Area by directly 
					 trying to access main.asp (instead
of going through home.asp or 
					 external_login.asp.
				
				6 -> User logon credentials are valid, but
User account may have expired or may have
					 permanently disabled by the Site
Manager of eChalk User Group.
	
****************************************************************************
*******/
			
				var sErrorCodeValue=sURL.substr(iIndex +
sErrorCode.length, 1);
				
				if(sErrorCodeValue == "1")
				{
					alert("eChalk has detected that
Cookie and/or Frames and/or Javascript support has been disabled in your
browser.\nPlease enable this feature and try to login again.");
				}
				else if(sErrorCodeValue == "2")
				{
					alert("eChalk can not process your
login request. Please contact eChalk Support.");
				}
				else if(sErrorCodeValue == "3")
				{
					alert("eChalk has detected that
Cookie support has been disabled in your browser.\nPlease enable this
feature and try to login again.");
				}				
				else if(sErrorCodeValue == "4")
				{
					alert("Invalid username or password.
Please try again.");
				}
				else if(sErrorCodeValue == "5")
				{
					alert("You could not be
authenticated or you may have timed out. Please try to login again.");
				}				
				else if(sErrorCodeValue == "6")
				{
					alert("Your Account has been
disabled. Please contact your Site Manager for more information.");
				}
				else
				{
					alert("Unexpected error occured
while login to eChalk. Please contact your Site Manager.");
				}
				
				document.eChalkLogin.uname.focus();
			}

		
		// Login username and password validation
		function eChalkLogin_onSubmit()
		{
			if (trim(document.eChalkLogin.uname.value) == "")
			{
				alert("Please enter a valid eChalk User
Name.");
				document.eChalkLogin.uname.focus();
				return false;
			}
			
			if (trim(document.eChalkLogin.pwd.value) == "")
			{
				alert("Please enter a valid Password.");
				document.eChalkLogin.pwd.focus();
				return false;
			}
			
			document.eChalkLogin.ExternalURL.value =
document.location.href;
			return true;
		}
		
		//This is a utility function. It returns the given string
trimming the
		//trailing and preceeding spaces.
		function trim(str)
		{
			var iStrBegin;
			var iStrEnd;
			
			if (str == null || str.length == 0)
				return str;
				
			var len = str.length;
					
			for (var iBegin=0; iBegin < len; iBegin++)
			{
				if (str.charAt(iBegin) != " ")
				{
					break;
				}
			}
			
			if (iBegin == len)
				return "";
			else 
				iStrBegin = iBegin;
			
			for (var iEnd=len-1; iEnd>=0; iEnd--)
			{
				if (str.charAt(iEnd) != " ")
				{
					break;
				}
			}
			iStrEnd = iEnd + 1;
			
			return str.substring(iStrBegin, iStrEnd);
		}
