// Begin script to display images when entry is invalid

function validate()
{

var error_strng ="";
// Check the fields
if ((window.document.Search.Parcel.value.length < 1) &&
	(window.document.Search.PIN.value.length < 1) &&
    (window.document.Search.Address.value.length < 1) &&
    (window.document.Search.StreetName.value.length < 1) &&
	(window.document.Search.rePartialPID.value.length < 1) &&
    (window.document.Search.OwnerName.value.length < 1) )
	{
		error_strng +="Please enter a valid \nParcel Number \nor PIN \nor Property Address \nor Partial Parcel ID \nor Partial Street Name \nor Partial Owner Name.";
	}
// Allow only PID or PIN	
else if((window.document.Search.Parcel.value.length > 1) &&
	   (window.document.Search.PIN.value.length > 1) &&
       (window.document.Search.Address.value.length < 1))
	   {
		error_strng +="Please enter only Parcel Number or PIN.";
	   }
else
	{
		
		//Partial Parcel ID pattern
		var PidPat  = /(\d{2}) (\d{3})/;
		// Check Partial, example: 18 056
		if ((window.document.Search.rePartialPID.value.length > 0) &&
			(window.document.Search.rePartialPID.value.match(PidPat) ==null) &&
			(window.document.Search.rePartialPID.value.match(/(\d{7})/) ==null)
			)
		 	{
				error_strng +="\nPlease enter a valid Partial Parcel Number.";
			};
			
		//Parcel ID pattern
		var PidPat  = /(\d{2}) (\d{3})([ A-Za-z])(\d{2}) (\d{3})/;
		// Check Parcel, example: 18 056A05 010 or 4302948
		if ((window.document.Search.Parcel.value.length > 0) &&
			(window.document.Search.Parcel.value.match(PidPat) ==null) &&
			(window.document.Search.Parcel.value.match(/(\d{7})/) ==null)
			)
		 	{
				error_strng +="\nPlease enter a valid Parcel Number.";
			};

		// Check PIN, 7 digits numeric
		if ((window.document.Search.PIN.value.length > 0) &&
			(window.document.Search.PIN.value.match(/(\d{7})/)==null))
		 	{
				error_strng +="\nPlease enter a valid PIN Number(7 Digits Number).";
			};


		// Check Address field, the format is : Street Number, Space, Street Name
		if ((window.document.Search.Address.value.length > 0) &&
			(window.document.Search.Address.value.search(" ") == -1 ))
			{
				error_strng +="\nPlease enter a valid Property Address.";
			}
			// Allow only PID or PIN	
		else if((window.document.Search.Parcel.value.length > 1) &&
	  		 (window.document.Search.PIN.value.length > 1) &&
      		 (window.document.Search.Address.value.length > 1) )
	  		 {
			error_strng +="Please enter only Parcel Number or PIN.";
	  	 }

		else {
				i = window.document.Search.Address.value.indexOf(" ");
				if (isNaN(window.document.Search.Address.value.substring(0, i)))
					{
						error_strng +="\nPlease enter a valid Property Address.";
					}
			};
	};

if (error_strng=="")
	{
		return true;
	}	else
		{
			//error_strng="Our system indicates that there are some omissions from the form.\n\nWe request that you\n\n" +error_strng;
			error_strng="Our system indicates that there are some omissions from the form.\n\nWe request that you:\n\n" +error_strng;
			alert (error_strng);		
			return false;
		}
		
		
}

//End -->
