﻿function usecontactAddress()
{
    var chkusecontactAddress = document.getElementById('chkusecontactAddress');
    if (chkusecontactAddress.checked)
    {
	    document.getElementById('ctl00_ContentPlaceHolder1_ucAddress_txtAddr1').value ='addr';// document.getElementById('ctl00_ContentPlaceHolder1_hidAddr1').value;
	    alert('checked');
    }
    else
    {
	    alert('not checked');
		
    }
}
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 ValidateCountry(sender, args)
{
   // alert(args.Value);
    if(args.Value == "-1")
    {      
        args.IsValid = false;
         return;
    }
      args.IsValid = true;  
}
function calculatevalue(ShareAmount,NoOfShares,UnitPrice)
{	
    var pound = ShareAmount.value;
    var divide = NoOfShares.value;
	var valid = "0123456789.";
	var ok = "yes";
	var temp;
	var commafound = "no";
	var newval = "";
	
	for (var i=0; i<pound.length; i++) 
	{
		temp = "" + pound.substring(i, i+1);
		
		if (temp != ",")
		{
			commafound = "yes";
			var newval = newval+temp;	
		}
	}
	
	//Check if found comma	
	if (commafound == "yes")
	{	
		pound = newval;
		ShareAmount.value = newval;
		NoOfShares.value = newval/divide;
		ShareAmount.value = round(newval);		
	}
	
	for (var i=0; i<pound.length; i++) 
	{
		temp = "" + pound.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = "no";
		
		if (temp != ",")
		{
			commafound = "yes";
			var newval = newval+temp;	
		}
	}
	
	if (ok == "no")
	{
		alert("Invalid entry!  Only numeric values are accepted!");
		ShareAmount.focus();
		ShareAmount.select();
	}
	else
	{
		
	}
}
//----------------------
function calculatevalue1(ShareAmount,NoOfShares,UnitPrice,defaultshares)
{
    var pound = ShareAmount.value;
    var divide = NoOfShares.value;
	var valid = "0123456789";
	var ok = "yes";
	var temp;
	var test;
	
	/************************* Code 121101 - Function to remove comma in value *************************/
		var temp2;
		var commafound2 = "no";
		var newval2 = "";
		
		for (var i=0; i<divide.length; i++) 
		{
			temp2 = "" + divide.substring(i, i+1);
			
			if (temp2 != ",")
			{
				commafound2 = "yes";
				var newval2 = newval2+temp2;	
			}
		}
		//Check if found comma	
		if (commafound2 == "yes")
		{	
			divide = newval2;
			NoOfShares.value = newval2;
		}
	/************************* End Code 121101 - Function to remove comma in value *************************/
	
	
	for (var i=0; i<divide.length; i++) 
	{
		temp = "" + divide.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = "no";
	}
	
	if (ok == "no")
	{
		alert("Invalid entry!  Only numeric values are accepted!");
		NoOfShares.focus();
		NoOfShares.select();
	}
	else
	{
		if ((divide == "")||(divide == 0))
		{
			alert('Field ordinary share capital cannot be empty or zero ');
			NoOfShares.value = defaultshares;
			UnitPrice.value = round(pound/defaultshares);			
		}
		else
		{
			var divisionvalueround = round(pound/divide);
			var divisionvalue = pound/divide;
			if (divisionvalue != divisionvalueround)
			{	
				alert('Please enter share value to obtain a whole figure of unit shares');
				NoOfShares.focus();
				NoOfShares.select();
			}
			else
			{
			UnitPrice.value = round(pound/divide);			
			}	
			
		}
	}
}
//------------------------
function checkb4split(ShareAmount,NoOfShares,UnitPrice,defaultvalue,btnAddClass,trAddClass)
{	
        var pound = ShareAmount.value;
        var divide = NoOfShares.value;
		//alert(divide)
		if ((pound == "")||(pound == 0)||(pound < defaultvalue))
		{	
			alert("Field authorised share capital cannot be empty, zero\nor less than " + defaultvalue);
			ShareAmount.value = defaultvalue;
			UnitPrice.value = round(defaultvalue/divide);
			return false;
		}
		else
		{	
			if ((divide == "")||(divide == 0))
			{
				alert('Please enter number of share(s)');
					NoOfShares.focus();
					NoOfShares.select();return false;
			}
			else
			{
				var divisionvalueround = round(pound/divide);
				var divisionvalue = pound/divide;
				if (divisionvalue != divisionvalueround)
				{	
					alert('Please enter share value to obtain a whole figure of unit shares');
					ShareAmount.focus();
					ShareAmount.select();return false;
				}
				else
				{
				UnitPrice.value = pound/divide;
				ShareAmount.value = round(pound);
				}
			}
			
		}
		if (divide > 1)
		{
			//showbox(obj,tr,form);
//            if (chk.checked == true)
//            {
//             trAddClass.style.display = "block";
//            }
//            else
//            {
//	            trAddClass.style.display = "none";	            
//            }	
            return true;
	      }
		else
		{
		    alert("Cannot Split this Share Capital, Number of Shares should be greater than 1");return false;
		     return false;   
		 }
		
}
//------------------------
function validateShareClass1(rowcount,shareQty)
{
    var qty = shareQty.value;
    var sum = 0;
    for(var i=2; i<rowcount+2; i++)
    {
       sum = sum + ("ctl00_ContentPlaceHolder1_gvShareClass_ctl0" + i + "_txtShareQty").value;
    }
    if (sum > qty)
	{
		alert("Invalid amount, the number of shares should sum up to "+qty+".\n\nPlease make necessary amendements ");
		ctl00_ContentPlaceHolder1_gvShareClass_ctl02_txtShareQty.focus();
	}
}

