<!--
<!-- Original: Richard Gorremans (RichardG@spiritwolfx.com) ==>
<!-- Updates: www.spiritwolfx.com
<!-- Begin
// Check browser version
var isNav4 = false, isNav5 = false, isIE4 = false
var strSeperator = "-"; 
var nextfield = ""
var netscape = "";
ver = navigator.appVersion; len = ver.length;
//alert(ver);
for(iln = 0; iln < len; iln++) if (ver.charAt(iln) == "(") break;
netscape = (ver.charAt(iln+1).toUpperCase() != "C");

// If you are using any Java validation on the back side you will want to use the / because 
// Java date validations do not recognize the dash as a valid date separator.

var err = 0; // Set the error code to a default of zero

if(navigator.appName == "Netscape") 
{
   if (navigator.appVersion < "5")  
   {
      isNav4 = true;
      isNav5 = false;
	}
   else
   if (navigator.appVersion > "4") 
   {
      isNav4 = true;
      isNav5 = true;
	}
}
else  
{
   isIE4 = true;
}


var keybYN = new keybEdit('yn','Valid values are \'Y\' or \'N\'.');
var keybNumeric = new keybEdit('01234567890-','Numeric and - input only.');
var keybNumericonly = new keybEdit('01234567890','Numeric input only.');
var keybAlpha = new keybEdit('abcdefghijklmnopqurstuvwxy ','Alpha input only.');
var keybAlphaNumeric = new keybEdit('abcdefghijklmnopqurstuvwxy01234567890 ','Alpha-numeric input only.');
var keybDecimal = new keybEdit('01234567890.','Decimal input only.');
var keybDate =  new keybEdit('01234567890/','Date input only');;
var keybYNNM = new keybEdit('yn');
var keybNumericNM = new keybEdit('01234567890');
var keybAlphaNM = new keybEdit('abcdefghijklmnopqurstuvwxy');
var keybAlphaNumericNM = new keybEdit('abcdefghijklmnopqurstuvwxy01234567890');
var keybDecimalNM = new keybEdit('01234567890.');
var keybDateNM = new keybEdit('01234567890/');;

function keyDown(DnEvents) { // handles keypress
// determines whether Netscape or Internet Explorer
k = (netscape) ? DnEvents.which : window.event.keyCode;
if (k == 13) { // enter key pressed
if (nextfield == 'submit') eval(nextfield).onclick(); // submit, we finished all fields
else { // we're not done yet, send focus to next box
if (nextfield != '')eval(nextfield).focus();nextfield='';
return false;
      }
   }
}
//document.onkeydown = keyDown; // work together to analyze keystrokes
//if (netscape) document.captureEvents(Event.KEYDOWN|Event.KEYUP|Event.KEYPRESS);

function keybEdit(strValid, strMsg) {
	/*	Function:		keybEdit
		Purpose:		The purpose of this function is to be a constructor for
						the keybEdit object.  keybEdit objects are used by the
						function editKeyBoard to determine which keystrokes are
						valid for form objects.  In addition, if an error occurs,
						they provide the error message.
						
						Please note that the strValid is converted to both
						upper and lower case by this constructor.  Also, that
						the error message is prefixed with 'Error:'.
						
						The properties for this object are the following:
							valid	=	Valid input characters
							message	=	Error message
							
						The methods for this object are the following:
							getValid()	=	Returns a string containing valid
											characters.
							getMessage()=	Returns a string containing the
											error message.

		Update Date:	Programmer:			Description:
	*/

	//	Variables
	var reWork = new RegExp('[a-z]','gi');		//	Regular expression\

	//	Properties
	if(reWork.test(strValid))
		this.valid = strValid.toLowerCase() + strValid.toUpperCase();
	else
		this.valid = strValid;

	if((strMsg == null) || (typeof(strMsg) == 'undefined'))
		this.message = '';
	else
		this.message = strMsg;

	//	Methods
	this.getValid = keybEditGetValid;
	this.getMessage = keybEditGetMessage;
	
	function keybEditGetValid() {
	/*	Function:		keybEdit
		Purpose:		The purpose of this function act as the getValid method
						for the keybEdit object.  Please note that most of the
						following logic is for handling numeric keypad input.

		Update Date:		Programmer:			Description:
	*/

		return this.valid.toString();
	}
	
	function keybEditGetMessage() {
	/*	Function:		keybEdit
		Purpose:		The purpose of this function act as the getMessage method
						for the keybEdit object.

		Update Date:	Programmer:			Description:
	*/
	
		return this.message;
	}
}




