function Adjust_Entry(objNm)
{
		var sTmpStr="";
		var sRemnChr="";
		var sFrstChr="";
		
		sTmpStr=objNm.value
		if (sTmpStr.length > 0) {
			sFrstChr=sTmpStr.substring(0,1);
		
			if (sTmpStr.length > 1) {
				sRemnChr=sTmpStr.substring(1, 99);
				objNm.value=sFrstChr.toUpperCase() + sRemnChr.toLowerCase();
			}
			
		}
}

function gl_CompIntegers(iInt1, iInt2, sMsg) {
	bValid=true;
	//alert(parseInt(iInt1) + "-" + parseInt(iInt2));
	if (parseInt(iInt1) > parseInt(iInt2)) {
		bValid=false;
		alert(sMsg);
	}
	return bValid;
}

function gl_ChkTimes(sHrOne, sMinOne, sAMPMOne,sHrTwo, sMinTwo, sAMPMTwo, sMsg) {
	var bValid=true
	sTmp=sHrOne
	//to deal with a leading zero on the hour
	if (sTmp.substring(0,1)=="0") sHrOne=sTmp.substring(1,2)
	if (sHrTwo.substring(0,1)=="0") sHrTwo=sHrTwo.substring(1,2)

	//alert("gl_ChkTimes\n\nsHrOne=" + sHrOne + ",sMinOne=" + sMinOne + ",sAMPMOne=" + sAMPMOne + "|\nsHrTwo=" + sHrTwo + ",sMinTwo=" + sMinTwo + ",sAMPMTwo=" + sAMPMTwo + "|") 

	if (sAMPMOne==sAMPMTwo) {
		if (sHrOne==sHrTwo && parseInt(sMinOne) == parseInt(sMinTwo)) {
			sMsg="Date and times are the same\n\nPlease adjust.";
			bValid=false
		}
		
		if (bValid) {
			//alert("gl_ChkTimes\n\nsHrOne.int=" + parseInt(sHrOne) + "\nsHrTwo.int=" + parseInt(sHrTwo) + "\nsHrTwo.int=" + sHrTwo)
			if (parseInt(sHrOne) > parseInt(sHrTwo)) bValid=false
			else {
				if (sHrOne==sHrTwo && parseInt(sMinOne) > parseInt(sMinTwo)) bValid=false
			}
		}
	}

	if (bValid==false) alert(sMsg);
	
	return bValid

}

function gl_ChkDates(sDateOne, sDateTwo, sMsg) {

	var bValid=true
	var delim1 = sDateOne.indexOf("-");   		// find the first dash
	var delim2 = sDateOne.lastIndexOf("-");	// find the last dash
	var ddOne=parseInt(sDateOne.substring(0,delim1),10);	// extract the day part
	var mmOnestring=sDateOne.substring(delim1+1,delim2);	// extract the month part
	var mmOne=g_getmnthnum(mmOnestring);	// convert the monthname to a number
	var yyyyOne=parseInt(sDateOne.substring(delim2+1,sDateOne.length),10); // get the year part

	var delim1 = sDateTwo.indexOf("-");   		// find the first dash
	var delim2 = sDateTwo.lastIndexOf("-");	// find the last dash
	var ddTwo=parseInt(sDateTwo.substring(0,delim1),10);	// extract the day part
	var mmTwostring=sDateTwo.substring(delim1+1,delim2);	// extract the month part
	var mmTwo=g_getmnthnum(mmTwostring);	// convert the monthname to a number
	var yyyyTwo=parseInt(sDateTwo.substring(delim2+1,sDateTwo.length),10); // get the year part
	
	//alert("gl_ChkDates\n\n" + sDateOne + "," + ddOne + "," + mmOne + "," + yyyyOne + "\n" + sDateTwo + "," + ddTwo + "," + mmTwo + "," + yyyyTwo);
	if (parseInt(yyyyOne) > parseInt(yyyyTwo)) bValid=false;
	
	if (parseInt(yyyyOne)==parseInt(yyyyTwo)) {
		//if the years are the same, ensure the first month does not exceed the second
		//alert("gl_ChkDates\n\n" + parseInt(mmOne) + ":" + parseInt(mmTwo));
		if (parseInt(mmOne) > parseInt(mmTwo)) {
			bValid=false
		}
		else {
			//if the months are the same, ensure the first day does not exceed the second
			if (parseInt(mmOne)==parseInt(mmTwo) && parseInt(ddOne) > parseInt(ddTwo)) bValid=false
		}
	}
	//alert(bValid)
	if (bValid==false) 
		alert(sMsg);
	
	return bValid
}