function validateShareClass(txtname,isround,dvdval)
{
    var val = txtname.value;
   // var txtname = 
    //var isround = 
    var dvdval = dvdval.value;
	var valid = "0123456789";
	var ok = "yes";
	var temp;
	var temp2;
	var commafound = "no";
	var newval = "";
	
	if (trim(val) != "")
	{
		for (var i=0; i<val.length; i++) 
		{
			temp = "" + val.substring(i, i+1);
			
			if (temp != ",")
			{
				commafound = "yes";
				var newval = newval+temp;	
			}
		}
		//Check if found comma	
		if (commafound == "yes")
		{	
			val = newval;
			txtname.value = newval;
		}
		for (var z=0; z<val.length; z++) 
		{
			temp2 = "" + val.substring(z, z+1);
			if (valid.indexOf(temp2) == "-1"){ok = "no";}
					
		}
		if (ok == "no")
		{
			alert("Invalid entry!  Only numeric values are accepted!");
			txtname.focus();
			txtname.value = '';
		}
		else
		{
			
			var txtround = txtname+".value= round(val)";
			if (isround=="flo")
			{
			    txtname.value = round(val);
			}
		}
	}
//	if (newval > dvdval)
//	{
//		alert("Invalid amount, the number of shares should sum up to "+dvdval+".\n\nPlease make necessary amendements ");
//		txtname.value = '';
//		txtname.focus();
//	}
}
//------------------------

//Functions to calculate the amount of each shares and also validating the fields
//pounds and amount of shares
function round (n) 
{
    n = Math.round(n * 100) / 100;
    n = (n + 0.001) + '';
    return n.substring(0, n.indexOf('.') + 3);
}
//------------------------
// Remove any extraneous leading or following spaces that you might have in a string
function trim (inputStringTrim)
{
	fixedTrim = "";
	lastCh = " ";
	for (x=0; x < inputStringTrim.length; x++){
		ch = inputStringTrim.charAt(x);
		if ((ch != " ") || (lastCh != " ")){
			fixedTrim += ch;
		}
		lastCh = ch;
	}
		
	if (fixedTrim.charAt(fixedTrim.length - 1) == " "){
		fixedTrim = fixedTrim.substring(0, fixedTrim.length - 1);
	}

	return fixedTrim
}
//-------------------------
//Following function validates an email entry and displays proper message if email address is incorrect
	function validateEmail (emailStr) {
		var isErr = "no";
		if (emailStr == "")
				{
					alert("Please enter your email address"); var isErr = "yes"; return isErr;
				}
		/* 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)"); var isErr = "yes";
			return isErr;
		}
		var user=matchArray[1]
		var domain=matchArray[2]
	
		// See if "user" is valid 
		if (user.match(userPat)==null) {
		    // user is not valid
	    	alert("The emailname doesn't seem to be valid."); var isErr = "yes";
		    return isErr;
		}
	
		/* 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!"); var isErr = "yes";
					return isErr;
			    }
	    	}
		    return true
		}
	
		// Domain is symbolic name
		var domainArray=domain.match(domainPat)
		if (domainArray==null) {
			alert("The domain name doesn't seem to be valid."); var isErr = "yes";
	    	return isErr;
		}
	
		/* domain name seems valid, but now make sure that it ends in a
		   three-letter word (like com, edu, gov) or a two-letter word,
		   representing country (uk, nl), and that there's a hostname preceding 
		   the domain or country. */
	
		/* Now we need to break up the domain to get a count of how many atoms
		   it consists of. */
		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>3) {
		   // 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."); var isErr = "yes";
		   return isErr;
		}
	
		// Make sure there's a host name preceding the domain.
		if (len<2) {
		   var errStr="This address is missing a hostname!"; var isErr = "yes";
		   alert(errStr);
		   return isErr;
		}
	
		// If we've gotten this far, everything's valid!
		return isErr;
	}//end validateEmail