void function editKeyBoard(objForm, objKeyb) {
	/*	Function:		editKeyBoard
		Purpose:		The purpose of this function is to edit edit keyboard input
						to determine if the keystrokes are valid.
	
		Update Date:		Programmer:			Description:
	*/
	strWork = objKeyb.getValid();
	strMsg = '';							// Error message
	blnValidChar = false;					// Valid character flag

	if(window.event.keyCode == 13) {
		keyDown();
		blnValidChar = true;
	}
	// Part 1: Validate input
	if(!blnValidChar)
		for(i=0;i < strWork.length;i++)
			//alert(strWork.charCodeAt(i));
			if(window.event.keyCode == strWork.charCodeAt(i)) {
				blnValidChar = true;

				break;
			}

	// Part 2: Build error message
	if(!blnValidChar) {
		if(objKeyb.getMessage().toString().length != 0)
			alert('Error: ' + objKeyb.getMessage());

		window.event.returnValue = false;		// Clear invalid character
		objForm.focus();						// Set focus
	}
}		

function SSNFormat(vSSNName,vSSNValue, e, vSSNCheck)  {
if (vSSNValue == "") {return false;}
mSSNName = vSSNName;
mSSNValue = vSSNValue;

// vSSNName = object name
// vSSNValue = value in the field being checked
// vSSNCheck = Perform validation as they leave the field
// e = event

   
   var whichCode = (window.Event) ? e.which : e.keyCode;
 
	// First thing is to remove any dashes that may be in the string being passed.
 	mSSNValue = trimString(replaceSubstring(vSSNValue,"-",""));
	if (mSSNValue.length >= 1)
	{
		if (mSSNValue.substr(0,9) == "000000000")
		{
			//allow for the test account purpose
		}
		else if (mSSNValue.substr(0,3) == "000" && mSSNValue.length >= 3 && vSSNCheck)
		{
			alert("SSN Cannot Begin With 000\nPlease Re-Check");
	         //vSSNName.value = "";
    	     vSSNName.focus();
        	 vSSNName.select();
	         return false;
		}
		/*
		else
		{
			if ((mSSNValue.substring(0,1) == "8" || mSSNValue.substring(0,1) == "9") && vSSNCheck)
			{
				alert("SSN Cannot Begin With an 8 or 9\nPlease Re-Check");
	    	     //vSSNName.value = "";
    	    	 vSSNName.focus();
	        	 vSSNName.select();
		         return false;
			}
		}
		*/
	}
	if (mSSNValue.length >= 10 && vSSNCheck)
	{
		alert("Too Many Numbers For SSN (format : xxx-xx-xxxx)\nPlease Re-Check");
		//vSSNName.value = "";
    	vSSNName.focus();
	    vSSNName.select();
		return false;
	}
	
	// If there is a dash in the original and the length of the trimmed string is 9 and the user is using NS. Return true
   if ((vSSNValue.indexOf("-") >= 1) && vSSNValue.length == 11 && mSSNValue.length == 9 && isNav4)
   {
         return true;
   }
   
   //Eliminate all the ASCII codes that are not valid
   var alphaCheck = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/-";
   if (alphaCheck.indexOf(vSSNValue) >= 1)  
   {
      if (isNav4)
      {
         vSSNName.value = "";
         vSSNName.focus();
         vSSNName.select();
         return false;
      }
      else
      {
         //vSSNName.value = vSSNName.value.substr(0, (vSSNValue.length-1));
         return false;
      } 
   }
   if (whichCode == 8) //Ignore the Netscape value for backspace. IE has no value
      return false;
   else 
   {
      //Create numeric string values for 0123456789/
      //The codes provided include both keyboard and keypad values

      var strCheck = '47,48,49,50,51,52,53,54,55,56,57,58,59,95,96,97,98,99,100,101,102,103,104,105';
      if (strCheck.indexOf(whichCode) != -1)  
      {
         if (isNav4)  
         {
            if ((mSSNValue.length < 9  && mSSNValue >= 1) && vSSNCheck)
            {
               alert("Invalid SSN (format : xxx-xx-xxxx)\nPlease Re-Check");
               //vSSNName.focus();
               vSSNName.select();
               return false;
            }
			else
			{
				if (vSSNCheck)
				{
					if (IsNumeric(vSSNValue))
					{
			            var mS1 = mSSNName.value.substr(0,3)+strSeperator+mSSNName.value.substr(3,2)+strSeperator+mSSNName.value.substr(5,4);
			            vSSNName.value = mS1;
					}
					else
					{
		               alert("Invalid SSN (format : xxx-xx-xxxx)\nPlease Re-Check");
        		       vSSNName.focus();
		               vSSNName.select();
        		       return false;
					}
				}
			}
            return true;
         }
         else  
         {
         // Non isNav Check
            if ((vSSNValue.length <= 10 && vSSNValue.length >=1) && vSSNCheck)
            {
               alert("Invalid SSN (format : xxx-xx-xxxx)\nPlease Re-Check");
               //vSSNName.value = "";
               vSSNName.focus();
               return true;
            }
            
            if (vSSNValue.length == 11)  
            {
    	        return true;
            }
            else
            {
               
	             if (vSSNValue.length == 3)  
                  {
                     vSSNName.value = vSSNValue+strSeperator;
                  }
                  if (vSSNValue.length == 6)  
                  {
                     vSSNName.value = vSSNValue+strSeperator;
                  }
               return true;
            }
         }
         return false;
      }
      else  
      {
         // If the value is not in the string return the string minus the last
         // key entered.
         if (isNav4)
         {
            //vSSNName.value = "";
            vSSNName.focus();
            vSSNName.select();
            return false;
         }
         else
         {
            //vSSNName.value = vSSNName.value.substr(0, (vSSNValue.length-1));
            return false;
         }
		}
	}
}

