
var markers=[];function FFSearcher(){this.localResults=[];this.zipcode="";}
FFSearcher.prototype.showResults=function(googleResults,ffMap){if(!googleResults){alert("Results undefined.");return;}
if(googleResults.length==0){alertLayer.populateLayer("fanFinderAlert","Your search yielded zero results. Please check the Place and/or Location.",null,300,500,true);return;}
this.localResults.splice(0);var ffResultsTable=document.getElementById('ffResultsTable');ffResultsTable.style.display="block";ffResultsTable.style.width="747px";var numRows=ffResultsTable.rows.length-1;var index=numRows;while(index>=1){ffResultsTable.deleteRow(index);index=ffResultsTable.rows.length-1;}
for(var i=0;i<markers.length;i++){myFFMap.gMap.removeOverlay(markers[i]);}
markers=[];var maxLat=-90;var maxLng=-180;var minLat=90;var minLng=180;for(i=0;i<googleResults.length;i++){var gresult=googleResults[i];var locationPt=new GLatLng(parseFloat(gresult.lat),parseFloat(gresult.lng));var dist=metersToMiles(locationPt.distanceFrom(myFFMap.currentSearchCenter));if(dist>=DEFAULT_SEARCH_RADIUS){continue;}
var gLat=parseFloat(gresult.lat);var gLng=parseFloat(gresult.lng);if(gLat>maxLat){maxLat=gLat;}
if(gLat<minLat){minLat=gLat;}
if(gLng>maxLng){maxLng=gLng;}
if(gLng<minLng){minLng=gLng;}
var localResult=new LocalFFResult(gresult,(i+1));localResult.addTableRow(ffResultsTable);myFFMap.gMap.addOverlay(localResult.mapMarker);this.localResults.push(localResult);markers.push(localResult.mapMarker);}
if(this.localResults.length==0){alertLayer.populateLayer("fanFinderAlert","Nothing found within "+DEFAULT_SEARCH_RADIUS+" miles. Please check the Place and/or Location.",null,300,500,true);return;}
var attribution=ffMap.localSearch.getAttribution();if(attribution){var searchwell=document.getElementById("searchwell");if(searchwell){searchwell.appendChild(attribution);}}
var bounds=new GLatLngBounds(new GLatLng(parseFloat(minLat),parseFloat(minLng)),new GLatLng(parseFloat(maxLat),parseFloat(maxLng)));if(this.localResults.length==1){var centerPoint=this.localResults[0].locationPt;myFFMap.centerOnPoint(centerPoint,myFFMap.gMap.getBoundsZoomLevel(bounds));}
else{myFFMap.centerOnPoint(bounds.getCenter(),myFFMap.gMap.getBoundsZoomLevel(bounds));}
ffResultsTable.style.visibility="visible";loadingLayer.hideLoading();}