	// 
	// Name:	checkWhitePagesSearch
	//
	// Description: For the White Pages Search:
	//              Check to see that the  LastName is not blank.
	//				Remove trailing . at the end of a first name and add wildcard (*)
	//              Check to see that the FirstName, LastName, StreetName and 
	//              Street Number do not exceed the maximum length
	//              Check to see that the Streetnumber is a Number.
	//
	function checkWhitePagesSearch(){
		document.WhitePagesSearch.L.value = trimString(document.WhitePagesSearch.L.value);
		document.WhitePagesSearch.F.value = trimString(document.WhitePagesSearch.F.value);

		//Get and format the first First Name.
		FirstName = document.WhitePagesSearch.F.value
		if (FirstName.length != 0 )
		{
			offset = FirstName.lastIndexOf(".")
			if (offset == -1)
			{
				FirstName = FirstName + "*"
			}
			else
			{
				FirstName = FirstName.slice(0,offset) + "*"
			}
		}
		else
		{
			FirstName = ""
		}

		// Assemble the First Name.
		if (FirstName.length != 0)
		// FirstName has a value.
		{
			document.WhitePagesSearch.F.value = FirstName
		}
		else
		{
			document.WhitePagesSearch.F.value = ""
		}

		if ((doesntContainChar("WhitePagesSearch","LastName","The Last Name") == true ) &&
			(doesntContainChar("WhitePagesSearch","FirstName1","The First Name") == true ) &&
			(isNotNull("WhitePagesSearch","LastName","a Last Name") == true ) &&
			(isBelowLength("WhitePagesSearch","LastName","The Last Name is",50) == true )&&
			(isBelowMaxTerms("WhitePagesSearch", "LastName", " ", 3, "Last Name") == true )	
		){
			return true;
		} 
		else{
			return false;
		}
	}
	


	//
	// Name:	doesntContainChar
	//
	// Description:	Checks to see if the string contains the following characters
	//				which are special characters to the EWP application:
	//				
	//				= , \ | *
	//
	// Parameters:	_form, the name of the form passed in.
	//				_field, the name of the text field.
	//				_msg, the name of the field to complete the error msg
	//
	function doesntContainChar(_form, _field, _msg){
		slash = "\\";
		
		if( eval("document."+_form+"."+_field+".value.indexOf('=')") > -1 ||
		    eval("document."+_form+"."+_field+".value.indexOf(',')") > -1 ||
		    eval("document."+_form+"."+_field+".value.indexOf(slash)") > -1 ||
		    eval("document."+_form+"."+_field+".value.indexOf('|')") > -1 ||
		    eval("document."+_form+"."+_field+".value.indexOf('*')") > -1){
			alert( _msg + " may not contain any of the following characters:\n\n= , \\ | *\n\nPartial matches will be returned.\nPlease remove them and try again.");
			eval("document."+_form+"." + _field + ".focus()");
			return false;
		}
		
		return true;
	}


	
	
	//
	// Name:	isBelowLength
	//
	// Description:	Checks the length of the text field.  Returns
	//		false if greater than the maxlength. An error message is 
	//		generated, and the user is returned to the offending text field also. Else 
	//		returns true.
	//
	// Parameters:	_form, the name of the form passed in.
	//				_field, the name of the text field.
	//				_msg, the name of the field to complete the error msg
	//				_maxlength, the maximum length allowed for the field.
	//
	function isBelowLength(_form, _field, _msg, _maxlength){
		if( eval("document."+_form+"."+_field+".value.length") > _maxlength ){
			alert( _msg + " " + 
				eval("document."+_form+"."+_field+".value.length") + 
				" characters long. The maximum length is " + _maxlength + " characters.");
			eval("document."+_form+"." + _field + ".focus()");
			return false;
		}
		
		return true;
	}

	
	
	
	
	//
	// Name:	isBelowMaxTerms
	//
	// Description:	Checks  to insure that the maximum number of terms(words) allowed
	//				for an imput field have not been exceeded
	//
	// Parameters:	_form, the name of the form passed in.
	//				_field, the name of the text field.
	//				_del, the delimiter used to split the string
	//				_max, the maximum number of terms allowed
	//				_msg, the name of the field to complete the error msg
	//
	function isBelowMaxTerms(_form, _field, _del, _max, _msg){
		stringval = eval("document."+_form+"."+_field+".value");
		newarray = stringval.split(_del);
		arrayLen = newarray.length;
		if( arrayLen > _max)
		{
			alert("You have entered " + arrayLen + " words in the " + _msg + " field. The maximum allowed is " + _max);
			eval("document."+_form+"." + _field + ".focus()");
			return false;
		}
		
		return true;
	}	



	
	//
	// Name:	isNotNull
	//
	// Description:	Checks the length of the text field.  Returns
	//		false if length less than or equal to zero or if null is
	//		found. An error message is generated, and the user
	//		is returned to the offending text field also. Else 
	//		returns true.
	//
	// Parameters:	_form, the name of the form passed in.
	//				_field, the name of the text field.
	//				_msg, the name of the field to complete the error msg
	//
	function isNotNull(_form, _field, _msg){
		if (eval("document."+_form+"."+_field+".value.length") <= 0 ||
			eval("document."+_form+"."+_field+".value.length") == null){
			alert("Please enter " + _msg + ".");
			eval("document."+_form+"." + _field + ".focus()");
			return false;
		}
		
		return true;
	}




	
	//
	// Name: PopUp
	//
	function popup(popupfile,winheight,winwidth) {
		open(popupfile,"PopupWindow","resizable=no,height=" + winheight + ",width=" + winwidth + ",scrollbars=no");
	}







