/**
 * Add State Module JS Files
 * @author Pathfinder Solutions India
 * @link http://www.pathfindersolutions.biz
 * @version 1.0
 * @package justmeans
 * @subpackage state
 */
 function fnValidatePublicURL (strURL)
 {
	var iChars = /[ ?'`\\~!@#$%&,.:;<>{}()=\/\"\/\*\/\^\/\+\/\|\/\/]/
	var SpecialChar = iChars.test(strURL);
	if (SpecialChar)
	{
		return false;
	}
	return true;
}

/**
 * fnValidateInput function
 * @param 
 * @return bool true or false
 */
	function fnValidateLoginInput()
	{
		var strErrorMessage = ""

			if(document.getElementById('id_txtloginemail').value == "")
			{
				strErrorMessage = strErrorMessage + " Enter Email. \n";
				//document.getElementById('id_txtloginemail').focus();
			}
			
			if(document.getElementById('id_txtloginpassword').value == "")
			{
				strErrorMessage = strErrorMessage + " Enter Password. \n";
				//document.getElementById('id_txtloginpassword').focus();
			}
			
			if(strErrorMessage == "")
			{
				return true;
			}
			else
			{
				alert(strErrorMessage);
				return false;
			}

	}
	
	function fnValidatePopLoginInput()
	{
		var strErrorMessage = ""

			if(document.getElementById('id_txtPoploginemail').value == "")
			{
				strErrorMessage = strErrorMessage + " Enter Email. \n";
				//document.getElementById('id_txtloginemail').focus();
			}
			else
			{
				//document.getElementById('id_txtloginemail').value = document.getElementById('id_txtPoploginemail').value;
			}
			
			if(document.getElementById('id_txtPoploginpassword').value == "")
			{
				strErrorMessage = strErrorMessage + " Enter Password. \n";
				//document.getElementById('id_txtloginpassword').focus();
			}
			else
			{
				//document.getElementById('id_txtloginpassword').value = document.getElementById('id_txtPoploginpassword').value;
			}
			
			if(strErrorMessage == "")
			{
				return true;
			}
			else
			{
				alert(strErrorMessage);
				return false;
			}

	}
	
	function fnValidateInput()
	{
		var strErrorMessage = ""

			if(document.getElementById('id_txtfname').value == "")
			{
				strErrorMessage = strErrorMessage + " Enter First Name. \n";
				//document.getElementById('id_txtfname').focus();
			}
						
			if(document.getElementById('id_txtlname').value == "")
			{
				strErrorMessage = strErrorMessage + " Enter Last Name. \n";
				//document.getElementById('id_txtlname').focus();
			}
					
			
			if ( document.getElementById('id_txtemail').value == "")
			{
				strErrorMessage = strErrorMessage + " Enter Email. \n";
			}
			else
			{
				
				var emailStr = document.getElementById('id_txtemail').value;
				
				if(!fnLoginEmailCheck (emailStr))
				{
					strErrorMessage = strErrorMessage + " Enter Valid Email. \n";
				}
			}
			
			if ( document.getElementById('id_txtpassword').value == "")
			{
				strErrorMessage = strErrorMessage + " Enter Password. \n";
				intIsPass = 1;
			}
			
			/*if ( document.getElementById('id_txtverifypassword').value == "")
			{
				strErrorMessage = strErrorMessage + " Enter Verify Password. \n";
				intIsVerifPass = 1;
			}*/
			
			var strPass = document.getElementById('id_txtpassword').value;
			/*var strVerifyPass = document.getElementById('id_txtverifypassword').value;
				if(strPass != strVerifyPass)
				{
					strErrorMessage = strErrorMessage + " Both Password Should be Same. \n";
				}*/
			var strPasslenght = strPass.length;
				//if(!(4 < strPasslenght > 10))
				if(strPasslenght > 10 || strPasslenght < 4)
				{
					strErrorMessage = strErrorMessage + " Password should be in between 4 - 10 digits. \n";
				}
			/*add by digambar to validate user public url */
			
			if(document.getElementById('id_txtprofileURL').value =="" || document.getElementById('id_txtprofileURL').value =="username")
			{
				strErrorMessage = strErrorMessage + " Enter Screen Name.\n";
				//document.getElementById('id_txtprofileURL').focus();
			}
			if(document.getElementById('id_txtprofileURL').value !="" && document.getElementById('id_txtprofileURL').value !="username")
			{
				var strPurl=document.getElementById('id_txtprofileURL').value;
				if (!fnValidatePublicURL(strPurl)) 
				{
				  	strErrorMessage= strErrorMessage+" Spaces, Sumbols and Punctuations are not allowed in Screen Name.\n";
			  	}				
			}
			/*****************************/

			
/*			if ( document.frmRegisterLogmeIn.chkIAgree.checked == false)
			{
				strErrorMessage = strErrorMessage + " Read User Agreement and Policy. \n";
			} */

			if(strErrorMessage == "")
			{
				return true;
			}
			else
			{
				alert(strErrorMessage);
				return false;
			}

	}
	
	
	var strGoTo;
	var gotosubdomain = "";
	var txtloginemail = "";
	var txtloginpassword = "";
	var chkLoginRemeberMe = "";
	var strloginas = "";
	var ajaxObjects = new Array();
	var gotoeditorials = "";
	
	function fnValidateLoginMeinInput()
	{ 
		strLoginEmail = "";	
		strLoginPassword = "";
		isNext = 1;
		enmIsError = true;
		
		
		if ( document.getElementById('id_txtloginemail').value == "" || document.getElementById('id_txtloginemail').accessKey == "LE?")
		{
			strLoginEmail = "<font color='red'>Enter Email Id.</font>";
			enmIsError = false;
		}
		else
		{
			if(boolLoginEmail == 0 && document.getElementById('id_txtloginemail').accessKey == "LE?")
			{
				strLoginEmail = "<font color='red'>Enter Email Id.</font>";
				enmIsError = false;
			}
			else
			{
				var emailStr = document.getElementById('id_txtloginemail').value;
				
				if(!fnLoginEmailCheck (emailStr))
				{
					strLoginEmail = "<font color='red'>Enter Valid Email .</font>";
					enmIsError = false;
				}
			}
		}
			
		if(strLoginEmail != "")
		{
			document.getElementById('lbl_txtloginemail').innerHTML = strLoginEmail;
			document.getElementById('lbl_txtloginemail').style.display = "";
		}
			
		if ( document.getElementById('id_txtloginpassword').value == "" || document.getElementById('id_txtloginpassword').accessKey == "LP?")
		{
			strLoginPassword = "<font color='red'>Enter Password.</font>";
			intIsPass = 1;
			enmIsError = false;
		}
		else
		{
			if(boolPassword == 0 && document.getElementById('id_txtloginpassword').accessKey == "LP?")
			{
				strLoginPassword = "<font color='red'>Enter Password.</font>";
				intIsPass = 1;
				enmIsError = false;
			}
		}
		if(strLoginPassword != "")
		{
			document.getElementById('lbl_txtloginpassword').innerHTML = strLoginPassword;
			document.getElementById('lbl_txtloginpassword').style.display = "";
		}
		if(enmIsError == true)
		{
			return true;
		}		
		else
		{
			return false;
		}
	}	
/**
 * fnCheckPublicURL function
 * @param public URL
 * @return 
 */	

		
	function fnCheckPublicURL()
	{
		var strErrorMessage = "";
		if ( document.getElementById('id_txtprofileURL').value == "" || document.getElementById('id_txtprofileURL').value == "username")
		{
			strErrorMessage = strErrorMessage + " Enter Screen Name. \n";
			intIsPass = 1;
		}
		if ((document.getElementById('id_txtprofileURL').value.length) > 30)
		{
			strErrorMessage = strErrorMessage + "Screen Name should not be more than 30 character. \n";
			intIsPass = 1;
		}
		var strURL = document.getElementById('id_txtprofileURL').value;
	  	if (!fnValidatePublicURL(strURL)) 
		{
		  	strErrorMessage="Spaces, Sumbols and Punctuations are not allowed in Screen Name.\n";
	  	}
		if(strErrorMessage != "")
		{
			alert(strErrorMessage);
			return false;
		}
		
	  	fnAjaxCaller('id_divURLCheckResponse','logmein','checkURL', '&url='+strURL, '', '');
	}
	
	/*function changePublicURL()
	{
		var purl =document.getElementById('id_txtprofileURL').value;
		//alert(purl);
		if(purl=='')
			document.getElementById('id_refreshpublicurl12').innerHTML ='username';
		else
			document.getElementById('id_refreshpublicurl12').innerHTML = purl;
	}*/
	
	
	boolFirstName = 0;
	boolLastName = 0;
	boolEmail = 0;
	boolPassword = 0;
	boolLoginEmail = 0;
	boolLoginPassword = 0;
	boolCompany = 0;
	
	function fnOnBlurLoginField(objField)
	{
		strFieldValue = objField.value;
		if(objField.value == "")
		{
			switch(objField.accessKey)
			{
				case "LE":
					objField.value = "Email?";
					objField.accessKey = "LE?";
					boolLoginEmail = 0;
					strLoginEmail = "Email";
					document.getElementById('lbl_txtloginemail').innerHTML = strLoginEmail;
					document.getElementById('lbl_txtloginemail').style.display = "none";
					document.getElementById('lbl_txtloginemail').style.color=  "#686e75";
					document.getElementById('id_txtloginemail').style.color=  "#686e75";
				break;
				case "LP":
					objField.value = "";
					objField.className = "passwordbg";
					objField.accessKey = "LP?";
					boolLoginPassword = 0;
					strLoginPassword = "Password";
					document.getElementById('lbl_txtloginpassword').innerHTML = strLoginPassword;
					document.getElementById('lbl_txtloginpassword').style.display = "none";
					document.getElementById('lbl_txtloginpassword').style.color=  "#686e75";
					document.getElementById('id_txtloginpassword').style.color=  "#686e75";
				break;
				case "SF":
					objField.value = "First Name?";
					objField.accessKey = "SF?";
					boolFirstName = 0;
					strSignupFirstName = "First Name";
					document.getElementById('lbl_txtfname').innerHTML = strSignupFirstName;
					document.getElementById('lbl_txtfname').style.display = "none";
					document.getElementById('lbl_txtfname').style.color=  "#686e75";
					document.getElementById('id_txtfname').style.color=  "#686e75";
				break;
				case "SL":
					objField.value = "Last Name?";
					objField.accessKey = "SL?";
					boolLastName = 0;
					strSignupLastName = "Last Name";
					document.getElementById('lbl_txtlname').innerHTML = strSignupLastName;
					document.getElementById('lbl_txtlname').style.display = "none";
					document.getElementById('lbl_txtlname').style.color=  "#686e75";
					document.getElementById('id_txtlname').style.color=  "#686e75";
				break;
				case "SE":
					objField.value = "Email?";
					objField.accessKey = "SE?";
					boolEmail = 0;
					strSignupPassword = "Email";
					document.getElementById('lbl_txtemail').innerHTML = strSignupPassword;
					document.getElementById('lbl_txtemail').style.display = "none";
					document.getElementById('lbl_txtemail').style.color=  "#686e75";
				document.getElementById('id_txtemail').style.color=  "#686e75";
				break;
				case "SP":
					objField.value = "";
					objField.className = "passwordbg";
					objField.accessKey = "SP?";
					boolPassword = 0;
					strSignupPassword = "Password";
					document.getElementById('lbl_txtpassword').innerHTML = strSignupPassword;
					document.getElementById('lbl_txtpassword').style.display = "none";
					
					document.getElementById('lbl_txtpassword').style.display = "none";
					document.getElementById('lbl_txtpassword').style.color=  "#686e75";
				document.getElementById('id_txtpassword').style.color=  "#686e75";
				break;
				case "SC":
					objField.value = "Company or University?";
					objField.accessKey = "SC?";
					boolCompany = 0;
					strSignupCompany = "Company";
					document.getElementById('lbl_txtusercompany').innerHTML = strSignupCompany;
					document.getElementById('lbl_txtusercompany').style.display = "none";
					document.getElementById('lbl_txtusercompany').style.color=  "#686e75";
					document.getElementById('lbl_txtusercompany').style.color=  "#686e75";
				break;
				
			}
		}
	}
	
	//////////////////////////////// LOGIN VALIDATION ///////////////////////////////////////
	function fnValidateLoginFields()
	{
		strLoginEmail = "";	
		strLoginPassword = "";
		
		if ( document.getElementById('id_txtloginemail').value == "" || document.getElementById('id_txtloginemail').accessKey == "LE?")
		{
			strLoginEmail = "<font color='red'>Enter Email.</font>";
		}
		else
		{
			if(boolLoginEmail == 0 && document.getElementById('id_txtloginemail').accessKey == "LE?")
			{
				strLoginEmail = "<font color='red'>Enter Email.</font>";
			}
			else
			{
				var emailStr = document.getElementById('id_txtloginemail').value;
				
				if(!fnLoginEmailCheck (emailStr))
				{
					strLoginEmail = "<font color='red'>Enter Valid Email</font>";
				}
			}
		}
			
		if(strLoginEmail != "")
		{
			document.getElementById('lbl_txtloginemail').innerHTML = strLoginEmail;
			document.getElementById('lbl_txtloginemail').style.display = "";
		}
			
		if ( document.getElementById('id_txtloginpassword').value == "" || document.getElementById('id_txtloginpassword').accessKey == "LP?")
		{
			strLoginPassword = "<font color='red'>Enter Password.</font>";
			intIsPass = 1;
		}
		else
		{
			if(boolPassword == 0 && document.getElementById('id_txtloginpassword').accessKey == "LP?")
			{
				strLoginPassword = "<font color='red'>Enter Password.</font>";
				intIsPass = 1;
			}
		}
			
			
		/*var strPass = document.getElementById('id_txtloginpassword').value;
		var strPasslenght = strPass.length;
		//if(!(4 < strPasslenght > 10))
		if(strPasslenght > 10 || strPasslenght < 4)
		{
			strLoginPassword = "<font color='red'>minimum 4 - 10 character long.</font>";
		}*/

		if(strLoginPassword != "")
		{
			document.getElementById('lbl_txtloginpassword').innerHTML = strLoginPassword;
			document.getElementById('lbl_txtloginpassword').style.display = "";
		}

		if(strLoginPassword == "" && strLoginEmail == "")
		{
			return true;
		}
		return false;
	}
	//////////////////////////////// LOGIN VALIDATION ///////////////////////////////////////
	
	
	
	function fnLoginField(objField)
	{
		strFieldValue = objField.value;
		switch(objField.accessKey)
		{
			case "LE?":
				objField.value = "";
				objField.accessKey = "LE";
				strLoginEmail = "Email";
				document.getElementById('lbl_txtloginemail').innerHTML = strLoginEmail;
				document.getElementById('lbl_txtloginemail').style.display = "";
				document.getElementById('lbl_txtloginemail').style.color=  "#000000";
				document.getElementById('id_txtloginemail').style.color=  "#000000";
			break;
			case "LP?":
				objField.value = "";
				objField.className = "logininput";
				objField.accessKey = "LP";
				strLoginPassword = "Password";
				document.getElementById('lbl_txtloginpassword').innerHTML = strLoginPassword;
				document.getElementById('lbl_txtloginpassword').style.display = "";
				document.getElementById('lbl_txtloginpassword').style.color=  "#000000";
				document.getElementById('id_txtloginpassword').style.color=  "#000000";
			break;
			case "SF?":
				boolFirstName = 1;
				objField.value = "";
				objField.accessKey = "SF";
				strSignupFirstName = "First Name";
				document.getElementById('lbl_txtfname').innerHTML = strSignupFirstName;
				document.getElementById('lbl_txtfname').style.display = "";
				document.getElementById('lbl_txtfname').style.color=  "#000000";
				document.getElementById('id_txtfname').style.color=  "#000000";
			break;
			case "SL?":
				boolLastName = 1;
				objField.value = "";
				objField.accessKey = "SL";
				strSignupLastName = "Last Name";
				document.getElementById('lbl_txtlname').innerHTML = strSignupLastName;
				document.getElementById('lbl_txtlname').style.display = "";
				document.getElementById('lbl_txtlname').style.color=  "#000000";
				document.getElementById('id_txtlname').style.color=  "#000000";
			break;
			case "SE?":
				boolEmail = 1;
				objField.value = "";
				objField.accessKey = "SE";
				strSignupEmail = "Email";
				document.getElementById('lbl_txtemail').innerHTML = strSignupEmail;
				document.getElementById('lbl_txtemail').style.display = "";
				document.getElementById('lbl_txtemail').style.color=  "#000000";
				document.getElementById('id_txtemail').style.color=  "#000000";
			break;
			case "SP?":
				boolPassword = 1;
				objField.value = "";
				objField.className = "logininput" ;
				objField.accessKey = "SP";
				strSignupPassword = "Password";
				document.getElementById('lbl_txtpassword').innerHTML = strSignupPassword;
				document.getElementById('lbl_txtpassword').style.display = "";
				document.getElementById('lbl_txtpassword').style.color=  "#000000";
				document.getElementById('id_txtpassword').style.color=  "#000000";
			break;
			case "SC?":
				boolCompany = 1;
				objField.value = "";
				objField.accessKey = "SC";
				strSignupCompany = "Company or University";
				document.getElementById('lbl_txtusercompany').innerHTML = strSignupCompany;
				document.getElementById('lbl_txtusercompany').style.display = "";
				document.getElementById('lbl_txtusercompany').style.color=  "#000000";
				document.getElementById('lbl_txtusercompany').style.color=  "#000000";
			break;
		}
		
	}
	//////////////////////// SIGNUP VALIDATION //////////////////////////////////
	
	function fnShowCapcha()
	{
		if(fnValidateFieldInput())
		{
			/*document.getElementById('registerfielddiv').style.display = "none";
			document.getElementById('registercapchadiv').style.display = "";*/
			
			document.getElementById('registerfielddiv').style.display = "none";
			document.getElementById('registercapchadiv').style.display = "";
			document.getElementById('registercapchadiv').align = "center";			
			
			document.getElementById("id_mainTable").style.height= "250px";
			document.getElementById("id_mainTable").style.width= "310px";			
			
			//Lightbox.hideBox();
			document.getElementById("newlogin").style.display='none';
			document.getElementById("loginseperator").style.display='none';
			///Lightbox.showBoxByID("divRegisterLogin", 550,335);
		}
		return false;
	}


	function fnHideCapcha()
	{
		
		/*document.getElementById('registerfielddiv').style.display = "";
		document.getElementById('registercapchadiv').style.display = "none";*/
		//if(document.getElementById("id_msg").)
		
		/*if(document.getElementById("id_capchamsg") == "null")
		{
			document.getElementById("id_msg").style.display = "none";
			document.getElementById("id_capchamsg").style.display = "none";
		}
		else
		{
			document.getElementById("id_capchamsg").style.display = "none";
		}*/
		
		//alert(document.getElementById("error_row").childNodes[0].id);
		
		if(document.getElementById("error_row").childNodes[0].id == "id_capchamsg")
			document.getElementById("id_capchamsg").style.display = "none";
		
		//document.getElementById("id_capchamsg").style.display = "none";
		document.getElementById('registerfielddiv').style.display = "";
		document.getElementById('newlogin').style.display = "";
		document.getElementById('registercapchadiv').style.display = "none";		
		//Lightbox.hideBox();
		
		//document.getElementById("newlogin").width='50%';
		
		document.getElementById('loginseperator').style.display = "";
		//document.getElementById('isBack').value = 1;
		document.getElementById("id_newlogin").style.display= "";	
		
		//Lightbox.showBoxByID("divRegisterLogin", 550,335);
		return false
	}
	
	function fnValidateFieldInput()
	{
		var strSignupFirstName = "First Name";
		var strSignupLastName = "Last Name";
		var strSignupEmail = "Email";
		var strSignupPassword = "Password";
		var strErrorMessage = ""
 		var strFnameNumericVal = "";
		enmIsError = true;
		
		if(document.getElementById('id_txtfname').value == "" || document.getElementById('id_txtfname').accessKey == "SF?")
		{
			strSignupFirstName = "<font color='red'>Enter First Name.</font>";
			enmIsError = false;
		}
		else
		{
			if(boolFirstName == 0 && document.getElementById('id_txtfname').accessKey == "SF?")
			{
				strSignupFirstName = "<font color='red'>Enter First Name.</font>";
				enmIsError = false;
			}
		}
			
			
		if(strSignupFirstName != "")
		{
			document.getElementById('lbl_txtfname').innerHTML = strSignupFirstName;
			document.getElementById('lbl_txtfname').style.display = "";
		}
			
		if(document.getElementById('id_txtlname').value == "" || document.getElementById('id_txtlname').accessKey == "SL?")
		{
			strSignupLastName = "<font color='red'>Enter Last Name.</font>";
			enmIsError = false;
		}
		else
		{
			if(boolLastName == 0 && document.getElementById('id_txtlname').accessKey == "SL?")
			{
				strSignupLastName = "<font color='red'>Enter Last Name.</font>";
				enmIsError = false;
			}
		}
			
		if(strSignupLastName != "")
		{
			document.getElementById('lbl_txtlname').innerHTML = strSignupLastName;
			document.getElementById('lbl_txtlname').style.display = "";
		}
			
		if ( document.getElementById('id_txtemail').value == "" || document.getElementById('id_txtemail').accessKey == "SE?")
		{
			strSignupEmail = "<font color='red'>Enter Email.</font>";
			enmIsError = false;
		}
		else
		{
			if(boolEmail == 0 && document.getElementById('id_txtemail').accessKey == "SE?")
			{
				strSignupEmail = "<font color='red'>Enter Email.</font>";
				enmIsError = false;
			}
			else
			{
				var emailStr = document.getElementById('id_txtemail').value;
				
				if(!fnLoginEmailCheck (emailStr))
				{
					strSignupEmail = "<font color='red'>Enter Valid Email.</font>";
					enmIsError = false;
				}
			}
		}
			
		if(strSignupEmail != "")
		{
			document.getElementById('lbl_txtemail').innerHTML = strSignupEmail;
			document.getElementById('lbl_txtemail').style.display = "";
		}
			
			
		if ( document.getElementById('id_txtpassword').value == "" || document.getElementById('id_txtpassword').accessKey == "SP?")
		{
			strSignupPassword = "<font color='red'>Enter Password.</font>";
			intIsPass = 1;
			enmIsError = false;
		}
		else
		{
			if(boolPassword == 0 && document.getElementById('id_txtpassword').accessKey == "SP?")
			{
				strSignupPassword = "<font color='red'>Enter Password.</font>";
				enmIsError = false;
				intIsPass = 1;
			}
		}
			
		var strPass = document.getElementById('id_txtpassword').value;
		var strPasslenght = strPass.length;
		if(strPasslenght > 10 || strPasslenght < 4)
		{
			strSignupPassword = "<font color='red'>min. 4-10 character long.</font>";
			enmIsError = false;
		}

		if(strSignupPassword != "")
		{
			document.getElementById('lbl_txtpassword').innerHTML = strSignupPassword;
			document.getElementById('lbl_txtpassword').style.display = "";
		}
		
		
		/*if(document.getElementById('txtusercompany').value == "" || document.getElementById('txtusercompany').accessKey == "SC?")
		{
			strSignupCompany = "<font color='red'>Enter Company or University.</font>";
			enmIsError = false;
		}
		else
		{
			if(boolFirstName == 0 && document.getElementById('txtusercompany').accessKey == "SC?")
			{
				strSignupCompany = "<font color='red'>Enter Company or University.</font>";
				enmIsError = false;
			}
		}
			
		if(strSignupCompany != "")
		{
			document.getElementById('lbl_txtusercompany').innerHTML = strSignupCompany;
			document.getElementById('lbl_txtusercompany').style.display = "";
		}*/
		
		if(enmIsError == true)
		{
			return true;
		}
		return false;
	}
	//////////////////////// SIGNUP VALIDATION //////////////////////////////////
	
	function fnLoginEmailCheck (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("Email address seems incorrect (check @ and .'s)")
		  return false
		}
		var user=matchArray[1]
		var domain=matchArray[2]
		
		// See if "user" is valid
		if (user.match(userPat)==null) {
			// user is not valid
			//alert("The username doesn't 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
		var domainArray=domain.match(domainPat)
		if (domainArray==null) {
		 //alert("The domain name doesn't seem to be valid.")
			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>4) {
		   // the address must end in a two letter or three letter word.
		   //alert("The address must end in a three-letter domain, or two letter country.")
		   return false
		}
		
		// Make sure there's a host name preceding the domain.
		if (len<2) {
		   var errStr="This address is missing a hostname!"
		   //alert(errStr)
	   return false
	}
	// If we've got this far, everything's valid!
	return true;
	}
