/************************************************************ * CirrusView - Real Estate Search Tool by GIRD Systems * (c) 2005-2006 All Rights Reserved * http://www.cirrusview.com/ ************************************************************/ CirrusView.prototype.initialize = CirrusView_initialize; CirrusView.prototype.resize = CirrusView_resize; CirrusView.prototype.update = CirrusView_update; function CirrusView(){ updateSearchFields(); this.icon = new Array(); this.icon['s'] = "images/icons/house1.png"; this.icon['c'] = "images/icons/house2.png"; this.icon['m'] = "images/icons/house3.png"; this.mapTypeArray = new Array(G_MAP_TYPE,G_HYBRID_TYPE,G_SATELLITE_TYPE); } function CirrusView_initialize(){ this.resize(); this.map = new GMap(document.getElementById("map")); this.map.addControl(new GSmallMapControl()); this.map.centerAndZoom(new GPoint(-84.45872784,39.134254669),2); GEvent.addListener(this.map,"moveend",function(){cirrusView.update();}); GEvent.addListener(cirrusView.map,"click",function(gmark,pt){window.open(gmark.url);}); if (window.attachEvent) window.attachEvent("onresize", function() {cirrusView.resize();}); else window.addEventListener("resize", function () {cirrusView.resize();}, false); this.addPending = new Array(); this.currentMLS = new Array(); this.update(); } function CirrusView_resize(){ document.getElementById("map").style.width = getWidth()-400 + "px"; document.getElementById("map").style.height = getHeight()-175 + "px"; document.getElementById("main").style.height = Math.round(getHeight()*0.95) + "px"; document.getElementById("map").style.top = "5px"; document.getElementById("map").style.left = "25px"; document.getElementById("sidebar").style.height = getHeight()-155 + "px"; document.getElementById("subbar").style.height = getHeight()-195 + "px"; document.getElementById("footer").style.top = getHeight()-85 + "px"; document.getElementById("footer").style.left = getWidth()*0.15 + "px"; if(!IE){ document.getElementById("status_msg").style.left = (getWidth() - 460) + "px"; document.getElementById("status_msg").style.top = "83px"; } else { document.getElementById("status_msg").style.left = (getWidth() - 483) + "px"; document.getElementById("status_msg").style.top = "85px"; } maxX = parseInt(document.getElementById("map").style.left)+parseInt(document.getElementById("map").style.width)-150; maxY = parseInt(document.getElementById("map").style.top)+parseInt(document.getElementById("map").style.height)-160; } function CirrusView_update(){ //document.getElementById("status_msg").style.visibility = 'visible'; cirrusView.request = GXmlHttp.create(); cirrusView.dataPullURL = "datapull.php?lat1=" + this.map.getBoundsLatLng().minY + "&lat2=" + this.map.getBoundsLatLng().maxY + "&lng1=" + this.map.getBoundsLatLng().minX + "&lng2=" + this.map.getBoundsLatLng().maxX; cirrusView.request.open("GET","datapull.php?lat1=" + this.map.getBoundsLatLng().minY + "&lat2=" + this.map.getBoundsLatLng().maxY + "&lng1=" + this.map.getBoundsLatLng().minX + "&lng2=" + this.map.getBoundsLatLng().maxX); cirrusView.request.onreadystatechange = function(){processXML();}; cirrusView.request.send(null); } function processXML(){ if (cirrusView.request.readyState != 4) return; var xmlDoc = cirrusView.request.responseXML; var markers = xmlDoc.documentElement.getElementsByTagName("marker"); cirrusView.addPending.length = 0; for(i=0;i 0) window.setTimeout('processPending()',1); else window.setTimeout('cleanUpOverlays()',1); } function processPending(){ if (cirrusView.addPending.length == 0) return; var pendMarker = cirrusView.addPending.pop(); if (checkMarker(pendMarker)) addMarker(pendMarker); if (cirrusView.addPending.length > 0) window.setTimeout('processPending()',1); else window.setTimeout('cleanUpOverlays()',1); } function cleanUpOverlays(){ for(i=cirrusView.map.overlays.length-1;i>=0;i--){ if(!checkMarker(cirrusView.map.overlays[i].markerData)){ cirrusView.currentMLS['MLS'+cirrusView.map.overlays[i].markerData.getAttribute("mls")] = null; cirrusView.map.removeOverlay(cirrusView.map.overlays[i]); window.setTimeout('cleanUpOverlays()',1); return; } } document.getElementById("status_msg").style.visibility = 'hidden'; } function checkMarker(pendMarker){ //if(parseFloat(pendMarker.getAttribute("lat")) < cirrusView.map.getBoundsLatLng().minY - (cirrusView.map.getBoundsLatLng().maxY-cirrusView.map.getBoundsLatLng().minY)){alert("OK1");return false;} //if(parseFloat(pendMarker.getAttribute("lat")) > cirrusView.map.getBoundsLatLng().maxY + (cirrusView.map.getBoundsLatLng().maxY-cirrusView.map.getBoundsLatLng().minY)){alert("OK2");return false;} //if(parseFloat(pendMarker.getAttribute("lng")) < cirrusView.map.getBoundsLatLng().minX - (cirrusView.map.getBoundsLatLng().maxX-cirrusView.map.getBoundsLatLng().minX)){alert("OK3");return false;} //if(parseFloat(pendMarker.getAttribute("lng")) > cirrusView.map.getBoundsLatLng().maxX + (cirrusView.map.getBoundsLatLng().maxX-cirrusView.map.getBoundsLatLng().minX)){alert("OK4");return false;} if (pendMarker.getAttribute("type") == 's' && !cirrusView.searchSingle) return false; if (pendMarker.getAttribute("type") == 'c' && !cirrusView.searchCondo) return false; if (pendMarker.getAttribute("type") == 'm' && !cirrusView.searchMulti) return false; if(parseFloat(pendMarker.getAttribute("price")) < cirrusView.searchMinPrice) return false; if(parseFloat(pendMarker.getAttribute("price")) > cirrusView.searchMaxPrice) return false; if((pendMarker.getAttribute("broker") != "HHB Partners, Realtors") && (cirrusView.showAllListings==0)) return false; if (pendMarker.getAttribute("type") == 'm'){ if (parseInt(pendMarker.getAttribute("units")) < cirrusView.searchUnits) return false; } else{ if(parseInt(pendMarker.getAttribute("bedrooms")) < cirrusView.searchBeds) return false; if((parseInt(pendMarker.getAttribute("bathrooms_full"))+parseInt(pendMarker.getAttribute("bathrooms_half"))) < cirrusView.searchBaths) return false; } return true; } function addMarker(marker){ var icon = new createIcon(cirrusView.icon[marker.getAttribute("type")]); var point = new GPoint(parseFloat(marker.getAttribute("lng")-0.0005),parseFloat(marker.getAttribute("lat")+0.0025)); var newMarker = new GMarker(point,icon); var url; var html; if ( marker.getAttribute("type") == "m"){ if (marker.getAttribute("section") == "NKY"){ url = "housedetailsmulti-nky.php?mls=" + marker.getAttribute("mls"); html = "
" + marker.getAttribute("address") + "
" + formatPrice(marker.getAttribute("price"),0) + "
Units: " + marker.getAttribute("units") + "
"; } else{ url = "housedetailsmulti.php?mls=" + marker.getAttribute("mls"); html = "
" + marker.getAttribute("address") + "
" + formatPrice(marker.getAttribute("price"),0) + "
Units: " + marker.getAttribute("units") + "
"; } } else { if (marker.getAttribute("section") == "NKY"){ url = "housedetails-nky.php?mls=" + marker.getAttribute("mls"); html = "
" + marker.getAttribute("address") + "
" + formatPrice(marker.getAttribute("price"),0) + "
Bedrooms: " + marker.getAttribute("bedrooms") + "
Baths: " + marker.getAttribute("bathrooms_full") + "/" + marker.getAttribute("bathrooms_half") + "
"; } else{ url = "housedetails.php?mls=" + marker.getAttribute("mls"); html = "
" + marker.getAttribute("address") + "
" + formatPrice(marker.getAttribute("price"),0) + "
Bedrooms: " + marker.getAttribute("bedrooms") + "
Baths: " + marker.getAttribute("bathrooms_full") + "/" + marker.getAttribute("bathrooms_half") + "
"; } } GEvent.addListener(newMarker, "mouseover", function() { document.getElementById("floating_info").innerHTML = html; document.getElementById("floating_info").style.visibility = 'visible'; document.getElementById("floating_info").style.left = tempX>maxX?maxX:tempX + "px"; document.getElementById("floating_info").style.top = tempY>maxY?maxY:tempY + "px"; }); GEvent.addListener(newMarker,"mouseout",function() {document.getElementById("floating_info").style.visibility = 'hidden';}); newMarker.markerData = marker; newMarker.url = url; cirrusView.map.addOverlay(newMarker); //cirrusView.map.overlays[cirrusView.map.overlays.length-1].iconImage.url = url; //cirrusView.map.overlays[cirrusView.map.overlays.length-1].iconImage.onclick = function(){window.open(this.url);}; cirrusView.currentMLS['MLS'+marker.getAttribute("mls")] = true; } function formatPrice(priceVal){ var i = 1000; var retStr = ""; var pricePiece = ""; priceVal = parseInt(priceVal); while(priceVal > 0){ pricePiece = ((priceVal%i)<100 && priceVal >= i)?((priceVal%i)+1000).toString().substring(1):priceVal%i; if(retStr=="") retStr = pricePiece; else retStr = pricePiece + "," + retStr; priceVal = priceVal-(priceVal%i); priceVal = parseInt(priceVal/1000); } retStr = "$" + retStr; return retStr; } function createIcon(img){ var icon = new GIcon(); icon.image = img; icon.shadow = ""; icon.iconSize = new GSize(18,15); icon.shadowSize = new GSize(0,0); icon.iconAnchor = new GPoint(0,0); icon.infoWindowAnchor = new GPoint(8,14); return icon; } function getWidth(){ if (self.innerWidth) return self.innerWidth; else if (document.documentElement && document.documentElement.clientWidth) return document.documentElement.clientWidth; else if (document.body) return document.body.clientWidth; } function getHeight(){ if (self.innerHeight) return self.innerHeight; else if (document.documentElement && document.documentElement.clientHeight) return document.documentElement.clientHeight; else if (document.body) return document.body.clientHeight; } function chooseTab(tabNumber){ document.getElementById("search").className = tabNumber==0?"active":""; document.getElementById("results").className = tabNumber==1?"active":""; document.getElementById("savedlistings").className = tabNumber==2?"active":""; } function moveToArea(){ var neighbrhd = document.getElementById('neighborhood'); var latLng = neighbrhd.options[neighbrhd.selectedIndex].value.split('%'); if(latLng.length == 2) cirrusView.map.centerAndZoom(new GPoint(latLng[1], latLng[0]), 2); neighbrhd.selectedIndex = 0; } function updateSearchFields(){ if (cirrusView == null) return; cirrusView.searchSingle = document.getElementById("singleFamily").checked; cirrusView.searchCondo = document.getElementById("condo").checked; cirrusView.searchMulti = document.getElementById("multiFamily").checked; cirrusView.searchBeds = document.getElementById("bdrms").value; cirrusView.searchBaths = document.getElementById("baths").value; cirrusView.searchMinPrice = document.getElementById("minPrice").value; cirrusView.searchUnits = document.getElementById("numMultiUnits").value; cirrusView.searchMaxPrice = document.getElementById("maxPrice").value; cirrusView.showAllListings = document.getElementById("showAll").value; //this.searchListingDate = 999999; } var cirrusView; //initialize the map after the page loads window.onload = function() { cirrusView = new CirrusView(); cirrusView.initialize(); updateSearchFields(); } var IE = document.all?true:false if (!IE) document.captureEvents(Event.MOUSEMOVE) document.onmousemove = getMouseXY; var tempX = 0; var tempY = 0; var maxX, maxY; function getMouseXY(e) { if (IE) { tempX = event.clientX + document.body.scrollLeft tempY = event.clientY + document.body.scrollTop } else { tempX = e.pageX tempY = e.pageY } if (tempX < 0){tempX = 0} if (tempY < 0){tempY = 0} return true; } //displays error messages in an alert box //---should be disabled prior to release--- window.onerror = function ( err, url, line ) { //alert( err + " [" + url + " - line " + line + "]" ); }