function Find()
{
	var self = this;

	// properties
	this.XmlReqFind;
	
	// methods
	this.findLayer = findLayer;
	this.processFeatureSearch = processFeatureSearch;
	this.zoomLatLong = zoomLatLong;
	this.findAddress = findAddress;
	this.processGeocodeSearch = processGeocodeSearch;
	this.zoomAddAcetate = zoomAddAcetate;
	this.conservationLandSearch = conservationLandSearch;
	this.placeSearch = placeSearch;
	this.search = search;
	this.searchVCLNA = searchVCLNA;
	this.processFeatureSearch2 = processFeatureSearch2;
	this.rangeSearch = rangeSearch;
	
	//field,low,high
	function rangeSearch( layer, fieldvaluepairs )
	{
	    if( null == fieldvaluepairs || fieldvaluepairs=="")
	        return;
	    url = server + "FindService.asmx/RangeSearch?userGroupName=" + user.userGroupName + "&layer=" + layer + "&fieldvaluepairs=" + fieldvaluepairs;
		    
	    self.XmlReqFind = new TXmlHttp();
		
	    if(self.XmlReqFind)
	    {
		    self.XmlReqFind.onreadystatechange = processFeatureSearch;
		    self.XmlReqFind.open("GET", url, true); //async call
		    self.XmlReqFind.send(null);
		}
	}
	
	function search( layer, fieldvaluepairs )
	{
	    if( null == fieldvaluepairs || fieldvaluepairs == "")
	        return;
	    url = server + "FindService.asmx/Search?userGroupName=" + user.userGroupName + "&layer=" + layer + "&fieldvaluepairs=" + fieldvaluepairs;
		    
	    self.XmlReqFind = new TXmlHttp();
		
	    if(self.XmlReqFind)
	    {
		    self.XmlReqFind.onreadystatechange = processFeatureSearch;
		    self.XmlReqFind.open("GET", url, true); //async call
		    self.XmlReqFind.send(null);
		}
	}
	
	function searchVCLNA( layer, fieldvaluepairs)
	{
	    if( null == fieldvaluepairs || fieldvaluepairs == "")
	        return;
	    
	    url = server + "FindService.asmx/SearchWithIntersect?userGroupName=" + user.userGroupName + "&targetLayer=" + layer + "&intersectLayer=Counties&intersectFieldValuePairs=JURIS|equalTo|" + document.getElementById("VCLNACounties").value.replace(/&/g, "%26") + "|false&targetFieldValuePairs=" + fieldvaluepairs;
		    
	    self.XmlReqFind = new TXmlHttp();
		
	    if(self.XmlReqFind)
	    {
		    self.XmlReqFind.onreadystatechange = processFeatureSearch;
		    self.XmlReqFind.open("GET", url, true); //async call
		    self.XmlReqFind.send(null);
		}
	}
	
	function findLayer()
	{
		// go into "tblFindFeature" to get each field namd and value.
		// build string to send to web service
		var table = document.getElementById("tblFindFeature");
		var findStr = "";
		
		for( var i = 0; i < table.rows.length; i++ )
		{
			var rowName = table.rows[i];
			var rowValue = document.getElementById("findLayer" + i);
			
			// remove ":" from rowName
			rowName = rowName.innerText.substr(0, rowName.innerText.lastIndexOf(':'));
			
			if( rowName != '' && rowValue.value != '' )
				findStr += rowName + "," + rowValue.value + "|";
		}
		
		findStr = findStr.substr(0, findStr.lastIndexOf('|'));
		
		var layerId = document.getElementById("selectSearchLayer").value;
		url = server + "FindService.asmx/FindLayer?layerId=" + layerId + "&values=" + findStr + "&userGroupName=" + user.userGroupName;
		
		self.XmlReqFind = new TXmlHttp();
		
		if(self.XmlReqFind)
		{
			self.XmlReqFind.onreadystatechange = processFeatureSearch;
			self.XmlReqFind.open("GET", url, true); //async call
			self.XmlReqFind.send(null);
		}
	}
	function placeSearch()
	{
	    if( null == document.getElementById("textNameFindPlaceName").value || document.getElementById("textNameFindPlaceName").value == "")
	        return;
	    url = server + "FindService.asmx/PlaceSearch?userGroupName=" + user.userGroupName + "&name=" + document.getElementById("textNameFindPlaceName").value;
		    
	    self.XmlReqFind = new TXmlHttp();
		
	    if(self.XmlReqFind)
	    {
		    self.XmlReqFind.onreadystatechange = processFeatureSearch;
		    self.XmlReqFind.open("GET", url, true); //async call
		    self.XmlReqFind.send(null);
		}
	}
	function conservationLandSearch( searchBy )
	{
	    if(searchBy == "COUNTY")
	    {
	        var counties = "";
	        for( var i=0; i< document.getElementById("selectCountyFindCounty").options.length; i++)
	        {
	            var c = document.getElementById("selectCountyFindCounty").options[i];
	            if(c.selected && c.value != "")
	            {
	                if(counties.length > 0)
	                    counties += "|";
	                counties += c.value.replace(/&/g,"%26");
	            }
	        }
	        //document.write(counties);
	        //alert(counties);
	        url = server + "FindService.asmx/ConservationLandSearch?userGroupName=" + user.userGroupName + "&county=" + counties + "&name=" + document.getElementById("textNameFindCounty").value + "&type=" + document.getElementById("selectTypeFindCounty").value + "&minacre=" + document.getElementById("textMinAcreageFindCounty").value + "&maxacre=" + document.getElementById("textMaxAcreageFindCounty").value + "&watershed=";
	        self.XmlReqFind = new TXmlHttp();
    		
		    if(self.XmlReqFind)
		    {
			    self.XmlReqFind.onreadystatechange = processFeatureSearch2;
			    self.XmlReqFind.open("GET", url, true); //async call
			    self.XmlReqFind.send(null);
		    }
	    }
	    else if (searchBy == "WATERSHED")
	    {
	        url = server + "FindService.asmx/ConservationLandSearch?userGroupName=" + user.userGroupName + "&county=&name=" + document.getElementById("textNameFindWatershed").value + "&type=" + document.getElementById("selectTypeFindWatershed").value + "&minacre=" + document.getElementById("textMinAcreageFindWatershed").value + "&maxacre=" + document.getElementById("textMaxAcreageFindWatershed").value + "&watershed=" + document.getElementById("selectWatershedCodeFindWatershed").value;
		    
		    self.XmlReqFind = new TXmlHttp();
    		
		    if(self.XmlReqFind)
		    {
			    self.XmlReqFind.onreadystatechange = processFeatureSearch;
			    self.XmlReqFind.open("GET", url, true); //async call
			    self.XmlReqFind.send(null);
		    }
	    }
	    else if (searchBy == "NAME")
	    {
	        url = server + "FindService.asmx/ConservationLandSearch?userGroupName=" + user.userGroupName + "&county=&name=" + document.getElementById("textNameFindPlaceName").value + "&type=&minacre=&maxacre=&watershed=";
		    
		    self.XmlReqFind = new TXmlHttp();
    		
		    if(self.XmlReqFind)
		    {
			    self.XmlReqFind.onreadystatechange = processFeatureSearch;
			    self.XmlReqFind.open("GET", url, true); //async call
			    self.XmlReqFind.send(null);
			}
	    }
	}
	
	function processFeatureSearch()
	{
		showLoading();
		var objectIds = new Array();
		var groupingSize = 10;
		var resultPagePrefix = "featSearch_page_";
		
		if( self.XmlReqFind.readyState == 4 )
		{
			if( self.XmlReqFind.status == 200 )
			{
				// parse response and place data into html table
				var resultTable = document.getElementById("divResultsList");
				resultTable.innerHTML = "";
				lastXMLFeatureResponse = browser.xmlToString(self.XmlReqFind.responseXML.documentElement);
				
				var response = self.XmlReqFind.responseXML.documentElement;
				var features = response.getElementsByTagName('FEATURES');
				var featureID = "";
				var html = "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" style=\"margin: 0px 0px 0px 0px;padding: 0px 0px 0px 0px;\" border=\"0\">";
				
				// get request specific top level values (layer, layerHyperlink, response feature count, hasMore features)
				var layer = features[0].attributes.getNamedItem('layer').value;
				var layerHyperlink = features[0].attributes.getNamedItem('hyperlink').value;
				var count = features[0].attributes.getNamedItem('count').value;
				var hasMore = features[0].attributes.getNamedItem('hasmore').value;
				
				if( count == 0 )
					spnResultsInfo.innerHTML = "No Features Found";
				else if( count == 1 )
					spnResultsInfo.innerHTML = "1 Feature Found";
				else
					spnResultsInfo.innerHTML = count + " Features Found";
				
				// looks at FEATURES elements
				for( var i = 0; i < features.length; i++ )
				{
					var featureCounter = 0;
					
					// looks at FEATURE elements
					for( var x = 0; x < features[i].childNodes.length; x++ )
					{

						if( features[i].childNodes[x].nodeName == 'FEATURE' )
						{
							var fieldCount = 0;
							var minx = "", miny = "", maxx = "", maxy = "";
								
							// get feature specific top level values (uniqueName, uniqueValue, primaryDisplay)
							var uniqueName = features[i].childNodes[x].attributes.getNamedItem('uniquename').value;
							var uniqueValue = features[i].childNodes[x].attributes.getNamedItem('uniquevalue').value;
							var pdisplay = features[i].childNodes[x].attributes.getNamedItem('pdisplay').value;
							
							objectIds.push(uniqueValue);
							
							// for parcels, need to add 1 to this value
							var totalFieldsInFeature = features[i].childNodes[x].attributes.getNamedItem('fields').value;
							
							if(0 == (featureCounter % groupingSize) && groupingSize > 0){
								var resultPageNumber = parseInt(featureCounter / groupingSize);
								if(0 != featureCounter){
									var hideThis = "document.getElementById(\'" + resultPagePrefix + (resultPageNumber-1) + "\').style.display=\'none\';";
									var showPrev = "document.getElementById(\'" + resultPagePrefix + (resultPageNumber-2) + "\').style.display=\'\';";
									var showNext = "document.getElementById(\'" + resultPagePrefix + (resultPageNumber) + "\').style.display=\'\';";
									if(featureCounter > groupingSize){
										html+= "<tr><td><table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\"><tr><td align=\"left\"><input type=\"button\" class=\"buttonNormal\" onclick=\"" + hideThis + showPrev + "return(false);\" value=\"Prev\"></td><td align=\"right\"><input type=\"button\" class=\"buttonNormal\" onclick=\"" + hideThis + showNext + "return(false);\" value=\"Next\"></td></tr></table></td></tr>";
									}else{
										html+= "<tr><td colspan=\"2\" align=\"right\"><input type=\"button\" class=\"buttonNormal\" onclick=\"" + hideThis + showNext + "return(false);\" value=\"Next\"></td></tr>";
									}
									html+= "<tr><td colspan=\"2\" align=\"center\">Page " + (resultPageNumber) + "</td></tr>";
									html+= "</table>";
									html+= "</div></td></tr>";
								}
								html+= "<tr><td><div id=\"" + resultPagePrefix + resultPageNumber + "\" style=\"display: " + (featureCounter == 0 ? "block" : "none") + ";\"><table width=\"100%\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\">";
							    
							}
							featureCounter++;
							
							for( var y = 0; y < features[i].childNodes[x].childNodes.length; y++ )
							{
								if( features[i].childNodes[x].childNodes[y].nodeName == 'ENVELOPE' )
								{
									// get envelope information
									minx = features[i].childNodes[x].childNodes[y].attributes.getNamedItem('minx').value;
									miny = features[i].childNodes[x].childNodes[y].attributes.getNamedItem('miny').value;
									maxx = features[i].childNodes[x].childNodes[y].attributes.getNamedItem('maxx').value;
									maxy = features[i].childNodes[x].childNodes[y].attributes.getNamedItem('maxy').value;
									
									// setup primary display field in HTML
									featureID = "feature" + x;
									className = "fieldPrimary";
									
									/*var objectIdHidden = document.getElementById("objectIdHidden");
									objectIdHidden.value = uniqueValue;
									var activeLayerHidden = document.getElementById("activeLayerHidden");
									activeLayerHidden.value = layer;
									var objectIdLayer = document.getElementById("objectIdLayer");
									objectIdLayer.value = layer;*/
									
									//html = "<table width=\"100%\" id=\"tblSearchResults" + featureID +"\" cellspacing=\"0\" cellpadding=\"2\" style=\"margin-top:5px;\">";
									html += "<tr><td><table style=\"width: 100%; padding: 5px 0px 0px 0px;\" id=\"tblSearchResults" + featureID +"\" cellspacing=\"0\" cellpadding=\"2\" style=\"margin-top:5px;\">";
									html += "<tr id=\"" + featureID + "\" class=\"" + className + "\">";
									html += "<td><img id=\"" + featureID + "img\" class=\"collapseImage\" src=\"images4/plus.png\" onmousedown=\"collapseFeatureData('" + featureID + "'," + totalFieldsInFeature + ",'tblSearchResults');\" />";
									
									if( pdisplay != '' )
										html += layer + ": " + pdisplay + "</td>";
									else
										html += layer + ": " + uniqueValue + "</td>";
									
									html += "<td align=\"right\">";
									
									
									html += "<img class=\"featureImage\" src=\"images4/feature_zoom_to.png\" onmousedown=\"map.zoomToFeature('" + minx + "', '" + miny + "', '" + maxx + "', '" + maxy + "', '" + layer + "');\" alt=\"Zoom to Feature\" />";
									html += "</td></tr>";
								}
								else if( features[i].childNodes[x].childNodes[y].nodeName == 'FIELDGROUP' )
								{
									var fieldGroupName = features[i].childNodes[x].childNodes[y].attributes.getNamedItem('name').value;
									var fieldGroupHyperlink = features[i].childNodes[x].childNodes[y].attributes.getNamedItem('hyperlink').value; 
									
									// looks at FIELD elements
									html += "<tbody id=\"" + featureID + "tbody\"style=\"display:none;\">";
									for( var z = 0; z < features[i].childNodes[x].childNodes[y].childNodes.length; z++ )
									{
										if( features[i].childNodes[x].childNodes[y].childNodes[z].nodeName == 'FIELD' )
										{
											var fieldName = features[i].childNodes[x].childNodes[y].childNodes[z].attributes.getNamedItem('name').value;
											var fieldAlias = features[i].childNodes[x].childNodes[y].childNodes[z].attributes.getNamedItem('alias').value;
											var fieldNameHyperlink = features[i].childNodes[x].childNodes[y].childNodes[z].attributes.getNamedItem('namehyperlink').value;
											var fieldValue = features[i].childNodes[x].childNodes[y].childNodes[z].attributes.getNamedItem('value').value;
											var fieldValueHyperlink = features[i].childNodes[x].childNodes[y].childNodes[z].attributes.getNamedItem('valuehyperlink').value;
											
											// add each field to the HTML
											className = (fieldCount % 2 == 1)?"Odd":"Even";
											featureID = "feature" + x + "field" + fieldCount;

											html += "<tr>";
											
											// add field name (alias)
											if( fieldNameHyperlink != "" )
											{
												html += "<td class=\"field" + className + "\">";
												html += "<a class=\"fieldLink\" href=\"" + fieldNameHyperlink + "\" target=\"_new\">";
												html += fieldAlias + "</a></td>";
											}
											else
												html += "<td class=\"field" + className + "\">" + fieldAlias + "</td>";
											
											// add field value
											if( fieldValue != null )
											{
												// check for hyperlink!
												if( fieldValueHyperlink != "" )
												{
													html += "<td class=\"fieldValue" + className + "\">";
													html += "<a class=\"fieldLink\" href=\"" + fieldValueHyperlink + "\" target=\"_new\">";
													html += fieldValue + "</a></td>";
												}
											    else if(fieldValue.indexOf("http://") == 0)
											    {
											        html += "<td class=\"fieldValue" + className + "\">";
												    html += "<a class=\"fieldLink\" href=\"" + fieldValue + "\" target=\"_new\">";
												    html += fieldValue + "</a></td>";
											    }
												else
													html += "<td class=\"fieldValue" + className + "\">" + fieldValue + "</a></td>";
											}
											else
												html += "<td></td>";
											
											fieldCount++;
										}
									}
								}
							}
							//html += "</tbody></tr></table>";
							//resultTable.innerHTML += html;
							
							html += "</tr>"; 
							html+="</tbody></table></td></tr>";
						}
						
					}		
					
				}
				
				if(groupingSize > 0){
					var resultPageNumber = parseInt((featureCounter-1) / groupingSize);
					var hideThis = "document.getElementById(\'" + resultPagePrefix + (resultPageNumber) + "\').style.display=\'none\';";
					var showPrev = "document.getElementById(\'" + resultPagePrefix + (resultPageNumber-1) + "\').style.display=\'\';";
					if(featureCounter > groupingSize){
						html+= "<tr><td colspan=\"2\" align=\"left\"><input type=\"button\" class=\"buttonNormal\" onclick=\"" + hideThis + showPrev + "return(false);\" value=\"Prev\" ></td></tr>";
					}
					if(resultPageNumber > 0){
						html+= "<tr><td colspan=\"2\" align=\"center\">Page " + (resultPageNumber + 1) + "</td></tr>";
					}
					html+= "</table>"
					html+= "</div></td></tr>";
				}
				
				html += "</table>";
				
				resultTable.innerHTML += html;
			
			
				/*if(objectIds.length > 0)
				{	
					var spanHtml = "<br/><span class=\"trInfo\" style=\"font-size:11px\">Export feature data to Excel </span><a href=\"feature_csv.aspx?objectId=";
					for( var n in objectIds)
					{
						spanHtml += objectIds[n] + ",";
					}

					spanHtml += "&layer=" + layer + "&reportType=Short Report&userGroupName=" + user.userGroupName + "\" target=\"_new\" border=\"0\"><img src=\"images/excel.gif\" alt=\"Export to Excel\" border=\"0\" /></a>";
					spnResultsInfo.innerHTML += spanHtml;
				}*/					
				
				activateMapTab(1);//displayResults();//activateTab("tabResults");
				trResultsInfo.style.display='';
				divResultsList.style.display='';
				subTabResultsList.className='subTabActive';
				
				// disable loading div
				loading.style.visibility = "hidden";
				
				if( hasMore == 'True' )
					alert("This search returned more than the number of features allowed.  Please refine your search for more detailed results.");
			}
		}
	}
	
	function processFeatureSearch2()
	{
		showLoading();
		var objectIds = new Array();
		var groupingSize = 10;
		var resultPagePrefix = "featSearch_page_";
		
		if( self.XmlReqFind.readyState == 4 )
		{
			if( self.XmlReqFind.status == 200 )
			{
				// parse response and place data into html table
				var resultTable = document.getElementById("divResultsList");
				resultTable.innerHTML = "";
				lastXMLFeatureResponse = browser.xmlToString(self.XmlReqFind.responseXML.documentElement);
				
				var response = self.XmlReqFind.responseXML.documentElement;
				var features = response.getElementsByTagName('FEATURES');
				var featureID = "";
				var html = "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" style=\"margin: 0px 0px 0px 0px;padding: 0px 0px 0px 0px;\" border=\"0\">";
				
				// get request specific top level values (layer, layerHyperlink, response feature count, hasMore features)
				var layer = features[0].attributes.getNamedItem('layer').value;
				var layerHyperlink = features[0].attributes.getNamedItem('hyperlink').value;
				var count = features[0].attributes.getNamedItem('count').value;
				var hasMore = features[0].attributes.getNamedItem('hasmore').value;
				
				var acres = 0;
				var zoomMinX = NaN;
				var zoomMinY = NaN;
				var zoomMaxX = NaN;
				var zoomMaxY = NaN;
				
				if( count == 0 )
					spnResultsInfo.innerHTML = "No Features Found";
				else if( count == 1 )
					spnResultsInfo.innerHTML = "1 Feature Found";
				else
					spnResultsInfo.innerHTML = count + " Features Found";
				
				// looks at FEATURES elements
				for( var i = 0; i < features.length; i++ )
				{
					var featureCounter = 0;
					
					// looks at FEATURE elements
					for( var x = 0; x < features[i].childNodes.length; x++ )
					{

						if( features[i].childNodes[x].nodeName == 'FEATURE' )
						{
							var fieldCount = 0;
							var minx = "", miny = "", maxx = "", maxy = "";
								
							// get feature specific top level values (uniqueName, uniqueValue, primaryDisplay)
							var uniqueName = features[i].childNodes[x].attributes.getNamedItem('uniquename').value;
							var uniqueValue = features[i].childNodes[x].attributes.getNamedItem('uniquevalue').value;
							var pdisplay = features[i].childNodes[x].attributes.getNamedItem('pdisplay').value;
							
							objectIds.push(uniqueValue);
							
							// for parcels, need to add 1 to this value
							var totalFieldsInFeature = features[i].childNodes[x].attributes.getNamedItem('fields').value;
							
							if(0 == (featureCounter % groupingSize) && groupingSize > 0){
								var resultPageNumber = parseInt(featureCounter / groupingSize);
								if(0 != featureCounter){
									var hideThis = "document.getElementById(\'" + resultPagePrefix + (resultPageNumber-1) + "\').style.display=\'none\';";
									var showPrev = "document.getElementById(\'" + resultPagePrefix + (resultPageNumber-2) + "\').style.display=\'\';";
									var showNext = "document.getElementById(\'" + resultPagePrefix + (resultPageNumber) + "\').style.display=\'\';";
									html += "<tr><td colspan=\"2\" style=\"font-size: xx-small;\"><b>NOTE:</b> Acreage values are not split by county or watershed boundaries.  Any watershed or county-based query reflects the total acreage values for all intersecting lands and some acreage totals may appear inflated.  Acreage does not include water bodies.<br/>Data scale differences may cause some discrepancies between tabular and map results; for examples, county boundaries are created at a smaller scale than parcel boundaries.  Parcels along rivers may therefore intersect with multiple counties though really only occuring in one.</tr></td>"
									if(featureCounter > groupingSize){
										html+= "<tr><td><table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\"><tr><td align=\"left\"><input type=\"button\" class=\"buttonNormal\" onclick=\"" + hideThis + showPrev + "return(false);\" value=\"Prev\"></td><td align=\"right\"><input type=\"button\" class=\"buttonNormal\" onclick=\"" + hideThis + showNext + "return(false);\" value=\"Next\"></td></tr></table></td></tr>";
									}else{
										html+= "<tr><td colspan=\"2\" align=\"right\"><input type=\"button\" class=\"buttonNormal\" onclick=\"" + hideThis + showNext + "return(false);\" value=\"Next\"></td></tr>";
									}
									html+= "<tr><td colspan=\"2\" align=\"center\">Page " + (resultPageNumber) + "</td></tr>";
									html+= "</table>";
									html+= "</div></td></tr>";
								}
								html+= "<tr><td><div id=\"" + resultPagePrefix + resultPageNumber + "\" style=\"display: " + (featureCounter == 0 ? "block" : "none") + ";\"><table width=\"100%\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\">";
							    
							}
							featureCounter++;
							
							for( var y = 0; y < features[i].childNodes[x].childNodes.length; y++ )
							{
								if( features[i].childNodes[x].childNodes[y].nodeName == 'ENVELOPE' )
								{   
									// get envelope information
									minx = features[i].childNodes[x].childNodes[y].attributes.getNamedItem('minx').value;
									miny = features[i].childNodes[x].childNodes[y].attributes.getNamedItem('miny').value;
									maxx = features[i].childNodes[x].childNodes[y].attributes.getNamedItem('maxx').value;
									maxy = features[i].childNodes[x].childNodes[y].attributes.getNamedItem('maxy').value;
									
									//check for zoom
									if(isNaN(zoomMinX) || zoomMinX > minx)
									    zoomMinX = minx;
									if(isNaN(zoomMinY) || zoomMinY > miny)
									    zoomMinY = miny;
									if(isNaN(zoomMaxX) || zoomMaxX < maxx)
									    zoomMaxX = maxx;
									if(isNaN(zoomMaxY) || zoomMaxY < maxy)
									    zoomMaxY = maxy;
									
									
									// setup primary display field in HTML
									featureID = "feature" + x;
									className = "fieldPrimary";
									
									/*var objectIdHidden = document.getElementById("objectIdHidden");
									objectIdHidden.value = uniqueValue;
									var activeLayerHidden = document.getElementById("activeLayerHidden");
									activeLayerHidden.value = layer;
									var objectIdLayer = document.getElementById("objectIdLayer");
									objectIdLayer.value = layer;*/
									
									//html = "<table width=\"100%\" id=\"tblSearchResults" + featureID +"\" cellspacing=\"0\" cellpadding=\"2\" style=\"margin-top:5px;\">";
									html += "<tr><td><table style=\"width: 100%; padding: 5px 0px 0px 0px;\" id=\"tblSearchResults" + featureID +"\" cellspacing=\"0\" cellpadding=\"2\" style=\"margin-top:5px;\">";
									html += "<tr id=\"" + featureID + "\" class=\"" + className + "\">";
									html += "<td><img id=\"" + featureID + "img\" class=\"collapseImage\" src=\"images4/plus.png\" onmousedown=\"collapseFeatureData('" + featureID + "'," + totalFieldsInFeature + ",'tblSearchResults');\" />";
									
									if( pdisplay != '' )
										html += layer + ": " + pdisplay + "</td>";
									else
										html += layer + ": " + uniqueValue + "</td>";
									
									html += "<td align=\"right\">";
									
									
									html += "<img class=\"featureImage\" src=\"images4/feature_zoom_to.png\" onmousedown=\"map.zoomToFeature('" + minx + "', '" + miny + "', '" + maxx + "', '" + maxy + "', '" + layer + "');\" alt=\"Zoom to Feature\" />";
									html += "</td></tr>";
								}
								else if( features[i].childNodes[x].childNodes[y].nodeName == 'FIELDGROUP' )
								{
									var fieldGroupName = features[i].childNodes[x].childNodes[y].attributes.getNamedItem('name').value;
									var fieldGroupHyperlink = features[i].childNodes[x].childNodes[y].attributes.getNamedItem('hyperlink').value; 
									
									// looks at FIELD elements
									html += "<tbody id=\"" + featureID + "tbody\"style=\"display:none;\">";
									for( var z = 0; z < features[i].childNodes[x].childNodes[y].childNodes.length; z++ )
									{
										if( features[i].childNodes[x].childNodes[y].childNodes[z].nodeName == 'FIELD' )
										{
											var fieldName = features[i].childNodes[x].childNodes[y].childNodes[z].attributes.getNamedItem('name').value;
											var fieldAlias = features[i].childNodes[x].childNodes[y].childNodes[z].attributes.getNamedItem('alias').value;
											var fieldNameHyperlink = features[i].childNodes[x].childNodes[y].childNodes[z].attributes.getNamedItem('namehyperlink').value;
											var fieldValue = features[i].childNodes[x].childNodes[y].childNodes[z].attributes.getNamedItem('value').value;
											var fieldValueHyperlink = features[i].childNodes[x].childNodes[y].childNodes[z].attributes.getNamedItem('valuehyperlink').value;
											
											// add each field to the HTML
											className = (fieldCount % 2 == 1)?"Odd":"Even";
											featureID = "feature" + x + "field" + fieldCount;

											html += "<tr>";
											
											// add field name (alias)
											if( fieldNameHyperlink != "" )
											{
												html += "<td class=\"field" + className + "\">";
												html += "<a class=\"fieldLink\" href=\"" + fieldNameHyperlink + "\" target=\"_new\">";
												html += fieldAlias + "</a></td>";
											}
											else
												html += "<td class=\"field" + className + "\">" + fieldAlias + "</td>";
											if( fieldName == "TOTALACRE" && fieldValue != null && isANumber(fieldValue))
											    acres += parseFloat(fieldValue);
											// add field value
											if( fieldValue != null )
											{
												// check for hyperlink!
												if( fieldValueHyperlink != "" )
												{
													html += "<td class=\"fieldValue" + className + "\">";
													html += "<a class=\"fieldLink\" href=\"" + fieldValueHyperlink + "\" target=\"_new\">";
													html += fieldValue + "</a></td>";
												}
											    else if(fieldValue.indexOf("http://") == 0)
											    {
											        html += "<td class=\"fieldValue" + className + "\">";
												    html += "<a class=\"fieldLink\" href=\"" + fieldValue + "\" target=\"_new\">";
												    html += fieldValue + "</a></td>";
											    }
												else
													html += "<td class=\"fieldValue" + className + "\">" + fieldValue + "</a></td>";
											}
											else
												html += "<td></td>";
											
											fieldCount++;
										}
									}
								}
							}
							//html += "</tbody></tr></table>";
							//resultTable.innerHTML += html;
							
							html += "</tr>"; 
							//html += "<tr><td colspan=\"2\" style=\"font-size: xx-small;\"><b>NOTE:</b> Acreage values are not split by county or watershed boundaries.  Any watershed or county-based query reflects the total acreage values for all intersecting lands and some acreage totals may appear inflated.  Acreage does not include water bodies.<br/>Data scale differences may cause some discrepancies between tabular and map results; for examples, county boundaries are created at a smaller scale than parcel boundaries.  Parcels along rivers may therefore intersect with multiple counties though really only occuring in one.</tr></td>"
						    html+="</tbody></table></td></tr>";
						}
						
					}		
					
				}
				
				if(groupingSize > 0){
					var resultPageNumber = parseInt((featureCounter-1) / groupingSize);
					var hideThis = "document.getElementById(\'" + resultPagePrefix + (resultPageNumber) + "\').style.display=\'none\';";
					var showPrev = "document.getElementById(\'" + resultPagePrefix + (resultPageNumber-1) + "\').style.display=\'\';";
					if(featureCounter > groupingSize){
						html+= "<tr><td colspan=\"2\" align=\"left\"><input type=\"button\" class=\"buttonNormal\" onclick=\"" + hideThis + showPrev + "return(false);\" value=\"Prev\" ></td></tr>";
					}
					if(layer == "Managed Conservation Lands")
    				    html += "<tr><td colspan=\"2\" style=\"font-size: xx-small;\"><b>NOTE:</b> Acreage values are not split by county or watershed boundaries.  Any watershed or county-based query reflects the total acreage values for all intersecting lands and some acreage totals may appear inflated.  Acreage does not include water bodies.<br/>Data scale differences may cause some discrepancies between tabular and map results; for examples, county boundaries are created at a smaller scale than parcel boundaries.  Parcels along rivers may therefore intersect with multiple counties though really only occuring in one.</tr></td>"			
				
					if(resultPageNumber > 0){
						html+= "<tr><td colspan=\"2\" align=\"center\">Page " + (resultPageNumber + 1) + "</td></tr>";
					}
					html+= "</table>"
					html+= "</div></td></tr>";
				}
				
				acres = "" + acres;
				var ind = acres.indexOf(".");
				if( ind == -1 )
				    acres += ".00";
				else if( acres.length > ind + 2 && ind > -1)
    				acres = acres.substring(0, ind + 3);
    			else
    			    acres += "0";
    			
				
				
				
				spnResultsInfo.innerHTML += "<br/>Total Acres:&nbsp;" + acres;
				//if(0 != (featureCounter % groupingSize) && groupingSize > 0)
				//    html += "<tr><td colspan=\"2\" style=\"font-size: xx-small;\"><b>NOTE:</b> Acreage values are not split by county or watershed boundaries.  Any watershed or county-based query reflects the total acreage values for all intersecting lands and some acreage totals may appear inflated.  Acreage does not include water bodies.<br/>Data scale differences may cause some discrepancies between tabular and map results; for examples, county boundaries are created at a smaller scale than parcel boundaries.  Parcels along rivers may therefore intersect with multiple counties though really only occuring in one.</tr></td>"
				html += "</table>";
				
				resultTable.innerHTML += html;
			
			
				/*if(objectIds.length > 0)
				{	
					var spanHtml = "<br/><span class=\"trInfo\" style=\"font-size:11px\">Export feature data to Excel </span><a href=\"feature_csv.aspx?objectId=";
					for( var n in objectIds)
					{
						spanHtml += objectIds[n] + ",";
					}

					spanHtml += "&layer=" + layer + "&reportType=Short Report&userGroupName=" + user.userGroupName + "\" target=\"_new\" border=\"0\"><img src=\"images/excel.gif\" alt=\"Export to Excel\" border=\"0\" /></a>";
					spnResultsInfo.innerHTML += spanHtml;
				}*/					
				
				activateMapTab(1);//displayResults();//activateTab("tabResults");
				trResultsInfo.style.display='';
				divResultsList.style.display='';
				subTabResultsList.className='subTabActive';
				
				// disable loading div
				loading.style.visibility = "hidden";
				if(!isNaN(zoomMinX) && !isNaN(zoomMinY) && !isNaN(zoomMaxX) && !isNaN(zoomMaxY))
				{
				    map.getMap("ZOOMIN", zoomMinX, zoomMinY, zoomMaxX, zoomMaxY, true);
				}
				if( hasMore == 'True' )
					alert("This search returned more than the number of features allowed.  Please refine your search for more detailed results.");
			}
		}
	}//end processfeaturesearch2
	
	function zoomLatLong(lat, lng)
	{
		var arr = new Array();
		arr[0] = calcLCCSP83(map.Projection, lat, Math.abs(lng))["east"];
		arr[1] = calcLCCSP83(map.Projection, lat, Math.abs(lng))["north"];
		
		//Convert meters to feet.  this should be expanded to be controlled by the map.units property
		arr[0] = convertDistanceUnits(arr[0], 'METERS', map.Units);
		arr[1] = convertDistanceUnits(arr[1], 'METERS', map.Units);
				
		minX = arr[0] - zoomTolerance;
		minY = arr[1] - zoomTolerance;
		maxX = arr[0] + parseFloat(zoomTolerance);
		maxY = arr[1] + parseFloat(zoomTolerance);
		
		map.getMap("ZOOMIN", minX, minY, maxX, maxY, true);
	}
	
	function findAddress(address, crossStreet)
	{
		url = server + "FindService.asmx/GetGeocode?address=" + address + "&crossStreet=" + crossStreet;
		
		self.XmlReqFind = new TXmlHttp();
		
		if(self.XmlReqFind)
		{
			self.XmlReqFind.onreadystatechange = processGeocodeSearch;
			self.XmlReqFind.open("GET", url, true); //async call
			self.XmlReqFind.send(null);
		}			
	}
	
	function processGeocodeSearch()
	{
		showLoading();
		
		if( self.XmlReqFind.readyState == 4 )
		{
			if( self.XmlReqFind.status == 200 )
			{
				var resultTable = document.getElementById("divResultsList");
				resultTable.innerHTML = "";
				
				var response = self.XmlReqFind.responseXML.documentElement;
				var features = response.getElementsByTagName('GCFEATURES');
				var featureID = "";
				var html = "";	
				
				var count = features[0].attributes.getNamedItem('count').value;
				
				if( count == 0 )
					spnResultsInfo.innerHTML = "No Features Found";
				else if( count == 1 )
					spnResultsInfo.innerHTML = "1 Feature Found";
				else
					spnResultsInfo.innerHTML = count + " Features Found";
					
					
				for( var i = 0; i < features.length; i++ )
				{
					// looks at FEATURE elements
					for( var x = 0; x < features[i].childNodes.length; x++ )
					{
						
						if( features[i].childNodes[x].nodeName == 'GCFEATURE' )
						{
							var score = features[i].childNodes[x].attributes.getNamedItem('score').value;
							var addressFound = features[i].childNodes[x].attributes.getNamedItem('addressfound').value;
							var xval = features[i].childNodes[x].attributes.getNamedItem('xval').value;
							var yval = features[i].childNodes[x].attributes.getNamedItem('yval').value;
							html += "<table width=\"100%\" id=\"tblSearchResults" + xval + yval +"\" cellspacing=\"0\" cellpadding=\"2\" style=\"margin-top:5px;\">";
							html += "<tr class=\"fieldPrimary\"><td align=\"left\">" + addressFound + "</td>";
							html += "<td align=\"right\"><img class=\"featureImage\" src=\"images4/feature_zoom_to.png\" onmousedown=\"find.zoomAddAcetate('" + addressFound + "', '" + xval + "', '" + yval + "', '" + xval + "', '" + yval + "');\" alt=\"Zoom to Feature\" /></td></tr>";
							
							
						}
					}
					html +="</table>";	
					resultTable.innerHTML += html;	
				}
			}
		}
		activateTab("tabResults");
		trResultsInfo.style.display='block';
		divResultsList.style.display='block';
		subTabResultsList.className='subTabActive';
		
		loading.style.visibility = "hidden";
	}
	
	function zoomAddAcetate(label, x, y)
	{
		var point = new Point();
		point.setLabel(label);
		point.setX(x);
		point.setY(y);
		map.AcetatePoints.push(point);
		map.zoomToFeature(x, y, x, y);
	}
}