google.load("search","1");google.load("maps","2");google.setOnLoadCallback(initialize,true);if(navigator.platform.match(/linux|bsd/i)){_mSvgEnabled=_mSvgForced=true}var map;var ne=-1;var sw;var s=0;var last;var lstart;var lend;var normal;var ia;var iam=[];var ci;var cim=[];var tooltip=document.createElement("div");var url=document.createElement("div");var myMarker=[];var tempMarker=[];var om;var myToggle=1;var setCenter=1;var sidebar=document.getElementById("resContainer");var customMarker=[];var customHash=[];var customMarkerCounter=0;var po=0;var currentType="";var zListener=0;var mysptd=0;function initialize(){if(GBrowserIsCompatible()){om=new OverlayMessage(document.getElementById("map_canvas"));map=new GMap2(document.getElementById("map_canvas"));map.setCenter(new GLatLng(44.02157,-92.465953),11);map.addControl(new doappZoom());map.enableScrollWheelZoom();searchLocationsNear();initIcons();GEvent.addListener(map,"moveend",function(){if(myToggle==0){om=new OverlayMessage(document.getElementById("map_canvas"));var c=map.getBounds();ne=c.getNorthEast();sw=c.getSouthWest();setCenter=0;searchLocationsNear()}});var b=document.getElementById("zoomPlus");var a=document.getElementById("zoomMinus");GEvent.addDomListener(b,"click",function(){zoomIn()});GEvent.addDomListener(a,"click",function(){zoomOut()});GEvent.addListener(map,"zoomend",function(){setZoom(this.getZoom())});map.getPane(G_MAP_FLOAT_PANE).appendChild(tooltip);tooltip.style.visibility="hidden"}}function zoomIn(){if(zListener==0){map.zoomIn();zListener=1}}function zoomOut(){if(zListener==0){map.zoomOut();zListener=1}}function clearmessage(){om.Clear()}function updateMap(){om=new OverlayMessage(document.getElementById("map_canvas"));map.clearOverlays();searchmapsessionset("0")}function initIcons(){normal=new GIcon();normal.image="House.png";normal.iconSize=new GSize(25,28);normal.iconAnchor=new GPoint(5,24);ia=new GIcon();ci=new GIcon();sh=new GIcon();sc=new GIcon();ba=new GIcon();co=new GIcon();en=new GIcon();fr=new GIcon();ga=new GIcon();gr=new GIcon();ho=new GIcon();ht=new GIcon();li=new GIcon();of=new GIcon();po=new GIcon();re=new GIcon();rs=new GIcon();tr=new GIcon();wo=new GIcon();sh.image="images/searchMap/PointedIcons/shopping.png";sc.image="images/searchMap/PointedIcons/schools.png";ba.image="images/searchMap/PointedIcons/bank.png";ci.image="images/searchMap/PointedIcons/child_care.png";co.image="images/searchMap/PointedIcons/coffee.png";en.image="images/searchMap/PointedIcons/entertainment.png";fr.image="images/searchMap/PointedIcons/fire_rescue.png";ga.image="images/searchMap/PointedIcons/gas.png";gr.image="images/searchMap/PointedIcons/grocery.png";ho.image="images/searchMap/PointedIcons/hospital.png";ht.image="images/searchMap/PointedIcons/hotel.png";li.image="images/searchMap/PointedIcons/library.png";of.image="images/searchMap/PointedIcons/offender.png";po.image="images/searchMap/PointedIcons/police.png";ia.image="images/searchMap/PointedIcons/postoffice.png";re.image="images/searchMap/PointedIcons/recreation.png";rs.image="images/searchMap/PointedIcons/restaurant.png";tr.image="images/searchMap/PointedIcons/transportation.png";wo.image="images/searchMap/PointedIcons/worship.png";ia.iconSize=new GSize(31,38);ci.iconSize=new GSize(31,38);sh.iconSize=new GSize(31,38);sc.iconSize=new GSize(31,38);gr.iconSize=new GSize(31,38);ba.iconSize=new GSize(31,38);co.iconSize=new GSize(31,38);en.iconSize=new GSize(31,38);fr.iconSize=new GSize(31,38);ga.iconSize=new GSize(31,38);ho.iconSize=new GSize(31,38);ht.iconSize=new GSize(31,38);li.iconSize=new GSize(31,38);of.iconSize=new GSize(31,38);po.iconSize=new GSize(31,38);re.iconSize=new GSize(31,38);rs.iconSize=new GSize(31,38);tr.iconSize=new GSize(31,38);wo.iconSize=new GSize(31,38);ia.iconAnchor=new GPoint(5,38);ci.iconAnchor=new GPoint(5,38);sh.iconAnchor=new GPoint(5,38);sc.iconAnchor=new GPoint(5,38);gr.iconAnchor=new GPoint(5,38);ba.iconAnchor=new GPoint(5,38);co.iconAnchor=new GPoint(5,38);en.iconAnchor=new GPoint(5,38);fr.iconAnchor=new GPoint(5,38);ga.iconAnchor=new GPoint(5,38);ho.iconAnchor=new GPoint(5,38);ht.iconAnchor=new GPoint(5,38);li.iconAnchor=new GPoint(5,38);of.iconAnchor=new GPoint(5,38);po.iconAnchor=new GPoint(5,38);re.iconAnchor=new GPoint(5,38);rs.iconAnchor=new GPoint(5,38);tr.iconAnchor=new GPoint(5,38);wo.iconAnchor=new GPoint(5,38)}function createMarker(a,c,g,e,d){var b=new GMarker(a,{icon:normal});var f=c.length;f=(f*4)+65;b.len=f;b.tooltip='<div class="ttContainer" style="width:'+f+';"><div class="ttFro"></div><div class="ttCon"><div class="ttPrice">$'+g+'<br /><span style="font-size:9px;">'+c+"</span></div></div></div>";b.leftTip='<div class="ttContainer" style="width:'+f+';"><div class="ttConLeft"><div class="ttPriceLeft">$'+g+'<br /><span style="font-size:9px;">'+c+'</span></div></div><div class="ttFroLeft"></div></div>';b.url="details.php?id="+e+"&type="+d+"&sort=1";return b}function showTooltip(h){var o=map.getCurrentMapType().getProjection().fromLatLngToPixel(map.fromDivPixelToLatLng(new GPoint(4,-17),true),map.getZoom());var e=map.getCurrentMapType().getProjection().fromLatLngToPixel(h.getPoint(),map.getZoom());var i=h.getIcon().iconAnchor;var m=h.getIcon().iconSize.width;var l=39;var g="";var u=-17;var k=4;var t=h.len;var r=h.getLatLng();var q=map.fromLatLngToDivPixel(r);q.x=q.x-k;q.y=q.y-u;var a=map.getBounds();var c=new GLatLng(a.getSouthWest().lat(),a.getNorthEast().lng());var b=map.fromLatLngToDivPixel(c);var d=myPs(q,b);var v=Math.abs(parseInt(d.x));var f="right";if((v-18)<t){f="left"}if(f=="right"){g=new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(e.x-o.x-i.x+m,e.y-o.y-i.y-l));tooltip.innerHTML=h.tooltip}else{g=new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize((e.x-o.x-i.x-t+13),e.y-o.y-i.y-l));tooltip.innerHTML=h.leftTip}g.apply(tooltip);tooltip.style.visibility="visible"}function myPs(d,c){return new GPoint(d.x-c.x,d.y-c.y)}function setZoom(c){var a=1;var b=3;while(b<c){document.getElementById("zoom"+a).style.backgroundImage="url(images/zoomBar/overlay_"+a+".png)";a+=1;b+=2}a=8;b=19;while(b>c){document.getElementById("zoom"+a).style.backgroundImage="url(images/zoomBar/zoom_"+a+".png)";a-=1;b-=2}}function searchLocationsNear(){myToggle=1;fullURL=window.location;if(ne==-1){var a="getHouses.php?s="+s+"&m=1"}else{var a="getHouses.php?sw="+ne+"&ne="+sw+"&s="+s+"&m=1"}appendScript(a)}function loadProg(v,q,t,h,m){var l=document.getElementById("mapShowing");l.innerHTML="Showing "+t+" of "+q+" Results";for(z=0;z<myMarker.length;z++){tempMarker[z]=myMarker[z]}var b=new GLatLngBounds();var e=0;for(n=0;n<t;n++){var r=v.markers[n].point;b.extend(r);myMarker[n]=createMarker(r,v.markers[n].address,v.markers[n].price,v.markers[n].mls,v.markers[n].type);map.addOverlay(myMarker[n]);GEvent.addListener(myMarker[n],"mouseover",function(){this.setImage("hover.png");showTooltip(this)});GEvent.addListener(myMarker[n],"click",function(){window.location.href=this.url});GEvent.addListener(myMarker[n],"mouseout",function(){this.setImage("House.png");tooltip.style.visibility="hidden"});map.addOverlay(myMarker[n])}if(setCenter==1){map.setCenter(b.getCenter(),map.getBoundsZoomLevel(b))}clearmessage();for(z=0;z<tempMarker.length;z++){map.removeOverlay(tempMarker[z])}myToggle=0;s=parseInt(m);var g=q;var c=document.getElementById("listingTotalArea");var d=document.getElementById("nextPrev");var o=document.getElementById("listingTotalAreaBot");var k=document.getElementById("nextPrevBot");d.innerHTML="";c.innerHTML="";k.innerHTML="";o.innerHTML="";if(g>0){val=s+1;datas=s+10;if(datas>g){datas=g}}c.innerHTML="Showing "+val+"-"+datas+" of "+g;o.innerHTML="Showing "+val+"-"+datas+" of "+g;if(g>10){var e=0;var f=0;if(s!="0"){prev=s-10}next=s+10;if(s!=0){d.innerHTML+='<a href="#nogo" onClick="paging('+prev+')" class="paging" ><< previous</a>&nbsp;&nbsp;';k.innerHTML+='<a href="#nogo" onClick="paging('+prev+')" class="paging" ><< previous</a>&nbsp;&nbsp;'}for(e=0;e<g;e=e+10){last=e}if(s==""||s==undefined){lstart=0;lend=(g>10*10)?10*10:g}else{if(s!=""){if(s/10>=9){lstart=s-(10*9);lend=(s+(10*2))>g?last+10:s+(10*2)}else{lstart=0;lend=(10*10>g)?g:10*10}}}j=1;for(e=lstart;e<lend;e=e+10){if(s==e){if((10+1)!=0){d.innerHTML+="<b>"+Math.round(e/10+1)+"</b>";k.innerHTML+="<b>"+Math.round(e/10+1)+"</b>"}}else{d.innerHTML+='<a href=\'#\' class="paging" onclick="paging('+e+');">'+Math.round(e/10+1)+"</a>&nbsp;";k.innerHTML+='<a href=\'#\' class="paging" onclick="paging('+e+');">'+Math.round(e/10+1)+"</a>&nbsp;"}values=Math.ceil(lend/10);if(j<values){d.innerHTML+=" : ";k.innerHTML+=" : "}j++}final1=g-10;count=(e/10);if(next<g){d.innerHTML+=' &nbsp;<a href="#" class="paging" onclick="paging('+next+');">next >></a> ';k.innerHTML+=' &nbsp;<a href="#" class="paging" onclick="paging('+next+');">next >></a> '}}var a=document.getElementById("resContainer");a.innerHTML="";for(p=0;p<h.houses.length;p++){var u=createSidebarEntry(h.houses[p]);if(u!=undefined){a.appendChild(u)}}zListener=0}function createSidebarEntry(b){if(b!=undefined){var c=document.createElement("div");var a='<div class="houseContainer">';a+='<div class="houseHeaderContainer">';a+='<div id="houseIcon"><img src="images/gHouse.png" /></div>';a+='<div id="houseAddress"><a href="details.php?id='+b.mls+"&type="+b.searchtype+'&sort=1">'+b.address+"</a></div>";a+="</div>";a+=' <div id="houseBodyContainer">';a+='<div id="houseBodyLeftContainer">';a+='	<div id="houseImageContainer">';a+='      <div id="houseImage"><a href="details.php?id='+b.mls+"&type="+b.searchtype+'&sort=1"><img src="'+b.image+'" border="0"  width="160" height="120" /></a></div>';a+='        	<div id="buttons">';a+="          		";a+="           </div>";a+="        </div>";a+='        <div id="houseDetailsContainer">';a+="	   "+b.bed+" Bedrooms <br /> "+b.bath+" Bathrooms <br />"+b.type+" <br /> "+b.sq+" Sq Ft <br /> MLS ID # "+b.mls+"<br /> Status: "+b.status+" <br />";a+='		<div class="left" style="color:#3669a9; font-weight:bold; padding-top:8px; margin-top:3px;"><a href="details.php?id='+b.mls+"&type="+b.searchtype+'&sort=1">Full Details ></a></div>';a+="		 </div>";a+="		</div>";a+='		<div id="houseBodyRightContainer">';a+='	   <div id="housePrice">$'+b.price+"</div>";a+='		<div id="houseAreaMap"><a href="details.php?id='+b.mls+"&type="+b.searchtype+'&sort=1"><div id="areaMap" class="up"></div></a></div>';a+='		<div id="houseAddTo">'+b.fav+"</div>";a+='		<div id="houseAddTo">'+b.trip+"</div>";a+="		</div>";a+="		</div>";a+='		<div class="space" style="border-bottom:solid 1px #7c7c7c; height:9px; width:504px;"></div>';a+="		</div>";c.innerHTML=a;c.style.marginBottom="5px";return c}}function appendScript(h){var e=document.createElement("script");e.setAttribute("src",h);e.setAttribute("type","text/javascript");var d=function(){e.onload=null;e.parentNode.removeChild(e);delete (e);if(typeof(h.onload)=="function"){h.onload()}},g=function(){if(e.readystate=="loaded"||e.readyState=="complete"){e.onreadystatechange=null;d()}};if(navigator.product=="Gecko"){e.onload=d}else{e.onreadystatechange=g}document.getElementsByTagName("head")[0].appendChild(e);return e}function toggleMap(a){var c=document.getElementById("searchvalue");var b=document.getElementById("sby");if(a=="m"){b.value=c.value;c.value="Address, City, State or Zip"}else{if(a=="a"){c.value=b.value;b.value="";setCenter=1}}updateMap()}function mapOffenders(c,b){for(n=0;n<c.offenders.length;n++){var a=c.offenders[n].point;customMarker[currentType][customMarkerCounter]=createCustomMarker(a,c.offenders[n].address,c.offenders[n].name);map.addOverlay(customMarker[currentType][customMarkerCounter]);GEvent.addListener(customMarker[currentType][customMarkerCounter],"mouseover",function(){showTooltip(this)});GEvent.addListener(customMarker[currentType][customMarkerCounter],"mouseout",function(){tooltip.style.visibility="hidden"});customMarkerCounter++}customHash[currentType]=customMarker[currentType].length;currentType="";customMarkerCounter=0}function togglePOI(g,h,f){if(mysptd==0){mysptd=1;currentType=g;if(h==0&&customHash[g]!=undefined){for(ab=0;ab<customHash[g];ab++){map.removeOverlay(customMarker[currentType][ab])}delete (customHash[g]);var e=document.getElementById(f);newSrc=e.src.replace("Color","GreyIcon");e.src=newSrc;mysptd=0}else{if(f=="Offender"){if(h==0){customMarker[currentType]=[];var e=document.getElementById(f);newSrc=e.src.replace("GreyIcon","Color");e.src=newSrc}var c=document.createElement("script");c.type="text/javascript";var d="getOffender.php";c.src=d;document.getElementsByTagName("head")[0].appendChild(c)}else{if(h==0){customMarker[currentType]=[];var e=document.getElementById(f);newSrc=e.src.replace("GreyIcon","Color");e.src=newSrc}var c=document.createElement("script");c.type="text/javascript";var a=map.getCenter().toString();a=a.replace(/\(|\)| /g,"");var b=map.getBounds().toSpan().toUrlValue();var d="http://ajax.googleapis.com/ajax/services/search/local?v=1.0&q="+g+"&sll="+a+"&sspn="+b+"&rsz=large&start="+h;d+="&callback=loadPOI";c.src=d;document.getElementsByTagName("head")[0].appendChild(c)}}}}function loadPOI(b){for(n=0;n<b.responseData.results.length;n++){var a=new GLatLng(b.responseData.results[n].lat,b.responseData.results[n].lng);customMarker[currentType][customMarkerCounter]=createCustomMarker(a,b.responseData.results[n].streetAddress,b.responseData.results[n].titleNoFormatting);map.addOverlay(customMarker[currentType][customMarkerCounter]);GEvent.addListener(customMarker[currentType][customMarkerCounter],"mouseover",function(){showTooltip(this)});GEvent.addListener(customMarker[currentType][customMarkerCounter],"mouseout",function(){tooltip.style.visibility="hidden"});customMarkerCounter++}if(customMarkerCounter<32){mysptd=0;togglePOI(currentType,customMarkerCounter)}else{mysptd=0;customHash[currentType]=customMarker[currentType].length;currentType="";customMarkerCounter=0}}function createCustomMarker(a,e,c){if(currentType=="banks"){var b=new GMarker(a,{icon:ba})}else{if(currentType=="child care"){var b=new GMarker(a,{icon:ci})}else{if(currentType=="coffee"){var b=new GMarker(a,{icon:co})}else{if(currentType=="entertainment"){var b=new GMarker(a,{icon:en})}else{if(currentType=="Fire Department"){var b=new GMarker(a,{icon:fr})}else{if(currentType=="gas station"){var b=new GMarker(a,{icon:ga})}else{if(currentType=="grocery"){var b=new GMarker(a,{icon:gr})}else{if(currentType=="hospitals"){var b=new GMarker(a,{icon:ho})}else{if(currentType=="hotels"){var b=new GMarker(a,{icon:ht})}else{if(currentType=="library"){var b=new GMarker(a,{icon:li})}else{if(currentType=="offender"){var b=new GMarker(a,{icon:of})}else{if(currentType=="police station"){var b=new GMarker(a,{icon:po})}else{if(currentType=="postoffice"){var b=new GMarker(a,{icon:ia})}else{if(currentType=="parks"){var b=new GMarker(a,{icon:re})}else{if(currentType=="restaurant"){var b=new GMarker(a,{icon:rs})}else{if(currentType=="transportation"){var b=new GMarker(a,{icon:tr})}else{if(currentType=="churches"){var b=new GMarker(a,{icon:wo})}else{if(currentType=="schools"){var b=new GMarker(a,{icon:sc})}else{if(currentType=="shopping"){var b=new GMarker(a,{icon:sh})}}}}}}}}}}}}}}}}}}}c=nameCheck(c);var d=c.length;d=(d*4)+65;b.len=d;b.leftTip='<div class="ttContainer" style="width:'+d+';"><div class="ttConLeft"><div class="ttPriceLeft">&nbsp;<br /><span style="font-size:9px;">'+c+'</span></div></div><div class="ttFroLeft"></div></div>';b.tooltip='<div class="ttContainer" style="width:'+d+';"><div class="ttFro"></div><div class="ttCon"><div class="ttPrice">&nbsp;<br /><span style="font-size:9px;">'+c+"</span></div></div></div>";return b}function nameCheck(a){if(a.length>28){a=a.substr(0,28);a+="..."}return a}function next(){s=parseInt(s)+10;searchLocationsNear()}function paging(a){s=parseInt(a);searchLocationsNear()}function prev(){s=parseInt(s)-10;searchLocationsNear()};