//------------------------------------------------

function checkques(Question1,Question2,Question3,Ans1,Ans2,Ans3)
{
//doc=document.contact;
   //alert('inside');
	if (Question1.selectedIndex==0)
	{
		alert('Please enter first option of your signature');
		Question1.focus();
		return false;
	}

	if (Question2.selectedIndex==0)
	{
		alert('Please enter second option of your signature');
		Question2.focus();
		return false;
	}
	
	if (Question3.selectedIndex==0)
	{
		alert('Please enter third option of your signature');
		Question3.focus();
		return false;
	}
	if ((Question1.selectedIndex==Question2.selectedIndex)||(Question2.selectedIndex==Question3.selectedIndex)||(Question1.selectedIndex==Question3.selectedIndex))
	{
	alert("You choose same question for two option\nPlease select different options !");
	return false; 
	}
	if ((Question1.selectedIndex==1) && (Ans1.value.length < 1))
	{
		alert('Please enter at least three characters of the name of your town');
		Ans1.focus();
		Ans1.select();
		return false;
	}
	if ((Question2.selectedIndex==1) && (Ans2.value.length <1))
	{
		alert('Please enter at least three characters of the name of your town');
		Ans2.focus();
		Ans2.select();
		return false;
	}
	if ((Question3.selectedIndex==1) && (Ans3.value.length <1))
	{
		alert('Please enter at least three characters of the name of your town');
		Ans3.focus();
		Ans3.select();
		return false;
	}

  
	if ((Question1.selectedIndex==3) && (Ans1.value.length <3))
		{
		alert('Please enter the last three characters of your National Insurance Number');
		Ans1.focus();
		Ans1.select();
		return false;
		}
	if ((Question2.selectedIndex==3) && (Ans2.value.length <3))
		{
		alert('Please enter the last three characters of your National Insurance Number');
		Ans2.focus();
		Ans2.select();
		return false;
		}
	if ((Question3.selectedIndex==3) && (Ans3.value.length <3))
		{
		alert('Please enter the last three characters of your National Insurance Number');
		Ans3.focus();
		Ans3.select();
		return false;
		}
	if ((Question1.selectedIndex==5) && (Ans1.value.length <1))
		{
		alert('Please enter the first three letters of your Mother maiden name');
		Ans1.focus();
		Ans1.select();
		return false;
		}
	if ((Question2.selectedIndex==5) && (Ans2.value.length <1))
		{
		alert('Please enter the first three letters of your Mother maiden name');
		Ans2.focus();
		Ans2.select();
		return false;
		}
	if ((Question3.selectedIndex==5) && (Ans3.value.length <1))
		{
		alert('Please enter the first three letters of your Mother maiden name');
		Ans3.focus();
		Ans3.select();
		return false;
		}
	if ((Question1.selectedIndex==6) && (Ans1.value.length <3))
			{
			alert("Please enter the first three letters of your eye colour");
			Ans1.focus();
			Ans1.select();
			return false;
			}
	if ((Question2.selectedIndex==6) && (Ans2.value.length <3))
		{
		alert('Please enter the first three letters of your eye colour');
		Ans2.focus();
		Ans2.select();
		return false;
		}
	if ((Question3.selectedIndex==6) && (Ans3.value.length <3))
		{
			alert('Please enter the first three letters of your eye colour');
			Ans3.focus();
			Ans3.select();
			return false;
		}
	if ((Question1.selectedIndex==7) && (Ans1.value.length <1))
		{
		alert('Please enter the first three letters of your Father first name');
		Ans1.focus();
		Ans1.select();
		return false;
		}
	else if ((Question2.selectedIndex==7) && (Ans2.value.length <1))
		{
		alert('Please enter the first three letters of your Father first name');
		Ans2.focus();
		Ans2.select();
		return false;
		}
	if ((Question3.selectedIndex==7) && (Ans3.value.length <1))
		{
		alert('Please enter the first three letters of your Father first name');
		Ans3.focus();
		Ans3.select();
		return false;
		}
	if (Question1.selectedIndex==4)
		 {
		 if ((isNaN(Ans1.value)) || (Ans1.value.length < 3))
		{
		alert('Please enter your last three digits of your Passport number');
		Ans1.focus();
		Ans1.select();
		return false;
		}
	}
	if (Question2.selectedIndex==4)
		 {
		 if ((isNaN(Ans2.value)) || (Ans2.value.length < 3))
		{
		alert('Please enter your last three digits of your Passport number');
		Ans2.focus();
		Ans2.select();
		return false;
		}
	}
	if (Question3.selectedIndex==4)
		 {
		 if ((isNaN(Ans3.value)) || (Ans3.value.length < 3))
		{
		alert('Please enter your last three digits of your Passport number');
		Ans3.focus();
		Ans3.select();
		return false;
		}
	}
	
	if (Question1.selectedIndex==2)
	 {
	 if ((isNaN(Ans1.value)) || (Ans1.value.length < 3))
		{
		alert('Please enter your last three digits of your telephone number');
		Ans1.focus();
		Ans1.select();
		return false;
		}
	}
	if (Question2.selectedIndex==2)
	 {
	 if ((isNaN(Ans2.value)) || (Ans2.value.length < 3))
		{
		alert('Please enter your last three digits of your telephone number');
		Ans2.focus();
		Ans2.select();
		return false;
		}
	}
	if (Question3.selectedIndex==2)
	 {
	 if ((isNaN(Ans3.value)) || (Ans3.value.length < 3))
		{
		alert('Please enter your last three digits of your telephone number');
		Ans3.focus();
		Ans3.select();
		return false;
		}
	}
return true;
}



