var timerlen=5,slideAniLen=250,timerID=[],startTime=[],obj=[],endWidth=[],moving=[],dir=[];function toggleSlide(a){document.getElementById("panzoombar").style.top="25px";document.getElementById("panzoombar").style.display="none";document.getElementById("slide").style.display="none";document.getElementById(a).style.display=="none"?slide_right(a):slide_left(a)}function slide_right(a){if(!moving[a])if(document.getElementById(a).style.display=="none"){moving[a]=true;dir[a]="right";startslide(a)}} function slide_left(a){if(!moving[a])if(document.getElementById(a).style.display!="none"){moving[a]=true;dir[a]="left";startslide(a)}}function startslide(a){obj[a]=document.getElementById(a);endWidth[a]=parseInt(obj[a].style.width);startTime[a]=(new Date).getTime();if(dir[a]=="right")obj[a].style.width="1px";obj[a].style.display="block";timerID[a]=setInterval("slidetick('"+a+"');",timerlen)} function slidetick(a){var b=(new Date).getTime()-startTime[a];if(b>slideAniLen)endSlide(a);else{b=Math.round(b/slideAniLen*endWidth[a]);if(dir[a]=="left")b=endWidth[a]-b;obj[a].style.width=b+"px"}} function endSlide(a){clearInterval(timerID[a]);if(dir[a]=="left"){obj[a].style.display="none";document.getElementById("panzoombar").style.left="25px";document.getElementById("panzoombar").style.display="";document.getElementById("slide").style.left="5px";document.getElementById("slide").innerHTML='>>'}else{document.getElementById("panzoombar").style.left="400px";document.getElementById("panzoombar").style.display=""; document.getElementById("slide").style.left="365px";document.getElementById("slide").innerHTML='<<'}document.getElementById("slide").style.display="";obj[a].style.width=endWidth[a]+"px";delete moving[a];delete timerID[a];delete startTime[a];delete endWidth[a];delete obj[a];delete dir[a]};var map,status="";function getStatus(){return status}function setStatus(a){status=a}var dragLayer,vectorLayerRoute,markersLayer; function init(){map=new OpenLayers.Map("map",{controls:[new OpenLayers.Control.Navigation,new OpenLayers.Control.Permalink,new OpenLayers.Control.LayerSwitcher],maxExtent:new OpenLayers.Bounds(-2.003750834E7,-2.003750834E7,2.003750834E7,2.003750834E7),maxResolution:156543.0399,numZoomLevels:19,units:"m",projection:new OpenLayers.Projection("EPSG:900913"),displayProjection:new OpenLayers.Projection("EPSG:4326")});map.addLayer(new OpenLayers.Layer.OSM.Mapnik("Mapnik"));map.addLayer(new OpenLayers.Layer.OSM.MapQuest("MapQuest")); map.addLayer(new OpenLayers.Layer.OSM.Osmarender("Osmarender"));vectorLayerRoute=new OpenLayers.Layer.Vector("Route",{maxResolution:156543.0339});map.addLayer(vectorLayerRoute);map.addControl(new OpenLayers.Control.LayerSwitcher);var a=new OpenLayers.Control.PanZoomBar({id:"panzoombar",displayClass:"olControlPanZoomBar"});map.addControl(a);document.getElementById("panzoombar").style.left="400px";document.getElementById("panzoombar").style.top="25px";dragLayer=new OpenLayers.Layer.Vector("Start/End Marker", {styleMap:new OpenLayers.StyleMap({externalGraphic:"${icon}",backgroundXOffset:0,backgroundYOffset:-7,graphicZIndex:10,backgroundGraphicZIndex:11,pointRadius:10,graphicWidth:22,graphicHeight:34}),rendererOptions:{yOrdering:true}});a=new OpenLayers.Control.DragFeature(dragLayer,{onDrag:function(b,c){b.move(map.getLonLatFromPixel(c));ISCALCULATING||routing(true)},onComplete:function(b,c){b.move(map.getLonLatFromPixel(c));ISCALCULATING||routing(false)},onLeave:function(){alert("here");ISCALCULATING|| routing(false)}});map.addControl(a);a.activate();map.addLayers([dragLayer]);markersLayer=new OpenLayers.Layer.Markers("Markers");map.addLayer(markersLayer);map.events.on({zoomend:function(){reroute()}});map.getCenter()||map.setCenter(new OpenLayers.LonLat(6E5,66E5),6)} function checkReturn(a,b){var c=b||window.event;if(c){var d=0;if(c.keyCode)d=c.keyCode;else if(typeof c.which!="undefined")d=c.which;if(d==13&&a=="start"){setStatus("start");geocodeAddress("start")}else if(d==13&&a=="end"){setStatus("end");geocodeAddress("end")}}}function closeOpenDiv(a){if(document.getElementById(a).style.display=="none")document.getElementById(a).style.display="";else document.getElementById(a).style.display="none"};var HOST_ROUTING_URL="http://routingdemo.geofabrik.de/route-de/",ISCALCULATING=false,EPSG_4326=new OpenLayers.Projection("EPSG:4326"),EPSG_900913=new OpenLayers.Projection("EPSG:900913"); function routing(a){if(isStartPointSet)if(isEndPointSet){a||(ISCALCULATING=false);if(!ISCALCULATING){ISCALCULATING=true;var b=getMarkerByName("start"),c=getMarkerByName("end");b=(new OpenLayers.LonLat(b.geometry.x,b.geometry.y)).transform(new OpenLayers.Projection("EPSG:900913"),new OpenLayers.Projection("EPSG:4326"));c=(new OpenLayers.LonLat(c.geometry.x,c.geometry.y)).transform(new OpenLayers.Projection("EPSG:900913"),new OpenLayers.Projection("EPSG:4326"));var d=document.createElement("script"); d.type="text/javascript";var f="showResultsRoute",e="&instructions=true";if(a){f="showResultsDragRoute";e="&instructions=false";document.getElementById("information").innerHTML='
Release mouse button to get Route Information!
(If no Route Summary is diplayed, press the Route!-button)'}else document.getElementById("information").innerHTML='One moment please ...
';d.src=HOST_ROUTING_URL+"&"+b.lat+"&"+b.lon+"&"+c.lat+"&"+c.lon+"&z="+this.map.getZoom()+"&output=json&jsonp="+ f+e;document.body.appendChild(d)}}else document.getElementById("information").innerHTML='Please set your Destination first!
';else document.getElementById("information").innerHTML='Please set your Start location first!
'}function reroute(){isStartPointSet&&isEndPointSet&&routing(false)}function showResultsDragRoute(a){a&&showRouteGeometry(a);ISCALCULATING=false} function showResultsRoute(a){if(a){document.getElementById("cbNoNames").checked==true?showNoNameStreets(a):showRouteGeometry(a);var b='Some information about your Way
from \''+a.route_summary.start_point+"' to '"+a.route_summary.end_point+"'
Distance: '+a.route_summary.total_distance/1E3+' km - Duration: '+ secondsToTime(a.route_summary.total_time)+'
Your Route-Instructions:
';b+="'+(d+1)+'. | '+a.route_instructions[d][0]+" on "+a.route_instructions[d][1]+" for "+getDistanceWithUnit(a.route_instructions[d][2])+" | "}b+="
One moment please ...
';a=GEOCODE_POST+"&q="+b;b=document.createElement("script");b.type="text/javascript";b.src=a;document.body.appendChild(b)} function showResultsGeocode(a){var b="",c="";if(a){b+='Search Results:
';b+="'+h+" | ";b+='';if(e.display_name)b+=''+e.display_name.trim()+"";b+=" | ";if(c=="")c=new OpenLayers.LonLat(e.lon,e.lat)}b+="