function PhoneFormat(vPhoneName,vPhoneValue, e, vPhoneCheck)  {
if (vPhoneValue == "") {return false;}
mPhoneName = vPhoneName;
mPhoneValue = vPhoneValue;

// vPhoneName = object name
// vPhoneValue = value in the field being checked
// vPhoneCheck = Perform validation as they leave the field
// e = event

   
   var whichCode = (window.Event) ? e.which : e.keyCode;
 
	// First thing is to remove any dashes that may be in the string being passed.
 	mPhoneValue = trimString(replaceSubstring(vPhoneValue,"-",""));
	if (mPhoneValue.length >= 1)
	{
		
		if (mPhoneValue.substr(0,3) == "000" && mPhoneValue.length >= 3 && vPhoneCheck)
		{
			alert("Phone Cannot Begin With 000\nPlease Re-Enter");
	         //vPhoneName.value = "";
    	     vPhoneName.focus();
        	 vPhoneName.select();
	         return false;
		}
	}
	if (mPhoneValue.length >= 11 && vPhoneCheck)
	{
		alert("Too Many Numbers For Phone (format : xxx-xxx-xxxx)\nPlease Re-Check");
		//vPhoneName.value = "";
    	vPhoneName.focus();
	    vPhoneName.select();
		return false;
	}
	
	// If there is a dash in the original and the length of the trimmed string is 10 and the user is using NS. Return true
   if ((vPhoneValue.indexOf("-") >= 1) && vPhoneValue.length == 12 && mPhoneValue.length == 10 && isNav4)
   {
         return true;
   }
   
   //Eliminate all the ASCII codes that are not valid
   var alphaCheck = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/-";
   if (alphaCheck.indexOf(vPhoneValue) >= 1)  
   {
      if (isNav4)
      {
         vPhoneName.value = "";
         vPhoneName.focus();
         vPhoneName.select();
         return false;
      }
      else
      {
         //vPhoneName.value = vPhoneName.value.substr(0, (vPhoneValue.length-1));
         return false;
      } 
   }
   if (whichCode == 8) //Ignore the Netscape value for backspace. IE has no value
      return false;
   else 
   {
      //Create numeric string values for 0123456789/
      //The codes provided include both keyboard and keypad values
      
      var strCheck = '47,48,49,50,51,52,53,54,55,56,57,58,59,95,96,97,98,99,100,101,102,103,104,105';
      if (strCheck.indexOf(whichCode) != -1)  
      {
         if (isNav4)  
         {
            if ((mPhoneValue.length < 10  && mPhoneValue >= 1) && vPhoneCheck)
            {
               alert("Invalid Phone (format : xxx-xxx-xxxx)\nPlease Re-Check");
               vPhoneName.focus();
               vPhoneName.select();
               return false;
            }
			else
			{
				if (vPhoneCheck)
				{
					if (IsNumeric(vPhoneValue))
					{
			            var mS1 = mPhoneName.value.substr(0,3)+strSeperator+mPhoneName.value.substr(4,3)+strSeperator+mPhoneName.value.substr(7,4);
			            vPhoneName.value = mS1;
					}
					else
					{
		               alert("Invalid Phone (format : xxx-xxx-xxxx)\nPlease Re-Check");
        		       vPhoneName.focus();
		               vPhoneName.select();
        		       return false;
					}
				}
			}
            return true;
         }
         else  
         {
         // Non isNav Check
            if ((vPhoneValue.length <= 11 && vPhoneValue.length >=1) && vPhoneCheck)
            {
               alert("Invalid Phone (format : xxx-xxx-xxxx)\nPlease Re-Check");
               //vPhoneName.value = "";
               vPhoneName.focus();
               return true;
            }
            
            if (vPhoneValue.length == 12)  
            {
    	        return true;
            }
            else
            {
               
	             if (vPhoneValue.length == 3)  
                  {
                     vPhoneName.value = vPhoneValue+strSeperator;
                  }
                  if (vPhoneValue.length == 7)  
                  {
                     vPhoneName.value = vPhoneValue+strSeperator;
                  }
               return true;
            }
         }
         return false;
      }
      else  
      {
         // If the value is not in the string return the string minus the last
         // key entered.
         if (isNav4)
         {
            //vPhoneName.value = "";
            vPhoneName.focus();
            vPhoneName.select();
            return false;
         }
         else
         {
            //vPhoneName.value = vPhoneName.value.substr(0, (vPhoneValue.length-1));
            return false;
         }
		}
	}
}

