  //---------------------------------------------------------------------
  function check_change_password()
  {
      if ( document.getElementById("txtPassword").value == "" || document.getElementById("txtPassword2").value == "")
	  {
	      alert("You must fill in both password fields.");
		  return false;
	  }
	  
	  var strPass, strPass2
	  
	  strPass =  document.getElementById("txtPassword").value;
	  strPass2 =  document.getElementById("txtPassword2").value;
      
	  if ( strPass.length < 6 || strPass.length > 10 || strPass2.length < 6 || strPass2.length > 10)
	  {
	      alert("Password must contain between 6 and 10 characters");
		  return false;
	  }
	  
	  if ( strPass != strPass2 )
	  {
	       alert("Your passwords are not identical.");
		   return false;
	  }
	  return true;
  }
 
  //---------------------------------------------------------------------
  function validate_form_login()
  {
      if ( validate_form_lost_password() )
	  {
	      var strPassword = document.getElementById("txtPassword").value;

          if ( strPassword == "")
	      {
	          alert("You must enter a password.");
              return false;
	      }
	  
	      if ( strPassword.length < 6 || strPassword.length > 10)
	      {
	           alert("Valid passwords must be between 6 and 10 characters.");
		       return false;
	      }
	      return true; 
	  }
	  return false;
  }
  //----------------------------------------------------------------------
  function validate_form_lost_password()
  {
	  //var strUsername = document.getElementById("txtUsername").value;
   
	  if ( window.document.getElementById("txtUsername").value == "")
	  {
	      alert("You must enter a username.")
          return false;
	  }  
	  return true;
  }

  //-----------------------------------------------------------------------
  function validate_phone_number()
  {
      	var strPhone = document.getElementById("txtPhone").value
	    var strValid = "0123456789()-.";
		var n, m;
		
		for ( n = 0; n < strPhone.length; n++)
		{
		     for ( m = 0; m < strValid.length; m++)
			 {
			     if ( strPhone.charAt(n) == strValid.charAt(m) )
				    break;
			 }
			 if ( m == strValid.length)
			    return "Phone number is not formatted properly.";
		}
		return ""; 
  }
 
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   //alert("Invalid E-mail ID")
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail ID")
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //alert("Invalid E-mail ID")
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("Invalid E-mail ID")
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    //alert("Invalid E-mail ID")
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Invalid E-mail ID")
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		    //alert("Invalid E-mail ID")
		    return false;
		 }

 		 return true;				
	}
  
  
  //-----------------------------------------------------------------------
  function validate_form_newmember()
  {
	 var aryReqErrs = new Array();
	 var aryErrs = new Array();
	 var intReqErrCount = 0;
	 var intErrCount = 0;

	 if ( document.getElementById("txtFirstname").value == "")
	    aryReqErrs[intReqErrCount++] = "first name";  
	 if ( document.getElementById("txtLastname").value == "")
	    aryReqErrs[intReqErrCount++] = "last name";    
	 if ( document.getElementById("txtTitle").value == "")
	    aryReqErrs[intReqErrCount++] = "title";  
	 if ( document.getElementById("txtPhone").value == "")
	    aryReqErrs[intReqErrCount++] = "phone";  
	 if ( document.getElementById("txtEMailAddress").value == "")
	    aryReqErrs[intReqErrCount++] = "email address";
	 if ( document.getElementById("txtEMailAddress2").value == "")
	    aryReqErrs[intReqErrCount++] = "retype email address";
	 if ( document.getElementById("txtEMailAddress").value != document.getElementById("txtEMailAddress2").value)
	   aryErrs[intErrCount++] = "The email addresses you entered are not identical.";
	 if ( ! echeck(document.getElementById("txtEMailAddress").value ))
	    aryErrs[intErrCount++] = "The email address you entered is not formatted properly.";
	 var strBanned = new Array( "yahoo.com",
                                "hotmail.com",
								"msn.com",
								"aol.com",
								"earthlink.net",
								"comcast.com",
								"wideopenwest.com",
								"sbc.net",
								"netzero.com",
								"gmail.com",
							    "mail.com" );
								
	  var strEmail = document.getElementById("txtEMailAddress").value						 
	  var strEMailParts = strEmail.split("@");
	  var strDomain = strEMailParts[strEMailParts.length - 1];
	  var strMatch;
	  
	  if ( strDomain != "")
	  {
	     for ( var c = 0; c < strBanned.length; c++)
	     {	       
		    strMatch =  strBanned[c].match(strDomain.toLowerCase());
		    
			if ( strMatch != null)
		         aryErrs[intErrCount++] = "Please use your business email address to register.\r \nIf you need help, or wish to receive the documents without registering, contact Valtera at 1-847-640-8820 or inquiries@valtera.com.";
	     }
	  }		
	 
	 /* var strPhoneErr = validate_phone_number();
	  if ( strPhoneErr != "")
	     aryErrs[intErrCount++] = strPhoneErr;
	  */
	  return check_errs(aryErrs, aryReqErrs);
	  
	  			 	
  }
  
  //---------------------------------------------------------------
  function check_errs(aryErrs, aryReqErrs)
  {
       if ( aryErrs.length == 0 && aryReqErrs.length == 0)
	      return true;
	   
	   var strMsg = "";
	   
	   for  ( var c = 0; c < aryReqErrs.length; c++)
	   {
	        if ( c == 0 )
			    strMsg += "The following required fields were not filled in : "; 
			else
			{
			    if ( c == ( aryReqErrs.length - 1 ) )
				     strMsg += " and "; 
                else
				     strMsg += ", ";
			}
			strMsg += aryReqErrs[c];
			
			if ( c == aryReqErrs.length - 1)
			   strMsg += ".";
	  }
	 
	  for ( c = 0; c < aryErrs.length; c++)
	  {
	      if ( strMsg != "")
		     strMsg += "\n \r";
		  strMsg += aryErrs[c];
	  }	   
	  
	  alert(strMsg);
	  return false;
  }
  