var mainMap;var cityMarkers=new Array();var allMarkers=new Array();var cityIconZoomLevel=8;var areaZoomLevel=11;var zoneZoomLevel=14;var markerManager;var myPano;var panoClient;var city_list=new Object();var city_gis=new Object();var city_list_html=new Object();var zone_details_html=new Object();var general_images_path="";Array.prototype.size=function(){var l=this.length?--this.length:-1;for(var k in this){l++;} return l;} function toggleZonesInCityListDisplay(city_div_id,toggle_link_id){if(document.getElementById(city_div_id).style.display=='none'){document.getElementById(city_div_id).style.display='block';document.getElementById(toggle_link_id).innerHTML='';}else{document.getElementById(city_div_id).style.display='none';document.getElementById(toggle_link_id).innerHTML='';}} function displayZoneDetailsInTopBox(zone_id){document.getElementById("zones_map_top_right_box").innerHTML="
"+zone_details_html[zone_id]+"
";} function showStreetView(lat,long){document.getElementById("pano").innerHTML="

Please wait for the street view of this location.

";point=new GLatLng(lat,long);toggleStreetMapView('street');mainMap.setCenter(point,zoneZoomLevel);panoClient.getNearestPanorama(point,showPanoData);} function toggleStreetMapView(view){if(document.getElementById("map_frame").style.display=='none'&&view=='map'){document.getElementById("pano").style.display='none';document.getElementById("map_frame").style.display='inline';mainMap.checkResize();}else if(document.getElementById("pano").style.display=='none'&&view=='street'){document.getElementById("pano").style.display='inline';document.getElementById("map_frame").style.display='none';myPano.checkResize();}} function toggleOverlay(){if(!overlayInstance){overlayInstance=new GStreetviewOverlay();map.addOverlay(overlayInstance);}else{map.removeOverlay(overlayInstance);overlayInstance=null;}} function showPanoData(panoData){if(panoData.code!=200){document.getElementById("pano").innerHTML="

Sorry but street view is not yet available for this location.

Click here to display the regular map view.

";return;}else{document.getElementById("pano").innerHTML="";var displayString=["Panorama ID: "+panoData.location.panoId,"LatLng: "+panoData.location.latlng,"Copyright: "+panoData.copyright,"Description: "+panoData.location.description].join("
");var angle=computeAngle(mainMap.getCenter(),panoData.location.latlng);myPano.setLocationAndPOV(panoData.location.latlng,{yaw:angle});}} function handleNoFlash(errorCode){if(errorCode==603){document.getElementById("pano").innerHTML="

Sorry but Flash doesn't appear to be supported by your browser and it's needed for displaying street view images.

Click here to download the latest version.

";return;}} function computeAngle(endLatLng,startLatLng){var DEGREE_PER_RADIAN=57.2957795;var RADIAN_PER_DEGREE=0.017453;var dlat=endLatLng.lat()-startLatLng.lat();var dlng=endLatLng.lng()-startLatLng.lng();var yaw=Math.atan2(dlng*Math.cos(endLatLng.lat()*RADIAN_PER_DEGREE),dlat)*DEGREE_PER_RADIAN;return wrapAngle(yaw);} function wrapAngle(angle){if(angle>=360){angle-=360;}else if(angle<0){angle+=360;} return angle;} function HotspotsMapTranslations(browser_support,homepage,show_on_map,loading) {this.browser_support=browser_support;this.homepage=homepage;this.show_on_map=show_on_map;this.loading=loading;} function HotspotsMap(viewport,external_object_name,translations,images_path) {this.translations=translations;if(GBrowserIsCompatible()){this.map=new GMap2(document.getElementById(viewport));this.map.addControl(new GLargeMapControl());this.map.addControl(new GMapTypeControl());this.markers=Array();this.xml_source=null;this.external_object_name=external_object_name;this.images_path=images_path;general_images_path=images_path;mainMap=this.map;panoClient=new GStreetviewClient();myPano=new GStreetviewPanorama(document.getElementById("pano"));GEvent.addListener(myPano,"error",handleNoFlash);}else{alert(this.translations.browser_support);}} HotspotsMap.prototype.buildHtmlFromHotspot=function(hotspot_element,icon) {var html="
";var name=hotspot_element.getElementsByTagName("name");var hotspotId=hotspot_element.getElementsByTagName("hotspotId");if(name.length==1){html+=""+GXml.value(name[0])+"";} html+="
";var civicNumber=hotspot_element.getElementsByTagName("civicNumber");if(civicNumber.length==1){html+=GXml.value(civicNumber[0])+" ";} var streetAddress=hotspot_element.getElementsByTagName("streetAddress");if(streetAddress.length==1){html+=GXml.value(streetAddress[0])+" ";} html+="
";var suburb=hotspot_element.getElementsByTagName("suburb");var city=hotspot_element.getElementsByTagName("city");if(suburb.length==1){html+=GXml.value(suburb[0]);if(city.length==1){html+=", ";}} if(city.length==1){html+=GXml.value(city[0])+" ";} html+='
[';var vianet_id=GXml.value(hotspot_element.getElementsByTagName("vianetId")[0]);if(0&&vianet_id!=''){html+='Book';} var websiteUrl=hotspot_element.getElementsByTagName("webSiteUrl");if(websiteUrl.length==1&&GXml.value(websiteUrl[0]).search(/zenbu.net.nz/)==-1){if(0&&vianet_id!=""){html+="|";} html+=""+this.translations.homepage+"";} var gis=hotspot_element.getElementsByTagName("gisCenterLatLong");if(hotspotId.length==1&&gis.length==1&&gis[0].getAttribute("lat")!=""&&gis[0].getAttribute("long")!=""){displayDiv=mainMap.getContainer();if((0&&vianet_id!="")||(websiteUrl.length==1&&GXml.value(websiteUrl[0]).search(/zenbu.net.nz/)==-1)){html+="|";} html+='Street View';} html+=']
';html+="
";return html;} HotspotsMap.prototype.createIcon=function(imageUrl,iSize,shadowUrl,sSize,iconAnchor,bubbleAnchor) {var icon=new GIcon();icon.image=imageUrl;icon.iconSize=iSize;icon.shadow=shadowUrl;icon.shadowSize=sSize;icon.iconAnchor=iconAnchor;icon.infoWindowAnchor=bubbleAnchor;return icon;} HotspotsMap.prototype.createCityBubble=function(point,icon,html) {var marker=new GMarker(point,icon);GEvent.addListener(marker,"click",function() {marker.openInfoWindowHtml(html);});GEvent.addListener(marker,"mouseover",function() {marker.openInfoWindowHtml(html);});return marker;} HotspotsMap.prototype.createInfoBubble=function(point,icon,html) {var marker=new GMarker(point,icon);GEvent.addListener(marker,"click",function() {marker.openInfoWindowHtml(html);});GEvent.addListener(marker,"mouseover",function() {marker.openInfoWindowHtml(html);});GEvent.addListener(marker,"openinfo",function() {var iwAnchor=icon.infoWindowAnchor;var iconAnchor=icon.iconAnchor;var offset=new GSize(iwAnchor.x-iconAnchor.x,iwAnchor.y-iconAnchor.y);mainMap.openInfoWindow(point,html,{pixelOffset:offset});});return marker;} HotspotsMap.prototype.openInfoBubble=function(bubbleId) {var marker=this.markers[bubbleId];var center=marker.getPoint();this.map.setCenter(center,zoneZoomLevel);GEvent.trigger(this.markers[bubbleId],"openinfo");toggleStreetMapView('map');} HotspotsMap.prototype.loadHotspotsStatus=function() {if(this.xml_source!=null){var self=this;GDownloadUrl(this.xml_source,function(data,responseCode){self.parseHotspotsStatus(GXml.parse(data));});}else{return false;}} HotspotsMap.prototype.parseHotspotsStatus=function(xml_doc) {var html_list="";var rh_city_list="";var rh_city_list_array=new Array();var down_list="";var up_markers=new Array();var display_markers=new Array();var image_extension=".png";var upIcon=this.createIcon(this.images_path+"ZonesMap/zone_up"+image_extension,new GSize(24,30),this.images_path+"ZonesMap/shadow.png",new GSize(37,34),new GPoint(10,20),new GPoint(10,1));var downIcon=this.createIcon(this.images_path+"ZonesMap/zone_down"+image_extension,new GSize(24,30),this.images_path+"ZonesMap/shadow.png",new GSize(37,34),new GPoint(10,20),new GPoint(10,1));var unknownIcon=this.createIcon(this.images_path+"ZonesMap/unknown"+image_extension,new GSize(24,30),this.images_path+"ZonesMap/blank.gif",new GSize(22,34),new GPoint(11,30),new GPoint(11,1));var hotspots=xml_doc.documentElement.getElementsByTagName("hotspot");for(var i=0;i";}else{down_list+=html+"
";} var marker=this.createInfoBubble(point,markerIcon,html);this.markers[GXml.value(hotspotId[0])]=marker;allMarkers.push(marker);var city="";var city_value="";var suburb="";var suburb_value="";var city_list_link_html=''+GXml.value(hotspots[i].getElementsByTagName("name")[0])+'';if(0&&vianet_id!=''){city_list_link_html+=' [book]';} city_list_link_html+='
';if(hotspots[i].getElementsByTagName("city").length==1){city=GXml.value(hotspots[i].getElementsByTagName("city")[0]);city_value=city.toUpperCase();} if(hotspots[i].getElementsByTagName("suburb").length==1){suburb=GXml.value(hotspots[i].getElementsByTagName("suburb")[0]);suburb_value=suburb.toUpperCase();} if(suburb_value!=""&&typeof city_list[suburb_value]!="undefined"){city_list[suburb_value]++;city_list_html[suburb_value]+=city_list_link_html;}else if(city_value!=""&&typeof city_list[city_value]!="undefined"){city_list[city_value]++;city_list_html[city_value]+=city_list_link_html;}else if(city_value!=""&&typeof city_list[city_value]=="undefined"){city_list[city_value]=1;city_gis[city_value]=point;city_list_html[city_value]=city_list_link_html;} var name=GXml.value(hotspots[i].getElementsByTagName("name")[0]);var box_info_html=""+name+"  [";if(0&&vianet_id!=''){box_info_html+='Book';} if(hotspotId.length==1&&gis.length==1&&gis[0].getAttribute("lat")!=""&&gis[0].getAttribute("long")!=""){if(0&&vianet_id!=''){box_info_html+='|';} displayDiv=mainMap.getContainer();box_info_html+='Street View|';box_info_html+='Map View';} box_info_html+=']
';var civicNumber=hotspots[i].getElementsByTagName("civicNumber");if(civicNumber.length==1){box_info_html+=GXml.value(civicNumber[0])+" ";} var streetAddress=hotspots[i].getElementsByTagName("streetAddress");if(streetAddress.length==1){box_info_html+=GXml.value(streetAddress[0])+" ";} box_info_html+="
";if(suburb_value!=""){box_info_html+=suburb;if(city_value!=""){box_info_html+=", ";}} if(city_value!=""){box_info_html+=city+"
";} var phone=hotspots[i].getElementsByTagName("contactPhoneNumber");if(phone.length==1){box_info_html+="ph: "+GXml.value(phone[0])+"  ";} var email=hotspots[i].getElementsByTagName("contactEmail");if(email.length==1){box_info_html+=""+GXml.value(email[0])+"";} zone_details_html[GXml.value(hotspotId[0])]=box_info_html;}} for(var city in city_list){if(typeof(city_list[city])!="undefined"&&typeof(city_gis[city])!="undefined"){var style='style="font-size: 0.90em; color: #888888; font-weight: 400;"';if(city_list[city]>12){style='style="font-size: 1.20em; color: #333333; font-weight: 900;"';}else if(city_list[city]>5){style='style="font-size: 1.10em; color: #444444; font-weight: 700;"';}else if(city_list[city]>2){style='style="font-size: 1.0em; color: #555555; font-weight: 600;"';}else if(city_list[city]>1){style='style="font-size: 0.90em; color: #666666; font-weight: 600;"';} city_list_str=""+city+"";city_list_str+="";city_list_str+="("+city_list[city]+")";city_list_str+="
"+city_list_html[city]+"
";rh_city_list_array.push(city_list_str+"
");label="