function replaceSubstring(inputString, fromString, toString) {
	// Not sure of the author on this code but is has always worked for me.
	// Goes through the inputString and replaces every occurrence of fromString with toString
   var temp = inputString;
   if (fromString == "") {
      return inputString;
   }
   if (toString.indexOf(fromString) == -1) { // If the string being replaced is not a part of the replacement string (normal situation)
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } else { // String being replaced is part of replacement string (like "+" being replaced with "++") - prevent an infinite loop
      var midStrings = new Array("~", "`", "_", "^", "#");
      var midStringLen = 1;
      var midString = "";
      // Find a string that doesn't exist in the inputString to be used
      // as an "inbetween" string
      while (midString == "") {
         for (var i=0; i < midStrings.length; i++) {
            var tempMidString = "";
            for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
            if (fromString.indexOf(tempMidString) == -1) {
               midString = tempMidString;
               i = midStrings.length + 1;
            }
         }
      } // Keep on going until we build an "inbetween" string that doesn't exist
      // Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + midString + toTheRight;
      }
      // Next, replace the "inbetween" string with the "toString"
      while (temp.indexOf(midString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(midString));
         var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } // Ends the check to see if the string being replaced is part of the replacement string or not
   return temp; // Send the updated string back to the user
} // Ends the "replaceSubstring" function