//function checkvalid()
//{
	
	//if ((document.contact.sselectsig.value==document.contact.sselectsig1.value)||(document.contact.sselectsig1.value==document.contact.sselectsig2.value)||(document.contact.sselectsig.value==document.contact.sselectsig2.value))
	//{
	//alert("You choose same question for two option\nPlease select different options !");
	//return false; 
	//}
	//else {return true;}
	
//}






















//// JScript File
//function calculatevalueraj(ShareAmount,NoOfShares,UnitPrice) 
//{

////    f(isNumeric(strVal))
////    {
////        var dblVar = parseFloat(strVar);

////        if(isNaN(dblVar))
////            alert('Error');
////    }
////    else
////        alert('Not numeric!');
////        
////        
////	alert('raj');
////	var txtShareAmount = document.getElementById(ShareAmount);
////	alert('raj');
////	//alert(txtShareAmount.value);
////	ShareAmount.value = "5555555555555";
//    alert(ShareAmount.value);
//    alert(NoOfShares.value);
//    alert(UnitPrice.value);
//	UnitPrice.value = ShareAmount.value / NoOfShares.value;
//	
//}

//  function isNumeric(val) {
//        var validChars = '0123456789.';

//        for(var i = 0; i < val.length; i++) {
//            if(validChars.indexOf(val.charAt(i)) == -1)
//                return false;
//        }