"+city+""+" has "+city_list[city]+" zone";if(city_list[city]>1){label+="s";} label+=".
Click here to show details.

";cityMarkers.push(this.createCityBubble(city_gis[city],upIcon,label));}} rh_city_list_array.sort();rh_city_list=rh_city_list_array.join("");markerManager=new MarkerManager(mainMap);markerManager.addMarkers(cityMarkers,0,cityIconZoomLevel);markerManager.addMarkers(allMarkers,cityIconZoomLevel+1);markerManager.refresh();html_list=rh_city_list;this.hotspots_info_list.innerHTML=html_list;} HotspotsMap.prototype.redraw=function() {this.hotspots_info_list.innerHTML=this.translations.loading;this.loadHotspotsStatus();} HotspotsMap.prototype.setHotspotsInfoList=function(hotspots_info_list) {this.hotspots_info_list=document.getElementById(hotspots_info_list);} HotspotsMap.prototype.setInitialPosition=function(lat,lng,zoom) {this.map.setCenter(new GLatLng(lat,lng),zoom);} HotspotsMap.prototype.setMapType=function(map_type) {this.map.setMapType(map_type);} HotspotsMap.prototype.setOnClickListener=function(callback_fct) {GEvent.addListener(this.map,'click',callback_fct);} HotspotsMap.prototype.setXmlSourceUrl=function(xml_source) {this.xml_source=xml_source;} if(GBrowserIsCompatible()){var geocoder=new GClientGeocoder();} function showLocationOnMap(response){if(GBrowserIsCompatible()){var point;if(!response||response.Status.code!=200){alert("The location you specified couldn't be found.\nPlease try a broader search.");}else{place=response.Placemark[0];point=new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);mainMap.setCenter(point,areaZoomLevel);toggleStreetMapView('map');}}} function showZonesAt(location){if(geocoder!=null){geocoder.getLocations(location+' New Zealand',showLocationOnMap);}} function showZonesAtPoint(lat,lng){pt=new GLatLng(parseFloat(lat),parseFloat(lng));mainMap.setCenter(pt,areaZoomLevel);}