function trimString(mThis)
{
    
    //Usage:     mThis = " Something ";
    //           mThis = trim(mThis);     <-- field passed by reference
    //           mVariableName = trim(mThis); <-- local variable
	//Note:      This function takes a string
    //Returns:   "Something"
    
    
    //Get rid of leading spaces
    while(''+mThis.charAt(0)==' ')
        mThis=mThis.substring(1,mThis.length);
    
    //Get rid of trailing spaces
    while(''+mThis.charAt(mThis.length-1)==' ')
        mThis=mThis.substring(0,mThis.length-1);
    
    return mThis;
}

function IsNumeric(s)
   {
      var l=s.length;
      var i;
      for(var i=0;i<=l;i++)
      {
         var strCheck="0123456789-";
         var sCheck=s.substr(i,1);
         
         if(sCheck>'')
         {
            if(strCheck.indexOf(sCheck) < 0)
            {
               return false;
            }
         }
      }
      return true;
      
   }		


function trim(input)
{
  var lre = /^\s*/;
  var rre = /\s*$/;
  input = input.replace(lre, "");
  input = input.replace(rre, "");
  return input;
}

/*Validate the Date Input*/
function datevalidate(curYear,field1)
{
    tmpDate = field1.value
	tmp = tmpDate;
	curYear = curYear.toString();
	if (tmpDate == "")
		return true;
		
	tmpVar = "";
	for(i=0;i<tmp.length;i++)
	{
		s = tmp.charAt(i);
		tmpVar = tmpVar + s.replace("-","/");
	}
	tmp = tmpVar;

	tmpVar = "";
	for(i=0;i<tmp.length;i++)
	{
		s = tmp.charAt(i);
		tmpVar = tmpVar + s.replace(".","/");
	}		
	tmp = tmpVar;
		
	dateArr = tmp.split("/");
		
	if(dateArr.length == 3)
	{
		if(dateArr[0].length == 1)
			dateArr[0]= "0" + dateArr[0];
		if(dateArr[1].length == 1)
			dateArr[1]= "0" + dateArr[1];
		if(dateArr[2].length == 2)
			dateArr[2] = curYear.substr(0,2) + dateArr[2];
		tmp = dateArr[0] + "/" + dateArr[1] + "/" + dateArr[2];
	}
	else if(dateArr.length == 2)
	{
		if(dateArr[0].length == 1)
			dateArr[0]= "0" + dateArr[0];
		if(dateArr[1].length == 1)
			dateArr[1]= "0" + dateArr[1];
		tmp = dateArr[0] + "/" + dateArr[1] + "/" + curYear;
	}
	else if(dateArr.length == 1)
	{
		if(dateArr[0].length == 8)
		{
			dy = dateArr[0].substr(0,2);
			mn = dateArr[0].substr(2,2);
			yr = dateArr[0].substr(4,4);
			tmp = dy + "/" + mn + "/" + yr;
		}
		else if(dateArr[0].length == 6)
		{
			dy = dateArr[0].substr(0,2);
			mn = dateArr[0].substr(2,2);
			yr = curYear.substr(0,2) + dateArr[0].substr(4,2);
			tmp = dy + "/" + mn + "/" + yr;
		}
		else if(dateArr[0].length == 4)
		{
			dy = dateArr[0].substr(0,2);
			mn = dateArr[0].substr(2,2);
			yr = curYear;
			tmp = dy + "/" + mn + "/" + yr;
		}
		else
		{
			tmp = "";
			alert("Invalid Date");
			return false;
		}
	}

	tmpDate = tmp;
	field1.value = tmpDate;	
	return true;		
	//"US" United States date style
	//"EU" European date style
	if(tmp != "")
		if(checkdate(tmp,'US'))
			return true;
		else
		{
			alert("Invalid Date");
			return false;
		}
	else
	{
		return false;
	}
}

