//***********************************************
function emailCheck (emailStr) 
	{
		var emailPat=/^(.+)@(.+)$/
		var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
		var validChars="\[^\\s" + specialChars + "\]"
		var quotedUser="(\"[^\"]*\")"
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
		var atom=validChars + '+'
		var word="(" + atom + "|" + quotedUser + ")"
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
		var matchArray=emailStr.match(emailPat)
		if (matchArray==null) {
			alert("The email address you have entered is not valid, please check @ and .'s")
		return false
		}
		
		var user=matchArray[1]
		var domain=matchArray[2]
		
		if (user.match(userPat)==null) {
		   alert("The email address you have entered is not valid, please check the first part of it")
		return false
		}
		var IPArray=domain.match(ipDomainPat)
		if (IPArray!=null) {
		   // this is an IP address
		  for (var i=1;i<=4;i++) {
		    if (IPArray[i]>255) {
		        alert("The email address you have entered is not valid, please check Destination IP")
			    return false
		    }
		   }
		   return true
		}
		var domainArray=domain.match(domainPat)
		if (domainArray==null) {
		alert("The email address you have entered is not valid, please check the domain name")
		   return false
		}
		var atomPat=new RegExp(atom,"g")
		var domArr=domain.match(atomPat)
		var len=domArr.length
		if (domArr[domArr.length-1].length<2 || 
		   domArr[domArr.length-1].length>6) {
		   alert("The email address you have entered is not valid,\nthe last part of the address must not have more than a six-letter domain")
		   return false
		}
		if (len<2) {
		  var errStr="The email address you have entered is not valid, this address is missing a hostname!"
		  alert(errStr)
		  return false
		}
	return true;
	}
//***********************************************
	function IsValidPhone(sText)
	{
	   var ValidChars = "0123456789- ";
	   var IsValidChar=true;
	   var Char;
	   for (i = 0; i < sText.length && IsValidChar == true; i++) 
	      { 
	      Char = sText.charAt(i); 
	      if (ValidChars.indexOf(Char) == -1) 
	         {
	         IsValidChar = false;
	         }
	      }
	   return IsValidChar;
	   }

//***********************************************
	function IsNumeric(sText)
	{
	   var ValidChars = "0123456789.,";
	   var IsNumber=true;
	   var Char;
	   for (i = 0; i < sText.length && IsNumber == true; i++) 
	      { 
	      Char = sText.charAt(i); 
	      if (ValidChars.indexOf(Char) == -1) 
	         {
	         IsNumber = false;
	         }
	      }
	   return IsNumber;
	   }
//***********************************************
	function IsValidPassword(sText)
	{
	   var ValidChars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	   var IsValidChar=true;
	   var Char;
	   for (i = 0; i < sText.length && IsValidChar == true; i++) 
	      { 
	      Char = sText.charAt(i); 
	      if (ValidChars.indexOf(Char) == -1) 
	         {
	         IsValidChar = false;
	         }
	      }
	   return IsValidChar;
	   }
//***********************************************
	function OpenWindow(upload,x,y) {
	      window.open(upload,"Enlarge","height="+ y +",width="+ x +",toolbar=no,scrollbars=yes,resizable=1,left=100,top=100")
		}
//***********************************************
	function OpenCookies(upload,x,y) {
	      window.open(upload,"Cookies","height="+ y +",width="+ x +",toolbar=no,scrollbars=yes,resizable=1,left=100,top=100")
		 }
//**********************************
	function Login_Validator(LoginForm)
		{
		//-----------------------
		 if(document.LoginForm.Email.value==""){
			alert("Please enter your e-mail address.")
			document.LoginForm.Email.focus()
			return false
	 	 	}
	  	if (document.LoginForm.Email.value.length > 70){
		  	tooMuch = document.LoginForm.Email.value.length - 70
		    alert("You have entered too many characters - Please remove " + tooMuch + " characters and resubmit")
			document.LoginForm.Email.focus()
			return false;
		  }
	  	if (emailCheck(document.LoginForm.Email.value)==false){
			document.LoginForm.Email.focus()
			return false
		  }
		//-----------------------
		if (document.LoginForm.Password.value == "")
		  {
		    alert("Please enter your password.");
		   document.LoginForm.Password.focus();
		    return (false);
		  }
		if (document.LoginForm.Password.value.length > 20){
		  	tooMuch = document.LoginForm.Password.value.length - 20
		    alert("You have entered too many characters - Please remove " + tooMuch + " characters and resubmit")
			document.LoginForm.Password.focus()
			return false;
		  }
		//-----------------------
		  return (true);
		}
//**********************************
function hilight( obj ) {
   obj.style.backgroundColor = '#E2ECF6';
   return true;
}
//***********************************************
function fade( obj ) {
   obj.style.backgroundColor = '#FFFFFF';
   return true;
}