//        return true;
//    }
////**********************************************
////*******************************************
//function calculatevalue1(form,pound,divide,defaultvalue)
//{	
//	var valid = "0123456789.";
//	var ok = "yes";
//	var temp;
//	var commafound = "no";
//	var newval = "";
//	
//	for (var i=0; i<pound.length; i++) 
//	{
//		temp = "" + pound.substring(i, i+1);
//		
//		if (temp != ",")
//		{
//			commafound = "yes";
//			var newval = newval+temp;	
//		}
//	}
//	
//	//Check if found comma	
//	if (commafound == "yes")
//	{	
//		pound = newval;
//		form.pounds.value = newval;
//		form.sharesof.value = newval/divide;
//		form.pounds.value = round(newval);
//	}
//	
//	for (var i=0; i<pound.length; i++) 
//	{
//		temp = "" + pound.substring(i, i+1);
//		if (valid.indexOf(temp) == "-1") ok = "no";
//		
//		if (temp != ",")
//		{
//			commafound = "yes";
//			var newval = newval+temp;	
//		}
//	}
//	
//	if (ok == "no")
//	{
//		alert("Invalid entry!  Only numeric values are accepted!");
//		form.pounds.focus();
//		form.pounds.select();
//	}
//	else
//	{
//			form.sharesof.value = pound/divide;
//			form.pounds.value = round(pound);
//	}
//}
////--------------------
//function calculatevalue1(form,pound,divide,defaultshares)
//{
//	var valid = "0123456789";
//	var ok = "yes";
//	var temp;
//	var test;
//	
//	/************************* Code 121101 - Function to remove comma in value *************************/
//		var temp2;
//		var commafound2 = "no";
//		var newval2 = "";
//		
//		for (var i=0; i<divide.length; i++) 
//		{
//			temp2 = "" + divide.substring(i, i+1);
//			
//			if (temp2 != ",")
//			{
//				commafound2 = "yes";
//				var newval2 = newval2+temp2;	
//			}
//		}
//		//Check if found comma	
//		if (commafound2 == "yes")
//		{	
//			divide = newval2;
//			form.dividedinto.value = newval2;
//		}
//	/************************* End Code 121101 - Function to remove comma in value *************************/
//	
//	
//	for (var i=0; i<divide.length; i++) 
//	{
//		temp = "" + divide.substring(i, i+1);
//		if (valid.indexOf(temp) == "-1") ok = "no";
//	}
//	
//	if (ok == "no")
//	{
//		alert("Invalid entry!  Only numeric values are accepted!");
//		form.dividedinto.focus();
//		form.dividedinto.select();
//	}
//	else
//	{
//		if ((divide == "")||(divide == 0))
//		{
//			alert('Field ordinary share capital cannot be empty or zero ');
//			form.dividedinto.value = defaultshares;
//			form.sharesof.value = round(pound/defaultshares);
//		}
//		else
//		{
//			var divisionvalueround = round(pound/divide);
//			var divisionvalue = pound/divide;
//			if (divisionvalue != divisionvalueround)
//			{	
//				alert('Please enter share value to obtain a whole figure of unit shares');
//				form.dividedinto.focus();
//				form.dividedinto.select();
//			}
//			else
//			{
//			form.sharesof.value = round(pound/divide);
//			}	
//			
//		}
//	}
//}
////------------
//function GetDoc()
//{
//	if(document.layers)
//		return window.document.frmPostcode1;
//	else
//		return window.document.all;
//}

//function EncodeSpaces(strSource)
//{
//	var nLength, nLooper, strDest, strTemp;
//	
//	strDest="";
//	nLength=strSource.length;
//	if(nLength ==0) return "";	
//	for(nLooper=0;nLooper<nLength;nLooper++)
//	{	
//		strTemp=strSource.substring(nLooper, nLooper+1);
//		if(strTemp == " ")
//			strDest = strDest + "+";
//		else
//			strDest = strDest + strTemp;
//	}
//	return strDest;
//}

////Following function validates an email entry and displays proper message if email address is incorrect
//	function validateEmail (emailStr) {
//		var isErr = "no";
//		if (emailStr == "")
//				{
//					alert("Please enter your email address"); var isErr = "yes"; return isErr;
//				}
//		/* 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)"); var isErr = "yes";
//			return isErr;
//		}
//		var user=matchArray[1]
//		var domain=matchArray[2]
//	
//		// See if "user" is valid 
//		if (user.match(userPat)==null) {
//		    // user is not valid
//	    	alert("The emailname doesn't seem to be valid."); var isErr = "yes";
//		    return isErr;
//		}
//	
//		/* 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!"); var isErr = "yes";
//					return isErr;
//			    }
//	    	}
//		    return true
//		}
//	
//		// Domain is symbolic name
//		var domainArray=domain.match(domainPat)
//		if (domainArray==null) {
//			alert("The domain name doesn't seem to be valid."); var isErr = "yes";
//	    	return isErr;
//		}
//	
//		/* domain name seems valid, but now make sure that it ends in a
//		   three-letter word (like com, edu, gov) or a two-letter word,
//		   representing country (uk, nl), and that there's a hostname preceding 
//		   the domain or country. */
//	
//		/* Now we need to break up the domain to get a count of how many atoms
//		   it consists of. */
//		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>3) {
//		   // 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."); var isErr = "yes";
//		   return isErr;
//		}
//	
//		// Make sure there's a host name preceding the domain.
//		if (len<2) {
//		   var errStr="This address is missing a hostname!"; var isErr = "yes";
//		   alert(errStr);
//		   return isErr;
//		}
//	
//		// If we've gotten this far, everything's valid!
//		return isErr;
//	}//end validateEmail