function gl_ChkField(objNm, chkType, sMsg)
{	
	bValid=true;
	
	//alert("validate.js, gl_ChkField\n\nchkType=" + chkType + "\nobjNm.value=" + objNm.value)
	
	if (chkType=='STRING')
	{
		if (objNm.value=='')
		{
			alert(sMsg + ' is empty');
			objNm.select;
			bValid=false;
		}
		var sTmp=objNm.value;
		//alert(sTmp);
		if (sTmp.indexOf('"') > 0) {
			alert(sMsg + ' has an invalid character!\n\nPlease refrain from using speech marks here');
			objNm.select;
			bValid=false;
		}
	}
	else if (chkType=='DATE')
	{
		if(!gl_chkDate(objNm)) {
			alert(sMsg + ' has an invalid date format');
			objNm.select;
			bValid=false;
		}
		
	}
	else if (chkType=='PASSWORD')
	{
		if (objNm.value=='' || objNm.length < 7) {
			alert(sMsg + ' has an invalid password format');
			objNm.select;
			bValid=false;
		}
	}
	else if (chkType=='INTEGER')
	{

		if (isNaN(objNm.value)) {
			alert(sMsg + ' has an invalid numeric format');
			objNm.select;
			bValid=false;
		}
	}
	else if (chkType=='REMAIL')
	{
	    sTmpStr=objNm.value
	    var emailReg = "^[\\w._-]*[\\w]@([\\w-_]*[\\w]\.)+[\\w]{2,}$";
	    var filter = new RegExp(emailReg);
	    if (!filter.test(sTmpStr))
	    {
		alert(sMsg + ' has an invalid format');
		objNm.select;
		bValid=false;
	    }
	}
	else if (chkType=='RHTTP')
	{
	    sTmpStr=objNm.value
	    var httpReg = "^https?:\/\/([\\w-]+.)+[\\w]{2,}$";
	    var filter = new RegExp(httpReg);
	    if (!filter.test(sTmpStr))
	    {
		alert(sMsg + ' has an invalid format');
		objNm.select;
		bValid=false;
	    }
	}
	else if (chkType=='EMAIL')
	{
		//check for existence of @ sign and at least one full stops				var iAtPos;
		var iFullStopPos;
		var sTmpStr;
		
		iAtPos = 0 
		iFullStopPos = 0
		iAtApos = 0

		sTmpStr=objNm.value
		iAtPos = sTmpStr.indexOf("@")
		iFullStopPos = sTmpStr.indexOf(".")
		iAtApos = sTmpStr.indexOf("'")
		
		//alert(objNm.value + '\niAtPos=' + iAtPos + '\niFullStopPos=' + iFullStopPos + '\niAtApos=' + iAtApos);
		if (objNm.value=='' || objNm.length < 3 ) {
			alert(sMsg + ' has an invalid length');
			objNm.select;
			bValid=false;		
		}
		else {
			if (iAtPos <= 0 || iFullStopPos <= 0 || iAtApos != -1) {
			alert(sMsg + ' has an invalid format');
			objNm.select;
			bValid=false; }
		}
	}


	return bValid;
}

// Remove all entries from a select list
function gl_pop_fs(objselect)	{
	for (;objselect.options(0);) objselect.options.remove(0);
}


// fname is the name if the database field (MS SQL SERVER ONLY)

function SQL_DateWhere(fname,dateformat)
{
	if (!dateformat) dateformat="DD-MMM-YYYY"
	if (dateformat=="DD-MMM-YYYY")
	{
		sql=" convert(varchar,datepart(dd,"+fname+"))+'-'";
		sql+="+substring(convert(varchar,datename(month,"+fname+")),1,3)+'-'";
		sql+="+convert(varchar,datepart(yy,"+fname+")) "+fname;
	}
	if (dateformat=="MMM-DD-YYYY")
	{
		sql="substring(convert(varchar,datename(month,"+fname+")),1,3)+' '";
		sql+="+convert(varchar,datepart(dd,"+fname+"))+', '";
		sql+="+convert(varchar,datepart(yy,"+fname+")) "+fname;
	}
	return (sql);
}

