var shpLayer=[];var aPoints=null;var lCityPins=null;var lTrailPins=null;var lFacilityPins=null;var lRadius=null;var _SearchUrl="";var xBlob=null;var url="";var IconType=1;var sTrailPolyLine=null;var ResultCount=0;var AppPath="/ParksTrails/";var selectedLayer="";var aSelectedColor=["0","255","0",".75"];function SearchUrl(){if(QueryType===0){if($("#ctl00_ContentPlaceHolder1_chkParks:checked").length!==0){QueryType+=1+8}if($("#ctl00_ContentPlaceHolder1_chkTrails:checked").length!==0){QueryType+=2+8}if($("#ctl00_ContentPlaceHolder1_chkFacilities:checked").length!==0){QueryType+=3+8}}return AppPath+"mpr_query.asmx/Search?Latitude="+strLatitude+"&Longitude="+strLongitude+"&Radius="+strRadius+"&Keyword="+strKeyword+"&Amenities="+strAmenities+"&Activities="+strActivities+"&Owner="+strOwner+"&QueryType="+QueryType}function get_icon(a){if((typeof(a)==="undefined")||(a===null)||a=="1"){a="green"}else{if(a=="2"){a="trails"}else{if(a=="3"){a="facility"}}}return AppPath+"img/icon_"+a+".gif"}function l(a){a=parseInt(a,0);if(a===1){if(lCityPins===null){lCityPins=new VEShapeLayer();lCityPins.SetTitle("CityPins")}return lCityPins}else{if(a===2){if(lTrailPins===null){lTrailPins=new VEShapeLayer();lTrailPins.SetTitle("TrailPins")}return lTrailPins}else{if(a===3){if(lFacilityPins===null){lFacilityPins=new VEShapeLayer();lFacilityPins.SetTitle("FacilityPins")}return lFacilityPins}else{if(a===4){if(lRadius===null){lRadius=new VEShapeLayer();lRadius.SetTitle("Radius")}return lRadius}}}}}function AddCircle(c,e,k){var h=[];var g=c*Math.PI/180;var j=e*Math.PI/180;var m=k/3956;var o;for(o=0;o<=360;o+=10){var f=(o/90)*Math.PI/2;var n=Math.asin(Math.sin(g)*Math.cos(m)+Math.cos(g)*Math.sin(m)*Math.cos(f));n=180*n/Math.PI;var b;if(Math.cos(g)===0){b=e}else{b=((j-Math.asin(Math.sin(f)*Math.sin(m)/Math.cos(g))+Math.PI)%(2*Math.PI))-Math.PI}b=180*b/Math.PI;var i=new VELatLong(n,b);h.push(i)}var a=new VEShape(VEShapeType.Polyline,h);a.SetLineColor(new VEColor(0,255,0,0.5));a.SetLineWidth(4);a.HideIcon();return a}function myclick(k,f,d){var e=18;if(parseInt(k,0)===2){e=15}var i=d.replace("  "," ").split(" ");var a=new VELatLong(parseFloat(i[0]),parseFloat(i[1]));map.SetCenterAndZoom(a,e);var c=l(parseInt(k,0));var g=null;if(parseInt(k,0)===2){if(c.GetShapeCount()>0){for(var j=0;j<c.GetShapeCount();j++){if(c.GetShapeByIndex(j).GetPoints()[0].toString()==a.toString()&&c.GetShapeByIndex(j).GetTitle().replace("'","").indexOf(f)>-1){g=c.GetShapeByIndex(j);break}}}if(g===null){for(var h=0;h<map.GetShapeLayerCount();h++){c=map.GetShapeLayerByIndex(h);for(var b=0;b<c.GetShapeCount();b++){if(c.GetShapeByIndex(b).GetPoints()[0].toString()==a.toString()&&c.GetShapeByIndex(b).GetTitle().replace("'","").indexOf(f)>-1){g=c.GetShapeByIndex(b);break}}}}}else{g=c.GetShapeByIndex(parseInt(f,0))}map.ShowInfoBox(g);$("#ctl00_ContentPlaceHolder1_updateMessage").hide(100)}function lineToPoint(b){var a="";b=b.replace("::|Main|#0,255,0,.75#::","").replace("::","");a=b.substring(b.indexOf("#",b.indexOf("#")+1)+1,b.indexOf("?"));a=a.replace(","," ").replace("  "," ");return a}function getResultLinks(e,b,f,a,g,h,c,d){var i='<div class="ResultItem cssPropType'+e+'">';i+='<a href="Details.aspx?pid='+c+'" class="ResultTitle"><strong>'+b+"</strong></a>";if(f!==""){i+=' <span class="small">('+parseFloat(f).toPrecision(3)+" mi)</span>"}i+="<br />";if(h!==""){i+='<div class="ChildList">'+h+"</div>"}i+='<a href="Details.aspx?pid='+c+'" class="medium" ID="lnkDetails">View Details</a> | ';if(e===2){i+='<a href="Details.aspx?pid='+c+"\" onclick=\"$('#ctl00_ContentPlaceHolder1_updateMessage').show(100, function() { myclick('"+e+"','"+b.replace("'","")+"', '"+d+'\'); }); return false;" class="medium" id="lnkParkJump">Zoom To</a>'}else{i+='<a href="Details.aspx?pid='+c+"\" onclick=\"$('#ctl00_ContentPlaceHolder1_updateMessage').show(100, function() { myclick('"+e+"','"+(parseInt(l(e).GetShapeCount(),0)-1)+"', '"+d+'\'); }); return false;" class="medium" id="lnkParkJump">Zoom To</a>'}i+="</div>";return i}function splitLayer(a,b){var c=[];if(b.indexOf("|")>-1){c.title=b.substr(b.indexOf("|")+1,b.lastIndexOf("|")-(b.indexOf("|")+1))}else{c.title=""}if(b.indexOf("#")>-1){c.color=b.substr(b.indexOf("#",b.lastIndexOf("|"))+1,b.lastIndexOf("#")-(b.indexOf("#",b.lastIndexOf("|"))+1)).split(",")}else{c.color=aSelectedColor}c.coords=b.replace("|"+c.title+"|","").replace("#"+c.color+"#","");if(b.indexOf("&&")>-1){c.description=b.substr(b.indexOf("&&")+2,b.lastIndexOf("&&")-(b.indexOf("&&")+2))}else{c.description=""}return c}function multiAddPolyLines(e,b){if($("#chkTrails:checked").length!==0&&$("#chkTrails:checked").length===0){return}var c=[];var f=null;if(b){f=b}else{f=new VEShapeLayer();map.AddShapeLayer(f)}var o=null;var a="";for(var r in shpLayer){var m=splitLayer("multiAdd",shpLayer[r]);var d=m.coords;var n=[];var h=[];if(d.indexOf("&&")>-1){d=d.substring(0,d.indexOf("&&"))}else{d=d.substring(0,d.lastIndexOf("?"))}if(d.indexOf("?")>-1){h=d.split("?");for(var j=0;j<h.length;j++){c=h[j].split(", ");if(!isNaN(parseFloat(c[0]))&&!isNaN(parseFloat(c[1]))){n.push(new VELatLong(parseFloat(c[0]),parseFloat(c[1])))}if(j===0){o=new VELatLong(parseFloat(c[0]),parseFloat(c[1]))}}}else{if(d!==""){c=d.split(", ");n.push(new VELatLong(parseFloat(c[0]),parseFloat(c[1])))}}if(n.length>1&&h.length>0){var s=map.GetMapView();var k=s.TopLeftLatLong;var g=s.BottomRightLatLong;if(($("#ctrlToolBox").length!==0||sTrailPolyLine!==null)||(map.GetZoomLevel()>=15&&o.Latitude<k.Latitude&&o.Latitude>g.Latitude&&o.Longitude>k.Longitude&&o.Longitude<g.Longitude)){var p=new VEShape(VEShapeType.Polyline,n);var q=m.color;p.SetLineColor(new VEColor(q[0],q[1],q[2],q[3]));f.AddShape(p);p.HideIcon()}if(a!=m.title&&$("#ctrlToolBox").length===0){var i=new VEShape(VEShapeType.Pushpin,o);f.AddShape(i);i.SetTitle(m.title);i.SetDescription(m.description);i.SetCustomIcon(get_icon("trails"));a=m.title}}if(r==selectedLayer&&(e)){f.AddShape(e)}}}function populateLayerSelect(){var a=$("#layerSelect").empty();for(var c in shpLayer){var b=splitLayer("popLayerSelect",shpLayer[c]);var d=b.title;if(d!==""){$('<option value="'+d+'">'+d+"</option>").appendTo($("#layerSelect"))}}$("#layerSelect").find("OPTION").each(function(){if($(this).val()===selectedLayer){this.selected=true}})}function rewritePolyCoords(){var a=$("#ctl00_ContentPlaceHolder1_txtPolyCoords").val();$("#ctl00_ContentPlaceHolder1_txtPolyCoords").val("");try{for(var b in shpLayer){$("#ctl00_ContentPlaceHolder1_txtPolyCoords").val($("#ctl00_ContentPlaceHolder1_txtPolyCoords").val()+"::"+shpLayer[b])}}catch(c){$("#ctl00_ContentPlaceHolder1_txtPolyCoords").val(a);alert("Error: "+c)}}function newTrailSeg(){var e=prompt("Enter new segment name.","");if(e===null){e="Main"}e=e.replace(/[~|'|#|$|%|\^|+|=|{|}|<|>|*|,|"]/g,"");shpLayer[e]="|"+e+"|#"+aSelectedColor.join(",")+"#";if($("#ctl00_ContentPlaceHolder1_txtPolyCoords").val()===""&&location.href.indexOf("y=")>-1&&location.href.indexOf("x=")>-1){var d=location.href.substring(location.href.indexOf("y=")+2,location.href.length);var b=d.split("&x=");shpLayer[e]+=b[0]+", "+b[1]+"?";var a=new VELatLong(parseFloat(b[0]),parseFloat(b[1]));var c=new VEShape(VEShapeType.Pushpin,a);c.SetCustomIcon(get_icon("trails"));map.AddShape(c);map.SetCenter(a)}rewritePolyCoords();selectedLayer=e;populateLayerSelect();alert("Right click on map to start a new line.")}function populateShpLayer(f,h,g){var c="";if(f){c=f}else{c=$("#ctl00_ContentPlaceHolder1_txtPolyCoords").val()}if(c===""){newTrailSeg()}else{var e=c.split("::");for(var a=0;a<e.length;a++){if(e[a]!==""){var d="";var b=splitLayer("popShpLayer",e[a]);if(b.title!==""){d=b.title;if(h){d+=h}}else{d="Main"}if(h){shpLayer[d]=e[a].replace(e[a].substr(e[a].indexOf("|")+1,e[a].lastIndexOf("|")-(e[a].indexOf("|")+1)),h)}else{shpLayer[d]=e[a]}if(g&&g!==""){shpLayer[d]+="&&"+g+"&&"}}}}if($("#layerSelect").length>0){populateLayerSelect()}}function processData(f){var a=null;var b="";var d=false;var g="";ResultCount=0;$(f).find("item").each(function(){try{a=parseInt($(this).find("PropertyType:first").text(),0);var p=$(this).find("georssline:first").text();g=$(this).find("title:first").text();var u=$(this).find("PropertyName:first").text();var v=$(this).find("description:first").text();var o=$(this).find("Distance:first").text();var m=$(this).find("Owner:first").text();var s=$(this).find("Children:first").text();var x=$(this).find("pid:first").text();var n=parseInt($(this).find("IsChild:first").text(),0);if((a===1&&$("#ctl00_ContentPlaceHolder1_chkParks:checked").length!==0)||(a===2&&$("#ctl00_ContentPlaceHolder1_chkTrails:checked").length!==0)||(a===3&&$("#ctl00_ContentPlaceHolder1_chkFacilities:checked").length!==0)){ResultCount++}if(map.GetZoomLevel()>=15&&p!==""){d=true;populateShpLayer(p,g,v);if(n===0&&url!=_SearchUrl){b+=getResultLinks(a,u,o,v,m,s,x,lineToPoint(p))}}else{var r=null;if(p!==""){r=lineToPoint(p)}else{r=$(this).find("georsspoint:first").text()}if(r!==""){var q=r.replace("  "," ").split(" ");var k=new VELatLong(parseFloat(q[0]),parseFloat(q[1]));var w=new VEShape(VEShapeType.Pushpin,k);if(aPoints!==null){aPoints.push(k)}w.SetTitle(g);w.SetDescription(v);w.SetCustomIcon(get_icon(a));l(a).AddShape(w);if(n===0&&url!=_SearchUrl){b+=getResultLinks(a,u,o,v,m,s,x,r)}}}}catch(t){alert(t.message+g)}});if(d){multiAddPolyLines(null,l(a))}if(strRadius!==""){l(4).AddShape(AddCircle(strCenterLat,strCenterLong,strRadius));if(boolShowCenter){var e=new VELatLong(strCenterLat,strCenterLong);var h="";if($("input[id$='txtAdrSearch']:first").val()!==""){h=$("input[id$='txtAdrSearch']:first").val();if($("input[id$='txtCity']:first").val()!==""){h+="<br />"+$("input[id$='txtCity']:first").val()+", WA"}}var c=new VEShape(VEShapeType.Pushpin,e);c.SetCustomIcon(get_icon("red"));c.SetTitle("You are here.");c.SetDescription(h);l(4).AddShape(c);if(aPoints!==null){aPoints.push(e)}}}for(var i=1;i<=4;i++){if(l(i).GetShapeCount()>0){map.AddShapeLayer(l(i))}}if(location.href.indexOf("ZoomTo")!==-1){var j=location.href.substr(location.href.indexOf("ZoomTo")+7).split(",");myclick(parseInt(j[0],0),parseInt(j[1],0))}if(b!==""){b="Results Found: "+ResultCount+"<br /><br />"+b}else{if(b===""&&url!==_SearchUrl){b="No locations found. Please try again."}}if(aPoints!==null&&aPoints.length>0){map.SetMapView(aPoints);aPoints=null}if(url!=_SearchUrl){_SearchUrl=url;$("#SearchResults").html(b)}xBlob=f}function readURLforGeoRSS(){url=SearchUrl();if(url.indexOf("/mpr_query.asmx/Search?Latitude=&Longitude=&Radius=&Keyword=&Amenities=&Activities=&Owner=&QueryType=")>-1){$("#SearchResults").html("No search criteria selected.")}else{if(url!=_SearchUrl||map.GetZoomLevel()>=15){map.DeleteAllShapeLayers();lCityPins=null;lTrailPins=null;lFacilityPins=null;lRadius=null;if(xBlob===null){$.get(url,processData)}else{processData(xBlob)}}}$("#ctl00_ContentPlaceHolder1_updateMessage").hide(100)}function mapResize(a,b){map.DetachEvent("onchangeview",readURLforGeoRSS);map.Resize(a,b);map.SetCenter(new VELatLong(strCenterLat,strCenterLong));map.AttachEvent("onchangeview",readURLforGeoRSS)}function getCookie(c){var d=document.cookie.indexOf(c+"=");var a=d+c.length+1;if((!d)&&(c!=document.cookie.substring(0,c.length))){return null}if(d===-1){return null}var b=document.cookie.indexOf(";",a);if(b===-1){b=document.cookie.length}return unescape(document.cookie.substring(a,b))}function setCookie(c,e,a,h,d,g){var b=new Date();b.setTime(b.getTime());if(a){a=a*1000*60*60*24}var f=new Date(b.getTime()+(a));document.cookie=c+"="+escape(e)+((a)?";expires="+f.toGMTString():"")+";path="+escape("/")}var minCriteriaHeight="18px";function goFullScreen(b){if(typeof(b)!=="undefined"&&b.toString().toLowerCase()=="true"){setCookie("FullScreen",true,30,AppPath,location.hostname,true);boolFullScreen=true}else{if(typeof(b)!=="undefined"&&b.toString().toLowerCase()=="false"){setCookie("FullScreen",false,30,AppPath,location.hostname,true);boolFullScreen=false}else{if(getCookie("FullScreen")!==null){boolFullScreen=getCookie("FullScreen")}}}var f=490;var h=490;if(boolFullScreen.toString().toLowerCase()=="true"){f=700;if(document.documentElement.clientHeight>0){f=document.documentElement.clientHeight-2}else{if(document.documentElement.scrollHeight>0){f=document.documentElement.scrollHeight-5}}h=document.documentElement.offsetWidth}$("#FullClick").unbind("click");if(boolFullScreen.toString().toLowerCase()=="false"){$("#Content").css({position:"relative",top:"auto",left:"auto",padding:"10px",borderLeft:"dotted 3px #ccc"});$("#map").css({position:"relative",margin:"0px 2px 2px 0px"});$("#mprFullHeader").show();$("#mprMainNav").show();$("#mprSiteNav").show();$("#mprFooter").show();$(".BackLink").show();$("#ctl00_ContentPlaceHolder1_sidebarX").show();$("#PinKey").css({position:"relative",top:"auto",left:"auto",background:"#ffffff url(img/HeaderBackGroundGraphic.gif) repeat-x bottom left"});$("#search_criteria").css({position:"relative",width:"703px",left:"0px",top:"1px",height:"18px",background:"#FFFFFF url(img/HeaderBackGroundGraphic.gif) repeat-x bottom",borderTop:"solid 1px #CBCBCB"});$("#oFullScreen").css({position:"relative",border:"0px",top:"auto",left:"auto",width:"24px",height:"24px",background:"#FFFFFF"});$("#FullClick").one("click",function(){goFullScreen("True")});$("#iFullScreen").css("position","relative").attr("src","img/FullScreen.gif").attr("alt","Go Full Screen");$("#ctl00_ContentPlaceHolder1_SearchUpdatePanel").css({position:"relative",left:"auto",height:"480px",top:"auto",background:"#FFFFFF"})}else{$("#mprFullHeader").hide();$("#mprMainNav").hide();$("#mprSiteNav").hide();$("#mprFooter").hide();$(".BackLink").hide();$("#ctl00_ContentPlaceHolder1_sidebarX").hide();minCriteriaHeight="28px";$("#Content").css({border:"none",position:"absolute",top:"0px",left:"0px",padding:"0px",margin:"0px"});$("#map").css({margin:"0px",position:"absolute",top:"0px",left:"0px",width:h+"px",height:f+"px",padding:"0px",border:"1px solid gray"});document.documentElement.style.overflow="hidden";var e=$("#PinKey").css({position:"absolute",top:(f-40)+"px",left:((h-720)/2)+"px"});if(document.getElementById("PinKey").style.filter===null){e.css("background","transparent url(img/side2BG.png) repeat")}else{e.css({backgroundColor:"#F1F7F7",filter:"alpha(opacity=80)"});$(".PinKey").css("backgroundImage","")}var a=354;$("#MSVE_navAction_leftBackground").css("height","136px");var g=h-a-64;$("#search_criteria").css({position:"absolute",width:g+"px",left:(a+10)+"px",top:"0px",height:"28px",borderTop:"0px"});if(document.getElementById($("#search_criteria").attr("id")).style.filter===null){$("#search_criteria").css("background","transparent url(img/side2BG.png) repeat")}else{$("#search_criteria").css({backgroundImage:"none",backgroundColor:"#F1F7F7",filter:"alpha(opacity=80)"})}var d=$("#oFullScreen").css({left:(h-44)+"px",border:"solid 1px #CBCBCB",position:"absolute",top:"0px",width:"34px",height:"28px",zIndex:9999});if(document.getElementById("oFullScreen").style.filter===null){d.css({background:"transparent url(img/side2BG.png) repeat",textAlign:"center"})}else{d.css({backgroundColor:"#F1F7F7",filter:"alpha(opacity=80)",textAlign:"center"});$("#oFullScreen").css("backgroundImage","")}$("#FullClick").one("click",function(){goFullScreen("False")});$("#iFullScreen").attr("src","img/FullScreenUndo.gif").css("position","relative").attr("alt","Return to Regular Navigation");var c=$("#ctl00_ContentPlaceHolder1_SearchUpdatePanel").css({position:"absolute",left:(h-245)+"px",height:(f-90)+"px",top:"34px",display:"block"});$("#ctl00_ContentPlaceHolder1_SearchUpdatePanel").css("height",(f-90)+"px");if(document.getElementById("ctl00_ContentPlaceHolder1_SearchUpdatePanel").style.filter===null){c.css("background","transparent url(img/side2BG.png) repeat")}else{c.css({backgroundColor:"#F1F7F7",filter:"alpha(opacity=80)"})}}mapResize(h,f);return false}function onLoad(){if(map===null){map=new VEMap("map");var c=new VEMapOptions();c.EnableBirdseye=false;map.LoadMap(new VELatLong(strCenterLat,strCenterLong),strZoom,"r",false,null,null,null,c)}Msn.VE.API.Constants.iconurl=get_icon("green");if(boolSmallMap===false){$("#ctl00_ContentPlaceHolder1_updateMessage").show(100);aPoints=[];goFullScreen();map.AttachEvent("onchangeview",readURLforGeoRSS)}else{if(map){map.DetachEvent("onchangeview",readURLforGeoRSS);$("#map").show();map.HideDashboard();var a=null;if(strLatitude!==""&&strLongitude!==""){a=new VELatLong(parseFloat(strLatitude),parseFloat(strLongitude))}else{a=new VELatLong(parseFloat(strCenterLat),parseFloat(strCenterLong))}var b=new VEShape(VEShapeType.Pushpin,a);b.SetCustomIcon(get_icon(IconType));l(IconType).AddShape(b);map.AddShapeLayer(l(IconType));map.SetCenterAndZoom(a,strZoom)}}}var timer={time:0,now:function(){return(new Date()).getTime()},start:function(){this.time=this.now()},since:function(){return this.now()-this.time}};function mapDispose(){if(map!==null){map.Dispose()}}function SideBarExpand(){var a=document.getElementById("sidebarXimg");if(a.src.indexOf("openarrow.gif")>0){$("#map").css({width:"240px",height:"490px"}).toggleClass("map-hover");$("#ctl00_ContentPlaceHolder1_SearchUpdatePanel").css("width","475px").attr("id","ctl00_ContentPlaceHolder1_SearchUpdatePanel_hover");a.src="img/closearrow.gif";mapResize(240,490)}else{$("#map").css({width:"490px",height:"490px"}).toggleClass("map");$("#ctl00_ContentPlaceHolder1_SearchUpdatePanel_hover").css("width","225px").attr("id","ctl00_ContentPlaceHolder1_SearchUpdatePanel");a.src="img/openarrow.gif";mapResize(490,490)}}function ViewCriteria(a){if(a.src.indexOf("img/expand.jpg")!=-1){a.src="img/collapse.jpg";$("#search_expand").html($("#search_criteria").html());if($("#map").offset().top===0){$("#search_expand").css({display:"block",top:"0px",paddingBottom:"13px",left:$("#search_criteria").css("left"),width:$("#search_criteria").width()})}else{$("#search_expand").css({display:"block",top:"11px",paddingBottom:"3px",left:"10px",width:$("#search_criteria").width()})}a.src="img/expand.jpg"}else{$("#search_expand").html("");$("#search_expand").hide()}}function hideLayer(){$("#ctl00_ContentPlaceHolder1_updateMessage").show(100);QueryType=0;if($("#ctl00_ContentPlaceHolder1_chkParks:checked").length!==0){setCookie("bParks","True");QueryType+=1+8}else{setCookie("bParks","False")}if($("#ctl00_ContentPlaceHolder1_chkTrails:checked").length!==0){setCookie("bTrails","True");QueryType+=2+8}else{setCookie("bTrails","False")}if($("#ctl00_ContentPlaceHolder1_chkFacilities:checked").length!==0){setCookie("bFacilities","True");QueryType+=3+8}else{setCookie("bFacilities","False")}xBlob=null;readURLforGeoRSS()}function openDrawTool(b,d,a){var c=window.open("DrawTool.aspx?PropertyID="+b+"&y="+d+"&x="+a);c.focus()}function closeDrawTool(){if(confirm("This will NOT save your work before closing.  Continue?")){window.close()}}function addPolyLine(a){map.DeleteAllShapeLayers();populateShpLayer();multiAddPolyLines(a)}function fnPolyLayers(a,g,f){if(g===""||g==="undefined"){populateShpLayer();g=$("#layerSelect").find("OPTION:selected").val()}var c,b,d=[];var e=null;if(shpLayer[g]){c=splitLayer("fnPolyLayers",shpLayer[g])}else{c=splitLayer("fnPolyLayers2",shpLayer[0])}if(a==="GetCoords"){return c.coords}else{if(a==="GetColor"){return c.color}else{if(a==="Append"){shpLayer[g]+=f+"?"}else{if(a==="Undo"){b=shpLayer[g].split("?");if(b.length>2){shpLayer[g]=shpLayer[g].replace(b[b.length-2]+"?","")}else{shpLayer[g]=""}}else{if(a==="GetLastPoint"){b=c.coords.split("?");if(b.length>2){d=b[b.length-2].split(", ");e=new VEShape(VEShapeType.Pushpin,new VELatLong(parseFloat(d[0]),parseFloat(d[1])));return e}else{return null}}else{if(a==="BackTrack"){b=c.coords.split("?");if(b.length>2){shpLayer[g]+=b[b.length-3]+"?"}d=b[b.length-3].split(", ");e=new VEShape(VEShapeType.Pushpin,new VELatLong(parseFloat(d[0]),parseFloat(d[1])));rewritePolyCoords();addPolyLine(e)}else{if(a==="Return2Start"){b=c.coords.split("?");shpLayer[g]+=b[0]+"?";d=b[0].split(", ");e=new VEShape(VEShapeType.Pushpin,new VELatLong(parseFloat(d[0]),parseFloat(d[1])));rewritePolyCoords();addPolyLine(e)}}}}}}}rewritePolyCoords()}function getLatLonPart(d){if(d===null||d.rightMouseButton){Msn.VE.API.Constants.iconurl=get_icon("trails");if(shpLayer.length>0){map.Clear()}if(selectedLayer===""){selectedLayer=$("#layerSelect").find("OPTION:selected:first").val()}var b=null;var a=null;var c="";if(d!==null){a=map.PixelToLatLong(new VEPixel(d.mapX,d.mapY));b=new VEShape(VEShapeType.Pushpin,a);c=a;b.SetTitle=c;fnPolyLayers("Append",selectedLayer,c)}else{if($("#ctl00_ContentPlaceHolder1_txtPolyCoords").val().indexOf("?")>-1){a=fnPolyLayers("GetLastPoint");b=a;c="End of Trail";b.SetTitle=c}}addPolyLine(b)}}function getNewMapTool(){setCookie("FullScreen",false,30,AppPath,location.hostname,true);boolFullScreen=false;onLoad();map.HideDashboard();map.AttachEvent("onclick",getLatLonPart);map.SetMapStyle(VEMapStyle.Aerial);if($("#ctl00_ContentPlaceHolder1_txtPolyCoords").val()!==""){populateShpLayer();getLatLonPart(null)}else{fnPolyLayers("Init","",null)}map.AddControl(document.getElementById("ctrlToolBox"),5)}function switchLayer(a){selectedLayer=$("#layerSelect").find("OPTION:selected").val();var b=fnPolyLayers("GetColor",selectedLayer,null);$("#layerColor").find("OPTION").each(function(){if($(this).val()==b){this.selected=true}});map.DeleteAllShapeLayers();multiAddPolyLines(fnPolyLayers("GetLastPoint",selectedLayer,null))}function switchColor(b){var c=$("#layerSelect").find("OPTION:selected").val();var a=fnPolyLayers("GetCoords",c,null);shpLayer[c]="|"+c+"|#"+$("#layerColor").find("OPTION:selected").val()+"#"+a;rewritePolyCoords();map.DeleteAllShapeLayers();multiAddPolyLines(fnPolyLayers("GetLastPoint",c,null))}function pinUndo(){fnPolyLayers("Undo","",null);map.DeleteAllShapeLayers();multiAddPolyLines(fnPolyLayers("GetLastPoint",$("#layerSelect").find("OPTION:selected").val(),null))}function backTrack(){fnPolyLayers("BackTrack","",null)}function return2Start(){fnPolyLayers("Return2Start","",null)}function zoomIn(){strZoom=map.GetZoomLevel()+1;map.SetZoomLevel(strZoom)}function zoomOut(){strZoom=map.GetZoomLevel()-1;map.SetZoomLevel(strZoom)}function mapReset(){pinCount=0;$("#ctl00_ContentPlaceHolder1_txtPolyCoords").val("::|Main|#"+aSelectedColor.join(",")+"#");shpLayer=[];map.DeleteAllShapeLayers();fnPolyLayers("Init","",null)}function GeoCode(a,b){$("#UpdateMessage").show();$("#map").show();if(map){map.Dispose()}map=new VEMap("map");map.LoadMap(new VELatLong(strCenterLat,strCenterLong),strZoom,VEMapStyle.Aerial,false,VEMapMode.Mode2D,false,1);map.HideDashboard();var c=AppPath+"mpr_query.asmx/GeoCodeAddress?Address="+a+"&City="+b;$.get(c,function(i){var h=$(i).find("GeoCoords:first").find("LatLong:first").text();var e=$(i).find("GeoCoords:first").find("Latitude:first").text();var g=$(i).find("GeoCoords:first").find("Longitude:first").text();$("#ctl00_ContentPlaceHolder1_txtYCoord").val(e);$("#ctl00_ContentPlaceHolder1_txtXCoord").val(g);if(h=="Search Failed"){alert("Error in mapping the address specified.  Please double check your address entry and try again.")}else{strLatitude=e;strLongitude=g;strZoom=16;var d=new VELatLong(e,g);var f=new VEShape(VEShapeType.Pushpin,d);f.SetCustomIcon(get_icon());map.AddShape(f);map.SetCenterAndZoom(d,strZoom)}$("#UpdateMessage").hide()})}function getLatLonDetail(f){var a=map.PixelToLatLong(new VEPixel(f.mapX,f.mapY));var c=a.toString();var d=c.split(", ");$("#ctl00_ContentPlaceHolder1_txtYCoord").val(d[0]);$("#ctl00_ContentPlaceHolder1_txtXCoord").val(d[1]);strLatitude=d[0];strLongitude=d[1];map.DeleteAllShapes();var b=new VEShape(VEShapeType.Pushpin,a);b.SetCustomIcon(get_icon(IconType));map.AddShape(b)}function getNewLatLon(){IconType=parseInt($("#ctl00_ContentPlaceHolder1_ddlPropType").find("OPTION:selected").val(),0);$("#map").show();var a=null;if(strLatitude!==""&&strLongitude!==""){a=new VELatLong(parseFloat(strLatitude),parseFloat(strLongitude))}else{a=new VELatLong(parseFloat(strCenterLat),parseFloat(strCenterLong))}if(map){map.Dispose()}map=new VEMap("map");map.LoadMap(a,strZoom,VEMapStyle.Aerial,false,VEMapMode.Mode2D,false,1);var b=new VEShape(VEShapeType.Pushpin,a);b.SetCustomIcon(get_icon(IconType));map.AddShape(b);map.HideDashboard();map.AttachEvent("onmouseup",getLatLonDetail);$("#mapMessage").html("Click on the map to select a new X/Y point.")}function LaunchBrowser(){var a=AppPath+"FCKeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/aspx/connector.aspx";window.open(a,"mWind","statusbar=yes,toolbar=no,height=550,width=650,resizable=yes,scrollbars=yes,location=yes")}function SetUrl(a){$("#ctl00_ContentPlaceHolder1_txtImageName").val(a.replace(AppPath+"/UserFiles/Image/",""))}$.fn.check=function(a){a=a||"on";return this.each(function(){switch(a){case"on":this.checked=true;break;case"off":this.checked=false;break;case"toggle":this.checked=!this.checked;break}})};function linkToggle(e,a){var d=$("#SearchCity").html().replace("Owned by cities: ","");var i="";i=", "+$("table[id$='cklCities']").find("label[for$='cklCities_"+e+"']:first").html();var b=$("input[id$='cklCities_0']");var f=new RegExp("("+i.replace(", ","")+"[,s]*)","g");d=d.replace(f,"");if(e>0&&e<10){var h=$("input[id$='cklCities_"+e+"']");var c=$("#imgOverlay"+e);if(h.attr("checked")){h.check("off");c.removeClass("mapOverlay"+e).addClass("mapOverlay_hidden");if(b.attr("checked")){b.check("off");i="";$("table[id$='cklCities']").find("LABEL").each(function(){if($(this).attr("for").indexOf("cklCities_")>-1&&$("#"+$(this).attr("for")+":checked").length>0){i+=", "+$(this).html()}});d=i}}else{h.check("on");c.addClass("mapOverlay"+e);d+=i}if(a){h.check("toggle")}}else{if(e===0){for(var g=1;g<10;g++){var h=$("input[id$='cklCities_"+g+"']");var c=$("#imgOverlay"+g);if(b.attr("checked")){h.check("off");c.removeClass("mapOverlay"+g).addClass("mapOverlay_hidden");d="  "}else{h.check("on");c.addClass("mapOverlay"+g);d="All Cities  "}}}}d=d.replace(", ,",",");if(d.indexOf(",")===0){d=d.substr(2)}$("#SearchCity").html("Owned by cities: "+d)}function updateKeyText(a){a=a.replace(/[^a-zA-Z 0-9]+/g,"");$("#SearchName").html("Contains keywords: "+a)}function updateAdrSearch(){var b=$("select[id$='ddlRadius']:first").find("OPTION:selected").text();var c=$("input[id$='txtAdrSearch']:first").val().replace(/[^a-zA-Z 0-9]+/g,"");var a=$("input[id$='txtCity']:first").val().replace(/[^a-zA-Z 0-9]+/g,"");$("#SearchAdr").html("Located with "+b+" of "+c+", "+a)}function updateActAmen(a){var b="";$("select[id$='lboxAmenities']:first").find("OPTION:selected").each(function(){b+=", "+$(this).text()});$("select[id$='lboxActivities']:first").find("OPTION:selected").each(function(){b+=", "+$(this).text()});if(b!==""){if(b.indexOf(",")===0){b=b.substr(2)}$("#SearchActAmen").html("Includes Amenties/Activities: "+b)}}function checkMap(c){if(c=="addr"){var a=$("#ctl00_ContentPlaceHolder1_txtCity").text();if(a===""){a=$("#ctl00_ContentPlaceHolder1_txtCity").val()}var b=$("#ctl00_ContentPlaceHolder1_txtAddress1").text();if(b===""){b=$("#ctl00_ContentPlaceHolder1_txtAddress1").val()}b="http://maps.live.com/?v=2&where1="+b+","+a+",WA";window.open(b,"mWind","statusbar=yes,toolbar=no,resizable=yes,scrollbars=yes,location=yes")}else{if(c=="latlon"){onLoad()}}}function ViewTrailDetail(e,b,d){map.DeleteAllShapeLayers();lTrailPins=null;var a=lineToPoint(e).replace("  "," ").split(" ");a=new VELatLong(parseFloat(a[0]),parseFloat(a[1]));var c=new VEShape(VEShapeType.Pushpin,a);c.SetTitle(b);c.SetDescription(d);c.SetCustomIcon(get_icon(2));if(boolSmallMap===true){boolSmallMap=false;map.Resize(450,450);$("#lnkTrailDetail").html('<img src="img/16-zoom.png" align="left" width="16" height="16" alt="-" hspace="1" />Hide Trail Detail');populateShpLayer(e,b,d);selectedLayer=b;multiAddPolyLines(c,l(2));$(".DetailLink").css("text-align","left");map.ShowDashboard()}else{boolSmallMap=true;map.Resize(210,220);$("#lnkTrailDetail").html('<img src="img/16-zoom.png" align="left" width="16" height="16" alt="+" hspace="1" />View Trail Detail');l(2).AddShape(c);map.HideDashboard();$(".DetailLink").css("text-align","right")}map.SetCenter(a);map.AddShapeLayer(l(2))};