var map=null;var overlayInstance=null;var client=null;var tableRow=1;var geo=null;var gdir=[];var markers=[];var markerHtmls=[];var markerImages=[];var markerCrimes=[];var markerGroups={"googleLstngs":[],"craigLstngs":[]};var bayArea={"peninsula":[],"northBay":[],"eastBay":[]};var bounds=null;var currentYaw=180;var currentPitch=0;var timer;var currentZoom=0;var zoomingIn=true;var panorama;var oTable;var oTBody;var rooms;var city;var listingType;var locality;var craigAddress=[];var count=0;var minPrice;var maxPrice;var state;bayArea["peninsula"]=["Atherton","Belmont","Brisbane","Burlingame","Colma","Daly City","East Palo Alto","Foster City","Half Moon Bay","Hillsborough","Menlo Park","Millbrae","Pacifica","Portola Valley","Redwood City","Redwood Shores","San Bruno","San Carlos","San Mateo","South San Francisco","Woodside"];bayArea["eastBay"]=["Oakland","Hayward","Fremont","Berkeley","Richmond","Alameda","Castro Valley","Newark","Union City","Emeryville","Albany","San Leandro","San Pablo","El Sobrante","Pinole","Hercules","Rodeo","Piedmont","El Cerrito","Dublin","Pleasanton","Livermore"];bayArea["northBay"]=["Marin County","Sonoma County","Napa County"];function fullScreen(){var a=document.getElementById("map");if(document.getElementById("fullScreen").innerHTML=='Full Screen'){document.getElementById("fullScreen").innerHTML="Normal View";a.style.cssText="margin-left:0; top:0;height:100%; width:100%;";document.style.cssText="height:100%; width:100%;margin:0; padding:0;";document.html.style.cssText="overflow:hidden; height:100%; width:100%;";document.getElementById("filter").style.cssText="margin-left:5%;"}else{document.getElementById("fullScreen").innerHTML="Full Screen";a.style.cssText="margin-left:35%; height:89%; width:64%;";document.getElementById("filter").style.cssText="margin-left:35%;"}};function displayFilters(a){if(a=='rms')document.getElementById("filter").style.cssText="position:static;border-color:#FFFFFF;";else if(a=='rnt')document.getElementById("filter").style.cssText="position:absolute;border-color:#009966;"};function getState(b){var c={"austin":"TX","baltimore":"MD","peninsula":"CA","eastBay":"CA","northBay":"CA","boston":"MA","chicago":"IL","columbus":"OH","dallas":"TX","denver":"CO","detroit":"MI","houston":"TX","indianapolis":"IN","jacksonville":"FL","los angeles":"CA","memphis":"TN","new york":"NY","philadelphia":"PA","phoenix":"AZ","san antonio":"TX","san diego":"CA","seattle":"WA","washington dc":"DC"};state=c[b];if(b=='peninsula')tempCity="San Mateo, CA";else if(b=='eastBay')tempCity="Oakland, CA";else if(b=='northBay')tempCity="Napa County, CA";else tempCity=b;geo.getLatLng(tempCity,function(a){map.setCenter(a,10)})};function start(){if(GBrowserIsCompatible()){var a=['42.35892,-71.05781','41.879535,-87.624333','34.052187,-118.243425','40.756054,-73.986951','37.775196,-122.419204','38.892091,-77.024055'];map=new GMap2(document.getElementById("map"));client=new GStreetviewClient();map.setCenter(new GLatLng(37.062500,-95.677068),4);var b=new GControlPosition(G_ANCHOR_BOTTOM_RIGHT,new GSize(30,30));map.addControl(new GLargeMapControl3D(),b);map.addControl(new GMapTypeControl());geo=new GClientGeocoder();bounds=new GLatLngBounds();for(var i=0;i<a.length;i++){var c=a[i].split(",");var d=new GLatLng(c[0],c[1]);map.addOverlay(new GMarker(d))}}document.getElementById("city").focus()};function trim(a,b){return ltrim(rtrim(a,b),b)};function ltrim(a,b){b=b||"\\s";return a.replace(new RegExp("^["+b+"]+","g"),"")};function rtrim(a,b){b=b||"\\s";return a.replace(new RegExp("["+b+"]+$","g"),"")};function spiral(){currentYaw+=2;panorama.panTo({yaw:currentYaw,pitch:currentPitch})};function onNewLocation(a,b){var c=new GLatLng(a,b);marker.setLatLng(c)};function clearMarkers(){map.getInfoWindow().hide();map.clearOverlays();markers=[];markerHtmls=[];markerImages=[];markerCrimes=[];markerGroups={"googleLstngs":[],"craigLstngs":[]}};function clearOldSnippets(){var a=document.getElementById("snippets_div");if(a&&a.firstChild){a.removeChild(a.firstChild)}a.innerHTML="";geo=new GClientGeocoder();bounds=new GLatLngBounds();craigAddress=[];count=0;var b=document.filterOption.filterOption;b[0].checked=true};function clearEventListeners(){for(i=0;i<gdir.length;i++){if(gdir[i])GEvent.clearInstanceListeners(gdir[i])}};function clearRef(){document.getElementById("fromAddress").value=""};function openPanoramaBubble(a,b,c,d){var e=document.createElement('div');e.style.width='340px';e.style.height='200px';e.id='pano';b.appendChild(e);if(panorama)panorama.remove();panorama=new GStreetviewPanorama(e);panorama.setLocationAndPOV(a.getLatLng(),{yaw:currentYaw,pitch:currentPitch,zoom:currentZoom});timer=window.setInterval(spiral,700);GEvent.addListener(panorama,"newpano",onNewLocation);a.openInfoWindowTabsHtml([new GInfoWindowTab('street view',b),new GInfoWindowTab('pictures',c),new GInfoWindowTab('crime report',d)])};function displayInfoWindow(i){marker=markers[i];contentNode=markerHtmls[i];contentNode_2=markerImages[i];contentNode_3=markerCrimes[i];if(marker)openPanoramaBubble(marker,contentNode,contentNode_2,contentNode_3)};function getDistance(m,n,o,p,q,r,s,u,v,w){if(!m){if(n)m=n+','+state;else m=city+','+state}var x=document.getElementById("fromAddress").value;if(!x){drawMarker(m,n,o,p,q,r,s,u,v,'','',w);count++;return}var y=count;gdir[y]=new GDirections();GEvent.addListener(gdir[y],"load",function(){var a=parseInt(gdir[y].getDuration().seconds/60);var b=parseInt(gdir[y].getDistance().html);drawMarker(m,n,o,p,q,r,s,u,v,b,a,w)});GEvent.addListener(gdir[y],"error",function(){var k=gdir[y].getStatus().code;var l=gdir[y].getStatus().code;if(gdir[y].getStatus().code=="620"){var t=window.setTimeout((function(a,b,c,d,e,f,g,h,i,j){return(function(){getDistance(a,b,c,d,e,f,g,h,i,j)})})(m,n,o,p,q,r,s,u,v,w),1000)}else{var k='-';var l='-';drawMarker(m,n,o,p,q,r,s,u,v,k,l,w)}});gdir[y].load('from: '+x+' to: '+m);count++};function drawTable(){oTable=document.createElement("TABLE");oTable.setAttribute("class","sortable");oTable.style.margin="0px 0px 0px 0px";oTable.style.width="100%";oTable.setAttribute("id","tbl_results");document.getElementById("snippets_div").appendChild(oTable);var a=oTable.createTHead();oTable.appendChild(a);var b=a.insertRow(-1);b.style.border="1px";var c=b.insertCell(-1);c.setAttribute("class","snippet-title");c.setAttribute("className","snippet-title");c.style.width="10%";c.innerHTML="<a href=\"javascript:sortTable("+"'offTblBdy',"+0+",true"+")\">"+'s/n'+"</a>";c=b.insertCell(-1);c.setAttribute("class","snippet-title");c.setAttribute("className","snippet-title");c.style.width="10%";c.innerHTML="<a href=\"javascript:sortTable("+"'offTblBdy',"+1+",true"+")\">"+'price'+"</a>";c=b.insertCell(-1);c.setAttribute("class","snippet-title");c.setAttribute("className","snippet-title");c.style.width="2%";c.innerHTML="<a href=\"javascript:sortTable("+"'offTblBdy',"+2+",true"+")\">"+'bed'+"</a>";c=b.insertCell(-1);c.setAttribute("class","snippet-title");c.setAttribute("className","snippet-title");c.style.width="2%";c.innerHTML="<a href=\"javascript:sortTable("+"'offTblBdy',"+3+",true"+")\">"+'distance (miles)'+"</a>";c=b.insertCell(-1);c.setAttribute("class","snippet-title");c.setAttribute("className","snippet-title");c.style.width="2%";c.innerHTML="<a href=\"javascript:sortTable("+"'offTblBdy',"+4+",true"+")\">"+'driving time (mins)'+"</a>";c=b.insertCell(-1);c.setAttribute("class","snippet-title");c.setAttribute("className","snippet-title");c.style.width="30%";c.innerHTML="<a href=\"javascript:sortTable("+"'offTblBdy',"+5+",true"+")\">"+'property'+"</a>";c=b.insertCell(-1);c.setAttribute("class","snippet-title");c.setAttribute("className","snippet-title");c.style.width="24%";c.innerHTML="<a href=\"javascript:sortTable("+"'offTblBdy',"+6+",true"+")\">"+'location'+"</a>";oTBody=document.createElement("TBODY");oTBody.setAttribute("id","offTblBdy");oTable.appendChild(oTBody)};function drawMarker(b,c,d,e,f,g,h,i,j,k,l,m){geo.getLatLng(b,function(a){if(a){drawMarker_2(b,c,d,e,f,g,h,i,j,k,l,a,m)}})};function drawMarker_2(b,c,d,e,f,g,h,j,k,l,m,n,o){var p=new GMarker(n);bounds.extend(n);var q=document.createElement('div');q.style.textAlign='center';q.style.width='350px';q.style.height='240px';q.innerHTML+='<a target="_blank" href="'+g+'">'+e+'</a>';q.innerHTML+='<br>';markerHtmls.push(q);var r="";if(!h[0])var p=new GMarker(n);else{for(var i=0;i<h.length;i++){r+='<a target="_blank" href="'+h[i]+'">'+'<img height="100px" width="100px" src="'+h[i]+'"/>'+'</a>'+' ';if(i>=2&&i==parseInt(h.length/2))r+="<br>"+"<br>"}var s=new GIcon(G_DEFAULT_ICON,"images/marker_green.png");var p=new GMarker(n,s)}markerImages.push(r);var t='<a target="_blank" href="http://www.crimereports.com/map?search='+b+'">'+'See reported crimes for the neighbourhood </a>';markerCrimes.push(t);GEvent.addListener(p,"click",function(){contentNode=q;var a=document.createElement('div');a.style.width='340px';a.style.height='200px';a.id='pano';contentNode.appendChild(a);if(panorama)panorama.remove();panorama=new GStreetviewPanorama(a);panorama.setLocationAndPOV(p.getLatLng(),{yaw:currentYaw,pitch:currentPitch,zoom:currentZoom});timer=window.setInterval(spiral,700);GEvent.addListener(panorama,"newpano",onNewLocation);p.openInfoWindowTabsHtml([new GInfoWindowTab('street view',contentNode),new GInfoWindowTab('pictures',r),new GInfoWindowTab('crime report',t)])});var u=oTBody.insertRow(-1);u.style.border="1px";if(o!="google"){markerGroups['craigLstngs'].push(p);var v="craigLstngs_"+(markerGroups['craigLstngs'].length-1);u.setAttribute("id",v)}else{markerGroups['googleLstngs'].push(p);var v="googleLstngs_"+(markerGroups['googleLstngs'].length-1);u.setAttribute("id",v)}markers.push(p);map.addOverlay(p);var w=u.insertCell(-1);w.setAttribute("class","snippet-data");w.setAttribute("className","snippet-data");if(!h[0])w.style.cssText="background-color:#FF6666";else w.style.cssText="background-color:#009966";w.innerHTML="<a onclick=\"displayInfoWindow("+(markers.length-1)+")\">"+(markers.length-1)+"</a>";var x=u.insertCell(-1);x.setAttribute("class","snippet-data");x.setAttribute("className","snippet-data");var y=u.insertCell(-1);y.setAttribute("class","snippet-data");y.setAttribute("className","snippet-data");var z=u.insertCell(-1);z.setAttribute("class","snippet-data");z.setAttribute("className","snippet-data");var A=u.insertCell(-1);A.setAttribute("class","snippet-data");A.setAttribute("className","snippet-data");var B=u.insertCell(-1);B.setAttribute("class","snippet-data");B.setAttribute("className","snippet-data");var C=u.insertCell(-1);C.setAttribute("class","snippet-data");C.setAttribute("className","snippet-data");if(l)z.innerHTML=l;else z.innerHTML="-";if(m)A.innerHTML=m;else A.innerHTML="-";if(d)x.innerHTML="$"+d;else x.innerHTML="Not listed";if(j)y.innerHTML=j;else y.innerHTML="-";if(e)B.innerHTML='<a target="_blank" href="'+g+'">'+e+'</a>';else B.innerHTML="-";if(c)C.innerHTML=c;else C.innerHTML="-"};function toggleGroup(a){if(a==1){for(var i=0;i<markers.length;i++)markers[i].show();for(var i=0;i<markerGroups['craigLstngs'].length;i++){var b="craigLstngs_"+i;var c=document.getElementById(b);c.style.display=''}for(var i=0;i<markerGroups['googleLstngs'].length;i++){var b="googleLstngs_"+i;var c=document.getElementById(b);c.style.display=''}return}else if(a==2){hideType="googleLstngs";showType="craigLstngs"}else if(a==3){hideType="craigLstngs";showType="googleLstngs"}for(var i=0;i<markerGroups[hideType].length;i++){markerGroups[hideType][i].hide();var b=hideType+"_"+i;var c=document.getElementById(b);c.style.display='none'}for(var i=0;i<markerGroups[showType].length;i++){markerGroups[showType][i].show();var b=showType+"_"+i;var c=document.getElementById(b);c.style.display=''}};function getGoogleListings(s){if(!document.getElementById("fromAddress").value)var u=0;else var u=450;j=count;var v='http://www.google.com/base/feeds/snippets?bq=';var w='[item type:housing][bedrooms:'+rooms+'][bathrooms:1]';w+='[location:@"'+s+'"][price:'+minPrice+'..'+maxPrice+']&alt=json-in-script&callback=?';v+=encodeURI(w);$.getJSON(v,function(k){var l=k.feed;listing=k.feed.entry;var m=l.entry;for(id in m){var n=m[id];var o=u*j;j++;myId='<a target="_blank" href="'+n.link[0].href+'">'+n.title.$t+'</a>';var p=[];for(imageID in n.g$image_link){if(n.g$image_link[imageID].$t!="http://www.sublet.com/Images/sublet_smalllogo.gif")p.push(n.g$image_link[imageID].$t)}var q=n.g$location[0].$t.split(',');if(String(q[q.length-1]).match("USA"))var r=q[q.length-4];else var r=q[q.length-3];var t=window.setTimeout((function(a,b,c,d,e,f,g,h,i,j){return(function(){getDistance(a,b,c,d,e,f,g,h,i,j)})})(n.g$location[0].$t,r,parseInt(rtrim(n.g$price[0].$t,'usd')),n.title.$t,myId,n.link[0].href,p,n.g$bedrooms[0].$t,parseInt(n.g$bathrooms[0].$t),'google'),o)}})};function getCraiglistings(k){if(!document.getElementById("fromAddress").value)var l=0;else var l=300;for(i=0;i<k.posts.length;i++){var m=k.posts[i].post;tempTitleHTML='<a target="_blank" href="'+m.link+'">'+m.title+'</a>';tempPics=m.pic.split("\n");var n=l*i;var t=window.setTimeout((function(a,b,c,d,e,f,g,h,i,j){return(function(){getDistance(a,b,c,d,e,f,g,h,i,j)})})(m.address,m.location,m.price,m.title,tempTitleHTML,m.link,tempPics,m.rooms,m.bath,'craig'),n)}if(listingType=='rnt'){if((city=='peninsula')||(city=='eastBay')||(city=='northBay')){cityCount=bayArea[city].length;for(var i=0;i<cityCount;i++){var o=bayArea[city][i]+", CA";getGoogleListings(o)}}else getGoogleListings(city)}};function initialize(){clearOldSnippets();clearEventListeners();clearMarkers();listingType=document.getElementById("radioval").value;if(listingType=='rms')rooms=0;else rooms=document.getElementById("rooms").value;minPrice=document.getElementById("minRent").value;maxPrice=document.getElementById("maxRent").value;city=document.getElementById("city").value;if(city!='city'){getState(city)}else{alert("Select a city");document.getElementById("city").focus();return}if(parseInt(minPrice)!=minPrice-0){alert("Enter a minimum rent - numbers only");document.getElementById("minRent").focus();return}if(parseInt(maxPrice)!=maxPrice-0){alert("Enter a maximum rent - numbers only");document.getElementById("maxRent").focus();return}drawTable();myUrl='http://www.1spotsearch.com/renting/getData.php?';myUrl+='city='+encodeURI(city)+'&room='+rooms+'&minPrice='+minPrice+'&maxPrice='+maxPrice+'&listingType='+listingType;bObj=new JSONscriptRequest(myUrl);bObj.buildScriptTag();bObj.addScriptTag()};function checkEnter(e){var a;var b=navigator.userAgent;var c=(b!=null&&b.indexOf("MSIE")!=-1);if(c){e=event;a=e.keyCode}else{a=e.which}if(a==13)initialize()};