function SQL_DateTimeWhere(fname,dateformat)
{
	if (!dateformat) dateformat="DD-MMM-YYYY"
	if (dateformat=="DD-MMM-YYYY")
	{
		sql=" convert(varchar,datepart(dd,"+fname+"))+' '";
		sql+="+convert(varchar,datename(month,"+fname+"))+' '";
		sql+="+convert(varchar,datepart(yy,"+fname+"))+' '";
	}
	if (dateformat=="MMM-DD-YYYY")
	{
		sql="convert(varchar,datename(month,"+fname+"))+' '";
		sql+="+convert(varchar,datepart(dd,"+fname+"))+' '";
		sql+="+convert(varchar,datepart(yy,"+fname+"))+' '";
	}
	sql+="+convert(varchar,datepart(hh,"+fname+"))+':'";
	sql+="+RIGHT('0'+convert(varchar,datepart(mi,"+fname+")),2)+':'";
	sql+="+RIGHT('0'+convert(varchar,datepart(ss,"+fname+")),2) "+fname;
	return (sql);
}

function SQL_SDateTm_Where(fname,dateformat)
{
	if (!dateformat) dateformat="DD-MMM-YYYY"
	if (dateformat=="DD-MMM-YYYY")
	{
		sql=" convert(varchar,datepart(dd,"+fname+"))+'-'";
		sql+="+substring(convert(varchar,datename(month,"+fname+")),1,3)+'-'";
		sql+="+convert(varchar,datepart(yy,"+fname+"))+' '";
	}
	if (dateformat=="MMM-DD-YYYY")
	{
		sql="substring(convert(varchar,datename(month,"+fname+")),1,3)+' '";
		sql+="+convert(varchar,datepart(dd,"+fname+"))+', '";
		sql+="+convert(varchar,datepart(yy,"+fname+"))+' '";
	}
	sql+="+convert(varchar,datepart(hh,"+fname+"))+':'";
	sql+="+RIGHT('0'+convert(varchar,datepart(mi,"+fname+")),2)+':'";
	sql+="+RIGHT('0'+convert(varchar,datepart(ss,"+fname+")),2) "+fname;

	return (sql);
}

function SQL_TimeWhere(fname)
{
	sql="convert(varchar,datepart(hh,"+fname+"))+':'";
	sql+="+RIGHT('0'+convert(varchar,datepart(mi,"+fname+")),2)+':'";
	sql+="+RIGHT('0'+convert(varchar,datepart(ss,"+fname+")),2) "+fname;
	return (sql);
}

// Returns the shortname of the supplied month number
function RetnMthXXX(monthno)
{
	var m=new Array(12);
	m[1]="Jan";		m[2]="Feb";		m[3]="Mar";		m[4]="Apr";
	m[5]="May";		m[6]="Jun";		m[7]="Jul";		m[8]="Aug";
	m[9]="Sep";		m[10]="Oct";	m[11]="Nov";	m[12]="Dec";
	if (monthno>=1 && monthno <=12)	return m[monthno];
	else return false;
}
	
	
// Returns the month number of the supplied month name. eg g_getmnthnum(January) returns 1
function RetnMthX(monthname)
{
	var sm=monthname.substring(0,3).toLowerCase()
	for (x=1;x<=12;x++)	{
			if (sm==g_getshtmnth(x).toLowerCase())
			return x;
		}
	return false;
}
	
// Checks if the number of days is valid for the supplied month and year.	
function ChkDaysMth(days,month,year)
{
	if (month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12)
		if (days>=1 && days <=31) return true;
		else return false; 
	if (month==4 || month==6 || month==9 || month==11)
		 if (days>=1 && days <=30) return true;
		 else return false; 
	if (month==2) 
		if (days>=1 && days <=28) return true;
		else
			if (days==29) 
			 	if (parseInt(year/4)==(year/4)) return true;
				else return false;
			else return false;
}

