/*
* Places script interface implemented as iMapPlot class.
* Written By: David Martin
* Copyright 2009 I.T. Beyond Pty Ltd
* Release version 2.4.6 - 2nd Sep 2009
*  
* Interface and display layer for ExplorOz Mapping System.
*/
var thisMap=null;function iMapPlot(a){thisMap=this;window.onerror="";this.currentElement=$(a);this.Map=null;this.DispProj=null;this.DataProj=null;this.FullExtent=null;this.inMove="";this.VectorLayer=null;this.VectorURL="";this.VectorSelect=null;this.VectorWalker=null;this.VectorWalkerIndex=-1;this.VectorReloadTimer=null;this.Pos=null;this.getClick=null;this.DrivingDirections=null;this.MMLoaded=false;this.apiTimeOut=0;this.loadMap()}iMapPlot.prototype.loadMap=function(){var a=this;$jq("#topolegend").hide();if(typeof OpenLayers=="undefined"){this.apiTimeOut++;if(this.apiTimeOut<30){setTimeout(function(){a.loadMap()},1000)}else{alert("There has been an error loading the mapping system - please try refresh")}return(false)}this.DataProj=new OpenLayers.Projection("EPSG:900913");this.DispProj=new OpenLayers.Projection("EPSG:4326");DispResolutions=[156543.0339,78271.51695,39135.758475,19567.8792375,9783.93961875,4891.969809375,2445.9849046875,1222.99245234375,611.496226171875,305.7481130859375,152.87405654296876,76.43702827148438,38.21851413574219,19.109257067871095,9.554628533935547,4.777314266967774,2.388657133483887,1.1943285667419434,0.5971642833709717,0.29858214168548586];this.FullExtent=new OpenLayers.Bounds(11056838.559733333,-5778405.80544,18854333.528855555,-885416.91662);OpenLayers.Control.Click=OpenLayers.Class(OpenLayers.Control,{handleRightClicks:true,defaultHandlerOptions:{single:true,"double":true,stopSingle:false,stopDouble:false},initialize:function(b){this.handlerOptions=OpenLayers.Util.extend({},this.defaultHandlerOptions);OpenLayers.Control.prototype.initialize.apply(this,arguments);this.handler=new OpenLayers.Handler.Click(this,{rightclick:this.righttrigger,click:this.trigger},this.handlerOptions)},trigger:function(b){clickpos=a.Map.getLonLatFromViewPortPx(b.xy).transform(a.DataProj,a.DispProj);if(a.inMove!==""){action=confirm("Move WaypointID: "+a.inMove+" to "+clickpos.lat+" "+clickpos.lon);if(action){$jq.ajax({type:"POST",data:"{'p':'"+a.inMove+"','lat':'"+clickpos.lat+"','lon':'"+clickpos.lon+"'}",url:BaseURL+"/iMapPlot/Services/Maps.asmx/setPosition",contentType:"application/json; charset=utf-8",dataType:"json",error:function(c){alert("Places setPosition failed...");$jq("body").css("cursor","default")},success:function(c){alert(c.d);a.inMove=""}})}else{a.inMove="";return false}return}$jq("body").css("cursor","wait");url=a.getFeatureURL()+"&x="+clickpos.lon+"&y="+clickpos.lat;a.loadVector(url,false)},righttrigger:function(b){}});options={projection:this.DataProj,displayProjection:this.DispProj,units:"m",restrictedExtent:this.FullExtent,maxExtent:this.FullExtent,resolutions:DispResolutions,controls:[]};urlArray=["http://mt0.exploroz.com/getTile.aspx","http://mt1.exploroz.com/getTile.aspx","http://mt2.exploroz.com/getTile.aspx","http://mt3.exploroz.com/getTile.aspx"];this.Map=new OpenLayers.Map(this.currentElement,options);this.Map.div.oncontextmenu=function(){return false};ovtopo=new OpenLayers.Layer.MapServer("ovtopo",urlArray,{},{buffer:0,gutter:0,maxResolution:78271.51695,minResolution:76.43702827148438,tileSize:new OpenLayers.Size(512,512)});topo=new OpenLayers.Layer.MapServer("topo",urlArray,{},{transitionEffect:"resize",buffer:0,gutter:0,maxResolution:9783.93961875,minResolution:9.554628533935547,attribution:'<img src="'+BaseURL+'/images/iMapPlot/OL_iMapPlot.gif" alt="Powered by iMapPlot" /><br /><span style="font-size:11px">Map data &copy;2008 I.T. Beyond Pty Ltd & GeoScience Australia</span>',tileSize:new OpenLayers.Size(512,512)});this.Map.addLayers([ovtopo,topo]);ovtopo.setVisibility(false);if(typeof GMap2!="undefined"){gstr=new OpenLayers.Layer.Google("gstr",{sphericalMercator:true,minZoomLevel:4,displayInLayerSwitcher:false,maxZoomLevel:18});gsat=new OpenLayers.Layer.Google("gsat",{type:G_SATELLITE_MAP,sphericalMercator:true,minZoomLevel:4,displayInLayerSwitcher:false,maxZoomLevel:18});ghyb=new OpenLayers.Layer.Google("ghyb",{type:G_HYBRID_MAP,sphericalMercator:true,minZoomLevel:4,displayInLayerSwitcher:false,maxZoomLevel:18});this.Map.addLayers([gstr,gsat,ghyb])}styleMap=new OpenLayers.StyleMap({"default":new OpenLayers.Style({graphicWidth:"${scaledSize}",graphicYOffset:"-${halfSize}",strokeColor:"${colorStroke}",strokeWidth:"${scaledStroke}",strokeDashstyle:"solid",strokeOpacity:0.9,graphicZIndex:12,externalGraphic:"http://maps.exploroz.com/images/symbols/${getSymbol}",label:"",labelAlign:"lb",fontColor:"#808080",fontFamily:"arial",fontWeight:"normal",fillColor:"#a0a0a0",fillOpacity:"${opacityFill}"},{context:{getSymbol:function(b){return b.attributes.symbol},colorStroke:function(b){if(b.geometry.CLASS_NAME=="OpenLayers.Geometry.Polygon"){return"#a0a0a0"}else{return"#4F53FF"}},opacityFill:function(b){if(b.geometry.CLASS_NAME=="OpenLayers.Geometry.Polygon"){return"0.4"}else{return"1"}},scaledSize:function(b){var c=b.layer.map.getZoom()*3;if(c<8){c=8}return c},halfSize:function(b){var c=b.layer.map.getZoom()*1.5;if(c<4){c=4}return c},scaledStroke:function(b){if(b.geometry.CLASS_NAME=="OpenLayers.Geometry.Polygon"){return 1}else{var c=b.layer.map.getZoom();if(c<2){c=2}else{if(c>4){c=4}}return c}}}}),select:new OpenLayers.Style({label:"${getTitle}",fontSize:"${scaledTitle}px",strokeColor:"${colorStroke}",fillColor:"#ee9900",fontWeight:"bold",fontColor:"black",graphicZIndex:13,externalGraphic:"http://maps.exploroz.com/images/symbols/s_${getSymbol}"},{context:{getTitle:function(b){if(b.geometry.CLASS_NAME=="OpenLayers.Geometry.Point"&&thisMap.Map.getZoom()>4){return"   "+b.attributes.title+"   "}else{return""}},scaledTitle:function(b){var c=b.layer.map.getZoom()*1.5;if(c<4){c=4}return c},getSymbol:function(b){return b.attributes.symbol},colorStroke:function(b){if(b.geometry.CLASS_NAME=="OpenLayers.Geometry.Polygon"){return"#ee9900"}else{return"#90EE90"}}}})});this.VectorLayer=new OpenLayers.Layer.Vector("VectorLayer",{styleMap:styleMap,displayInLayerSwitcher:false,rendererOptions:{zIndexing:true}});this.Map.addLayers([this.VectorLayer]);this.VectorSelect=new OpenLayers.Control.SelectFeature(this.VectorLayer,{onSelect:OpenLayers.Function.bind(this.onVectorSelect,this)});this.Map.addControl(this.VectorSelect);cont=new OpenLayers.Layer.MapServer("cont",urlArray,{tt:1},{visibility:$jq("#mo_cont").is(":checked"),isBaseLayer:false,transitionEffect:"resize",opacity:0.5,buffer:0,gutter:0,maxResolution:1222.99245234375,minResolution:0.5971642833709717,tileSize:new OpenLayers.Size(512,512)});leot=new OpenLayers.Layer.MapServer("treks",urlArray,{tt:2},{visibility:$jq("#mo_treks").is(":checked"),isBaseLayer:false,transitionEffect:"resize",buffer:0,gutter:0,tileSize:new OpenLayers.Size(1024,1024),opacity:0.8});leor=new OpenLayers.Layer.WMS("roadc","http://www.exploroz.com/cgi-bin/mapserver/mapserv.exe?map=e:\\inetpub\\vs153145\\iMapPlot\\map\\Roads\\NationalTile.map",{layers:"R_Cond",format:"png",transparent:"true"},{visibility:$jq("#mo_roadc").is(":checked"),isBaseLayer:false,singleTile:true});geog=new OpenLayers.Layer.WMS("geog","http://maps.exploroz.com/cgi-bin/mapserver/mapserv.exe?map=e:\\inetpub\\vs153148\\MapServer\\map\\Places\\geog.map",{layers:"all",format:"gif",transparent:"true"},{visibility:$jq("#mo_geog").is(":checked"),isBaseLayer:false,singleTile:true,opacity:0.8});resv=new OpenLayers.Layer.WMS("resv","http://maps.exploroz.com/cgi-bin/mapserver/mapserv.exe?map=e:\\inetpub\\vs153148\\MapServer\\map\\Places\\resv.map",{layers:"all",format:"gif",transparent:"true"},{visibility:$jq("#mo_resv").is(":checked"),isBaseLayer:false,singleTile:true,opacity:0.8});recr=new OpenLayers.Layer.WMS("recr","http://maps.exploroz.com/cgi-bin/mapserver/mapserv.exe?map=e:\\inetpub\\vs153148\\MapServer\\map\\Places\\recr.map",{layers:"all",format:"gif",transparent:"true"},{visibility:$jq("#mo_recr").is(":checked"),isBaseLayer:false,singleTile:true,opacity:0.8});infr=new OpenLayers.Layer.WMS("infr","http://maps.exploroz.com/cgi-bin/mapserver/mapserv.exe?map=e:\\inetpub\\vs153148\\MapServer\\map\\Places\\infr.map",{layers:"all",format:"gif",transparent:"true"},{visibility:$jq("#mo_infr").is(":checked"),isBaseLayer:false,singleTile:true,opacity:0.8});heri=new OpenLayers.Layer.WMS("heri","http://maps.exploroz.com/cgi-bin/mapserver/mapserv.exe?map=e:\\inetpub\\vs153148\\MapServer\\map\\Places\\heri.map",{layers:"all",format:"gif",transparent:"true"},{visibility:$jq("#mo_heri").is(":checked"),isBaseLayer:false,singleTile:true,opacity:0.8});serv=new OpenLayers.Layer.WMS("serv","http://maps.exploroz.com/cgi-bin/mapserver/mapserv.exe?map=e:\\inetpub\\vs153148\\MapServer\\map\\Places\\serv.map",{layers:"all",format:"gif",transparent:"true"},{visibility:$jq("#mo_serv").is(":checked"),isBaseLayer:false,singleTile:true,opacity:0.8});acom=new OpenLayers.Layer.WMS("acom","http://maps.exploroz.com/cgi-bin/mapserver/mapserv.exe?map=e:\\inetpub\\vs153148\\MapServer\\map\\Places\\acom.map",{layers:"all",format:"gif",transparent:"true"},{visibility:$jq("#mo_acom").is(":checked"),isBaseLayer:false,singleTile:true,opacity:0.8});popu=new OpenLayers.Layer.WMS("popu","http://maps.exploroz.com/cgi-bin/mapserver/mapserv.exe?map=e:\\inetpub\\vs153148\\MapServer\\map\\Places\\popu.map",{layers:"all",format:"gif",transparent:"true"},{visibility:$jq("#mo_popu").is(":checked"),isBaseLayer:false,singleTile:true,opacity:0.8});eotm=new OpenLayers.Layer.WMS("eotm","http://maps.exploroz.com/cgi-bin/mapserver/mapserv.exe?map=e:\\inetpub\\vs153148\\MapServer\\map\\Places\\eotm.map",{layers:"all",format:"gif",transparent:"true"},{visibility:$jq("#mo_eotm").is(":checked"),isBaseLayer:false,singleTile:true,opacity:0.8});late=new OpenLayers.Layer.WMS("late","http://maps.exploroz.com/cgi-bin/mapserver/mapserv.exe?map=e:\\inetpub\\vs153148\\MapServer\\map\\Places\\latest.map",{layers:"all",format:"gif",transparent:"true"},{visibility:$jq("#l_latest").is(":checked"),isBaseLayer:false,singleTile:true,opacity:0.8});temp=new OpenLayers.Layer.WMS("temp","http://maps.exploroz.com/cgi-bin/mapserver/mapserv.exe?map=e:\\inetpub\\vs153148\\MapServer\\map\\Places\\temp.map",{layers:"all",format:"gif",transparent:"true"},{visibility:false,isBaseLayer:false,singleTile:true,displayInLayerSwitcher:false});this.Map.addLayers([cont,leot,leor,geog,resv,recr,infr,heri,serv,acom,popu,eotm,late,temp]);this.Map.addControl(new OpenLayers.Control.Navigation({zoomWheelEnabled:false,handleRightClicks:true}));this.Map.addControl(new OpenLayers.Control.MousePosition({div:OpenLayers.Util.getElement("olctl_mp")}));this.Map.addControl(new OpenLayers.Control.ScaleLine());lyst=new OpenLayers.Control.Scale();lyst.div=OpenLayers.Util.getElement("olctl_st");this.Map.addControl(lyst);this.Map.addControl(new OpenLayers.Control.Attribution());ovmapOptions={projection:this.DataProj,displayProjection:this.DispProj,units:"m",restrictedExtent:this.FullExtent,maxExtent:this.FullExtent,resolutions:DispResolutions,minRatio:4,maxRatio:16};lyov=new OpenLayers.Control.OverviewMap({size:new OpenLayers.Size(213,108),div:OpenLayers.Util.getElement("ctl_ov_i"),mapOptions:ovmapOptions});this.Map.addControl(lyov);this.setBaseLayer("topo");this.Map.events.register("changebaselayer",null,function(){a.updateZoomBar();a.restoreMap()});this.Map.events.register("zoomend",null,function(){a.restoreMap();a.updateZoomBar()});this.resetMap();this.getClick=new OpenLayers.Control.Click();this.Map.addControl(this.getClick);this.getClick.activate();this.VectorSelect.activate();$jq("#Reload").hide();this.updateZoomBar()};iMapPlot.prototype.getFeatureURL=function(){var b,a,d,c;lstr="";olays=this.Map.getLayersBy("isBaseLayer",false);for(b=0;b<olays.length;b++){if(olays[b].visibility&&olays[b].displayInLayerSwitcher){lstr+=olays[b].name+"|"}}if(lstr.length>0){poistr="&poistr="+lstr}else{poistr=""}a=this.Map.getZoom();if(a>10){a=10}d=parseInt((10-a)*5,10);if(d===0){d=1}c=BaseURL+"/iMapPlot/Services/getFeatureatPos.aspx?d="+d+poistr;if($jq("#mo_cadd").is(":checked")){c+="&n=true"}return c};iMapPlot.prototype.changeOverlay=function(a){var b;visible=false;if($jq("#mo_"+a).is(":checked")){visible=true}for(b=0;b<this.Map.layers.length;b++){if(this.Map.layers[b].name==a){this.Map.layers[b].setVisibility(visible)}}};iMapPlot.prototype.updateZoomBar=function(){$jq("#olctl_zoombar").slider("option","max",this.Map.getNumZoomLevels()-1);$jq("#olctl_zoombar").slider("option","value",this.Map.getZoom());$jq("#olctl .ui-slider-handle").css("text-align","center").text(this.Map.getZoom())};iMapPlot.prototype.setBaseLayer=function(b){var a;$jq("#olctl_ls a").removeClass("ui-state-active");$jq("#ml_"+b).addClass("ui-state-active");for(a=0;a<this.Map.layers.length;a++){if(this.Map.layers[a].name==b){this.Map.setBaseLayer(this.Map.layers[a],false)}}};iMapPlot.prototype.reloadVector=function(b,c,a){var d=this;currentfrequency=$jq("#lt_speed").slider("option","value")*60;if(currentfrequency==0){$jq("#lt_count").text("0");$jq("#tl_refresh").addClass("ui-state-disabled")}else{$jq("#tl_refresh").removeClass("ui-state-disabled");currenttimeout=parseInt($jq("#lt_count").text());if(currenttimeout==currentfrequency){d.loadVector(b,c,a)}if(currenttimeout<=0){d.VectorLayer.destroyFeatures();d.loadVector(b,c,a);currenttimeout=$jq("#lt_speed").slider("option","value")*60;$jq("#lt_count").text(currenttimeout)}$jq("#lt_count").text(currenttimeout-1)}this.VectorReloadTimer=window.setTimeout(function(){d.reloadVector(b,c,a)},1000)};iMapPlot.prototype.reloadVector_restart=function(){$jq("#lt_count").text("0")};iMapPlot.prototype.loadVector=function(b,c,a){var d=this;if(!a){a=-1}this.VectorURL=b;if(c){$jq("#Reload").show()}this.WalkVectors_Stop();this.VectorLayer.events.triggerEvent("loadstart");$jq.ajax({type:"GET",url:this.VectorURL,complete:function(e){d.onVectorLoadSuccess(e,a)},error:function(){d.onVectorLoadFailure()}});this.VectorLoaded=true};iMapPlot.prototype.unSelectVectors=function(){this.VectorSelect.unselectAll()};iMapPlot.prototype.WalkVectors_Stop=function(){this.restoreMap();clearTimeout(this.VectorWalker);$jq("#mm_btns button").removeClass("ui-state-active");$jq("#mm_stop").addClass("ui-state-active")};iMapPlot.prototype.WalkVectors_Play=function(){this.restoreMap();this.WalkVectorsLoop(this.VectorWalkerIndex+=1);$jq("#mm_btns button").removeClass("ui-state-active");$jq("#mm_play").addClass("ui-state-active");this.Map.zoomTo(this.getMaxFeatureZoom())};iMapPlot.prototype.WalkVectors_Next=function(){this.WalkVectors_Stop();this.VectorWalkerIndex+=1;this.selectVector(this.VectorWalkerIndex)};iMapPlot.prototype.WalkVectors_Prev=function(){this.WalkVectors_Stop();this.VectorWalkerIndex-=1;this.selectVector(this.VectorWalkerIndex)};iMapPlot.prototype.WalkVectors_First=function(){this.WalkVectors_Stop();this.VectorWalkerIndex=0;this.selectVector(this.VectorWalkerIndex)};iMapPlot.prototype.WalkVectors_Last=function(){this.WalkVectors_Stop();this.VectorWalkerIndex=this.VectorLayer.features.length-1;this.selectVector(this.VectorWalkerIndex)};iMapPlot.prototype.showControl=function(a){$jq("#"+a).show("slow");$jq("#ctl_ov a").show()};iMapPlot.prototype.WalkVectors=function(){this.WalkVectors_Stop();this.showControl("ctl_mm");this.VectorWalkerIndex=-1;this.WalkVectors_Play()};iMapPlot.prototype.WalkVectorsLoop=function(a){var b=this;if(this.VectorLayer.features.length==1){return true}if(a<this.VectorLayer.features.length){this.selectVector(a);this.VectorWalkerIndex=a;this.VectorWalker=window.setTimeout(function(){b.WalkVectorsLoop(a+=1)},$jq("#mm_speed").slider("option","value")*1000)}else{this.WalkVectors_Stop()}};iMapPlot.prototype.selectVector=function(a){if(a<0){this.VectorWalkerIndex=0;return}if(a>=this.VectorLayer.features.length){this.VectorWalkerIndex=this.VectorLayer.features.length;return}this.unSelectVectors();this.VectorSelect.select(this.VectorLayer.features[a]);this.Map.panTo(this.VectorLayer.features[a].geometry.getBounds().getCenterLonLat())};iMapPlot.prototype.replaceVector=function(a){this.VectorLayer.removeFeatures(this.VectorLayer.features[this.VectorLayer.features.length-1]);var b=this.getFeatureURL()+"&p="+a;$jq("body").css("cursor","wait");this.loadVector(b,false)};iMapPlot.prototype.clearVectors=function(){this.VectorLayer.removeFeatures()};iMapPlot.prototype.onVectorLoadSuccess=function(c,a){var b;if(c.responseText===""){alert("No result found - please adjust your entry and try again")}else{features=new OpenLayers.Format.GeoRSS({featureTitle:"",featureDescription:"",internalProjection:this.DataProj,externalProjection:this.DispProj,createFeatureFromItem:function(d){feature=OpenLayers.Format.GeoRSS.prototype.createFeatureFromItem.apply(this,arguments);feature.attributes.symbol=this.getChildValue(d,"*","symbol");feature.attributes.image=this.getChildValue(d,"*","image");feature.attributes.fulldesc=this.getChildValue(d,"*","fulldesc");feature.attributes.altitude=this.getChildValue(d,"*","altitude");feature.attributes.group=this.getChildValue(d,"*","group");feature.attributes.gid=this.getChildValue(d,"*","gid");feature.attributes.length=this.getChildValue(d,"*","length");feature.attributes.traveltime=this.getChildValue(d,"*","traveltime");feature.attributes.traveltimestr=this.getChildValue(d,"*","traveltimestr");feature.attributes.direction=this.getChildValue(d,"*","direction");titem=this.getElementsByTagNameNS(d,"*","treks");if(titem[0]){feature.attributes.treks="";for(b=0;b<titem[0].childNodes.length;b++){feature.attributes.treks+=titem[0].childNodes[b].nodeValue}}return feature}}).read(c.responseText);if(features.length>0){this.unSelectVectors();this.VectorLayer.addFeatures(features);if(a>-1){this.Map.zoomTo(a)}if(features.length==1){if(features[0].geometry.CLASS_NAME=="OpenLayers.Geometry.Point"){this.Map.setCenter(features[0].geometry.getBounds().getCenterLonLat())}else{this.Map.zoomToExtent(features[0].geometry.bounds)}this.VectorSelect.select(this.VectorLayer.features[this.VectorLayer.features.length-1])}else{if(features[0].fid.substring(0,1)=="L"){this.Map.zoomToExtent(this.VectorLayer.getDataExtent());this.VectorSelect.select(this.VectorLayer.features[this.VectorLayer.features.length-1]);this.showControl("ctl_lt")}else{this.Map.zoomToExtent(this.VectorLayer.getDataExtent());this.showControl("ctl_mm")}}}}$jq("#Reload").hide();$jq("body").css("cursor","default");this.VectorLayer.events.triggerEvent("loadend")};iMapPlot.prototype.onVectorLoadFailure=function(a){OpenLayers.Console.userError(OpenLayers.i18n("errorLoadingVectorData",{url:this.VectorURL}));$jq("#Reload").hide();this.VectorLayer.events.triggerEvent("loadend")};iMapPlot.prototype.onVectorSelect=function(b){var a,c=b.geometry.getBounds().getCenterLonLat().clone().transform(thisMap.DataProj,thisMap.DispProj);if(b.attributes.title===""&&b.attributes.treks!==undefined){content=b.attributes.treks}else{content="<h5>Your Selection:</h5>";if(b.attributes.symbol){content+='<img class="poiimg" src="http://maps.exploroz.com/images/symbols/'+b.attributes.symbol.replace(".","-16.")+'" title="'+b.attributes.symbol.replace(".gif","")+'" />'}if(b.attributes.link&&b.attributes.link!==null){content+='<h1><a href="javascript:void(0);" onclick="theMap.showPlace(\''+b.id+"');\">"+b.attributes.title+"</a></h1>"}else{if(b.geometry.CLASS_NAME=="OpenLayers.Geometry.LineString"&&b.attributes.title.indexOf(" to ")>-1){c=b.attributes.title.indexOf(" to ");content+="<b>From:</b> "+b.attributes.title.substr(0,c)+"<br />";content+="<b>To:</b> "+b.attributes.title.substr(c+4)+""}else{content+="<h1>"+b.attributes.title+"</h1>"}}if(b.geometry.CLASS_NAME=="OpenLayers.Geometry.Point"){content+='<div style="clear:both"></div>Pos: '+c.lat.toFixed(5)+" "+c.lon.toFixed(5);if(b.attributes.altitude){content+=" &nbsp;Alt: "+b.attributes.altitude+"m"}thePlace=b.attributes.title.replace("'","'")+"@"+c.lat+","+c.lon;content+="<br />Get Directions: <a href=\"javascript:void(0)\" onclick=\"$jq('#FromAddress').val('"+thePlace+"').focus();$jq('#ctl_d').show('slow');\">From Here</a> | ";content+="<a href=\"javascript:void(0)\" onclick=\"$jq('#ToAddress').val('"+thePlace+"').focus();$jq('#ctl_d').show('slow');\">To Here</a>";if(!b.attributes.image){b.attributes.image="http://maps.google.com/staticmap?center="+c.lat+","+c.lon+"&zoom=15&size=180x150&maptype=hybrid&key="+googlekey+"&sensor=false"}}if(b.geometry.CLASS_NAME=="OpenLayers.Geometry.LineString"&&!b.attributes.image){pointstr="";numpoints=39;if(b.geometry.components.length<=numpoints){numpoints=b.geometry.components.length}dbpt=b.geometry.getLength()/numpoints;for(a=0;a<numpoints;a++){point=b.geometry.GetPointAtDistance(a*dbpt).transform(this.DataProj,this.DispProj);pointstr+=point.y.toFixed(5)+","+point.x.toFixed(5)+"|"}pnt1=b.geometry.components[b.geometry.components.length-1];thePoint=new OpenLayers.Geometry.Point(pnt1.x,pnt1.y).transform(this.DataProj,this.DispProj);pointstr+=thePoint.y.toFixed(5)+","+thePoint.x.toFixed(5);b.attributes.image="http://maps.google.com/staticmap?path=rgba:0x90ee90ff,weight:2|"+pointstr+"&size=180x150&maptype=satellite&key="+googlekey+"&sensor=false"}if(b.attributes.image){content+='<img src="'+b.attributes.image+'" style="padding:2px 4px;" /><br />'}if(b.attributes.description){content+=b.attributes.description+"<br />"}if(b.geometry.CLASS_NAME=="OpenLayers.Geometry.LineString"){content+="<b>Distance:</b> "+Math.round(b.attributes.length*100)/100+" km<br />";content+="<b>Direction: </b> "+Math.round(b.attributes.direction)+" &deg;<br />";if(b.attributes.traveltime>0){content+="<b>Average Speed: </b> "+Math.round(parseFloat(b.attributes.length/b.attributes.traveltime*100))/100+" km/hr<br />";content+="<b>Travel Time: </b> "+b.attributes.traveltimestr+"<br />"}}if(b.geometry.CLASS_NAME=="OpenLayers.Geometry.Polygon"){content+='<div class="ictl">'}if(b.geometry.CLASS_NAME=="OpenLayers.Geometry.Point"){if(b.attributes.link){content+=' <a href="javascript:void(0);" onclick="theMap.showPlace(\''+b.id+"');\">more</a>"}content+='<div class="ictl">';if(b.fid.substr(0,1)=="P"){content+='<a href="javascript:void(0)" onclick="WindowPreview(\''+BaseURL+"/Places/Admin/Maint.aspx?wm=1&p="+b.fid.replace("P","")+'\', 800,800);"><img src="//maps.exploroz.com/images/icons/Edit16.gif" title="Edit Place" /> Edit Place</a><br />'}else{if(b.fid.substr(0,1)=="M"){content+='<a href="javascript:void(0)" onclick="WindowPreview(\''+BaseURL+"/Places/Admin/Maint.aspx?wm=1&n=1&p="+b.fid.replace("P","")+'\', 800,800);"><img src="//maps.exploroz.com/images/icons/Edit16.gif" title="Add Place" /> Add New Place</a><br />'}}content+='<a href="javascript:void(0)" onclick="thisMap.zoomFeature(\''+b.id+'\')"><img src="//maps.exploroz.com/images/icons/Zoom16.gif" title="Zoom Place" /> Zoom Place</a><br />';if(b.fid.substr(0,1)!="L"){content+='<a href="javascript:void(0)" onclick="thisMap.downloadFeatures(\''+b.fid+'\')"><img src="//maps.exploroz.com/images/icons/Download16.gif" title="Download" /> Download Place</a><br />'}}if(b.geometry.CLASS_NAME=="OpenLayers.Geometry.LineString"){content+='<div class="ictl">';if(b.geometry.CLASS_NAME=="OpenLayers.Geometry.LineString"&&b.attributes.fulldesc){content+='<a href="javascript:void(0)" onclick="thisMap.toggleRoute(\''+b.id+'\');" ><img src="//maps.exploroz.com/images/icons/Notes16.gif" title="Driving Notes" /> <span class="routebtn">Driving Notes</span></a><br />'}content+='<a href="javascript:void(0)" onclick="thisMap.toggleProfile(\''+b.id+'\');"><img src="//maps.exploroz.com/images/icons/Profile16.gif" title="Altitude Profile" /> <span class="profilebtn">Altitude Profile</span></a><br />';content+='<a href="javascript:void(0)" onclick="thisMap.zoomFeature(\''+b.id+'\')"><img src="//maps.exploroz.com/images/icons/Zoom16.gif" title="Zoom Place" /> Zoom Route</a><br />';if(b.fid.substr(0,1)!="L"){content+='<a href="javascript:void(0)" onclick="thisMap.downloadFeatures(\''+b.fid+'\')"><img src="//maps.exploroz.com/images/icons/Download16.gif" title="Download" /> Download Route</a><br />'}}fbounds=new OpenLayers.Bounds();fbounds=b.geometry.getBounds().clone();fbounds.transform(thisMap.DataProj,thisMap.DispProj);content+='<a href="'+BaseURL+"/Shop/AllItems.aspx?me="+fbounds.left+"+"+fbounds.right+"+"+fbounds.bottom+"+"+fbounds.top+'"><img src="//maps.exploroz.com/images/icons/Cart16.gif" title="Maps &amp; Books" /> Maps &amp; Books</a>';content+="</div>";if(typeof userisPlaceAdmin!="undefined"&&userisPlaceAdmin&&b.fid!==""&&b.fid.substr(0,1)!="L"){if(b.geometry.CLASS_NAME=="OpenLayers.Geometry.Point"){content+='Administration: <a href="javascript:void(0);" onclick="thisMap.inMove = '+b.fid.replace("P","")+';;">Move</a>';content+=' | <a href="javascript:void(0);" onclick="thisMap.delPlace(\''+b.fid+"');\">Delete</a>"}if(b.geometry.CLASS_NAME=="OpenLayers.Geometry.LineString"){if(b.attributes.length){content+='Administration: <a href="javascript:void(0);" onclick="thisMap.saveRoute(\''+b.id+"');\">Save</a>"}}}if(b.attributes.treks){content+=b.attributes.treks}}for(a=0;a<this.VectorLayer.features.length;a++){if(this.VectorLayer.features[a].id==b.id){this.VectorWalkerIndex=a}}if(!b.attributes.gid){content+='<img class="selctl" onclick="thisMap.clearFeature(\''+b.id+'\')" src="//maps.exploroz.com/images/icons/Delete16.gif" title="Clear" />'}$jq("#geoinfo").html(content);jqinit();this.hideTemplayer();this.restoreMap()};iMapPlot.prototype.clearHighlight=function(){$jq("#geoinfo div").removeClass("fhlight");$jq("#geoinfo div .fzoom").remove();this.Map.getLayersByName("temp")[0].setVisibility(false)};iMapPlot.prototype.featureHighlight=function(c,b){var a=this;if($jq("#"+c+b).hasClass("fhlight")){return true}this.clearHighlight();tempLayer=this.Map.getLayersByName("temp")[0];switch(c){case"eo":tempLayer.params.LAYERS="ExplorOz_H";tempLayer.params.TrekID=b;break;case"ut":tempLayer.params.LAYERS="User_H";tempLayer.params.PlotID=b;break;case"pl":tempLayer.params.LAYERS="Latest_H";tempLayer.params.PlaceID=b;break;case"tp":tempLayer.params.LAYERS="EOTrackMe_H";tempLayer.params.TrackingID=b;break}tempLayer.setVisibility(true);$jq("#"+c+b).addClass("fhlight").attr("title","View on map").append('<img class="fzoom" src="//maps.exploroz.com/images/icons/Zoom13.gif" title="Click to zoom" />');$jq(".fzoom").click(function(d){d.stopPropagation();a.ctr=a.Map.getCenter();a.zl=a.Map.getZoom();a.zoomFeatureExtent(c,b)});$jq(".fzoom").mouseout(function(d){a.Map.setCenter(a.ctr,a.zl)});tempLayer.redraw()};iMapPlot.prototype.hideTemplayer=function(){this.Map.getLayersByName("temp")[0].setVisibility(false)};iMapPlot.prototype.clearFeature=function(a){if(a){feature=this.VectorLayer.getFeatureById(a);this.VectorLayer.removeFeatures(feature)}else{this.VectorLayer.destroyFeatures()}if(this.VectorLayer.features.length>0){this.VectorSelect.select(this.VectorLayer.features[this.VectorLayer.features.length-1])}else{$jq("#geoinfo").html(basegeoinfo);if(this.Map.getZoom()==0){thisMap.restoreMap()}this.Map.zoomToExtent(this.FullExtent)}};iMapPlot.prototype.clearGroup=function(a){for(i=0;i<this.VectorLayer.features.length;i++){feature=this.VectorLayer.features[i];if(feature.attributes.gid==a){this.VectorLayer.removeFeatures(feature);i--}}if(this.VectorLayer.features.length>0){this.VectorSelect.select(this.VectorLayer.features[this.VectorLayer.features.length-1])}else{$jq("#geoinfo").html(basegeoinfo);if(this.Map.getZoom()==0){thisMap.restoreMap()}this.Map.zoomToExtent(this.FullExtent)}};iMapPlot.prototype.zoomFeature=function(a){feature=this.VectorLayer.getFeatureById(a);if(feature.geometry.CLASS_NAME=="OpenLayers.Geometry.Point"){this.Map.setCenter(feature.geometry.getBounds().getCenterLonLat(),8)}else{this.Map.zoomToExtent(feature.geometry.bounds)}};iMapPlot.prototype.zoomGroup=function(a){gbounds=new OpenLayers.Bounds();for(i=0;i<this.VectorLayer.features.length;i++){feature=this.VectorLayer.features[i];if(feature.attributes.gid==a){gbounds.extend(feature.geometry.bounds)}}this.Map.zoomToExtent(gbounds)};iMapPlot.prototype.IOFormats=function(){io_options={internalProjection:this.DataProj,externalProjection:this.DispProj};gmlOptions={featureType:"feature",featureNS:"http://www.exploroz.com/places"};gmlIOOptions=OpenLayers.Util.extend(OpenLayers.Util.extend({},gmlOptions),io_options);this.IOformats={wkt:new OpenLayers.Format.WKT(io_options),geojson:new OpenLayers.Format.GeoJSON(io_options),georss:new OpenLayers.Format.GeoRSS(gmlIOOptions),gml3:new OpenLayers.Format.GML.v3(gmlIOOptions),kml:new OpenLayers.Format.KML(io_options),gpx:new OpenLayers.Format.GPX(io_options)}};iMapPlot.prototype.downloadFeatures=function(a){$jq("#ctl_dn").toggle("slow");$jq("#ctl_dn .download").unbind().click(function(){alert("Downloading is for Members Only\nGo to Members in the menu above for further information.");$jq("#ctl_dn").hide("slow")})};iMapPlot.prototype.uploadFeatures=function(){var a=this;$jq("#ctl_up").toggle("slow");if($jq("#ctl_up_fileUploader").length==0){jqc=BaseURL+"/scripts/jQuery/Components/";jqi=BaseURL+"/scripts/jQuery/images/";$jq("#ctl_up_file").uploadify({uploader:jqc+"uploadify.swf",script:jqc+"Uploadify.ashx",auto:true,fileDesc:"GPX Files",fileExt:"*.gpx",folder:BaseURL+"/uploads/temp",rollover:true,width:54,height:17,buttonImg:jqi+"Up_SelectFile.gif",cancelImg:jqi+"cancel.png",onComplete:function(f,h,b,c,g){a.loadVector(BaseURL+"/iMapPlot/Services/getGPXFile.aspx?f="+b.filePath,true);return true}})}};iMapPlot.prototype.saveRoute=function(a){feature=this.VectorLayer.getFeatureById(a);if(feature.geometry.CLASS_NAME=="OpenLayers.Geometry.LineString"){theLine=feature.geometry.clone();$jq.ajax({type:"POST",data:"{'l':'"+feature.attributes.length+"','tt':'"+feature.attributes.traveltime+"','ls':'"+theLine.transform(this.DataProj,this.DispProj)+"','a':'"+feature.attributes.altitude+"'}",url:BaseURL+"/iMapPlot/Services/Maps.asmx/updRoute",contentType:"application/json; charset=utf-8",dataType:"json",error:function(b){alert("An error has occured please try again!")},success:function(b){alert(b.d)}})}};iMapPlot.prototype.getMaxFeatureZoom=function(){var a,b=20;for(a=0;a<this.VectorLayer.features.length;a++){feature=this.VectorLayer.features[a];if(feature.geometry.CLASS_NAME=="OpenLayers.Geometry.LineString"){Zoom=this.Map.getZoomForExtent(feature.geometry.getBounds());if(Zoom<b){b=Zoom}}}return b};iMapPlot.prototype.showPlace=function(a){feature=this.VectorLayer.getFeatureById(a);if(!feature.attributes.fulldesc){$jq(".mappanel *").css("cursor","wait");$jq.ajax({type:"POST",data:"{'p':'"+feature.fid.replace("P","")+"'}",url:BaseURL+"/iMapPlot/Services/Maps.asmx/getPlace",contentType:"application/json; charset=utf-8",dataType:"json",error:function(b){alert("An error has occured please try again!")},success:function(b){feature.attributes.fulldesc=b.d;$jq("#map_alt").html(feature.attributes.fulldesc);$jq("#map_alt_pan").show("slow");$jq(".mappanel *").css("cursor","default")}})}else{$jq("#map_alt").html(feature.attributes.fulldesc);$jq("#map_alt_pan").show("slow")}};iMapPlot.prototype.getFeaturebyFID=function(a){for(i=0;i<this.VectorLayer.features.length;i++){feature=this.VectorLayer.features[i];if(feature.fid==a){return feature}}return null};iMapPlot.prototype.showPlaceReady=function(a){feature=this.getFeaturebyFID("P"+a);jqinit();if(feature){pos=feature.geometry.getBounds().getCenterLonLat().clone().transform(thisMap.DataProj,thisMap.DispProj);$jq("#sat_zoombar").slider({min:10,max:20,value:15,animate:true,slide:function(c,b){$jq("#sat_zoombar .ui-slider-handle").css("text-align","center").text(parseInt(b.value-4));$jq("#satimg").attr("src","http://maps.google.com/staticmap?center="+pos.lat+","+pos.lon+"&zoom="+b.value+"&size=180x150&maptype=satellite&key="+googlekey+"&sensor=false");$jq("#satlink").attr("href","http://maps.google.com/staticmap?center="+pos.lat+","+pos.lon+"&zoom="+parseInt(b.value+1)+"&size=800x600&maptype=satellite&key="+googlekey+"&sensor=false")}});$jq("#sat_zoombar .ui-slider-handle").css("text-align","center").text("11");if(typeof userisRegistered!="undefined"&&userisRegistered){$jq(".edit").editable(BaseURL+"/iMapPlot/Services/Maps.asmx/updPlaceItem",{indicator:"Saving...",event:"edit",loadurl:BaseURL+"/iMapPlot/Services/Maps.asmx/getPlaceItem",height:16,submitdata:{p:a},loaddata:{p:a},loadtype:"POST"});$jq(".editarea").editable(BaseURL+"/iMapPlot/Services/Maps.asmx/updPlaceItem",{indicator:"Saving...",event:"edit",loadurl:BaseURL+"/iMapPlot/Services/Maps.asmx/getPlaceItem",type:"textarea",cancel:"Cancel",submit:"Ok",rows:10,submitdata:{p:a},loaddata:{p:a},loadtype:"POST"});$jq(".edit_trigger").bind("click",function(){$jq(this).prev().trigger("edit")}).css({"float":"right","font-size":"9px"})}}};iMapPlot.prototype.delPlace=function(a){action=confirm("Delete PlaceID: "+a.replace("P","")+"\nAre you sure?");if(action){$jq.ajax({type:"POST",data:"{'p':'"+a.replace("P","")+"'}",url:BaseURL+"/iMapPlot/Services/Maps.asmx/delPlace",contentType:"application/json; charset=utf-8",dataType:"json",error:function(b){alert("Place delete failed...")},success:function(b){alert(b.d)}})}};iMapPlot.prototype.viewFeatures=function(){var f,c,b,e,d=[],a="";if($jq("#map_alt").html().indexOf("My Plans")==-1){$jq("#map_alt").html('<h3>My Plans <img class="help" onclick="getKeyword(\'B1296\', true)" onmouseout="UnTip()" src="'+BaseURL+'/images/icons/Help-12.gif" title="Click for help" alt="Help" /></h3><ul>');f:for(c=0;c<this.VectorLayer.features.length;c++){for(b=0,e=d.length;b<e;b++){if(d[b]==this.VectorLayer.features[c].attributes.group){continue f}}d[d.length]=this.VectorLayer.features[c].attributes.group;if(this.VectorLayer.features[c].attributes.gid){a+=this.VectorLayer.features[c].attributes.gid+"|";$jq("#map_alt").append('<li class="mp">'+this.VectorLayer.features[c].attributes.group+'<div><a href="javascript:void(0)" onclick="thisMap.zoomGroup(\''+this.VectorLayer.features[c].attributes.gid+'\');thisMap.restoreMap();"><img src="//maps.exploroz.com/images/icons/View16.gif" title="View" /></a> <a href="javascript:void(0)" onclick="thisMap.clearGroup(\''+this.VectorLayer.features[c].attributes.gid+'\');thisMap.viewFeatures();"><img src="//maps.exploroz.com/images/icons/Delete16.gif" title="Delete" /></a></div></li>')}else{a+=this.VectorLayer.features[c].fid+"|";$jq("#map_alt").append('<li class="mp">'+this.VectorLayer.features[c].attributes.group+'<div><a href="javascript:void(0)" onclick="thisMap.selectVector('+c+')"><img src="//maps.exploroz.com/images/icons/View16.gif" title="View" /></a> <a href="javascript:void(0)" onclick="thisMap.clearFeature(\''+this.VectorLayer.features[c].id+'\');thisMap.viewFeatures();"><img src="//maps.exploroz.com/images/icons/Delete16.gif" title="Delete" /></a></div></li>')}}$jq("#map_alt").append("</ul>");tools='<div class="ictl">';if(a!==""){tools+='<a href="javascript:void(0)" onclick="thisMap.downloadFeatures(\''+a.replace(new RegExp("[|]+$","g"),"")+'\')"><img src="//maps.exploroz.com/images/icons/Download16.gif" title="Download" /> Download My Plans</a><br />'}if(typeof userisPlaceAdmin!="undefined"&&userisPlaceAdmin){tools+='<a href="javascript:void(0)" onclick="thisMap.uploadFeatures()"><img src="//maps.exploroz.com/images/icons/Upload16.gif" title="Upload" /> Upload Data</a><br />'}$jq("#map_alt").append(tools+"</div>");$jq("#map_alt_pan").show("slow");jqinit()}else{this.restoreMap()}};iMapPlot.prototype.toggleRoute=function(a){if($jq(".routebtn").text()=="Driving Notes"){this.restoreMap();$jq(".routebtn").text("Show Map");feature=this.VectorLayer.getFeatureById(a);fulldesc="<h3>Driving Notes</h3><h4>"+feature.attributes.title+"</h3>";fulldesc+=feature.attributes.fulldesc;$jq("#map_alt").html(fulldesc);$jq("#map_alt_pan").show("slow");jqinit()}else{this.restoreMap()}};iMapPlot.prototype.restoreMap=function(){$jq(".olctl_pan").hide("slow");$jq(".profilebtn").text("Altitude Profile");$jq(".routebtn").text("Driving Notes");$jq("#map_alt_pan").hide("slow");$jq("#map_alt").html("")};iMapPlot.prototype.toggleProfile=function(c){var a,b=this;if($jq(".profilebtn").text()=="Altitude Profile"){this.restoreMap();$jq(".profilebtn").text("Show Map");this.feature=this.VectorLayer.getFeatureById(c);this.maxNodes=50;this.dbp=this.feature.geometry.getLength()/this.maxNodes;if(this.feature.attributes.altitude===null){$jq("#Reload").show();pointstr="";for(a=0;a<this.maxNodes;a++){point=this.feature.geometry.GetPointAtDistance(a*this.dbp).transform(this.DataProj,this.DispProj);pointstr+=point.x.toFixed(5)+" "+point.y.toFixed(5);if(a<this.maxNodes-1){pointstr+=","}}this.getAltitude(pointstr)}else{this.maxNodes=this.feature.attributes.altitude.split(",").length;if(this.maxNodes>350){newstr="";altarray=this.feature.attributes.altitude.split(",");nodeMod=this.maxNodes/350;for(a=0;a<this.maxNodes;a++){if(a%nodeMod<1){newstr+=altarray[a]+","}}this.feature.attributes.altitude=newstr.substr(0,newstr.length-1);this.maxNodes=this.feature.attributes.altitude.split(",").length;this.dbp=this.feature.geometry.getGeodesicLength(b.DataProj)/this.maxNodes}this.dbp=this.feature.geometry.getGeodesicLength(b.DataProj)/this.maxNodes;this.drawProfile()}}else{this.restoreMap()}};iMapPlot.prototype.zoomFeatureExtent=function(e,d){var c,a,b=this;$jq(".mappanel *").css("cursor","wait");switch(e){case"pl":c=BaseURL+"/iMapPlot/Services/MapsProxy.asmx/Places_ExtentbyID?id="+d;break;case"tp":c=BaseURL+"/iMapPlot/Services/MapsProxy.asmx/Tracking_ExtentbyID?id="+d;break;default:c=BaseURL+"/iMapPlot/Services/MapsProxy.asmx/Treks_ExtentbyID?TrekType="+e+"&id="+d;break}$jq.ajax({type:"GET",url:c,success:function(f){a=$jq(f).find("string").text().split(",");b.Map.zoomToExtent(new OpenLayers.Bounds(a[1],a[3],a[0],a[2]).transform(thisMap.DispProj,thisMap.DataProj));$jq(".mappanel *").css("cursor","default")},error:function(){$jq("#geoinfo").css("cursor","default")}})};iMapPlot.prototype.getAltitude=function(b){var a=this;alturl=BaseURL+"/iMapPlot/Services/MapsProxy.asmx/Utils_AltitudebyPointArray?PointArray="+b;$jq.ajax({type:"GET",url:alturl,success:function(c){a.feature.attributes.altitude=$jq(c).find("string").text();a.drawProfile()},failure:function(){alert("getAltitude failed cannot determine profile. Please try again...");$jq("#Reload").hide()}})};iMapPlot.prototype.drawProfile=function(){var j=this,d=Infinity,f,k=0,a,g,c=[],n="",l="",h=Infinity,e=0,m,b;altitude=this.feature.attributes.altitude.split(",");a="http://chart.apis.google.com/chart?chtt=ExplorOz Altitude Profile&cht=ls&amp;chs=560x300&amp;chco=000000&amp;chf=bg,s,fefefe&amp;chxtc=1,-560|0,-300&amp;chd=t:";for(f=0;f<this.maxNodes;f++){if(altitude[f]<-10000){altitude[f]=0}c[f]=parseInt((altitude[f+1]-altitude[f])/this.dbp*10000,10)/100;n+=" "+c[f];l+=" "+altitude[f];if(c[f]<h){h=c[f];m=f}if(c[f]>e){e=c[f];b=f}g=parseInt(altitude[f],10);if(g<d){d=g}if(g>k){k=g}a+=altitude[f];if(f<this.maxNodes-1){a+=","}}a+="&amp;chm=R,ff0000aa,0,"+parseInt(b/(this.maxNodes-1)*1000,10)/1000+","+parseInt((b+1)/(this.maxNodes-1)*1000,10)/1000+"|R,00ff00aa,0,"+parseInt(m/(this.maxNodes-1)*1000,10)/1000+","+parseInt((m+1)/(this.maxNodes-1)*1000,10)/1000+"|B,efe6d1bb,0,0,0";a+="&amp;chds="+d+","+k+"&amp;chxt=x,y&amp;chxr=0,0,"+this.feature.geometry.getGeodesicLength(j.DataProj)/1000+"|1,"+d+","+k+"";profile="<h3>Route Profile</h3><h4>"+this.feature.attributes.title+"</h3>";profile+='<div style="margin:auto; text-align:center; margin-bottom:6px"><img src="'+a+'" alt="Loading ExplorOz Route Profile" />';profile+='<br />Max incline grade: <span style="color:#FC5254">'+e+'%</span> &nbsp; Max decline grade: <span style="color:#39E33A">'+h+"%</span> &nbsp; Sample distance: "+Math.round(this.dbp*100)/100+" m</div>";profile+=this.feature.attributes.description;$jq("#Reload").hide();$jq("#map_alt").html(profile);$jq("#map_alt_pan").show("slow");jqinit()};iMapPlot.prototype.zoomTo=function(b,a){this.Map.setCenter(b,a)};iMapPlot.prototype.resetMap=function(){this.Map.zoomToExtent(this.FullExtent)};iMapPlot.prototype.getDirections=function(b,a){if(this.DrivingDirections===null){this.DrivingDirections=new DrivingDirections()}this.DrivingDirections.getDirections(b,a);this.restoreMap();return false};var DirectionString="",Processing=0,ProcessStack;buildNearPopulated=function(){if(PosLongitude>0&&WaypointID>0){thisPos=new OpenLayers.LonLat(PosLongitude,PosLatitude);getNearPopulated(thisPos)}};getNearPopulated=function(b){var a=BaseURL+"/Places/Admin/getNearPopulated.aspx?lat="+b.lat+"&lon="+b.lon;responseObj=new OpenLayers.Ajax.Request(a,{method:"get",onComplete:function(c){response=c.responseText||"no response text";ProcessNearPopulated(b,response)},onFailure:function(){alert("Places getNearPopulated failed...");OpenLayers.Element.hide("Reload")}})};ProcessNearPopulated=function(pos,json){var i;DirectionString="";Processing=0;ProcessStack=[];ProcessStack[0]=[];ProcessStack[1]=[];ProcessStack[2]=[];jsonArray=eval("("+json+")");for(i=0;i<jsonArray.length;i++){pdata=jsonArray[i];ProcessStack[0][i]=pos;ProcessStack[1][i]=new OpenLayers.LonLat(pdata.lon,pdata.lat);ProcessStack[2][i]=pdata.id+","+pdata.t+","+pdata.gcd+","+pdata.d+","}getLocation()};getLocation=function(){if(GBrowserIsCompatible()){GoogleLocation=new GDirections();GEvent.addListener(GoogleLocation,"load",onGLocationsLoad);GEvent.addListener(GoogleLocation,"error",handleLocationErrors);GetAllLocations(Processing)}};GetAllLocations=function(b){var a;if(ProcessStack[0].length>b){DirectionString+=ProcessStack[2][b];GoogleLocation.load("from: "+ProcessStack[0][b].lat+","+ProcessStack[0][b].lon+" to: "+ProcessStack[1][b].lat+","+ProcessStack[1][b].lon,{locale:"en_AU"})}else{a=BaseURL+"/Places/Admin/setNearPopulated.aspx?w="+WaypointID+"&loc="+DirectionString;responseObj=new OpenLayers.Ajax.Request(a,{method:"get",onComplete:function(c){response=c.responseText||"no response text";$jq(".location").html(response)},onFailure:function(){$jq("#Reload").hide()}})}};handleLocationErrors=function(){DirectionString+="Error|";Processing+=1;GetAllLocations(Processing)};onGLocationsLoad=function(){DirectionString+=GoogleLocation.getSummaryHtml().replace("&nbsp;"," ")+"|";Processing+=1;GetAllLocations(Processing)};DrivingDirections=function(){this.GoogleDirections=null;this.DirectionsLayer=null;this.GooglePolyline=null;this.OLPolyLine=null;this.initDDinterface();this.GMTimeout=0};DrivingDirections.prototype.initDDinterface=function(){var a=this;if(typeof GMap2=="undefined"){this.GMTimeout++;if(this.GMTimeout<30){setTimeout(function(){a.initDDinterface()},1000)}else{alert("There has been an error loading the Driving Notes interface - please try refresh")}return(false)}if(GBrowserIsCompatible()){this.GoogleDirections=new GDirections();this.DirectionsLayer=thisMap.VectorLayer;GEvent.addListener(this.GoogleDirections,"load",OpenLayers.Function.bind(this.onGDirectionsLoad,this));GEvent.addListener(this.GoogleDirections,"error",OpenLayers.Function.bind(this.handleErrors,this))}};DrivingDirections.prototype.getDirections=function(c,b){var a=this;if(typeof this.GoogleDirections!="object"){a.initDDinterface();OpenLayers.Element.show("Reload")}this.GoogleDirections.load("from: "+c+" to: "+b,{locale:"en_AU",getPolyline:true,getSteps:true});return true};DrivingDirections.prototype.handleErrors=function(){if(this.GoogleDirections.getStatus().code==G_GEO_UNKNOWN_ADDRESS){alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: "+this.GoogleDirections.getStatus().code)}else{if(this.GoogleDirections.getStatus().code==G_GEO_SERVER_ERROR){alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: "+this.GoogleDirections.getStatus().code)}else{if(this.GoogleDirections.getStatus().code==G_GEO_MISSING_QUERY){alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: "+this.GoogleDirections.getStatus().code)}else{if(this.GoogleDirections.getStatus().code==G_GEO_BAD_KEY){alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: "+this.GoogleDirections.getStatus().code)}else{if(this.GoogleDirections.getStatus().code==G_GEO_BAD_REQUEST){alert("A directions request could not be successfully parsed.\n Error code: "+this.GoogleDirections.getStatus().code)}else{alert("An unknown error occurred.")}}}}}$jq("#Reload").hide()};DrivingDirections.prototype.onGDirectionsLoad=function(){var a=this;this.GooglePolyline=this.GoogleDirections.getPolyline();pointList=[];for(NumPolyPoint=0;NumPolyPoint<this.GooglePolyline.getVertexCount();++NumPolyPoint){thisPnt=new OpenLayers.Geometry.Point(this.GooglePolyline.getVertex(NumPolyPoint).lng(),this.GooglePolyline.getVertex(NumPolyPoint).lat());pointList.push(thisPnt.transform(thisMap.DispProj,thisMap.DataProj))}this.OLPolyLine=new OpenLayers.Geometry.LineString(pointList);features=[];for(NumRoute=0;NumRoute<this.GoogleDirections.getNumRoutes();++NumRoute){route=this.GoogleDirections.getRoute(NumRoute);startname=route.getStartGeocode().address;endname=route.getEndGeocode().address;directions='<div class="dddnt"><b>Distance:</b> '+this.GoogleDirections.getSummaryHtml()+"</div>";startPnt=new OpenLayers.Geometry.Point(route.getStartGeocode().Point.coordinates[0],route.getStartGeocode().Point.coordinates[1]);endPnt=new OpenLayers.Geometry.Point(route.getEndGeocode().Point.coordinates[0],route.getEndGeocode().Point.coordinates[1]);directions+='<table class="ddtable" border="0" cellpadding="2" cellspacing="0">';for(NumStep=0;NumStep<route.getNumSteps();++NumStep){directions+='<tr><td style="text-align:right; width:20px">'+parseInt(NumStep+1,10)+".</td><td>"+route.getStep(NumStep).getDescriptionHtml()+'</td><td style="text-align:right">'+route.getStep(NumStep).getDistance().html+'</td><td style="text-align:right">'+route.getStep(NumStep).getDuration().html+"</td></tr>"}directions+="</table>";route=null;theFeature=new OpenLayers.Feature.Vector(this.OLPolyLine,{title:startname+" to "+endname,length:this.GoogleDirections.getDistance().meters/1000,traveltime:this.GoogleDirections.getDuration().seconds/3600,traveltimestr:this.GoogleDirections.getDuration().html,direction:startPnt.DirectionTo(endPnt),description:"",fulldesc:directions,altitude:null,group:startname+" to "+endname+" (Route)"});theFeature.fid="D"+startname+"_to_"+endname;features.push(theFeature)}this.DirectionsLayer.addFeatures(features);a.id=features[0].id;pointList=null;directions=null;this.GoogleDirections.clear();features=null;this.GooglePolyline=null;window.setTimeout(function(){theMap.zoomFeature(a.id);theMap.selectVector(a.DirectionsLayer.features.length-1);$jq("#Reload").hide()},200)};iMapPlot.prototype.Print=function(a){PrintWindow=window.open("","ExplorOz_Page_Print","width=800,height=600,top=250,left=345,toolbar=no,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes");PrintWindow.document.writeln("<html><head><title>iMapplot @ ExplorOz</title>");PrintWindow.document.writeln('<link href="'+BaseURL+'/Scripts/CSStyles.css_161008.aspx" type="text/css" rel="stylesheet"/>');PrintWindow.document.writeln('<link id="ctl00_PlacesStyle" type="text/css" rel="stylesheet" href="'+BaseURL+'/iMapPlot/Scripts/Mapping.css" />');PrintWindow.document.writeln('</head><body style="background-color:white;text-align:left;width:728px;">');PrintWindow.document.writeln('<img src="'+BaseURL+'/images/ExplorOz_Logo.jpg" id="ctl00_WebLogo" class="WebLogo" alt="ExplorOz Logo" /><img class="Filler" src="'+BaseURL+'/images/blank.gif" alt=""/><div id="ctl00_HeaderTitle" class="PageTitle"><strong>www.ExplorOz.com</strong></div>');PrintWindow.document.writeln($jq("#"+a).html());PrintWindow.document.writeln('<div class="PageCopyright" style="width:728px">'+$jq(".PageCopyright").html()+"</div>");PrintWindow.document.writeln("</body></html>");PrintWindow.document.close();PrintWindow.focus();PrintWindow.print();PrintWindow.close();return false};OpenLayers.Geometry.Point.prototype.DirectionTo=function(b){var c,a;if(b instanceof OpenLayers.Geometry.Point){lat1=this.y.toRad();lat2=b.y.toRad();dLon=(b.x-this.x).toRad();c=Math.sin(dLon)*Math.cos(lat2);a=Math.cos(lat1)*Math.sin(lat2)-Math.sin(lat1)*Math.cos(lat2)*Math.cos(dLon);result=Math.round(Math.atan2(c,a).toBrng()*100)/100}else{result=null}return result};Number.prototype.toRad=function(){return this*Math.PI/180};Number.prototype.toDeg=function(){return this*180/Math.PI};Number.prototype.toBrng=function(){return(this.toDeg()+360)%360};OpenLayers.Geometry.LineString.prototype.GetPointAtDistance=function(b){var e,d,a,c;if(b===0){return new OpenLayers.Geometry.Point(this.components[0].x,this.components[0].y)}if(b<0){return null}dist=0;olddist=0;for(c=1;(c<this.components.length&&dist<b);c++){olddist=dist;dist+=this.components[c].distanceTo(this.components[c-1])}if(dist<b){return null}e=this.components[c-2];d=this.components[c-1];a=(b-olddist)/(dist-olddist);thePoint=new OpenLayers.Geometry.Point(e.x+(d.x-e.x)*a,e.y+(d.y-e.y)*a);return thePoint};