function newWinOfSize(urlLoc,w,h) {
  _winName = "MyNewWindow";
  _info  = "toolbar=no";      // yes|no 
  _info += ",location=no";    // yes|no 
  _info += ",directories=no"; // yes|no 
  _info += ",status=no";     // yes|no 
  _info += ",menubar=no";     // yes|no 
  _info += ",scrollbars=no";// auto|yes|no 
  _info += ",resizable=no";  // yes|no 
  _info += ",dependent";      // close the parent, close the popup, omit if you want otherwise 
  _info += ",height=" + h;
  _info += ",width=" + w;
  _info += ",left=200";
  _info += ",top=200";
  DispWin=window.open(urlLoc,_winName,_info);
} 

/* State Abbreviation Key Window Popup */
function newStateWinOfSize(urlLoc,w,h,formName) {
  _winName = "_statelist";
  _info  = "toolbar=no";      // yes|no 
  _info += ",location=no";    // yes|no 
  _info += ",directories=no"; // yes|no 
  _info += ",status=no";     // yes|no 
  _info += ",menubar=no";     // yes|no 
  _info += ",scrollbars=no";// auto|yes|no 
  _info += ",resizable=no";  // yes|no 
  _info += ",dependent";      // close the parent, close the popup, omit if you want otherwise 
  _info += ",height=" + h;
  _info += ",width=" + w;
  _info += ",left=200";
  _info += ",top=200";
  urlLoc = urlLoc + '?frm=' + formName;
  DispWin=window.open(urlLoc,_winName,_info);
} 

/*
Check required form elements script-
By JavaScript Kit (http://javascriptkit.com)
Over 200+ free scripts here!
*/
function checkrequired(which){
var pass=true
if (document.images){
for (i=0;i<which.length;i++){
var tempobj=which.elements[i]
if (tempobj.name=="L"){
if (((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex==-1)){
pass=false
break
}
}
}
}
if (!pass){
alert("A last name is required for a white pages search!")
return false
}
else


		if ((doesntContainChar("WhitePagesSearch","L","The Last Name") == true ) &&
			(doesntContainChar("WhitePagesSearch","F","The First Name") == true ) &&
			(isNotNull("WhitePagesSearch","L","a Last Name") == true ) &&
			(isBelowLength("WhitePagesSearch","L","The Last Name is",50) == true )&&
			(isBelowMaxTerms("WhitePagesSearch", "L", " ", 3, "Last Name") == true )	
		){
			return true;
		} 
		else{
			return false;
		}

//return true
}

