var Dashboard=new Class({initialize:function(mapWindow,mapObject){this.mapWindow=mapWindow;
this.mapObject=mapObject;
this.isbirdsEye=false;
this.hasHybrid=false;
this.hasBirdsEyeHybrid=false;
this.mapStyles={shaded:mapWindow.getVEMapStyle("Shaded"),road:mapWindow.getVEMapStyle("Road"),hybrid:mapWindow.getVEMapStyle("Hybrid"),aerial:mapWindow.getVEMapStyle("Aerial"),birdseyeHybrid:mapWindow.getVEMapStyle("BirdseyeHybrid"),birdseye:mapWindow.getVEMapStyle("Birdseye")};
var iframe=$(mapWindow.document.body);
$("dashboard").removeClass("hide").setStyle("visibility","visible");
$("dashboard").style.display="block";
$$("#compassCard, #mapSliderBox").setStyle("position","relative");
$$("#compassCard, #mapSliderBox").setStyle("position","absolute");
this.addSlider();
this.addBirdseyeOrientation();
this.addMinimap();
this.addSearch();
mapObject.AddShapeLayer(mapWindow.getVEShapeLayer());
mapObject.SetShapesAccuracy(mapWindow.getVEShapeAccuracy("Pushpin"));
mapObject.SetFailedShapeRequest(mapWindow.getVEFailedShapeRequest("DoNotDraw"));
mapObject.SetShapesAccuracyRequestLimit(10);
mapObject.HideDashboard();
this.addlayerButtons();
mapObject.AttachEvent("oninitmode",this.toggleBirdseye.bind(this));
mapObject.AttachEvent("onobliqueenter",this.toggleBirdseye.bind(this));
mapObject.AttachEvent("onobliqueleave",this.toggleBirdseye.bind(this));
mapObject.AttachEvent("onchangeview",this.toggleBirdseye.bind(this));
mapObject.AttachEvent("onchangemapstyle",this.toggleMapType.bind(this));
mapObject.AttachEvent("onendzoom",this.zoomStepEvent.bind(this));
mapObject.AttachEvent("onmouseup",this.panEnd.bind(this));
mapObject.AttachEvent("ontokenerror",this.tokenErrorHandler.bind(this));
mapObject.AttachEvent("ontokenexpire",this.tokenExpireHandler.bind(this));
mapObject.SetMouseWheelZoomToCenter(false);
mapObject.SetMapStyle(this.currentMapStyle);
this.toggleMapType({mapStyle:this.currentMapStyle});
this.zoomStepEvent()
},tokenErrorHandler:function(event){alert("token error: "+event)
},tokenExpireHandler:function(event){alert("token expired: "+event)
},addMinimap:function(){this.mapObject.ShowMiniMap($(this.mapObject.mapelement).getSize().size.x-150,0,this.mapWindow.getVEMiniMapSize("Small"));
$(this.mapWindow.document.getElementById("MSVE_minimap_resize")).addEvent("click",this.toggleMiniMap.bind(this));
this.minimap=$(this.mapWindow.document.getElementById("MSVE_minimap"));
this.minimapStatus=true;
this.toggleMiniMap()
},addSlider:function(){this.slider=new Slider($("mapSlider"),$("mapSliderKnob"),{steps:18,mode:"vertical",offset:0,onComplete:this.doZoomStep.bind(this)});
$("zoomout").addEvent("click",this.zoom.bind(this,-1));
$("zoomin").addEvent("click",this.zoom.bind(this,1))
},addSearch:function(){var fieldset=$("searchMap");
if(fieldset){fieldset.getElement("span.button").addEvent("click",this.search.bind(this));
var input=fieldset.getElement("input");
input.addEvents({keydown:this.keydownSearch.bindWithEvent(this,input,input.value)});
var i=new InputInitalValue([input])
}},addlayerButtons:function(){this.currentMapStyle=this.mapStyles.shaded;
var mapStyleList=$("mapStyle");
this.mapStyleButtons={};
this.mapStyleButtons[this.mapStyles.shaded]=mapStyleList.getElement("li.shaded").toggleClass("highlight").addEvent("click",this.toggleMapType.bind(this,{mapStyle:this.mapStyles.shaded}));
this.mapStyleButtons[this.mapStyles.aerial]=mapStyleList.getElement("li.aerial");
var hybridCheckBox=this.mapStyleButtons[this.mapStyles.aerial].getElement("label");
this.mapStyleButtons[this.mapStyles.aerial].addEvents({click:this.toggleMapType.bind(this,{mapStyle:this.mapStyles.aerial}),mouseenter:this.showHybridCheckbox.bindWithEvent(hybridCheckBox,true),mouseleave:this.showHybridCheckbox.bindWithEvent(hybridCheckBox,false)});
this.mapStyleButtons[this.mapStyles.birdseye]=mapStyleList.getElement("li.birdsEye");
var birdsEyeHybridCheckBox=this.mapStyleButtons[this.mapStyles.birdseye].getElement("label");
this.mapStyleButtons[this.mapStyles.birdseye].addEvents({click:this.toggleMapType.bind(this,{mapStyle:this.mapStyles.birdseye}),mouseenter:this.showHybridCheckbox.bindWithEvent(birdsEyeHybridCheckBox,true),mouseleave:this.showHybridCheckbox.bindWithEvent(birdsEyeHybridCheckBox,false)});
this.currentMapStyleButton=this.mapStyleButtons[this.mapStyles.shaded];
$("compassCard").addEvents({mousedown:this.panTo.bind(this),mouseup:this.panEnd.bind(this)});
$$("#showHybrid, #showBirdsEyeHybrid").addEvent("click",this.toggleHybrid.bindWithEvent(this))
},addBirdseyeOrientation:function(){$$("#birdseyeOrientation li").each(function(li){li.getElement("span.button").addEvent("click",this.toggleBirdsEyeOrientation.pass(li.id,this))
},this)
},toggleMiniMap:function(){this.minimap[(this.minimapStatus?"remove":"add")+"Class"]("toggle");
this.minimapStatus=!this.minimapStatus
},zoomStepEvent:function(){this.slider.set((this.isbirdsEye?2:19)-this.mapObject.GetZoomLevel())
},zoom:function(value){this.doZoomStep((this.isbirdsEye?2:19)-this.mapObject.GetZoomLevel()-value)
},doZoomStep:function(zoomLevel){zoomLevel=(this.isbirdsEye?2:19)-zoomLevel;
if($defined(zoomLevel)&&zoomLevel!=this.mapObject.GetZoomLevel()){if(zoomLevel<=(this.isbirdsEye?2:19)){this.mapObject.SetZoomLevel(zoomLevel)
}}},panTo:function(event){var speed=20;
switch(new Event(event).target.id){case"upLeft":var x=-speed,y=-speed;
break;
case"up":var x=0,y=-speed;
break;
case"upRight":var x=speed,y=-speed;
break;
case"left":var x=-speed,y=0;
break;
case"right":var x=speed,y=0;
break;
case"downLeft":var x=-speed,y=speed;
break;
case"down":var x=0,y=speed;
break;
case"downRight":var x=speed,y=speed;
break
}this.mapObject.StartContinuousPan(x,y)
},panEnd:function(){this.mapObject.EndContinuousPan()
},toggleMapType:function(event){var mapStyle=event.mapStyle;
if(!((mapStyle===this.mapStyles.birdseye||mapStyle===this.mapStyles.birdseyeHybrid)&&!this.mapObject.IsBirdseyeAvailable())){if(this.currentMapStyle!=mapStyle){if(mapStyle===this.mapStyles.birdseyeHybrid){mapStyle=this.mapStyles.birdseye
}if(mapStyle===this.mapStyles.hybrid){mapStyle=this.mapStyles.aerial
}this.currentMapStyleButton.removeClass("highlight");
this.currentMapStyleButton=this.mapStyleButtons[mapStyle].addClass("highlight");
if(mapStyle===this.mapStyles.birdseye&&this.hasBirdsEyeHybrid){mapStyle=this.mapStyles.birdseyeHybrid
}if(mapStyle===this.mapStyles.aerial&&this.hasHybrid){mapStyle=this.mapStyles.hybrid
}this.mapObject.SetMapStyle(mapStyle);
this.currentMapStyle=mapStyle
}}var currentMapStyle=this.mapObject.GetMapStyle();
this.isbirdsEye=currentMapStyle===this.mapStyles.birdseye||currentMapStyle===this.mapStyles.birdseyeHybrid;
this.toggleBirdseye()
},showHybridCheckbox:function(event,isShow){if(!this.getParent().hasClass("disabled")){this.style.display=isShow?"block":"none"
}},toggleHybrid:function(event){var target=$(event.target),isAerial=target.getParent().getParent().hasClass("aerial");
this[isAerial?"hasHybrid":"hasBirdsEyeHybrid"]=target.checked;
this.toggleMapType({mapStyle:this.mapStyles[isAerial?(target.checked?"hybrid":"aerial"):(target.checked?"birdseyeHybrid":"birdseye")]})
},toggleBirdseye:function(){$("birdseyeOrientation")[(this.isbirdsEye?"remove":"add")+"Class"]("hide");
this.mapStyleButtons[this.mapStyles.birdseye][(this.mapObject.IsBirdseyeAvailable()?"remove":"add")+"Class"]("disabled");
this.slider.element[(this.isbirdsEye?"add":"remove")+"Class"]("birdseye");
this.slider.options.steps=this.isbirdsEye?1:19
},toggleBirdsEyeOrientation:function(id){this.mapObject.SetBirdseyeOrientation(this.mapWindow.getVEOrientation(id.capitalize()));
$$("#birdseyeOrientation li").each(function(li){li[(li.id===id?"add":"remove")+"Class"]("active")
})
},keydownSearch:function(event){var event=new Event(event);
if(event.key==="enter"){event.preventDefault();
this.search()
}},search:function(){if(this.mapObject.mmLayer){this.mapObject.mmLayer.switschMMLayerByFind()
}var searchTxt=$("HRS_SEARCHBOX").value;
if(searchTxt!=this.initialSearchString){try{if(this.mapObject.GetMapStyle()===this.mapStyles.birdseye){this.toggleMapType({mapStyle:this.mapStyles.shaded})
}this.mapObject.Find(null,searchTxt,null,null,0,1,true,true,true,true,this.moreResults.bind(this))
}catch(e){}}},moreResults:function(layer,resultsArray,places,hasMore,veErrorMessage){if(!this.searchlayer){this.searchlayer=this.mapWindow.getVEShapeLayer();
this.mapObject.AddShapeLayer(this.searchlayer)
}if(places!=null&&places.length>0){if(this.searchPushpin){this.mapObject.DeleteShape(this.searchPushpin);
this.searchPushpin=null
}var latLong=places[0].LatLong;
this.searchPushpin=this.mapWindow.getVEShape(latLong.Latitude,latLong.Longitude);
this.searchPushpin.SetTitle(places[0].Name);
this.searchPushpin.SetCustomIcon('<div class="pushPin searchCenter"> </div>');
this.searchlayer.DeleteAllShapes();
this.searchlayer.AddShape(this.searchPushpin)
}else{this.mapObject.ShowMessage(veErrorMessage)
}}});
var MWSLayer=new Class({options:{layers:{railroadTransportation:{name:"SICMaj40"},waterTransportation:{name:"SICMaj44"},busStation:{name:"SIC4170"},airport:{name:"SIC4581"},golf:{name:"SIC7992"},parkRecreationArea:{name:"SIC7947"},touristAttraction:{name:"SIC7999"},hospital:{name:"SICInd806"},museum:{name:"SIC8410"},fun:{name:"SIC7996"},sportsComplex:{name:"SIC7940"},restaurants:{name:"SIC5800"}},hasInit:false},initialize:function(mapWindow,mapObject){this.mapWindow=mapWindow;
this.mapObject=mapObject;
this.defaultRadius=400;
mapObject.mwsLayer=this;
$("poiToggler").addEvent("click",this.togglePoiLayer)
},init:function(){for(var key in this.options.layers){var input=$(key),layer=this.options.layers[key];
if(input){layer.shapeLayer=this.mapWindow.getVEShapeLayer();
layer.shapeLayer.Hide();
input.addEvent("click",this.getMWSData.bindWithEvent(this))
}}},calculateRadius:function(){var view=this.mapObject.GetMapView();
var topLeft=this.mapWindow.getVELatLong(view.TopLeftLatLong.Latitude,view.TopLeftLatLong.Longitude);
var bottomLeft=this.mapWindow.getVELatLong(view.BottomRightLatLong.Latitude,view.TopLeftLatLong.Longitude);
var radius=Math.round(getDistance(topLeft,bottomLeft)/2);
if(radius>this.defaultRadius){radius=this.defaultRadius
}return radius
},refreshLayer:function(){for(key in map.mwsLayer.options.layers){var layer=map.mwsLayer.options.layers[key];
if(layer.isOnMap){var latlon=this.mapObject.GetCenter();
DynamicMap.getDataFromMWS(latlon.Latitude,latlon.Longitude,this.calculateRadius(),layer.name,"map.mwsLayer.options.layers['"+key+"']",function(jsResult){if(jsResult!=null){eval(jsResult.result)
}})
}}},getMWSData:function(event){var target=event.target,key=target.id,load=target.checked;
layer=this.options.layers[key];
if(layer){if(load){if(!layer.isOnMap){var latlon=this.mapObject.GetCenter();
var isIframe=(window.iframeMap||parent.iframeMap)?true:false;
DynamicMap.getDataFromMWS(latlon.Latitude,latlon.Longitude,this.calculateRadius(),layer.name,"map.mwsLayer.options.layers['"+key+"']",isIframe,function(jsResult){if(jsResult!=null){eval(jsResult.result)
}})
}if(layer.shapeLayer){layer.shapeLayer.Show()
}}else{this.mapObject.DeleteShapeLayer(layer.shapeLayer);
this.options.layers[key].shapeLayer=this.mapWindow.getVEShapeLayer()
}layer.isOnMap=load
}},reinitMWSLayer:function(){this.options.layers.each(function(item){var layer=item.shapeLayer;
layer.DeleteAllShapes();
this.mapObject.DeleteShapeLayer(layer);
layer=this.mapWindow.getVEShapeLayer()
})
},resetIsOnMap:function(){for(var key in this.options.layers){this.options.layers[key].isOnMap=false
}},enableCheckBoxes:function(enable){for(var key in this.options.layers){var input=$(key);
if(input){if(!enable){input.checked=enable
}input.disabled=!enable
}}},togglePoiLayer:function(){var lis=$$("#routingMask, #pois");
lis[lis.length-1].toggleClass("show");
if(lis.length>1){lis[0].removeClass("show");
lis[0].getElement("h5 strong").removeClass("open")
}this.getElement("strong").toggleClass("open")
}});
function getDistance(p1,p2){var p1Lat=latLonToRadians(p1.Latitude);
var p1Lon=latLonToRadians(p1.Longitude);
var p2Lat=latLonToRadians(p2.Latitude);
var p2Lon=latLonToRadians(p2.Longitude);
var R=6371;
var dLat=p2Lat-p1Lat;
var dLong=p2Lon-p1Lon;
var a=Math.sin(dLat/2)*Math.sin(dLat/2)+Math.cos(p1Lat)*Math.cos(p2Lat)*Math.sin(dLong/2)*Math.sin(dLong/2);
var c=2*Math.atan2(Math.sqrt(a),Math.sqrt(1-a));
return(R*c)
}function latLonToRadians(point){return point*Math.PI/180
}var InputInitalValue=new Class({initialize:function(inputs){inputs.each(function(input){var initialValue=input.value;
input.addEvent("focus",this.toggle.bind(input,[initialValue,true])).addEvent("blur",this.toggle.bind(input,[initialValue,false])).setStyle("color","#808080")
},this)
},toggle:function(initialValue,isFocus){if(this.value===""||this.value===initialValue){this.setStyle("color",isFocus?"":"#808080").value=isFocus?"":initialValue
}}});
var Routing=new Class({options:{start:"",end:"",minutes:"",hours:"",totalRange:""},initialize:function(mapWindow,mapObject,routingPopupUrl,options){this.mapWindow=mapWindow;
this.mapObject=mapObject;
this.routingPopupUrl=routingPopupUrl;
this.setOptions(options);
mapObject.routing=this;
$("routingButton").addEvent("click",this.initRouting.bindWithEvent(this));
$("routingToggler").addEvent("click",this.togglerRoutingLayer);
$("routingStartAddress").addEvent("keydown",this.remFreeRoutingPoint.bindWithEvent(this,"start"));
$("routingEndAddress").addEvent("keydown",this.remFreeRoutingPoint.bindWithEvent(this,"end"));
$$("form").addEvent("submit",this.stopFormSubmit.bindWithEvent(this));
this.mapToken="";
map.veMap.AttachEvent("onclick",this.clickToRouting.bind(this))
},stopFormSubmit:function(event){if(this.stopSubmit){new Event(event).stop();
if($("routingStartAddress").value!=""&&$("routingEndAddress").value!=""){this.routingPopup=window.open(this.routingPopupUrl,"routing","width=425,height=550,left=50,top=0,scrollbars=yes,menubar=yes, resize=yes");
this.initRouting();
this.stopSubmit=false
}}},init:function(){this.routingAddress={start:null,end:null};
this.freeRoutingPoints={start:null,end:null};
this.evaluateLocation={start:function(locations){map.routing.setRoutingAddress((locations!=null?locations[0].Name:map.routing.options.start),"start")
},end:function(locations){map.routing.setRoutingAddress((locations!=null?locations[0].Name:map.routing.options.end),"end")
}};
DynamicMap.getToken(function(data){map.routing.mapToken=data
})
},initRouting:function(event){if(event){new Event(event).stop()
}if($("routingStartAddress").value!=""&&$("routingEndAddress").value!=""){if(!this.stopSubmit){this.closeRoutingPopup()
}this.routingPopup=window.open(this.routingPopupUrl,"routing","width=425,height=550,left=50,top=0,scrollbars=yes,menubar=yes, resize=yes");
if(this.mapToken==""){return 
}map.veMap.SetClientToken(this.mapToken);
this.routingAddress={start:$("routingStartAddress").value,end:$("routingEndAddress").value};
this.routingOptions=this.mapWindow.getVERouteOptions();
this.routingOptions.DrawRoute=false;
this.routingOptions.SetBestMapView=false;
this.routingOptions.ShowDisambiguation=false;
this.routingOptions.ShowErrorMessages=true;
this.routingOptions.DistanceUnit=this.mapWindow.getVERouteDistanceUnit();
if((this.routingAddress.start!=""&&this.routingAddress.end!="")||(this.freeRoutingPoints.end&&this.freeRoutingPoints.start)){this.startRouting()
}else{}}},openRoutingPopup:function(){if(this.routingPopup){if($(this.routingPopup.document.getElementById("routing_address_switch"))){this.initializePopup()
}else{if(window.ie){this.routingPopup.attachEvent("onload",this.initializePopup.bind(this));
this.routingPopup.attachEvent("onunload",this.clearRoutingPopup.bind(this))
}else{this.routingPopup.addEventListener("load",this.initializePopup.bind(this),false)
}}}},initializePopup:function(){$(this.routingPopup.document.getElementById("routing_address_switch")).addEvent("click",this.switchRoutingAddresses.bind(this));
map.routing.writeRoutingDetails()
},closeRoutingPopup:function(){if(this.routingPopup){this.routingPopup.close()
}},clearRoutingPopup:function(){this.routingPopup=null
},startRouting:function(){this.toggleRouteWaiting(true);
var routingPoints=[this.freeRoutingPoints.start?this.freeRoutingPoints.start:this.routingAddress.start,this.freeRoutingPoints.end?this.freeRoutingPoints.end:this.routingAddress.end];
this.routingOptions.RouteCallback=this.evaluateRoute.bind(this);
map.veMap.GetDirections(routingPoints,this.routingOptions);
if(window.ie6){map.routing.wait(2000)
}},wait:function(millis){var date=new Date();
var curDate=null;
do{curDate=new Date()
}while(curDate-date<millis)
},getRoutingGeometries:function(veRoute){if(!this.veRoutingLayer){this.veRoutingLayer=this.mapWindow.getVEShapeLayer();
map.veMap.AddShapeLayer(this.veRoutingLayer)
}else{this.veRoutingLayer.DeleteAllShapes()
}if(this.routingLayer){this.freeRoutingShapes.start.Hide();
this.freeRoutingShapes.end.Hide()
}this.routingDetails={hour:Math.floor(veRoute.Time/60/60),min:Math.ceil((veRoute.Time/60)%60),distance:veRoute.Distance.toFixed(1),distanceUnit:this.routingOptions.DistanceUnit,routingDirections:[],routingAddress:this.routingAddress};
var waypointIconDistance=31;
var waypoints=new Array();
for(i=0,l=veRoute.RouteLegs.length;
i<l;
i++){var routeLegs=veRoute.RouteLegs[i].Itinerary.Items;
for(var j=0,m=routeLegs.length;
j<m;
j++){var item=routeLegs[j];
this.routingDetails.routingDirections[j]={num:j+1,description:item.Text,latitude:item.LatLong.Latitude,longitude:item.LatLong.Longitude,distance:item.Distance.toFixed(1)};
waypoints[j]=item.LatLong.Latitude+","+item.LatLong.Longitude;
this.createRoutePointShapes(item.LatLong,this.routingDetails.routingDirections[j].num,item.Text,'<div class="waypoint" style="background-position:0 -'+(j*waypointIconDistance)+'px"></div>')
}}var points=veRoute.ShapePoints;
var routeShape=null;
if(window.ie6||window.ie7){var i=0;
var partSize=5000;
var partStart=(i)*partSize;
var partEnd=partStart+partSize;
this.pointsPart=new Array();
this.generateRoute=new Array();
var j=0;
while(partEnd!=points.length-1){partStart=(i)*partSize;
partEnd=partStart+partSize;
if(partEnd>points.length){partEnd=points.length-1;
this.pointsPart[i]=points.slice(partStart)
}else{this.pointsPart[i]=points.slice(partStart,partEnd)
}this.generateRoute[i]=function(){var routeShape=map.routing.mapWindow.getVEShapePolyline(map.routing.pointsPart[j]);
routeShape.SetLineColor(map.routing.mapWindow.getVEColor(50,220,250,0.7));
routeShape.SetLineWidth(3);
routeShape.HideIcon();
routeShape.SetTitle("Route");
routeShape.SetDescription("Route");
map.routing.veRoutingLayer.AddShape(routeShape);
j++
};
i++
}this.generateRoute.each(function(item){item.delay(100)
},this)
}else{routeShape=this.mapWindow.getVEShapePolyline(points);
routeShape.SetLineColor(this.mapWindow.getVEColor(50,220,250,0.7));
routeShape.SetLineWidth(3);
routeShape.HideIcon();
routeShape.SetTitle("Route");
routeShape.SetDescription("Route");
this.veRoutingLayer.AddShape(routeShape)
}this.createRoutePointShapes(points[0],this.options.start,this.routingAddress.start,'<div  class="startRoute"></div>');
this.createRoutePointShapes(points[points.length-1],this.options.end,this.routingAddress.end,'<div  class="endRoute"></div>');
var boundingRectangle=this.veRoutingLayer.GetBoundingRectangle();
map.veMap.SetMapView(boundingRectangle);
var mapRouting={routingMapZoom:map.veMap.GetZoomLevel(),routingMapCenterLat:map.veMap.GetCenter().Latitude,routingMapCenterLon:map.veMap.GetCenter().Longitude,routingShapes:points.join(";"),routingWaypoints:waypoints.join(";"),routingWaypointIconDistance:waypointIconDistance,routingMapNorthWestLat:boundingRectangle.TopLeftLatLong.Latitude,routingMapNorthWestLon:boundingRectangle.TopLeftLatLong.Longitude,routingMapSouthEastLat:boundingRectangle.BottomRightLatLong.Latitude,routingMapSouthEastLon:boundingRectangle.BottomRightLatLong.Longitude};
var pixel=map.veMap.LatLongToPixel(points[0]);
if(pixel.x<30||pixel.y<30){map.veMap.SetZoomLevel(map.veMap.GetZoomLevel()-1)
}DynamicMap.setMapRouting(mapRouting,function(data){map.routing.openRoutingPopup()
})
},createRoutePointShapes:function(veLatLon,title,description,icon){var shape=this.mapWindow.getVEShape(veLatLon.Latitude,veLatLon.Longitude);
shape.SetTitle(""+title);
shape.SetDescription(description);
shape.SetCustomIcon(icon);
this.veRoutingLayer.AddShape(shape)
},routingWarning:function(alertMessage){},evaluateRoute:function(veRoute){map.routing.toggleRouteWaiting(false);
if(veRoute&&veRoute.RouteLegs&&veRoute.RouteLegs.length!=0){map.routing.getRoutingGeometries(veRoute)
}else{map.routing.closeRoutingPopup()
}},switchRoutingAddresses:function(){this.routingAddress={start:this.routingAddress.end,end:this.routingAddress.start};
this.freeRoutingPoints={start:this.freeRoutingPoints.end,end:this.freeRoutingPoints.start};
this.setRoutingAddress(this.routingAddress.start,"start",this.freeRoutingPoints?this.freeRoutingPoints.start:null);
this.setRoutingAddress(this.routingAddress.end,"end",this.freeRoutingPoints?this.freeRoutingPoints.end:null);
this.startRouting()
},setRoutingAddress:function(address,startEnd,point){this.routingAddress[startEnd]=address;
$("routing"+startEnd.capitalize()+"Address").value=this.routingAddress[startEnd];
if(point){if(!this.freeRoutingPoints){this.freeRoutingPoints={}
}this.freeRoutingPoints[startEnd]=point
}this.showRoutingLayer()
},clickToRouting:function(event){if(event.rightMouseButton){if(!this.routingLayer){this.initFreeRouting()
}this.routingLayer.removeClass("hide").setStyles({top:Math.min(event.mapY,this.layerMaxPosition.top),left:Math.min(event.mapX,this.layerMaxPosition.left)});
this.freeRoutingPoint=map.veMap.PixelToLatLong(this.mapWindow.getVEPixel(event.mapX,event.mapY))
}else{if(this.routingLayer){this.routingLayer.addClass("hide")
}}},setFreeRoutingPoint:function(event,startEnd){new Event(event).stop();
this.routingLayer.addClass("hide");
this.freeRoutingPoints[startEnd]=this.freeRoutingPoint;
this.freeRoutingShapes[startEnd].Show();
this.freeRoutingShapes[startEnd].SetPoints([this.freeRoutingPoint]);
map.veMap.FindLocations(this.freeRoutingPoint,this.evaluateLocation[startEnd]);
var lis=$$("#routingMask, #pois");
lis[0].addClass("show");
lis[1].removeClass("show");
lis[1].getElement("h5 strong").addClass("open");
lis[0].getElement("strong").toggleClass("open")
},remFreeRoutingPoint:function(event,startEnd){if(new Event(event).key==="enter"){this.stopSubmit=true
}map.routing.freeRoutingPoints[startEnd]=null
},initFreeRouting:function(){this.freeRoutingShapes={};
var layer=this.mapWindow.getVEShapeLayer();
map.veMap.AddShapeLayer(layer);
["start","end"].each(function(item){var icon=this.mapWindow.getVEShape(0,0);
icon.Hide();
icon.SetCustomIcon('<div  class="'+item+'Route"></div>');
layer.AddShape(icon);
this.freeRoutingShapes[item]=icon
},this);
this.routingLayer=$(this.mapWindow.document.getElementById("routeStartEnd")).remove().injectInside(this.mapObject.mapelement);
this.routingLayer.getElements("a").each(function(a,cnt){a.addEvent("click",this.setFreeRoutingPoint.bindWithEvent(this,cnt?"end":"start"))
},this);
this.routingLayer.setStyle("visibility","hidden").removeClass("hide");
var layerSize=this.routingLayer.getSize().size,mapSize=$(this.mapObject.mapelement).getSize().size;
this.routingLayer.setStyle("visibility","visible").addClass("hide");
this.layerMaxPosition={top:mapSize.y-layerSize.y,left:mapSize.x-layerSize.x}
},writeRoutingDetails:function(){var doc=map.routing.routingPopup.document;
var distanceUnit=(this.routingDetails.distanceUnit==="Kilometer"?"km":"mi");
doc.getElementById("routingLength").innerHTML=this.routingDetails.distance+" "+distanceUnit+", "+this.routingDetails.hour+" h "+this.routingDetails.min+" min";
var routingDetails='<table><colgroup><col class="count"/><col /><col class="length"/></colgroup><tbody>';
for(i=0,l=this.routingDetails.routingDirections.length;
i<l;
i++){routingDetails+='<tr class="'+(i%2?"odd":"even")+'"><td class="count tRight">'+this.routingDetails.routingDirections[i].num+" </td><td>"+this.routingDetails.routingDirections[i].description+' </td><td class="length tRight">'+this.routingDetails.routingDirections[i].distance+" "+distanceUnit+"</td></tr>"
}routingDetails+="</tbody></table>";
doc.getElementById("routingStartAddress").innerHTML=this.routingDetails.routingAddress.start;
doc.getElementById("routingEndAddress").innerHTML=this.routingDetails.routingAddress.end;
var routingDirections=doc.getElementById("routingDirections");
routingDirections.className="";
routingDirections.innerHTML=routingDetails
},toggleRouteWaiting:function(onOff){$("routingMask").setStyle("opacity",onOff?0.8:1)
},showRoutingLayer:function(){var lis=$$("#routingMask, #pois");
lis[0].addClass("show");
lis[1].removeClass("show");
lis[1].getElement("h5 strong").addClass("open");
lis[0].getElement("strong").toggleClass("open")
},togglerRoutingLayer:function(){var lis=$$("#routingMask, #pois");
lis[0].toggleClass("show");
lis[1].removeClass("show");
lis[1].getElement("h5 strong").removeClass("open");
this.getElement("strong").toggleClass("open")
}});
Routing.implement(new Options);
var MultiMapLayer=new Class({initialize:function(mapWindow,mapObject){this.mapWindow=mapWindow;
this.mapObject=mapObject;
this.mapObject.mmLayer=this;
this.mmLayer=null;
this.mmOn=false;
this.mc0=null;
this.mmOnChangeView=this.onChangeView.bind(this);
this.mmSwitchedMapStyle=null;
this.mmBounds=new Array();
this.mmBounds.push(this.mapWindow.getVELatLongRectangle(31.728167146023935,34.18945312500001,14.008696370634683,60.62304687500001));
this.mmBounds.push(this.mapWindow.getVELatLongRectangle(47.754097979680026,66.44531249999999,-9.102096738726443,135.35156250000003));
this.mmBounds.push(this.mapWindow.getVELatLongRectangle(63.97596090918337,38.583984375000014,47.754097979680026,177.5390625));
this.mmBounds.push(this.mapWindow.getVELatLongRectangle(60.630101766266684,28.388671874999993,56.80087831233044,38.583984375000014));
this.mmBounds.push(this.mapWindow.getVELatLongRectangle(56.80087831233044,31.376953125000018,52.26815737376816,38.583984375000014));
this.mmBounds.push(this.mapWindow.getVELatLongRectangle(47.754097979680026,38.056640625,43.06888777416962,50.296875));
this.mmBounds.push(this.mapWindow.getVELatLongRectangle(41.9022770409637,26.455078125000014,36.24427318493909,45.00000000000001));
this.mapObject.AttachEvent("onchangemapstyle",this.onChangeMapStyle.bind(this));
this.mapWindow.setMMIK();
this.createMMLayer();
this.mc0=this.mapObject.GetCenter()
},createMMLayer:function(){var tileSourceSpec=this.mapWindow.getVETileSourceSpecification("multimaphrs","",1,this.mmBounds,1,17,this.switchMMLayerByTileLoad.bind(this),1,100);
this.mapObject.AddTileLayer(tileSourceSpec,true)
},onChangeView:function(e){var mc1=this.mapObject.GetCenter();
var d=Math.abs(this.mc0.Latitude-mc1.Latitude)+Math.abs(this.mc0.Longitude-mc1.Longitude);
this.mc0=mc1;
if(d>0.1){if(this.mmOn){this.mmOn=false
}else{if(this.mmLayer!=null){this.hideMMLayer()
}}}},onChangeMapStyle:function(e){if(this.mmLayer==null&&this.mapObject.GetMapStyle()==this.mmSwitchedMapStyle){this.mapObject.ShowBaseTileLayer();
this.mmSwitchedMapStyle=null
}},showMMLayer:function(){this.mmOn=true;
this.mapObject.AttachEvent("onchangeview",this.mmOnChangeView);
this.hideVELayer();
this.mmLayer=this.mapWindow.getMMMapFactory(this.mapObject);
this.mmLayer.draw();
this.mmLayer.addEventHandler("coverageUpdated",this.coverageUpdatedHandler.bind(this));
var mapStyle=this.mapObject.GetMapStyle();
var mmPreferences=this.mapWindow.getMMDataPreferences(mapStyle);
this.mapWindow.setMMDataPreferences(mapStyle,mmPreferences);
this.mmLayer.redraw()
},hideMMLayer:function(){if(this.mmLayer!=null){if(this.mapObject.m_vetilesourcemanager.m_vetilesources.length>1){this.mapObject.DetachEvent("onchangeview",this.mmOnChangeView);
this.mmLayer.remove();
this.mmLayer=null;
this.showVELayer();
this.removeMMcopy()
}else{this.hideMMLayer.delay(1000)
}}},hideVELayer:function(){this.mmSwitchedMapStyle=this.mapObject.GetMapStyle();
this.mapObject.HideBaseTileLayer()
},showVELayer:function(){this.mapObject.ShowBaseTileLayer()
},removeMMcopy:function(){var divs=this.mapWindow.document.getElementsByTagName("div");
for(var i=divs.length-1;
i>=0;
i--){div=divs[i];
var s=div.innerHTML.substring(30,0);
if(s.search(/NAVTEQ|MapABC|Loading copyright data|Map Data|Infomap/)>=0){div.parentNode.removeChild(div);
break
}}},coverageUpdatedHandler:function(){var center=this.mapObject.GetCenter();
var zoomLevel=this.mapObject.GetZoomLevel();
var mapStyle=this.mapObject.GetMapStyle();
var coverage=this.mapWindow.getMMCoverage(center,zoomLevel,mapStyle);
if(coverage=="undefined"){this.hideMMLayer()
}},switchMMLayerByTileLoad:function(tileContext){this.mmOn=true;
if(this.mmLayer!=null&&tileContext.ZoomLevel<11){this.hideMMLayer()
}else{if(this.mmLayer==null&&tileContext.ZoomLevel>=11){this.showMMLayer()
}}return null
},switschMMLayerByFind:function(){this.mmOn=false
},showMMBoxes:function(){this.boxLayer=this.mapWindow.getVEShapeLayer();
this.mapObject.AddShapeLayer(this.boxLayer);
for(i=0;
i<this.mmBounds.length;
i++){var rec=this.mmBounds[i];
var topRightLatLong=this.mapWindow.getVELatLong(rec.TopLeftLatLong.Latitude,rec.BottomRightLatLong.Longitude);
var bottomLeftLatLon=this.mapWindow.getVELatLong(rec.BottomRightLatLong.Latitude,rec.TopLeftLatLong.Longitude);
var shape=this.mapWindow.getVEShapePolygon(new Array(rec.TopLeftLatLong,topRightLatLong,rec.BottomRightLatLong,bottomLeftLatLon));
shape.HideIcon();
shape.SetLineWidth(1);
shape.SetLineColor(this.mapWindow.getVEColor(100,100,100,0.5));
shape.SetFillColor(this.mapWindow.VEColor(100,100,100,0.5));
this.boxLayer.AddShape(shape)
}}});