/*Email Validation
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- V1.1.3: Sandeep V. Tamhankar (stamhankar@hotmail.com) -->
<!-- Original:  Sandeep V. Tamhankar (stamhankar@hotmail.com) -->
<!-- Changes:
 1.1.4: Fixed a bug where upper ASCII characters (i.e. accented letters
international characters) were allowed.

1.1.3: Added the restriction to only accept addresses ending in two
letters (interpreted to be a country code) or one of the known
TLDs (com, net, org, edu, int, mil, gov, arpa), including the
new ones (biz, aero, name, coop, info, pro, museum).  One can
easily update the list (if ICANN adds even more TLDs in the
future) by updating the knownDomsPat variable near the
top of the function.  Also, I added a variable at the top
of the function that determines whether or not TLDs should be
checked at all.  This is good if you are using this function
internally (i.e. intranet site) where hostnames don't have to 
conform to W3C standards and thus internal organization e-mail
addresses don't have to either.
Changed some of the logic so that the function will work properly
with Netscape 6.

1.1.2: Fixed a bug where trailing . in e-mail address was passing
(the bug is actually in the weak regexp engine of the browser; I
simplified the regexps to make it work).

1.1.1: Removed restriction that countries must be preceded by a domain,
so abc@host.uk is now legal.  However, there's still the 
restriction that an address must end in a two or three letter
word.

1.1: Rewrote most of the function to conform more closely to RFC 822.

1.0: Original  
// -->

<!-- Begin*/
function emailCheck (emailStr) {

emailStr = emailStr.toLowerCase()
/* The following variable tells the rest of the function whether or not
to verify that the address ends in a two-letter country or well-known
TLD.  1 means check it, 0 means don't. */

var checkTLD=1;

/* The following is the list of known TLDs that an e-mail address must end with. */

var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

/* The following pattern is used to check if the entered e-mail address
fits the user@domain format.  It also is used to separate the username
from the domain. */

var emailPat=/^(.+)@(.+)$/;

/* The following string represents the pattern for matching all special
characters.  We don't want to allow special characters in the address. 
These characters include ( ) < > @ , ; : \ " . [ ] */

var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

/* The following string represents the range of characters allowed in a 
username or domainname.  It really states which chars aren't allowed.*/

var validChars="\[^\\s" + specialChars + "\]";

/* The following pattern applies if the "user" is a quoted string (in
which case, there are no rules about which characters are allowed
and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
is a legal e-mail address. */

var quotedUser="(\"[^\"]*\")";

/* The following pattern applies for domains that are IP addresses,
rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
e-mail address. NOTE: The square brackets are required. */

var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

/* The following string represents an atom (basically a series of non-special characters.) */

var atom=validChars + '+';

/* The following string represents one word in the typical username.
For example, in john.doe@somewhere.com, john and doe are words.
Basically, a word is either an atom or quoted string. */

var word="(" + atom + "|" + quotedUser + ")";

// The following pattern describes the structure of the user

var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

/* The following pattern describes the structure of a normal symbolic
domain, as opposed to ipDomainPat, shown above. */

var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

/* Finally, let's start trying to figure out if the supplied address is valid. */

/* Begin with the coarse pattern to simply break up user@domain into
different pieces that are easy to analyze. */

var matchArray=emailStr.match(emailPat);

if (matchArray==null) {

/* Too many/few @'s or something; basically, this address doesn't
even fit the general mould of a valid e-mail address. */

alert("Email address seems incorrect (check @ and .'s)");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];

// Start by checking that only basic ASCII characters are in the strings (0-127).

for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("Ths Email username contains invalid characters.");
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("Ths Email domain name contains invalid characters.");
return false;
   }
}

// See if "user" is valid 

if (user.match(userPat)==null) {

// user is not valid

alert("The Email username does not seem to be valid.");
return false;
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */

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("Destination IP address is invalid!");
return false;
   }
}
return true;
}

// Domain is symbolic name.  Check if it's valid.
 
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("The email domain name does not seem to be valid.");
return false;
   }
}

/* domain name seems valid, but now make sure that it ends in a
known top-level domain (like com, edu, gov) or a two-letter word,
representing country (uk, nl), and that there's a hostname preceding 
the domain or country. */

if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("The email address must end in a well-known domain or two letter " + "country.");
return false;
}

// Make sure there's a host name preceding the domain.

if (len<2) {
alert("The email address is missing a hostname!");
return false;
}

// If we've gotten this far, everything's valid!
return true;
}

//  End -->


-->
