var sv_marker;var mt1;var overlayInstance=null;var client;var lastMarkerLocation;var panorama;var svLatlng;var geocoder;var gmarkers=[];var rgeomarkers=[];var rbounds,gbounds;var titleText_;var titleTextRetryCount=0;var mapZoom;var sv_enabled=false;var guyIcon=new GIcon(G_DEFAULT_ICON);guyIcon.image="http://www.giswebhosting.com/guy/man_arrow-0.gif";guyIcon.transparent="http://www.giswebhosting.com/guy/man-pick.png";guyIcon.imageMap=[26,13,30,14,32,28,27,28,28,36,18,35,18,27,16,26,16,20,16,14,19,13,22,8];guyIcon.iconSize=new GSize(49,52);guyIcon.iconAnchor=new GPoint(25,35);guyIcon.infoWindowAnchor=new GPoint(25,5);function setTitleText(a){var b=document.getElementById("title_text");if(b){b.innerHTML=a}else{titleText_=a;setTimeout("retryTitleText()",100)}}function retryTitleText(){var a=document.getElementById("title_text");titleTextRetryCount++;if(a){a.innerHTML=titleText_}else{if(titleTextRetryCount<10){setTimeout("retryTitleText()",100)}}}function loadStreetView(){client=new GStreetviewClient();geocoder=new GClientGeocoder();svLatlng=gmap.getCenter();openNewPanorama();toggleOverlay();sv_enabled=true}function stopStreetView(){client=null;geocoder=null;toggleOverlay();if(sv_marker){gmap.removeOverlay(sv_marker)}if(mt1){mt1.disable();mt1=null}sv_enabled=false}function openNewPanorama(){if(sv_marker==null){sv_marker=new GMarker(svLatlng,{icon:guyIcon,draggable:true})}mt1=new MarkerTracker(sv_marker,gmap);gmap.addOverlay(sv_marker);client.getNearestPanorama(svLatlng,onResponse);lastMarkerLocation=svLatlng;GEvent.addListener(sv_marker,"dragend",onDragEnd);GEvent.addListener(sv_marker,"click",openPanoramaBubble)}function openPanoramaBubble(){if(sv_marker&&sv_marker.Location&&sv_marker.Location.location&&sv_marker.Location.location.description){var h=sv_marker.Location.location.description}else{var h="unknown"}gmarkers[0]=sv_marker;var d=document.createElement("div");d.style.width="625px";d.style.height="275px";var i=document.createElement("table");i.setAttribute("border","0");var f=document.createElement("tbody");var g=document.createElement("tr");var a=document.createElement("th");a.setAttribute("id","title_text");var j=document.createTextNode(h);a.appendChild(j);g.appendChild(a);f.appendChild(g);i.appendChild(f);var e=document.createElement("tr");var c=document.createElement("td");var b=document.createElement("div");b.style.width="625px";b.style.height="255px";b.id="pano";c.appendChild(b);e.appendChild(c);f.appendChild(e);d.appendChild(i);sv_marker.openInfoWindowHtml(d);setTimeout(delaySetPanorama,1000);GEvent.addListener(gmap,"infowindowclose",function(){if(document.getElementById("panoflash1")==null){var q=document.createElement("div");q.id="panoflash1";q.style.display="none";document.getElementsByTagName("body").item(0).appendChild(q);document.getElementById("panoflash1").SetReturnValue=function(){}}if(document.getElementById("panoflash2")==null){var p=document.createElement("div");p.id="panoflash2";p.style.display="none";document.getElementsByTagName("body").item(0).appendChild(p);document.getElementById("panoflash2").SetReturnValue=function(){}}if(document.getElementById("panoflash3")==null){var o=document.createElement("div");o.id="panoflash3";o.style.display="none";document.getElementsByTagName("body").item(0).appendChild(o);document.getElementById("panoflash3").SetReturnValue=function(){}}if(document.getElementById("panoflash4")==null){var n=document.createElement("div");n.id="panoflash4";n.style.display="none";document.getElementsByTagName("body").item(0).appendChild(n);document.getElementById("panoflash4").SetReturnValue=function(){}}if(document.getElementById("panoflash5")==null){var m=document.createElement("div");m.id="panoflash5";m.style.display="none";document.getElementsByTagName("body").item(0).appendChild(m);document.getElementById("panoflash5").SetReturnValue=function(){}}if(document.getElementById("panoflash6")==null){var l=document.createElement("div");l.id="panoflash6";l.style.display="none";document.getElementsByTagName("body").item(0).appendChild(l);document.getElementById("panoflash6").SetReturnValue=function(){}}if(document.getElementById("panoflash7")==null){var k=document.createElement("div");k.id="panoflash7";k.style.display="none";document.getElementsByTagName("body").item(0).appendChild(k);document.getElementById("panoflash7").SetReturnValue=function(){}}})}function delaySetPanorama(){panorama=new GStreetviewPanorama(document.getElementById("pano"));panorama.setLocationAndPOV(sv_marker.getLatLng());GEvent.addListener(panorama,"initialized",onNewLocation);GEvent.addListener(panorama,"yawchanged",onYawChange);GEvent.addListener(panorama,"yawchanged",onPovYawChange);GEvent.addListener(panorama,"pitchchanged",onPovPitchChange);GEvent.addListener(panorama,"zoomchanged",onPovZoomChange);GEvent.addListener(panorama,"error",onPanoError)}function toggleOverlay(){if(!overlayInstance){overlayInstance=new GStreetviewOverlay();gmap.addOverlay(overlayInstance)}else{gmap.removeOverlay(overlayInstance);overlayInstance=null}}function onYawChange(b){var a=16;var c=360/a;if(b<0){b+=360}guyImageNum=Math.round(b/c)%a;guyImageUrl="http://www.giswebhosting.com/guy/man_arrow-"+guyImageNum+".gif";sv_marker.setImage(guyImageUrl)}var panoramaPov=new Object();function onPovYawChange(a){panoramaPov.yaw=a}function onPovPitchChange(a){panoramaPov.pitch=a}function onPovZoomChange(a){panoramaPov.zoom=a}function onPanoError(a){if(a=="600"){alert("Street view is not available for this location. Please drag the street view icon to a blue outlined street.")}else{alert("error:"+a)}}function onNewLocation(j){var b=j.latlng;panorama.pitch=j.pov.pitch;panorama.yaw=j.pov.yaw;panorama.zoom=j.pov.zoom;var m=sv_marker.getLatLng().x;var l=sv_marker.getLatLng().y;var a=b.x;var n=b.y;var i=(a-m);var h=(n-l);var k=gmap.getCenter();var f=k.x;var d=k.y;var g=f+i;var e=d+h;var c=new GLatLng(e,g);sv_marker.setLatLng(b);gmap.getInfoWindow().reset(b,null,new GSize(625,275),gmap.getInfoWindow().getPixelOffset());gmap.setCenter(c);panorama.focus()}function onDragEnd(){var a=sv_marker.getLatLng();client.getNearestPanorama(a,onResponse)}function onResponse(a){if(a.code!=200){sv_marker.setLatLng(lastMarkerLocation)}else{var b=new GLatLng(a.location.lat,a.location.lng);geocoder.getLocations(b,rgeocoder_callback);sv_marker.setLatLng(b);sv_marker.Location=a;lastMarkerLocation=b;openPanoramaBubble()}}function rgeocoder_callback(a){if(a.Status.code==G_GEO_SUCCESS){for(var e=0;e<rgeomarkers.length;e++){gmap.removeOverlay(rgeomarkers[e])}rgeomarkers=[];rbounds=new GLatLngBounds();for(var e=0;e<a.Placemark.length;e++){var h=a.Placemark[e].Point.coordinates;var g=new GLatLng(h[1],h[0]);rbounds.extend(g);html="placemark "+e;var b=createMarker2(g,null,e,html,a.Placemark[e]);rgeomarkers.push(b);if(g.distanceFrom(svLatlng)<10){var d=a.Placemark[e].address;d+="<br>address is approximate";var c=document.getElementById("title_text");if(c){c.innerHTML=d}else{setTitleText(d)}}}}else{var f="Code "+a.Status.code;if(reasons[a.Status.code]){f=reasons[a.Status.code]}alert('Could not find "'+search+'" '+f)}}function setMarker(b,a){if(b=="g"){GEvent.trigger(gmarkers[a],"click")}else{if(b=="r"){GEvent.trigger(rgeomarkers[a],"click")}else{alert("bad marker array")}}}function createMarker2(b,a,c,e,d){var g=new GMarker(b,{draggable:true});g.marker_num=c;var f;if(d){f="Address: "+d.address;f+="<br>Accuracy: "+d.AddressDetails.Accuracy}else{f="Address: no address found"}GEvent.addListener(g,"click",function(){var h="<br>("+g.getLatLng().toUrlValue(6)+")";g.openInfoWindowHtml(e+"<br>"+f+h)});return g};