/*
    Copyright (c) 2006-2009, SpatialPoint, LLC.
    
    All rights reserved.
    
    http://www.spatialpoint.com
*/
var tiles={};var shapes={};function getVEMapOptions(){var A=new VEMapOptions();A.EnableBirdseye=false;A.LoadBaseTiles=true;return A}function appSetup(){mapDiv=document.getElementById("ve_map");map=new VEMap(mapDiv.id);map.SetClientToken(clientToken);map.SetTileBuffer(0);var A=getVEMapOptions();map.LoadMap(new VELatLong(39.450001,-94),4,VEMapStyle.Road,false,VEMapMode.Mode2D,false,0,A);map.SetShapesAccuracy(VEShapeAccuracy.Pushpin);map.AttachEvent("ontokenexpire",handleTokenExpire);map.AttachEvent("ontokenerror",handleTokenError);map.AttachEvent("onerror",function(B){alert("Error: "+B.message)});map.AttachEvent("onchangeview",function(B){updateLegend(B.zoomLevel)});map.AttachEvent("onmouseover",function(B){if(B.elementID!=null){return true}});map.setCursor=function(B){mapDiv.childNodes[0].style.cursor=B};map.resetCursor=function(){this.setCursor("")};createLayers();if(generalHomePoints&&generalHomePoints.length&&generalHomePoints.length>0){window.setTimeout(loadPushpins,100)}setActiveMapTab($get("tab_generalcoverage"));setActiveFinderTab($get("tab_address"))}function createLayers(){tiles.GeneralCombined=new TileLayer({name:"GeneralCombined",displayName:"General LayerCake",hostUrl:hostUrl+"tiles/",displayThemes:"General_Combined*;General_Ext2*;TravelTalk*;Planned*",minZoomLevel:8,maxZoomLevel:20,zIndex:200,opacity:0.5,imageFormat:imageFormat,themeId:lookupThemeIds.GeneralCombined,toolTipFieldIndex:0,toolTipZoomLevel:8,onVisibleChange:function(A){if($get(this.name+"Visibility")){$get(this.name+"Visibility").checked=A.getVisible()}}});tiles.GeneralMarketing=new TileLayer({name:"GeneralMarketing",displayName:"General Marketing",hostUrl:hostUrl+"tiles/",displayThemes:"General_Mkt*;General_Ext_*;TravelTalk*;Planned*",minZoomLevel:5,maxZoomLevel:7,zIndex:200,opacity:0.5,imageFormat:imageFormat,themeId:0,toolTipFieldIndex:0,toolTipZoomLevel:8,onVisibleChange:function(A){if($get(this.name+"Visibility")){$get(this.name+"Visibility").checked=A.getVisible()}}});tiles.UnlimitedText=new TileLayer({name:"UnlimitedText",displayName:"Unlimited Text",hostUrl:hostUrl+"shadeoverridetiles/",displayThemes:"General_Mkt*;General_Ext_*;TravelTalk*",minZoomLevel:4,maxZoomLevel:20,zIndex:200,opacity:0.5,imageFormat:imageFormat,themeId:0,toolTipFieldIndex:0,toolTipZoomLevel:8,onVisibleChange:function(A){if($get(this.name+"Visibility")){$get(this.name+"Visibility").checked=A.getVisible()}}});tiles.DualBandCombined=new TileLayer({name:"DualBandCombined",displayName:"Dual-band LayerCake",hostUrl:hostUrl+"tiles/",displayThemes:"Dual_Combined*;Dual_Ext2*;TravelTalk*",minZoomLevel:8,maxZoomLevel:20,zIndex:200,opacity:0.5,imageFormat:imageFormat,themeId:lookupThemeIds.DualBandCombined,toolTipFieldIndex:0,toolTipZoomLevel:8,onVisibleChange:function(A){if($get(this.name+"Visibility")){$get(this.name+"Visibility").checked=A.getVisible()}}});tiles.DualBandMarketing=new TileLayer({name:"DualBandMarketing",displayName:"Dual-band Marketing",hostUrl:hostUrl+"tiles/",displayThemes:"Dual_Mkt*;Dual_Ext_*;TravelTalk*",minZoomLevel:5,maxZoomLevel:7,zIndex:200,opacity:0.5,imageFormat:imageFormat,themeId:0,toolTipFieldIndex:0,toolTipZoomLevel:8,onVisibleChange:function(A){if($get(this.name+"Visibility")){$get(this.name+"Visibility").checked=A.getVisible()}}});tiles.TravelTalk=new TileLayer({name:"TravelTalk",displayName:"TravelTalk",hostUrl:hostUrl+"tiles/",displayThemes:"TravelTalk*",minZoomLevel:4,maxZoomLevel:4,zIndex:150,opacity:0.5,imageFormat:imageFormat,themeId:4,toolTipFieldIndex:0,toolTipZoomLevel:8,onVisibleChange:function(A){if($get(this.name+"Visibility")){$get(this.name+"Visibility").checked=A.getVisible()}}});shapes.generalHomePoints=new ShapeLayer({name:"generalHomePoints",displayName:"generalHomePoints",themeId:9,minZoomLevel:4,maxZoomLevel:4,zIndex:299,getIconUrl:function(A){return dots[0]},getIconTitle:function(A){return""},onVisibleChange:function(A){if($get(this.name+"Visibility")){$get(this.name+"Visibility").checked=A.getVisible()}}});shapes.generalExtendedPoints=new ShapeLayer({name:"generalExtendedPoints",displayName:"generalExtendedPoints",themeId:10,minZoomLevel:4,maxZoomLevel:4,zIndex:298,getIconUrl:function(A){return dots[1]},getIconTitle:function(A){return""},onVisibleChange:function(A){if($get(this.name+"Visibility")){$get(this.name+"Visibility").checked=A.getVisible()}}});shapes.generalFuturePoints=new ShapeLayer({name:"generalFuturePoints",displayName:"generalFuturePoints",themeId:11,minZoomLevel:4,maxZoomLevel:4,zIndex:297,getIconUrl:function(A){return dots[2]},getIconTitle:function(A){return""},onVisibleChange:function(A){if($get(this.name+"Visibility")){$get(this.name+"Visibility").checked=A.getVisible()}}});shapes.dualHomePoints=new ShapeLayer({name:"dualHomePoints",displayName:"dualHomePoints",themeId:12,minZoomLevel:4,maxZoomLevel:4,zIndex:299,getIconUrl:function(A){return dots[0]},getIconTitle:function(A){return""},onVisibleChange:function(A){if($get(this.name+"Visibility")){$get(this.name+"Visibility").checked=A.getVisible()}}});shapes.dualExtendedPoints=new ShapeLayer({name:"dualExtendedPoints",displayName:"dualExtendedPoints",themeId:13,minZoomLevel:4,maxZoomLevel:4,zIndex:298,getIconUrl:function(A){return dots[1]},getIconTitle:function(A){return""},onVisibleChange:function(A){if($get(this.name+"Visibility")){$get(this.name+"Visibility").checked=A.getVisible()}}})}function handleTokenExpire(){alert("Your session has expired, please refresh the page.")}function handleTokenError(){alert("Your session is invalid, please refresh the page to reinitialize your session.")}function handleErrorResponse(B){var A=B.get_stackTrace();var F=B.get_message();var D=B.get_statusCode();var E=B.get_exceptionType();var C=B.get_timedOut();var G=[];G.push("Stack Trace: "+A);G.push("Service Error: "+F);G.push("Status Code: "+D);G.push("Exception Type: "+E);G.push("Timedout: "+C);alert(G.join("\n"))}function getMapViewBoundingRectange(){var A=map.GetMapView();return{NorthEast:{Longitude:A.BottomRightLatLong.Longitude,Latitude:A.TopLeftLatLong.Latitude},SouthWest:{Longitude:A.TopLeftLatLong.Longitude,Latitude:A.BottomRightLatLong.Latitude}}}function setViewPort(boundingRectangle){if(boundingRectangle){var points=[];with(boundingRectangle){points.push(new VELatLong(NorthEast.Latitude,NorthEast.Longitude));points.push(new VELatLong(SouthWest.Latitude,SouthWest.Longitude))}map.SetMapView(points)}}function getMouseLatLong(A){return map.PixelToLatLong(new VEPixel(A.mapX,A.mapY))}var SIGNAL_STRENGTH=["best","good","moderate"];function onClearLocation(){for(var A in SIGNAL_STRENGTH){hideControl("legend.general.layerCake."+SIGNAL_STRENGTH[A]);hideControl("legend.dualBand.layerCake."+SIGNAL_STRENGTH[A])}}function onSetLocation(C){var B;onClearLocation();function A(D){if(pushpin){var E=[];if(D&&D.length>0){var F="legend.";if(tiles.GeneralCombined.themeId==B){F+="general.layerCake."+D}else{F+="dualBand.layerCake."+D}showControl(F)}else{}}}if(activeMapTab!="tab_unlimitedtext"){if(activeMapTab=="tab_generalcoverage"){B=tiles.GeneralCombined.themeId}else{B=tiles.DualBandCombined.themeId}Service.GetCoverage(C,B,A,handleErrorResponse)}}function loadPushpins(){shapes.dualHomePoints.addPushpins(dualHomePoints);shapes.dualExtendedPoints.addPushpins(dualExtendedPoints);shapes.generalHomePoints.addPushpins(generalHomePoints);shapes.generalExtendedPoints.addPushpins(generalExtendedPoints);shapes.generalFuturePoints.addPushpins(generalFuturePoints)}function zoomTo(B,A){map.SetCenterAndZoom(new VELatLong(B,A),10)}function setActiveFinderTab(A){activeFinderTab=A.id;$("a.form_tab").removeClass("current");$(A).addClass("current");$("div.form_holder").css("display","none");$("div.popup").css("display","none");switch(activeFinderTab){case"tab_address":$("div#address").css("display","block");$get("address_street").focus();break;case"tab_xstreet":$("div#xstreet").css("display","block");$get("xstreet_street1").focus();break;case"tab_place":$("div#place").css("display","block");$get("place_place").focus();break}}function setActiveMapTab(B){activeMapTab=B.id;$("a.map_tab").removeClass("current");$(B).addClass("current");$("div.popup").css("display","none");for(var A in tiles){if(tiles[A].getVisible()){tiles[A].setVisible(false)}}for(var A in shapes){if(shapes[A].getVisible()){shapes[A].setVisible(false)}}switch(activeMapTab){case"tab_generalcoverage":tiles.GeneralCombined.setVisible(true);tiles.GeneralMarketing.setVisible(true);tiles.TravelTalk.setVisible(true);shapes.generalFuturePoints.setVisible(true);shapes.generalExtendedPoints.setVisible(true);shapes.generalHomePoints.setVisible(true);break;case"tab_unlimitedtext":tiles.UnlimitedText.setVisible(true);break;case"tab_dualband":$("div#popup_dualband").css("display","block");tiles.DualBandCombined.setVisible(true);tiles.DualBandMarketing.setVisible(true);tiles.TravelTalk.setVisible(true);shapes.dualExtendedPoints.setVisible(true);shapes.dualHomePoints.setVisible(true);break}if(pushpin){onSetLocation(pushpin.GetPoints()[0])}updateLegend(map.GetZoomLevel())}function updateLegend(B){$("div.legend_holder").css("display","none");var A="";if(B>7){A="_layercake"}else{if(B>4){A="_boundaries"}}switch(activeMapTab){case"tab_generalcoverage":$("div#generalcoverage"+A+"_legend").css("display","block");break;case"tab_unlimitedtext":$("div#unlimitedtext_legend").css("display","block");break;case"tab_dualband":$("div#dualband"+A+"_legend").css("display","block");break}}var PopupPointerHeight=23;var PopupPointerOffset=20;var PopupWidth=200;function PinHover(F){if(F.elementID){var B=map.GetShapeByID(F.elementID);if(B.Type=="Point"){var A=map.LatLongToPixel(new VELatLong(B.Latitude,B.Longitude));var E=(A.y+map.GetTop()-PopupPointerOffset-(PopupPointerHeight/2));var D=A.x+map.GetLeft();if(D>(map.GetLeft()+map.GetWidth()-PopupWidth)){popupPointerDiv.className="custom_popup_pointer_right";D-=PopupWidth}else{popupPointerDiv.className="custom_popup_pointer"}popupMasterDiv.style.top=E+"px";popupMasterDiv.style.left=D+"px";var C=[];C.push("<div style='float:right; font-size: x-small; text-align:right'><a href='javascript:void(0)' onclick='HidePopup()'>[Close]</a></div>");C.push("<b>");C.push(B.Title);C.push("</b><br/>");C.push(B.GetDescription());popupContentDiv.innerHTML=C.join("");popupMasterDiv.style.display="block";return true}else{return false}}}function hideControl(B){var A=document.getElementById(B);if(A!=null){A.style.visibility="hidden";A.style.display="none"}}function showControl(B){var A=document.getElementById(B);if(A!=null){A.style.visibility="visible";A.style.display="block"}}function toggleDisplay(B){var A=document.getElementById(B);if(A.style.visibility=="hidden"){A.style.visibility="visible";A.style.display="block"}else{A.style.visibility="hidden";A.style.display="none"}}function trim(A){return A.replace(/^\s*|\s*$/g,"")}function isKeyPressed(B,C){B=(B)?B:(window.event)?event:null;if(B){var A=(B.charCode)?B.charCode:((B.keyCode)?B.keyCode:((B.which)?B.which:0));return(A==C)}return false}function getXCoord(A){x=0;while(A){x+=A.offsetLeft;A=A.offsetParent}return x}function getYCoord(A){y=0;while(A){y+=A.offsetTop;A=A.offsetParent}return y}function findPos(A){var B=curtop=0;if(A.offsetParent){B=A.offsetLeft;curtop=A.offsetTop;while(A=A.offsetParent){B+=A.offsetLeft;curtop+=A.offsetTop}}return[B,curtop]}function onBlurCloseButton(A){A.src="images/icn_close_unselected.gif"}function onMouseOverCloseButton(A){A.src="images/icn_close_selected.gif"}function getPixels(A){return A.substr(0,A.length-2)*1}function OnFailed(B){var A=B.get_stackTrace();var F=B.get_message();var D=B.get_statusCode();var E=B.get_exceptionType();var C=B.get_timedOut();var G="Stack Trace: "+A+"\nService Error: "+F+"\nStatus Code: "+D+"\nException Type: "+E+"\nTimedout: "+C;alert(G)}function isClassNameAtPoint(A,D,C){var B=document.elementFromPoint(A,D);while(B){if(B.className&&(B.className.indexOf(C)!=-1)){return true}B=B.parentNode}return false}function getObjectProperties(D){if(D){var C=[];for(var B in D){try{if(D[B]){C.push(B+" = "+D[B])}}catch(A){}}return C.join(", ")}return"getObjectProperties parameter 'obj' is Undefined"}function clearOptions(B){var A=document.getElementById(B);if(A){A.options.length=0}}function getFieldValues(C,D){var B=[];for(var A=0;A<C.length;A++){B.push(C[A][D])}B.sort();return B}function setOptions(D,A){var C=document.getElementById(D);if(C){C.options.length=0;for(var B=0;B<A.length;B++){C.options[B]=new Option(A[B],B)}}}function isInteger(C){var A="0123456789";for(var B=0;B<C.length;B++){if(A.indexOf(C.charAt(B))==-1){return false}}return true}var pushpin=null;function setLocation(C){var B;if(typeof (C.selectedIndex)!="undefined"){B=foundLocations[C.selectedIndex]}else{B=foundLocations[C]}if(B!=null){removePushpin();try{var D=getVELatLong(B.Location.Coordinates);pushpin=new VEShape(VEShapeType.Pushpin,D);pushpin.SetCustomIcon("images/ui/arrow_down.gif");pushpin.SetTitle(getLocationDisplayName(B.Location));map.AddShape(pushpin);if(B.Location.BestMapView!=null){map.SetMapView([getVELatLong(B.Location.BestMapView.NorthEast),getVELatLong(B.Location.BestMapView.SouthWest)])}else{map.SetCenterAndZoom(D,17)}if(typeof (onSetLocation)!="undefined"){onSetLocation(B.Location.Coordinates)}}catch(A){alert(A.message)}}}var LOCATIONFINDER_FIELDS=["address_street","address_city","address_state","address_zip","xstreet_street1","xstreet_street2","xstreet_city","xstreet_state","xstreet_zip","place_place"];function clearLocation(){removePushpin();for(var A=0;A<LOCATIONFINDER_FIELDS.length;A++){var B=$get(LOCATIONFINDER_FIELDS[A]);if(B.type=="select"){B.selectedIndex=-1}else{B.value=""}}if(typeof (onClearLocation)!="undefined"){onClearLocation()}}function findLocation(){$("div.form_row_matches").css("display","none");var location=new Object();location.street=location.city=location.state=location.zip=location.country="";location.country="United States";switch(activeFinderTab){case"tab_address":location.street=trim($get("address_street").value);location.city=trim($get("address_city").value);with($get("address_state")){location.state=options[selectedIndex].value}location.ZIPCode=trim($get("address_zip").value);if(location.street+location.city+location.state+location.ZIPCode==""){alert("Please type-in a location.");$get("address_street").focus();return }break;case"tab_xstreet":location.street=trim($get("xstreet_street1").value)+" & "+trim($get("xstreet_street2").value);location.city=trim($get("xstreet_city").value);with($get("xstreet_state")){location.state=options[selectedIndex].value}location.zip=trim($get("xstreet_zip").value);if(trim($get("xstreet_street1").value)+trim($get("xstreet_street2").value)+location.city+location.state+location.ZIPCode==""){alert("Please type-in a location.");$get("xstreet_street1").focus();return }break;case"tab_place":location.street=trim($get("place_place").value);if(location.street==""){alert("Please type-in a place or landmark name.");$get("place_place").focus();return }break}Service.Geocode(location,geocodeResponse,handleErrorResponse)}function geocodeResponse(A){foundLocations=A;switch(A.length){case 0:alert("Unable to find the location, please try again.");break;case 1:setLocation(0);break;default:var C=$get(activeFinderTab+"_matches").options;C.length=0;for(var B=0;B<A.length;B++){C[B]=new Option(getLocationDisplayName(A[B].Location))}$get(activeFinderTab+"_match").style.display="block";break}}function getLocationDisplayName(A){if(A.Address!==null){return A.Address.FormattedAddress}return A.PlaceName}function getVELatLong(A){return new VELatLong(A.Latitude,A.Longitude)}function removePushpin(){if(pushpin!=null){map.DeleteShape(pushpin);pushpin=null}}function ShapeLayer(A){this._isClearing=false;this._shapeLayer=new VEShapeLayer();this._shapeLayer.Hide();this.criteria=null;this.onVisibleChange=null;this.onUpdated=null;if(A){for(var B in A){this[B]=A[B]}if(A.criteria){this.setCriteria(A.criteria)}if(A.minZoomLevel){this._shapeLayer.SetMinZoomLevel(A.minZoomLevel)}if(A.maxZoomLevel){this._shapeLayer.SetMaxZoomLevel(A.maxZoomLevel)}}this.getType=function(){return"ShapeLayer"};this.addShapeLayer=function(){map.AddShapeLayer(this._shapeLayer)};this.removeShapeLayer=function(){map.DeleteShapeLayer(this._shapeLayer)};this.getShapeLayer=function(){return this._shapeLayer};this.toggle=function(){return this.setVisible(!this.getVisible())};this.setVisible=function(E){if(E===true){try{this.addShapeLayer()}catch(D){}this._shapeLayer.Show();if(this.minZoomLevel&&(map.GetZoomLevel()==this.minZoomLevel)){for(var C=0;C<this._shapeLayer.GetShapeCount();C++){this._shapeLayer.GetShapeByIndex(C).Show()}}}else{this._shapeLayer.Hide()}if(this.onVisibleChange){this.onVisibleChange(this)}return true};this.getVisible=function(){return this._shapeLayer.IsVisible()};this.zoom=function(){map.SetMapView(this._shapeLayer.GetBoundingRectangle())};this.clear=function(){this._isClearing=true;this._shapeLayer.DeleteAllShapes();this._isClearing=false};this.addPushpin=function(I,G,H,F,E){var C=new VELatLong(parseFloat(I),parseFloat(G));var D=new VEShape(VEShapeType.Pushpin,C);if(H){D.SetTitle(H)}if(F){D.SetDescription(F)}if(E){D.SetCustomIcon(E)}if(this.zIndex){D.SetZIndex(this.zIndex)}this._shapeLayer.AddShape(D)};this.addPushpins=function(G){while(this._isClearing===true){Math.SQRT2(1023)}var D=[];for(var F=0;F<G.length;F++){var C=new VELatLong(G[F].Coordinates.Latitude,G[F].Coordinates.Longitude);var E=new VEShape(VEShapeType.Pushpin,C);if(this.getIconTitle){E.SetTitle(this.getIconTitle(G[F]))}else{E.SetTitle(G[F].Title)}if(this.getIconDescription){E.SetDescription(this.getIconDescription(G[F]))}else{E.SetDescription(G[F].Description)}if(this.getIconUrl){E.SetCustomIcon(this.getIconUrl(G[F]))}else{if(G[F].IconUrl){E.SetCustomIcon(G[F].IconUrl)}}if(this.zIndex){E.SetZIndex(this.zIndex)}D.push(E)}this._shapeLayer.AddShape(D);if(this.onUpdated){this.onUpdated(this)}};this.setCriteria=function(E){var C=this.getVisible();if(C===true){this.setVisible(false)}var D=this;Service.GetPushpins(E,function(F){D.addPushpins(F);if((C===true)||(D.criteria===null)){D.criteria=E;D.setVisible(true)}else{D.criteria=E}D.zoom()},function(F){if(C===true){D.setVisible(true)}handleErrorResponses(F)});this.clear()};this.getCriteria=function(){return this.criteria};this.getShapeCount=function(){return this._shapeLayer.GetShapeCount()};this.getShapeLayer=function(){return this._shapeLayer};this.addCircle=function(E,C){var D=getCirclePoints(E,C);var F=new VEShape(VEShapeType.Polygon,D);F.HideIcon();F.centroid=E;F.radius=C;this.addShape(F);return F};this.addDonut=function(F,H,G){var D=getCirclePoints(F,H);var C=getCirclePoints(F,G);var E=D.concat(C);var I=new VEShape(VEShapeType.Polygon,E);I.HideIcon();I.SetLineWidth(1);I.SetLineColor(new VEColor(0,0,0,0));I.centroid=F;I.innerRadius=H;I.outerRadius=G;this.addShape(I);return I};this.addPolygon=function(D){var C=new VEShape(VEShapeType.Polygon,D);C.HideIcon();this.addShape(C)};this.addShape=function(C){try{if(!C._visible){C._visible=true;C.getVisible=function(){return this._visible};C.hide=function(){this.Hide();this._visible=false};C.show=function(){this.Show();this._visible=true};C.toggle=function(){if(this.getVisible()){this.hide()}else{this.show()}}}this._shapeLayer.AddShape(C);if(this.onUpdated){this.onUpdated(this)}}catch(D){displayException(D)}};this.deleteShape=function(C){try{this._shapeLayer.DeleteShape(C);if(this.onUpdated){this.onUpdated(this)}}catch(D){displayException(D)}};this.deleteShapeByIndex=function(D){try{var C=this._shapeLayer.GetShapeByIndex(D);this._shapeLayer.DeleteShape(C);if(this.onUpdated){this.onUpdated(this)}}catch(E){displayException(E)}};this._getClusterPushpins=function(){if(!this.getVisible()){return }var D=[];var H;if(map.GetMapStyle()==VEMapStyle.Birdseye){H=19;var G=map.GetBirdseyeScene();var F=G.GetBoundingRectangle();D.push(F.TopLeftLatLong);D.push(F.BottomRightLatLong)}else{var C=map.GetMapView();D.push(C.TopLeftLatLong);D.push(C.BottomRightLatLong);H=map.GetZoomLevel()}var E={NorthWest:D[0],SouthEast:D[1]};if(this._zoomlevel!=H){this.clear();this._zoomlevel=H}if(this.minZoomLevel&&(this.minZoomLevel>H)){return }Service.GetClusterPushpins(E,H,this.themeId,Function.createDelegate(this,this._onMapDataSucceeded),handleErrorResponse)};this._onMapDataSucceeded=function(F){this.clear();var C=[];for(var E=0;E<F.length;E++){var G=F[E];var D=new VEShape(VEShapeType.Pushpin,new VELatLong(G.Coordinates.Latitude,G.Coordinates.Longitude));if(this.zIndex){D.SetZIndex(this.zIndex)}D.Bounds=G.ClusterArea;if(G.Count>1){D.SetCustomIcon("<img src='images/legend/black_circles.gif'>")}else{D.SetCustomIcon("<img src='images/legend/black_circle.gif'>")}C.push(D)}this._shapeLayer.AddShape(C)};this._pinActivate=function(D){if(D.elementID&&this.getVisible()){var C=map.GetShapeByID(D.elementID);if(C&&C.Bounds&&C.GetShapeLayer()==this._shapeLayer){this._currentpin=C;this._currentindex=0;this._getPushpinsAtClusterPushpin();this._currentpin.SetDescription("<div id='"+this._PopupPrefix+this._currentpin.GetID()+"'>Loading...</div>");this._currentpin.SetTitle("")}}};this._getPushpinsAtClusterPushpin=function(){Service.GetClusterPushpin(this._currentpin.Bounds,this._currentindex,this.themeId,Function.createDelegate(this,this._onContentSucceeded),handleErrorResponse,this._currentpin.GetID())};this._onContentSucceeded=function(K,G){if(G==this._currentpin.GetID()&&$get(this._PopupPrefix+G)){if(map.GetMapMode()==VEMapMode.Mode3D){this._currentpin.SetTitle(K.Title);this._currentpin.SetDescription(K.Details)}else{var D=[];if(this.displayName){D.push("<div style='width:100%; font-size: large; text-align: center;'><u>");D.push(this.displayName);D.push("</u><br/><br/></div>")}var C=document.createElement("div");if(K.PushpinCount>1){var J=document.createElement("div");var H=document.createElement("span");D.push(this._currentindex+1);D.push(" of ");D.push(K.PushpinCount);D.push(" Locations&nbsp;");H.innerHTML=D.join("");J.appendChild(H);var E=document.createElement("button");E.innerHTML="&lt; Previous";J.appendChild(E);Sys.UI.DomElement.addCssClass(E,"ActionButton");if(this._currentindex>0){$addHandler(E,"click",Function.createDelegate(this,this._previousRecord))}else{E.disabled=true}E=document.createElement("button");E.innerHTML="Next &gt;";J.appendChild(E);Sys.UI.DomElement.addCssClass(E,"ActionButton");if(this._currentindex<(K.PushpinCount-1)){$addHandler(E,"click",Function.createDelegate(this,this._nextRecord))}else{E.disabled=true}C.appendChild(J);D=[]}var F=document.createElement("div");D.push(K.Title);if(K.Description){D.push("<br/>");D.push(K.Description)}F.innerHTML=D.join("");C.appendChild(F);$get(this._PopupPrefix+G).innerHTML="";$get(this._PopupPrefix+G).appendChild(C);C.appendChild(document.createElement("br"));var E=document.createElement("button");E.innerHTML="More Information At this Point";E.style.fontSize="xx-small";var I=this._currentpin.GetPoints()[0];E.onclick=function(){getMoreInfoAt(I.Latitude,I.Longitude)};C.appendChild(E)}}};this._previousRecord=function(){this._currentindex--;$get(this._PopupPrefix+this._currentpin.GetID()).innerHTML="Loading...";this._getPushpinsAtClusterPushpin()};this._nextRecord=function(){this._currentindex++;$get(this._PopupPrefix+this._currentpin.GetID()).innerHTML="Loading...";this._getPushpinsAtClusterPushpin()};this.Dispose=function(){alert("Disposing...")};if(this._init){this._init()}}function getCirclePoints(B,I,J){var C=B.Latitude;var D=B.Longitude;var F=C*Math.PI/180;var H=D*Math.PI/180;var K=I/3956;if(!J){J=10}var E,L,A;var G=[];for(var M=0;M<=360;M+=J){E=(M/90)*Math.PI/2;L=Math.asin(Math.sin(F)*Math.cos(K)+Math.cos(F)*Math.sin(K)*Math.cos(E));L=180*L/Math.PI;if(Math.cos(F)==0){A=D}else{A=((H-Math.asin(Math.sin(E)*Math.sin(K)/Math.cos(F))+Math.PI)%(2*Math.PI))-Math.PI}A=180*A/Math.PI;G.push(new VELatLong(L,A))}return G}var tooltipPushpin=null;function GetDefaultTileLayerConfig(){return{name:null,isSelectable:false,themeId:null,toolTipFieldIndex:null,toolTipZoomLevel:null,hostUrl:null,urlParameters:"",displayThemes:null,zIndex:20,opacity:0.7,minZoomLevel:1,maxZoomLevel:20,bounds:[],useUniqueSuffix:false,imageFormat:".png",onSelectionStateChange:null,onVisibleChange:null}}function TileLayer(A){this._visible=false;this._tileLayerAdded=false;var C=GetDefaultTileLayerConfig();for(var B in C){this[B]=C[B]}if(A){for(var B in A){this[B]=A[B]}}if(!this.imageFormat.match(/^\./)){this.imageFormat="."+this.imageFormat}this.selectionState={Ids:[],Count:0,Data:""};this.thematicState={Info:null,CacheKey:null,Data:""};this.getType=function(){return"TileLayer"};this.getIsSelectable=function(){return this.isSelectable};this.setIsSelectable=function(D){this.isSelectable=D};this.addTileLayer=function(){var G=this;var E="";if(this.useUniqueSuffix===true){var D=new Date();E="&"+D.getHours()+"."+D.getMinutes()+"."+D.getSeconds()}var F=new VETileSourceSpecification(this.name,"");F.NumServers=1;F.Opacity=this.opacity;F.ZIndex=this.zIndex;F.GetTilePath=function(H){return G.getTilePath(H)+G.urlParameters+E};if(this.bounds.length>0){F.Bounds=this.bounds}if(this.minZoomLevel){F.MinZoomLevel=this.minZoomLevel}if(this.maxZoomLevel){F.MaxZoomLevel=this.maxZoomLevel}map.AddTileLayer(F,true);this._tileLayerAdded=true};this.removeTileLayer=function(){if(!this._tileLayerAdded){return }map.DeleteTileLayer(this.name)};this.toggle=function(){return this.setVisible(!this.getVisible())};this.setVisible=function(D){if(this.getVisible()===D){return false}if(D===true){if(this._tileLayerAdded===false){this.addTileLayer()}else{map.ShowTileLayer(this.name)}}else{if(this._tileLayerAdded===true){map.HideTileLayer(this.name)}}this._visible=D;if(this.onVisibleChange){this.onVisibleChange(this)}return true};this.getVisible=function(){return this._visible};this.refresh=function(){if(this.getVisible()){this.removeTileLayer();this.addTileLayer()}};this.setOpacity=function(D){if(this.getVisible()){this.opacity=D;this.refresh()}else{this.opacity=D}};this.getOpacity=function(){return this.opacity};this.setDisplayThemes=function(D){if(D===this.displayThemes){return }if(D){this.displayThemes=D.toLowerCase()}else{this.displayThemes=D}this.refresh()};this.getDisplayThemes=function(){return this.displayThemes};this.getEmptySelectionState=function(){return{Ids:[],Count:0,Data:"",Summary:{HomeCount:0,ApartmentCount:0,BusinessCount:0,TotalCount:0}}};this.setSelectionState=function(D){this.selectionState=D;if(this.getVisible()){map.ShowTileLayer(this.name)}if(this.onSelectionStateChange){this.onSelectionStateChange(this)}};this.clearSelection=function(){this.setSelectionState(this.getEmptySelectionState())};this.setThematicState=function(D){this.thematicState=D;if(this.getVisible()){this.ShowTileLayer(this.name)}};this.clearThematic=function(){this.setThematicState({Info:null,Data:"",CacheKey:null})};this.getTilePath=function(H){if(H!=null&&H!="undefined"){var F=[this.hostUrl];var D=0;for(var G=H.ZoomLevel;G>0;G--){D=0;var E=1<<(G-1);if((H.XPos&E)!=0){D++}if((H.YPos&E)!=0){D+=2}F.push(D)}F.push(this.imageFormat);if(this.displayThemes&&this.displayThemes!==null){F.push("?DT=");F.push(this.displayThemes);if(this.selectionState.Data&&(this.selectionState.Data>"")){F.push("&SS=");F.push(this.selectionState.Data)}else{if(this.thematicState.Data&&(this.thematicState.Data>"")){if(this.thematicState.CacheKey){F.push("&CK=");F.push(this.thematicState.CacheKey)}F.push("&TS=");F.push(this.thematicState.Data)}}}return F.join("")}};this.clearTooltip=function(){this._pixelCoordinates=null;if(this._tooltipHandle){window.clearTimeout(this._tooltipHandle);this._tooltipHandle=null}};this.startTooltip=function(D){if((D.zoomLevel<this.toolTipZoomLevel)||(this.getVisible()===false)){return }if(this._tooltipHandle){window.clearTimeout(this._tooltipHandle)}map.HideInfoBox();this._pixelCoordinates=new VEPixel(D.mapX,D.mapY);var E=this;this._tooltipHandle=window.setTimeout(function(){if(map.GetMapStyle()=="b"){return }var G=E._pixelCoordinates;var F=map.PixelToLatLong(G);Service.GetInfoAtPoint(F,E.themeId,E.toolTipFieldIndex,function(H){if(G!=E._pixelCoordinates){return }if(H&&H.length&&H.length>0){tooltipPushpin.SetPoints([F]);tooltipPushpin.SetTitle("Wire Center");tooltipPushpin.SetDescription("<div>"+H+"</div>");map.ShowInfoBox(tooltipPushpin)}else{tooltipPushpin.Hide()}},handleErrorResponse)},500)};this.toggleAtCoordinates=function(D){var E=this;Service.SelectAtCoordinates(D,this.themeId,-1,"Toggle",this.selectionState.Data,function(F){E.setSelectionState(F)},handleErrorResponses)};this.clickAtPoint=function(E){if(E.leftMouseButton===true){var D=new VEPixel(E.mapX,E.mapY);var F=map.PixelToLatLong(D);var G=this;if(E.ctrlKey===true){SessionService.SelectAtCoordinates(F,this.themeId,"Toggle",function(H){G.refresh()},handleErrorResponses)}else{if(E.shiftKey===true){Service.SelectWithinRadius(F,0.5,this.themeId,-1,"Select",this.selectionState.Data,function(H){G.setSelectionState(H)},handleErrorResponses)}}}};this.selectWithinRadius=function(E,D){var F=this;Service.SelectWithinRadius(E,D,this.themeId,-1,"Select",this.selectionState.Data,function(G){F.setSelectionState(G)},handleErrorResponses)};this.selectWithinPolygon=function(D){var E=this;Service.SelectWithinPolygon(D,this.themeId,-2,"Select",this.selectionState.Data,function(F){E.setSelectionState(F)},handleErrorResponses)};this.getSelected=function(E){var D=this;Service.GetSelected(this.themeId,0,this.selectionState.Data,function(F){E(F,D)},handleErrorResponses)};this.setInfo=function(D){this.info=D;this.themeId=D.ThemeId};this.getInfo=function(){return this.info}};