// Examines a text field and tries to convert it onto a recognised date.	
function gl_chkDate(fd_datefield,date_format,no_change)
{
	if (!date_format) date_format="DD-MMM-YYYY"
	date_format=date_format.toUpperCase()
	var datefield = fd_datefield.value
	if (g_trim(datefield)=='')
	{
		if (!no_change) // If this has a value, don't fire the pagechanged event
			if (typeof pagechanged != "undefined") 
				pagechanged()
		return true;
	}
	//convert slashes to dashes
	while (datefield.indexOf("/") != -1) 
	{  // The end of the next line is not commented out. Only the editor thinks so!
		datefield = datefield.replace(/\//g,"-"); 
	}
	while (datefield.indexOf(" ") != -1) 
	{  // The end of the next line is not commented out. Only the editor thinks so!
		datefield = datefield.replace(/\ /g,"-"); 
	}
	while (datefield.indexOf(",") != -1) 
	{  // The end of the next line is not commented out. Only the editor thinks so!
		datefield = datefield.replace(/\,/g,""); 
	}
	var delim1 = datefield.indexOf("-");   		// find the first dash
	var delim2 = datefield.lastIndexOf("-");	// find the last dash
	if (delim1 != -1 && delim1 == delim2) {		// if both can't be found then give up
		alert ('Date format not valid.');
		fd_datefield.focus();
		fd_datefield.select();
		return false;
	}
	if (delim1 != -1) 
	{	 // There are delimiters
		if (date_format=="MMM-DD-YYYY")
		{
			var mmstring=datefield.substring(0,delim1);	// extract the month part
			var dd=parseInt(datefield.substring(delim1+1,delim2),10);	// extract the day part
		} else
		{ // Assume Euro Date
			var dd=parseInt(datefield.substring(0,delim1),10);	// extract the day part
			var mmstring=datefield.substring(delim1+1,delim2);	// extract the month part
		}
		if (isNaN(mmstring)) { //if the month isn't a number, check for a month name.
			var mm=g_getmnthnum(mmstring);	// convert the monthname to a number
			if (isNaN(mm)) { 	// if it couldn't be converted, then exit.
				alert('Date format not valid. Month name not found');
				fd_datefield.focus();
				fd_datefield.select();
				return false;
			}
		} else { var mm=parseInt(mmstring,10); } // the month is a number, so keep it
		var yyyy=parseInt(datefield.substring(delim2+1,datefield.length),10); // get the year part
	} else 
	{ // there are no delimitors. Assume a date format of DDMMYY[YY] or MMDDYY[YY]
		if (date_format=="MMM-DD-YYYY")
		{
			var mm=parseInt(datefield.substring(0,2),10);	// get the month part
			var dd=parseInt(datefield.substring(2,4),10);	// get the day part
		} else
		{
			var dd=parseInt(datefield.substring(0,2),10);	// get the day part
			var mm=parseInt(datefield.substring(2,4),10);	// get the month part
		}
		var yyyy=parseInt(datefield.substring(4,datefield.length),10);	// get the year part
	}
	if (isNaN(dd) || isNaN(mm) || isNaN(yyyy)) {	// All the fields need to be numeric
		alert('Date format not valid - Non numeric entries');
		fd_datefield.focus();
		fd_datefield.select();
		return false;
	}
	if (mm<1 || mm >12) {	// month as to be 1 to 12 
		alert('Date format not valid. Invalid month');
		fd_datefield.focus();
		fd_datefield.select();
		return false;
	}
	if (yyyy < 100)		// If the year had only 2 digits
		if (yyyy > 30) yyyy+=1900; else yyyy+=2000;		// add to it. Pivot year is 1930
	if (!g_chkdaysmnth(dd,mm,yyyy)) {	// Check the number of days is valid for this month.
		alert('Date format not valid. Invalid days');
		fd_datefield.focus();
		fd_datefield.select();
		return false;
	}
	if (date_format=="MMM-DD-YYYY")
	{
		fd_datefield.value=""+g_getshtmnth(mm)+" "+dd+", "+yyyy;	// Format the return date as MMM-DD-YYYY
	} else
	{
		fd_datefield.value=""+dd+"-"+g_getshtmnth(mm)+"-"+yyyy;	// Format the return date as DD-MMM-YYYY
	}
	if (!no_change) // If this has a value, don't fire the pagechanged event
		if (typeof pagechanged != "undefined") 
			pagechanged()
	return true;
}

// Checks if the number of days is valid for the supplied month and year.	
function g_chkdaysmnth(days,month,year)
{
	if (month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12)
		if (days>=1 && days <=31) return true;
		else return false; 
	if (month==4 || month==6 || month==9 || month==11)
		 if (days>=1 && days <=30) return true;
		 else return false; 
	if (month==2) 
		if (days>=1 && days <=28) return true;
		else
			if (days==29) 
			 	if (parseInt(year/4)==(year/4)) return true;
				else return false;
			else return false;
}

// Returns the shortname of the supplied month number
function g_getshtmnth(monthno)
{
	var m=new Array(12);
	m[1]="Jan";		m[2]="Feb";		m[3]="Mar";		m[4]="Apr";
	m[5]="May";		m[6]="Jun";		m[7]="Jul";		m[8]="Aug";
	m[9]="Sep";		m[10]="Oct";	m[11]="Nov";	m[12]="Dec";
	if (monthno>=1 && monthno <=12)	return m[monthno];
	else return false;
}

// Returns the month number of the supplied month name. eg g_getmnthnum(January) returns 1
function g_getmnthnum(monthname)
{
	var sm=monthname.substring(0,3).toLowerCase()
	for (x=1;x<=12;x++)	{
			if (sm==g_getshtmnth(x).toLowerCase())
			return x;
		}
	return false;
}


// Get the next id for the table		// Use new ADO D.Roughan
function g_getnextid(tbl) {return (query2("sp_gen_id '"+tbl+"'")("id").value)}

// Create the WHERE query for the owners - should be called from pages
function g_whereowner(tbl)
{
	s=tbl+".owner1_id='"+parent.g_owner1_id+"' ";
	if (parent.g_owner2_id) s+="AND "+tbl+".owner2_id='"+parent.g_owner2_id+"' ";
	if (parent.g_owner3_id) s+="AND "+tbl+".owner3_id='"+parent.g_owner3_id+"' ";
	return s;
}

// Strip out single quotes from a field
function g_dbprep(v)
{
	if (v)
	{
		n=v;
		n=n.replace(/\'/g,"''");
		return g_trim(n);
	}
	else 
	{
		n="";
		return n;
	}
}
	
// Prepare the field that was returned from the database
function g_prep(st)
{
	if (st==null) st="";
	if (typeof st=="string") st=g_trim(st);	
	if (st=='--') st=''; 	// Deal with NULL date DD-MMM-YYY
	if (st==",") st='';		// Deal with NULL date MMM DD, YYYY
	return st;
}

// Opens a new Browse window with the URL provided
function g_open_url(url_location)
{
	if (url_location) {
		open('http://'+url_location,'',"height=570,width=850,left=0,top=0,location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes,titlebar=yes,toolbar=yes");
	}
}	

// Opens the Australian White Pages in a new Browser
function g_whitepages()
{
	var location="http://www.whitepages.com.au/search.shtml"
	open(location,'',"height=600,width=800,left=0,top=0,location=yes,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=no,toolbar=yes");		
}

function g_yellowpages()
{
	var location="http://www.yellowpages.com.au/search/search.html"
	open(location,'',"height=600,width=800,left=0,top=0,location=yes,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=no,toolbar=yes");		
}

function g_postcodes()
{
	var location="http://www.whitepages.com.au/pcode.shtml"
	open(location,'',"height=600,width=800,left=0,top=0,location=yes,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=no,toolbar=yes");		
}

// number formater
function g_format_numbers (expr, decplaces) {
	// raise incoming value by power of 10 times the
	// number of decimal places; round to an integer; convert to string
	var str = "" + Math.round (eval(expr) * Math.pow(10,decplaces))
	// pad small value strings with zeros to the left of rounded number
	while (str.length <= decplaces) {
		str = "0" + str;
	}
	// establish location of decimal point
	var decpoint = str.length - decplaces;
	// assemble final result from : (a) the string up to the position of
	// the decimal point; (b) the decimal point; and (c) the balance
	// of the string. Return finished product.
	if (decplaces == 0)
		return str.substring(0,decpoint);
	else	
		return str.substring(0,decpoint) + '.' + str.substring(decpoint,str.length);
}
// puts number in dollar format
function g_dollarise (expr) {
	return g_format_numbers(expr,2)
}	

// Trim any spaces from the RHS and LHS of the string
function g_trim(ts) {
		if (ts) {
			for (;ts.charAt(ts.length-1)==' ';) 
				ts=ts.substring(0,ts.length-1);
			for (;ts.charCodeAt(ts.length-1)==0;) 
				ts=ts.substring(0,ts.length-1);
			for (;ts.charAt(0)==' ';)
				ts=ts.substring(1,ts.length);
		}
		return ts;
	}

// Check for a valid email address
function emailCheck(emailStr) {
	/* 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 appears 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 part of the email address is not 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 part of the email address is not valid.")
		 return false
	}	
	/* 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.")
		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
	}
	return true;
}



