var map=null,selectedAz=-1,routeDiv=document.getElementById("route");_mSvgForced=_mSvgEnabled=true;var doneStartPoint=false,startMarker=null,endMarker=null,routeConst="ROUTELINE",orLatitude=0,orLongitude=0,defaultStartRadious=350,defaultEndRadious=350,theData,polies=[],lines=[],aPointLat=null,aPointLon=null,bPointLat=null,bPointLon=null,dirCarOrWalk=new GDirections(null,document.getElementById("fakeDirections"));GEvent.addListener(dirCarOrWalk,"load",onGDirectionsCarOrWalkLoad);
var disambMarkers=[],dirStartMarkerList=[],dirEndMarkerList=[],dirStart=new GDirections(null,document.getElementById("fakeDirections"));GEvent.addListener(dirStart,"load",onGDirectionsStartLoad);var dirEnd=new GDirections(null,document.getElementById("fakeDirections"));GEvent.addListener(dirEnd,"load",onGDirectionsEndLoad);var routeId="";
$(document).ready(function(){$("#paramsbox").toggle("slide",{},1);$("#permalinkDialog").dialog({resizable:false,autoOpen:false,title:"Permalink al percorso"});$("#messageDialog").dialog({resizable:true,autoOpen:false,title:"Attenzione!",width:350,height:200,modal:false});$("#permalinkBtn").hide("fast");$("#permalinkTextArea").focus(function(){this.select()});$("#routePdfBtn").hide("fast");creteMap();$("#stRadious").slider({max:1000,min:100,value:defaultStartRadious});$("#enRadious").slider({max:1000,
min:100,value:defaultEndRadious});$("#stRadious").bind("slide",function(a,d){document.getElementById("stMt").innerHTML=d.value});$("#enRadious").bind("slide",function(a,d){document.getElementById("enMt").innerHTML=d.value});document.getElementById("stMt").innerHTML=defaultStartRadious;document.getElementById("enMt").innerHTML=defaultEndRadious;routeId=gup("rid");routeId!=""&&manageSingleRoute(routeId)});
function runRoutePdf(){window.open("/mi/routepdf?rid="+escape(routeId).replace(/\+/,"%2B"),"pdf","")}
function manageSingleRoute(a){var d=(new Date).getTime(),b="http://www.milano-italia.it/mi/sroute";$.getJSON(b,{rid:a},function(c){theData=c;if(c.resultCode=="OK"){var e=c.points[c.points.length-1],g=document.getElementById("bpoint");bPointLat=e.latitude;bPointLon=e.longitude;g.value=e.address;g.style.backgroundColor="#FFFFFF";e=new GLatLng(e.latitude,e.longitude);startMarker=new GMarker(e,{icon:startico,draggable:false});GEvent.addListener(startMarker,"click",function(){});map.addOverlay(startMarker);
e=c.points[0];g=document.getElementById("apoint");aPointLat=e.latitude;aPointLon=e.longitude;g.value=e.address;g.style.backgroundColor="#FFFFFF";e=new GLatLng(e.latitude,e.longitude);endMarker=new GMarker(e,{icon:endico,draggable:false});GEvent.addListener(endMarker,"click",function(){});map.addOverlay(endMarker);e=document.getElementById("permalinkTextArea");e.value="http://www.milano-italia.it/route/"+escape(c.routeId).replace(/\+/,"%2B")+"/"+c.routeNormName+".html";drawRoute(c.points,c.routeValue);
$("#permalinkBtn").show("fast");$("#routePdfBtn").show("fast");c=(new Date).getTime()-d;pageTracker._trackEvent("percorso","permalink","",c)}else{c=document.getElementById("messageDialog");c.innerHTML="Il link al percorso non \u00e8 pi\u00f9 valido. Puoi in ogni caso inserire l'indirizzo di partenza e di arrivo per cacolare l'itinerario che ti serve.";$("#messageDialog").dialog("open")}})}function TextualZoomControl(){}TextualZoomControl.prototype=new GControl;
TextualZoomControl.prototype.initialize=function(a){var d=document.createElement("div"),b=document.createElement("div");b.className="zoominstyle";var c=document.createElement("img");c.setAttribute("src","/images/zoominctr.png");c.setAttribute("className","customMapControl");c.setAttribute("class","customMapControl");b.appendChild(c);GEvent.addDomListener(c,"click",function(){a.zoomIn()});c=document.createElement("img");c.setAttribute("src","/images/zoomoutctr.png");c.setAttribute("className","customMapControl");
c.setAttribute("class","customMapControl");b.appendChild(c);GEvent.addDomListener(c,"click",function(){a.zoomOut()});c=document.createElement("img");c.setAttribute("src","/images/mappactr.png");c.setAttribute("className","customMapControl");c.setAttribute("class","customMapControl");b.appendChild(c);GEvent.addDomListener(c,"click",function(){a.setMapType(G_NORMAL_MAP)});c=document.createElement("img");c.setAttribute("src","/images/satellitectr.png");c.setAttribute("className","customMapControl");
c.setAttribute("class","customMapControl");b.appendChild(c);GEvent.addDomListener(c,"click",function(){a.setMapType(G_SATELLITE_MAP)});c=document.createElement("img");c.setAttribute("src","/images/ibridactr.png");c.setAttribute("className","customMapControl");c.setAttribute("class","customMapControl");b.appendChild(c);GEvent.addDomListener(c,"click",function(){a.setMapType(G_HYBRID_MAP)});d.appendChild(b);a.getContainer().appendChild(d);return d};
TextualZoomControl.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(7,7))};
function creteMap(){map=new GMap2(document.getElementById("box_map"));map.setCenter(new GLatLng(45.463983,9.185944),12);map.addControl(new TextualZoomControl);map.disableDoubleClickZoom();GEvent.addListener(map,"dblclick",function(a,d){if(!a)if(d)if(selectedAz==1){startMarker!=null&&map.removeOverlay(startMarker);startMarker=new GMarker(d,{icon:startico,draggable:false});GEvent.addListener(startMarker,"click",function(){});map.addOverlay(startMarker);a="http://www.milano-italia.it/mi/revgeo";$.post(a,
{olat:d.lat(),olon:d.lng()},function(b){document.getElementById("apoint").value=b.Placemark[0].address},"json")}else if(selectedAz==2){endMarker!=null&&map.removeOverlay(endMarker);endMarker=new GMarker(d,{icon:endico,draggable:false});GEvent.addListener(endMarker,"click",function(){});map.addOverlay(endMarker);a="http://www.milano-italia.it/mi/revgeo";$.post(a,{olat:d.lat(),olon:d.lng()},function(b){document.getElementById("bpoint").value=b.Placemark[0].address},"json")}})}
function zoomOnMarker(a,d){if(a!=null){var b=new GLatLngBounds;b.extend(a.getPoint());a=(b.getNorthEast().lng()+b.getSouthWest().lng())/2;var c=(b.getNorthEast().lat()+b.getSouthWest().lat())/2;a=new GLatLng(c,a);d!=null?map.setCenter(a,map.getBoundsZoomLevel(b)-d):map.setCenter(a,map.getBoundsZoomLevel(b))}}
function fit(a){for(var d=new GLatLngBounds,b=0;b<a.length;b++)d.extend(a[b].getPoint());a=(d.getNorthEast().lng()+d.getSouthWest().lng())/2;b=(d.getNorthEast().lat()+d.getSouthWest().lat())/2;a=new GLatLng(b,a);map.setCenter(a,map.getBoundsZoomLevel(d))}
function geocoding(a){var d="http://www.milano-italia.it/mi/geo";$.post(d,{add:a},function(b){b=new GLatLng(b.Placemark[0].Point.coordinates[1],b.Placemark[0].Point.coordinates[0]);b=new GMarker(b,{icon:startico,draggable:false});map.addOverlay(b);zoomOnMarker(b)},"json")}function zoomOnPoint(a,d){a=new GLatLng(a,d);a=new GMarker(a,{icon:startico,draggable:false});zoomOnMarker(a,3)}
function zoomOnPointStreet(a,d){a=new GLatLng(a,d);d=new GLatLngBounds;d.extend(a);map.setCenter(a,map.getBoundsZoomLevel(d))}
function RouteByCar(){var a=(new Date).getTime(),d=document.getElementById("directionStart");try{map.clearOverlays();routeDiv.innerHTML=""}catch(b){}d=[];d.push(aPointLat+","+aPointLon);d.push(bPointLat+","+bPointLon);dirCarOrWalk.loadFromWaypoints(d,{travelMode:G_TRAVEL_MODE_DRIVING,getPolyline:true,getSteps:true,locale:"it"});a=(new Date).getTime()-a;pageTracker._trackEvent("percorso","calcola","inMacchina",a)}
function RouteByWalk(){var a=(new Date).getTime(),d=document.getElementById("directionStart");try{map.clearOverlays();routeDiv.innerHTML=""}catch(b){}d=[];d.push(aPointLat+","+aPointLon);d.push(bPointLat+","+bPointLon);dirCarOrWalk.loadFromWaypoints(d,{travelMode:G_TRAVEL_MODE_WALKING,getPolyline:true,getSteps:true,locale:"it"});a=(new Date).getTime()-a;pageTracker._trackEvent("percorso","calcola","aPiedi",a)}
function onGDirectionsCarOrWalkLoad(){map.addOverlay(dirCarOrWalk.getPolyline());startMarker=new GMarker(new GLatLng(aPointLat,aPointLon),{icon:startico,draggable:false});GEvent.addListener(startMarker,"click",function(){});map.addOverlay(startMarker);endMarker=new GMarker(new GLatLng(bPointLat,bPointLon),{icon:endico,draggable:false});GEvent.addListener(endMarker,"click",function(){});map.addOverlay(endMarker);var a=new GLatLngBounds;a.extend(startMarker.getLatLng());a.extend(endMarker.getLatLng());
var d=routeDiv,b=dirCarOrWalk.getRoute(0),c=document.createElement("div");c.setAttribute("className","routeTitleStyle");c.setAttribute("class","routeTitleStyle");c.innerHTML="Distanza "+b.getSummaryHtml();d.appendChild(c);c=document.createElement("div");c.setAttribute("className","routeOverflowStyle");c.setAttribute("class","routeOverflowStyle");d.appendChild(c);for(i=0;i<b.getNumSteps();i++){d=b.getStep(i);var e=document.createElement("div");e.setAttribute("className","routeStepStyle");e.setAttribute("class",
"routeStepStyle");c.appendChild(e);var g=document.createElement("div");g.setAttribute("className","routeStepDirectionTextStyle");g.setAttribute("class","routeStepDirectionTextStyle");g.innerHTML='<a href="javascript: zoomOnPointStreet('+d.getLatLng().lat()+","+d.getLatLng().lng()+')">'+i+"</a> "+d.getDescriptionHtml();e.appendChild(g);g=document.createElement("div");g.setAttribute("className","outeStepDirectionInfoStyle");g.setAttribute("class","outeStepDirectionInfoStyle");g.innerHTML=d.getDistance().html+
" circa "+d.getDuration().html;e.appendChild(g);if(i<b.getNumSteps()-1){e=document.createElement("div");e.setAttribute("className","routeStepSeparatorStyle");e.setAttribute("class","routeStepSeparatorStyle");c.appendChild(e)}a.extend(d.getLatLng())}b=(a.getNorthEast().lng()+a.getSouthWest().lng())/2;c=(a.getNorthEast().lat()+a.getSouthWest().lat())/2;b=new GLatLng(c,b);map.setCenter(b,map.getBoundsZoomLevel(a))}
function calculateRouteSuspend(){var a=document.getElementById("messageDialog");a.innerHTML="Il servizio &egrave; momentaneamente sospeso per manutenzione. Sar&agrave; nuovamente attivo entro 1 ora. Ci scusiamo per il disagio arrecato.";$("#messageDialog").dialog("open")}
function calculateRoute(){pageTracker._trackEvent("percorso","calcola","TOTALE");var a=document.getElementById("apoint"),d=document.getElementById("bpoint");a.style.backgroundColor="#FFFFFF";d.style.backgroundColor="#FFFFFF";if(a.value=="")alert("Indirizzo di partenza non valido.");else if(d.value=="")alert("Indirizzo di arrivo non valido.");else{var b=routeDiv;d="http://www.milano-italia.it/mi/geo";$.post(d,{add:a.value},function(c){if(c.Status.code!=200||c.Placemark.length<=0)alert("Impossibile trovare l'indirizzo di partenza. Riprova cambiando le indicazioni.");
else{b.innerHTML="";if(c.Placemark.length>1){a.style.backgroundColor="#FFF1A8";drawDisambInfo(c,true)}else disambEndPoint(c.Placemark[0].Point.coordinates[1],c.Placemark[0].Point.coordinates[0],c.Placemark[0].address)}},"json")}}
function disambEndPoint(a,d,b){var c=document.getElementById("apoint"),e=document.getElementById("bpoint");c.style.backgroundColor="#FFFFFF";e.style.backgroundColor="#FFFFFF";for(i=0;i<disambMarkers.length;i++)map.removeOverlay(disambMarkers[i]);aPointLat=a;aPointLon=d;startMarker=new GMarker(new GLatLng(aPointLat,aPointLon),{icon:startico,draggable:false});GEvent.addListener(startMarker,"click",function(){startMarker.openInfoWindowHtml(b)});c.value=b;var g=routeDiv;a="http://www.milano-italia.it/mi/geo";
$.post(a,{add:e.value},function(f){if(f.Status.code!=200||f.Placemark.length<=0)alert("Impossibile trovare l'indirizzo di arrivo. Riprova cambiando le indicazioni.");else{g.innerHTML="";if(f.Placemark.length>1){e.style.backgroundColor="#FFF1A8";drawDisambInfo(f,false)}else setEndPoint(f.Placemark[0].Point.coordinates[1],f.Placemark[0].Point.coordinates[0],f.Placemark[0].address)}},"json")}
function setEndPoint(a,d,b){for(i=0;i<disambMarkers.length;i++)map.removeOverlay(disambMarkers[i]);var c=document.getElementById("bpoint");bPointLat=a;bPointLon=d;endMarker=new GMarker(new GLatLng(bPointLat,bPointLon),{icon:endico,draggable:false});GEvent.addListener(endMarker,"click",function(){endMarker.openInfoWindowHtml(b)});c.value=b;c.style.backgroundColor="#FFFFFF";a=routeDiv;a.innerHTML="";a=document.getElementById("routingTypeForm");d="ptransit";for(i=0;i<a.routingType.length;i++)if(a.routingType[i].checked==
true)d=a.routingType[i].value;$("#permalinkBtn").hide("fast");$("#routePdfBtn").hide("fast");d=="ptransit"&&RouteByPublicTransit();d=="car"&&RouteByCar();d=="walk"&&RouteByWalk()}
function drawDisambInfo(a,d){var b=routeDiv,c=document.createElement("div");c.setAttribute("className","disambTitleStyle");c.setAttribute("class","disambTitleStyle");c.innerHTML=d?'<img src="/images/dd-start_round.png" style="padding-right: 4px"> Forse cercavi: ':'<img src="/images/dd-end_round.png" style="padding-right: 4px"> Forse cercavi: ';b.appendChild(c);c=document.createElement("div");c.setAttribute("className","disambOverflowStyle");c.setAttribute("class","disambOverflowStyle");b.appendChild(c);
b=a.Placemark.length>9?9:a.Placemark.length;for(var e=0;e<b;e++){disambPointMain=document.createElement("div");disambPointMain.setAttribute("className","disambPointMainStyle");disambPointMain.setAttribute("class","disambPointMainStyle");c.appendChild(disambPointMain);disambPointIcon=document.createElement("div");disambPointIcon.setAttribute("className","disambPointIconStyle");disambPointIcon.setAttribute("class","disambPointIconStyle");disambPointIcon.innerHTML='<a href="javascript: zoomOnPoint('+
a.Placemark[e].Point.coordinates[1]+","+a.Placemark[e].Point.coordinates[0]+');"><img src="http://maps.google.it/intl/it_it/mapfiles/icon_yellow'+(e+1)+'.png"></a>';disambPointMain.appendChild(disambPointIcon);disambPointName=document.createElement("div");disambPointName.setAttribute("className","disambPointNameStyle");disambPointName.setAttribute("class","disambPointNameStyle");disambPointName.innerHTML=d?"<a href=\"javascript: disambEndPoint('"+a.Placemark[e].Point.coordinates[1]+"','"+a.Placemark[e].Point.coordinates[0]+
"','"+a.Placemark[e].address+"');\">"+a.Placemark[e].AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName+" ("+a.Placemark[e].AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.SubAdministrativeAreaName+")</a>":"<a href=\"javascript: setEndPoint('"+a.Placemark[e].Point.coordinates[1]+"','"+a.Placemark[e].Point.coordinates[0]+"','"+a.Placemark[e].address+"');\">"+a.Placemark[e].AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName+
" ("+a.Placemark[e].AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.SubAdministrativeAreaName+")</a>";disambPointMain.appendChild(disambPointName);disambPointAddress=document.createElement("div");disambPointAddress.setAttribute("className","disambPointAddressStyle");disambPointAddress.setAttribute("class","disambPointAddressStyle");disambPointAddress.innerHTML=a.Placemark[e].address;disambPointName.appendChild(disambPointAddress);disambDivClear=document.createElement("div");disambDivClear.setAttribute("className",
"clear");disambDivClear.setAttribute("class","clear");disambPointMain.appendChild(disambDivClear);var g=createNumberMarker(a.Placemark[e].Point.coordinates[1],a.Placemark[e].Point.coordinates[0],e+1,a.Placemark[e].address);map.addOverlay(g);disambMarkers[e]=g}fit(disambMarkers)}
function RouteByPublicTransit(){var a=(new Date).getTime(),d="TIME",b="http://www.milano-italia.it/mi/routes",c=document.getElementsByName("tansitTypes"),e="";for(z=0;z<c.length;z++)if(c[z].checked)e+=c[z].value+",";if(e!="")e+="4";var g=$("#stRadious").slider("option","value"),f=$("#enRadious").slider("option","value");$.getJSON(b,{dlat:bPointLat,dlon:bPointLon,ods:g,dds:f,olat:aPointLat,olon:aPointLon,ty:d,tt:e},function(h){theData=h;if(h.resultCode=="OK"){var j=(new Date).getTime()-a;pageTracker._trackEvent("percorso",
"calcola","trasportoPubblico",j);routeFinded(h,a)}else if(h.resultCode=="NOSTARTPOINT"){pageTracker._trackEvent("percorso","calcola","nostartpoint");j=document.getElementById("messageDialog");j.innerHTML="Non &egrave; stato possibile travare un mezzo di trasporto in un raggio di "+g+" metri rispetto al punto di <b>PARTENZA</b> indicato. Per calcolare il percorso sono state utilizzate le fermate pi\u00f9 vicine tra quelle disponibili.";$("#messageDialog").dialog("open");routeFinded(h,a)}else if(h.resultCode==
"NOENDPOINT"){pageTracker._trackEvent("percorso","calcola","noendpoint");j=document.getElementById("messageDialog");j.innerHTML="Non &egrave; stato possibile travare un mezzo di trasporto in un raggio di "+f+" metri rispetto al punto di <b>ARRIVO</b> indicato. Per calcolare il percorso sono state utilizzate le fermate pi\u00f9 vicine tra quelle disponibili.";$("#messageDialog").dialog("open");routeFinded(h,a)}else if(h.resultCode=="NOENDANDSTARTPOINT"){pageTracker._trackEvent("percorso","calcola",
"noendandstartpoint");j=document.getElementById("messageDialog");j.innerHTML="Non &egrave; stato possibile travare un mezzo di trasporto in un raggio di "+g+" metri rispetto al punto di <b>PARTENZA</b> e di "+f+" metri rispetto al punto di <b>ARRIVO</b> indicati. Per calcolare il percorso sono state utilizzate le fermate pi\u00f9 vicine tra quelle disponibili per entrambi i punti.";$("#messageDialog").dialog("open");routeFinded(h,a)}else if(h.resultCode=="NOROUTEFINDED"){pageTracker._trackEvent("percorso",
"calcola","noroutedefined");j=document.getElementById("messageDialog");j.innerHTML="Non &egrave; stato possibile travare un percorso con gli indirizzi specificati. Ti ricordiamo che i percorsi sono disponibli solo per l'area di Milano e per alcune zone limitrofe.";$("#messageDialog").dialog("open")}})}
function routeFinded(a){var d=document.getElementById("permalinkTextArea");d.value="http://www.milano-italia.it/route/"+escape(a.routeId).replace(/\+/,"%2B")+"/"+a.routeNormName+".html";routeId=a.routeId;drawRoute(a.points,a.routeValue);$("#permalinkBtn").show("fast");$("#routePdfBtn").show("fast")}
function chooseAlternativePoint(a,d,b,c){if(b){aPointLat=a;aPointLon=d;startMarker!=null&&map.removeOverlay(startMarker);startMarker=new GMarker(new GLatLng(aPointLat,aPointLon),{icon:startico,draggable:false});map.addOverlay(startMarker);document.getElementById("apoint").value=c}else{bPointLat=a;bPointLon=d;endMarker!=null&&map.removeOverlay(endMarker);endMarker=new GMarker(new GLatLng(bPointLat,bPointLon),{icon:startico,draggable:false});map.addOverlay(endMarker);document.getElementById("bpoint").value=
c}RouteByPublicTransit()}
function drawAlternativePoint(a,d){try{map.clearOverlays();map.addOverlay(startMarker);map.addOverlay(endMarker);routeDiv.innerHTML="";polies=[];lines=[];disambMarkers=[]}catch(b){}var c=routeDiv,e=document.createElement("div");e.setAttribute("className","disambTitleStyle");e.setAttribute("class","disambTitleStyle");e.innerHTML="Trasporti pi\u00f9 vicini alla zona indicata:";c.appendChild(e);e=document.createElement("div");e.setAttribute("className","disambOverflowStyle");e.setAttribute("class","disambOverflowStyle");
c.appendChild(e);c=a.nearestPoint.length>9?9:a.nearestPoint.length;for(var g=0,f=0;f<c;f++)g=g<=a.nearestPoint[f].distance?a.nearestPoint[f].distance:g;d?disambMarkers.push(startMarker):disambMarkers.push(endMarker);for(f=0;f<c;f++){alternativePointMain=document.createElement("div");alternativePointMain.setAttribute("className","alternativePointMainStyle");alternativePointMain.setAttribute("class","alternativePointMainStyle");e.appendChild(alternativePointMain);alternativePointHand=document.createElement("div");
alternativePointHand.setAttribute("className","alternativePointHandStyle");alternativePointHand.setAttribute("class","alternativePointHandStyle");alternativePointMain.appendChild(alternativePointHand);alternativePointTextMain=document.createElement("div");alternativePointTextMain.setAttribute("className","alternativePointTextMainStyle");alternativePointTextMain.setAttribute("class","alternativePointTextMainStyle");alternativePointMain.appendChild(alternativePointTextMain);alternativePointTextStop=
document.createElement("div");alternativePointTextStop.setAttribute("className","alternativePointTextStopStyle");alternativePointTextStop.setAttribute("class","alternativePointTextStopStyle");alternativePointTextStop.innerHTML='<a href="javascript: chooseAlternativePoint('+a.nearestPoint[f].latitude+","+a.nearestPoint[f].longitude+","+d+",'"+a.nearestPoint[f].address+"');\">"+a.nearestPoint[f].name+"</a>";alternativePointTextMain.appendChild(alternativePointTextStop);alternativePointTextLine=document.createElement("div");
alternativePointTextLine.setAttribute("className","alternativePointTextLineStyle");alternativePointTextLine.setAttribute("class","alternativePointTextLineStyle");alternativePointTextLine.innerHTML="["+a.nearestPoint[f].lineNumber+"] "+a.nearestPoint[f].lineName;alternativePointTextMain.appendChild(alternativePointTextLine);alternativePointTextIco=document.createElement("div");alternativePointTextIco.setAttribute("className","alternativePointTextIcoStyle");alternativePointTextIco.setAttribute("class",
"alternativePointTextIcoStyle");alternativePointTextIco.innerHTML='<img src="/images/device'+a.nearestPoint[f].lineType+'.jpg">';alternativePointMain.appendChild(alternativePointTextIco);var h=244*a.nearestPoint[f].distance/g;alternativePointTextDistance=document.createElement("div");alternativePointTextDistance.setAttribute("className","alternativePointTextDistanceStyle");alternativePointTextDistance.setAttribute("class","alternativePointTextDistanceStyle");alternativePointTextDistance.innerHTML=
'<img src="/images/bar.jpeg" style="margin-left:4px;border: 1px solid #ffffff" height="4px" width="'+h+'px">&nbsp;'+a.nearestPoint[f].distance+" mt";alternativePointMain.appendChild(alternativePointTextDistance);disambDivClear=document.createElement("div");disambDivClear.setAttribute("className","clear");disambDivClear.setAttribute("class","clear");alternativePointMain.appendChild(disambDivClear);h=new GLatLng(a.nearestPoint[f].latitude,a.nearestPoint[f].longitude);if(a.nearestPoint[f].lineType==
1)chlnMarker=new GMarker(h,{icon:chlnicon1,draggable:false,title:"tram linea "+a.nearestPoint[f].lineNumber+", "+a.nearestPoint[f].lineName});else if(a.nearestPoint[f].lineType==2)chlnMarker=new GMarker(h,{icon:chlnicon2,draggable:false,title:"metro'"+a.nearestPoint[f].lineNumber+", "+a.nearestPoint[f].lineName});else if(a.nearestPoint[f].lineType==3)chlnMarker=new GMarker(h,{icon:chlnicon3,draggable:false,title:"autobus"+a.nearestPoint[f].lineNumber+", "+a.nearestPoint[f].lineName});else if(a.nearestPoint[f].lineType==
5)chlnMarker=new GMarker(h,{icon:chlnicon5,draggable:false,title:"passante"+a.nearestPoint[f].lineNumber+", "+a.nearestPoint[f].lineName});else if(a.nearestPoint[f].lineType==6)chlnMarker=new GMarker(h,{icon:chlnicon6,draggable:false,title:"filobus"+a.nearestPoint[f].lineNumber+", "+a.nearestPoint[f].lineName});else if(a.nearestPoint[f].lineType==7)chlnMarker=new GMarker(h,{icon:chlnicon7,draggable:false,title:"metro' leggero"+a.nearestPoint[f].lineNumber+", "+a.nearestPoint[f].lineName});map.addOverlay(chlnMarker);
disambMarkers.push(chlnMarker);h=[];h.push(chlnMarker.getLatLng());h.push(disambMarkers[0].getLatLng());var j=new GPolyline(h,"#ffffff",8,0.7);map.addOverlay(j);j=new GPolyline(h,"#96b5f3",2,0.7);map.addOverlay(j)}fit(disambMarkers)}
function drawDirectionStart(a,d){var b=document.getElementById("directionStart");if(b.innerHTML!="")try{for(x=0;x<dirStartMarkerList.length;x++)map.removeOverlay(dirStartMarkerList[x]);map.removeOverlay(dirStart.getPolyline());b.innerHTML="";b.style.display="none"}catch(c){}else{b=[];b.push(a);b.push(d);dirStart.loadFromWaypoints(b,{travelMode:G_TRAVEL_MODE_WALKING,getPolyline:true,getSteps:true,locale:"it"})}}
function onGDirectionsStartLoad(){map.addOverlay(dirStart.getPolyline());var a=document.getElementById("directionStart");a.style.display="inline";var d=dirStart.getRoute(0);for(i=0;i<d.getNumSteps();i++){var b=d.getStep(i),c=createDirectionMarker(b);dirStartMarkerList.push(c);map.addOverlay(c);routeStep=document.createElement("div");routeStep.setAttribute("className","routeStepDirectionStyle");routeStep.setAttribute("class","routeStepDirectionStyle");a.appendChild(routeStep);routeStepText=document.createElement("div");
routeStepText.innerHTML='<a href="javascript: zoomOnPointStreet('+b.getLatLng().lat()+","+b.getLatLng().lng()+')">'+i+"</a> "+b.getDescriptionHtml();routeStepText.setAttribute("className","routeStepTextDirectionStyle");routeStepText.setAttribute("class","routeStepTextDirectionStyle");routeStep.appendChild(routeStepText);routeStepDistance=document.createElement("div");routeStepDistance.innerHTML=b.getDistance().html+" circa "+b.getDuration().html;routeStepDistance.setAttribute("className","routeStepDistanceDirectionStyle");
routeStepDistance.setAttribute("class","routeStepDistanceDirectionStyle");routeStep.appendChild(routeStepDistance);if(i<d.getNumSteps()-1){b=document.createElement("div");b.setAttribute("className","routeStepSeparatorStyle");b.setAttribute("class","routeStepSeparatorStyle");a.appendChild(b)}}fit(dirStartMarkerList)}
function calculateBearing(a,d,b,c){var e=Math.sin(d-c)*Math.cos(b);a=Math.cos(a)*Math.sin(b)-Math.sin(a)*Math.cos(b)*Math.cos(d-c);e=Math.atan2(-e,a);e=e*180/Math.PI+1/7200;return e=Math.floor(e)}
function drawDirectionEnd(a,d){var b=document.getElementById("directionEnd");if(b.innerHTML!="")try{map.removeOverlay(dirEnd.getPolyline());b.innerHTML="";b.style.display="none";for(z=0;z<dirEndMarkerList.length;z++)map.removeOverlay(dirEndMarkerList[z])}catch(c){}else{b=[];b.push(a);b.push(d);dirEnd.loadFromWaypoints(b,{travelMode:G_TRAVEL_MODE_WALKING,getPolyline:true,getSteps:true,locale:"it"})}}
function onGDirectionsEndLoad(){map.addOverlay(dirEnd.getPolyline());var a=document.getElementById("directionEnd");a.style.display="inline";var d=dirEnd.getRoute(0);for(i=0;i<d.getNumSteps();i++){var b=d.getStep(i),c=createDirectionMarker(b);dirEndMarkerList.push(c);map.addOverlay(c);routeStep=document.createElement("div");routeStep.setAttribute("className","routeStepDirectionStyle");routeStep.setAttribute("class","routeStepDirectionStyle");a.appendChild(routeStep);routeStepText=document.createElement("div");
routeStepText.innerHTML='<a href="javascript: zoomOnPointStreet('+b.getLatLng().lat()+","+b.getLatLng().lng()+')">'+i+"</a> "+b.getDescriptionHtml();routeStepText.setAttribute("className","routeStepTextDirectionStyle");routeStepText.setAttribute("class","routeStepTextDirectionStyle");routeStep.appendChild(routeStepText);routeStepDistance=document.createElement("div");routeStepDistance.innerHTML=b.getDistance().html+" circa "+b.getDuration().html;routeStepDistance.setAttribute("className","routeStepDistanceDirectionStyle");
routeStepDistance.setAttribute("class","routeStepDistanceDirectionStyle");routeStep.appendChild(routeStepDistance);if(i<d.getNumSteps()-1){b=document.createElement("div");b.setAttribute("className","routeStepSeparatorStyle");b.setAttribute("class","routeStepSeparatorStyle");a.appendChild(b)}}fit(dirEndMarkerList)}
function createDirectionMarker(a){var d=new GLatLng(a.getLatLng().lat(),a.getLatLng().lng()),b=new GMarker(d,{icon:diricon,draggable:false}),c=(new Date).getTime()+""+Math.floor(Math.random()*99999);GEvent.addListener(b,"click",function(){var e=document.createElement("div");e.setAttribute("id","pano"+c);e.setAttribute("style","width:320px; height:250px");e="<b>"+a.getDescriptionHtml();a.getDistance();a.getDuration();b.openInfoWindowHtml(e);e=new GStreetviewPanorama(document.getElementById("pano"+
c));myPOV={yaw:370.64659986187695,pitch:0};e.setLocationAndPOV(d,myPOV);GEvent.addListener(e,"error",handleNoFlash)});return b}
function drawRoute(a,d){try{map.clearOverlays();map.addOverlay(startMarker);map.addOverlay(endMarker);routeDiv.innerHTML="";polies=[];lines=[]}catch(b){}var c=document.createElement("div");c.setAttribute("className","routeTitleStyle");c.setAttribute("class","routeTitleStyle");c.innerHTML="Arrivo previsto in "+Math.round(d/60)+' minuti  <input type="button" value="Alternative" onclick="drawOtherRoutes()">';routeDiv.appendChild(c);c=document.createElement("div");c.setAttribute("className","routeOverflowStyle");
c.setAttribute("class","routeOverflowStyle");routeDiv.appendChild(c);routeWalkMainLine=document.createElement("div");routeWalkMainLine.setAttribute("className","routeWalkMainLineStyle");routeWalkMainLine.setAttribute("class","routeWalkMainLineStyle");c.appendChild(routeWalkMainLine);routeWalkDirectionStart=document.createElement("div");routeWalkDirectionStart.setAttribute("className","routeWalkDirectionStyle");routeWalkDirectionStart.setAttribute("class","routeWalkDirectionStyle");routeWalkDirectionStart.setAttribute("id",
"directionStart");c.appendChild(routeWalkDirectionStart);routeWalkImage=document.createElement("div");routeWalkImage.setAttribute("className","routeWalkImageLineStyle");routeWalkImage.setAttribute("class","routeWalkImageLineStyle");routeWalkImage.innerHTML='<img src="/images/device4.jpg">';routeWalkMainLine.appendChild(routeWalkImage);routeWalkName=document.createElement("div");routeWalkName.setAttribute("className","routeWalkNameLineStyle");routeWalkName.setAttribute("class","routeWalkNameLineStyle");
routeWalkName.innerHTML='Percorso a piedi <input type="button" value="Dettagli" onclick="javascript: drawDirectionStart(\''+aPointLat+","+aPointLon+"','"+a[0].latitude+","+a[0].longitude+'\')"><div id="directionSt"></div>';routeWalkMainLine.appendChild(routeWalkName);d=new GLatLngBounds;d.extend(startMarker.getLatLng());d.extend(endMarker.getLatLng());for(var e=-1,g,f=[],h=0;h<a.length;h++){var j=createRedMarker(a[h]);map.addOverlay(j);if(e!=a[h].lineid){if(h!=0){routeWalkMainLine=document.createElement("div");
routeWalkMainLine.setAttribute("className","routeWalkMainLineStyle");routeWalkMainLine.setAttribute("class","routeWalkMainLineStyle");c.appendChild(routeWalkMainLine);routeWalkImage=document.createElement("div");routeWalkImage.setAttribute("className","routeWalkImageLineStyle");routeWalkImage.setAttribute("class","routeWalkImageLineStyle");routeWalkImage.innerHTML='<img src="/images/device4.jpg">';routeWalkMainLine.appendChild(routeWalkImage);routeWalkName=document.createElement("div");routeWalkName.setAttribute("className",
"routeWalkNameLineStyle");routeWalkName.setAttribute("class","routeWalkNameLineStyle");routeWalkName.innerHTML="Cambio linea trasporto";routeWalkMainLine.appendChild(routeWalkName);g=new GPolyline(f,"#ffffff",11,0.9);map.addOverlay(g);g=new GPolyline(f,"#4499cc",5,0.9);map.addOverlay(g);polies.push(g);f=[]}var l;g=new GLatLng(a[h].latitude,a[h].longitude);if(a[h].lineType==1)l=new GMarker(g,{icon:chlnicon1,draggable:false,title:"prendi il tram linea "+a[h].lineNumber+", "+a[h].lineName});else if(a[h].lineType==
2)l=new GMarker(g,{icon:chlnicon2,draggable:false,title:"prendi il metro'"+a[h].lineNumber+", "+a[h].lineName});else if(a[h].lineType==3)l=new GMarker(g,{icon:chlnicon3,draggable:false,title:"prendi l'autobus"+a[h].lineNumber+", "+a[h].lineName});else if(a[h].lineType==5)l=new GMarker(g,{icon:chlnicon5,draggable:false,title:"prendi il passante"+a[h].lineNumber+", "+a[h].lineName});else if(a[h].lineType==6)l=new GMarker(g,{icon:chlnicon6,draggable:false,title:"prendi il filobus"+a[h].lineNumber+", "+
a[h].lineName});else if(a[h].lineType==7)l=new GMarker(g,{icon:chlnicon7,draggable:false,title:"prendi il metro' leggero"+a[h].lineNumber+", "+a[h].lineName});map.addOverlay(l);g=document.createElement("div");g.setAttribute("className","routeStepLineStyle");g.setAttribute("class","routeStepLineStyle");c.appendChild(g);routeStepMainLine=document.createElement("div");routeStepMainLine.setAttribute("className","routeStepMainLineStyle");routeStepMainLine.setAttribute("class","routeStepMainLineStyle");
g.appendChild(routeStepMainLine);routeStepMainImage=document.createElement("div");routeStepMainImage.setAttribute("className","routeStepMainImageLineStyle");routeStepMainImage.setAttribute("class","routeStepMainImageLineStyle");routeStepMainImage.innerHTML='<img src="/images/device'+a[h].lineType+'.jpg">';routeStepMainLine.appendChild(routeStepMainImage);routeStepMainName=document.createElement("div");routeStepMainName.setAttribute("className","routeStepMainNameLineStyle");routeStepMainName.setAttribute("class",
"routeStepMainNameLineStyle");routeStepMainName.innerHTML="["+a[h].lineNumber+"] "+a[h].startDirection+" - "+a[h].stopDirection;routeStepMainLine.appendChild(routeStepMainName);var k=document.createElement("div");k.setAttribute("className","routeStepSeparatorStyle");k.setAttribute("class","routeStepSeparatorStyle");routeStepMainLine.appendChild(k)}lines.push(j);f.push(j.getLatLng());var m=document.createElement("div");m.setAttribute("className","routeStepStyle");m.setAttribute("class","routeStepStyle");
g.appendChild(m);if(e!=a[h].lineid)e=a[h].lineid;else{k=document.createElement("div");k.setAttribute("className","routeStepSeparatorStyle");k.setAttribute("class","routeStepSeparatorStyle");m.appendChild(k)}k=document.createElement("div");k.setAttribute("className","routeStepNameStyle");k.setAttribute("class","routeStepNameStyle");k.innerHTML='<a target="new" href="/percorso/dettaglio/'+a[h].normalizedName+'.html">'+a[h].name+"</a>";m.appendChild(k);k=document.createElement("div");k.setAttribute("className",
"routeStepDescStyle");k.setAttribute("class","routeStepDescStyle");k.innerHTML=a[h].address;m.appendChild(k);d.extend(j.getPoint())}g=new GPolyline(f,"#ffffff",11,0.9);map.addOverlay(g);g=new GPolyline(f,"#4499cc",5,0.9);map.addOverlay(g);polies.push(g);routeWalkMainLine=document.createElement("div");routeWalkMainLine.setAttribute("className","routeWalkMainLineStyle");routeWalkMainLine.setAttribute("class","routeWalkMainLineStyle");c.appendChild(routeWalkMainLine);routeWalkImage=document.createElement("div");
routeWalkImage.setAttribute("className","routeWalkImageLineStyle");routeWalkImage.setAttribute("class","routeWalkImageLineStyle");routeWalkImage.innerHTML='<img src="/images/device4.jpg">';routeWalkMainLine.appendChild(routeWalkImage);routeWalkName=document.createElement("div");routeWalkName.setAttribute("className","routeWalkNameLineStyle");routeWalkName.setAttribute("class","routeWalkNameLineStyle");routeWalkName.innerHTML='Percorso a piedi <input type="button" value="Dettagli" onclick="javascript: drawDirectionEnd(\''+
a[a.length-1].latitude+","+a[a.length-1].longitude+"','"+bPointLat+","+bPointLon+'\')"><div id="directionSt"></div>';routeWalkMainLine.appendChild(routeWalkName);routeWalkDirectionEnd=document.createElement("div");routeWalkDirectionEnd.setAttribute("className","routeWalkDirectionStyle");routeWalkDirectionEnd.setAttribute("class","routeWalkDirectionStyle");routeWalkDirectionEnd.setAttribute("id","directionEnd");c.appendChild(routeWalkDirectionEnd);a=(d.getNorthEast().lng()+d.getSouthWest().lng())/
2;l=(d.getNorthEast().lat()+d.getSouthWest().lat())/2;a=new GLatLng(l,a);map.setCenter(a,map.getBoundsZoomLevel(d));drawWalkPolylineRoute()}function drawWalkPolylineRoute(){for(i=0;i<polies.length;i++)if(i+1<polies.length){var a=[];a.push(polies[i].getVertex(polies[i].getVertexCount()-1));a.push(polies[i+1].getVertex(0));a=new GPolyline(a,"#444444",4,0.7);map.addOverlay(a)}}
function drawOtherRoutes(){var a=theData,d=routeDiv;d.innerHTML="";var b=document.createElement("div");b.setAttribute("className","otherRoutesTitleStyle");b.setAttribute("class","otherRoutesTitleStyle");b.innerHTML="Percorsi alternativi: ";d.appendChild(b);b=document.createElement("div");b.setAttribute("className","otherOverflowStyle");b.setAttribute("class","otherOverflowStyle");d.appendChild(b);d=a.otherRoutes.length;for(var c=0,e=0;e<d;e++)c=c<=a.otherRoutes[e].values?a.otherRoutes[e].values:c;
for(e=0;e<d;e++){otherMain=document.createElement("div");otherMain.setAttribute("className","otherMainStyle");otherMain.setAttribute("class","otherMainStyle");b.appendChild(otherMain);otherName=document.createElement("div");otherName.setAttribute("className","otherNameStyle");otherName.setAttribute("class","otherNameStyle");otherName.innerHTML="<a href=\"javascript: selectOtherRoute('"+a.otherRoutes[e].routeId+'\');"><span class="bluevid"><b>'+a.otherRoutes[e].totalElements+"</b> fermate DA:</span>"+
a.otherRoutes[e].startStop+'<span class="bluevid"> A: </span>'+a.otherRoutes[e].endStop+"</a>";otherDetail=document.createElement("div");otherDetail.setAttribute("className","otherDetailStyle");otherDetail.setAttribute("class","otherDetailStyle");var g="";for(g=0;g<a.otherRoutes[e].lineTypes.length;g++){var f=document.createElement("div");f.setAttribute("className","otherLineTypeImageStyle");f.setAttribute("class","otherLineTypeImageStyle");f.innerHTML=a.otherRoutes[e].lineIds[g]+'<img src="/images/device'+
a.otherRoutes[e].lineTypes[g]+'.jpg" style="width:15px">';otherDetail.appendChild(f)}otherMain.appendChild(otherDetail);otherDetail.appendChild(otherName);g=240*a.otherRoutes[e].values/c;f=document.createElement("div");f.setAttribute("className","otherLineTimeStyle");f.setAttribute("class","otherLineTimeStyle");f.innerHTML='<img src="/images/bar.jpeg" style="margin-left:4px;border: 1px solid #e0e1e2" height="4px" width="'+g+'px">&nbsp;'+Math.round(a.otherRoutes[e].values/60)+" min";otherMain.appendChild(f);
disambDivClear=document.createElement("div");disambDivClear.setAttribute("className","clear");disambDivClear.setAttribute("class","clear");otherMain.appendChild(disambDivClear)}}
function selectOtherRoute(a){var d=theData;d="http://www.milano-italia.it/mi/oroute";$.getJSON(d,{key:a},function(b){theData=b;if(b.resultCode=="OK"){drawRoute(b.points,b.routeValue);routeId=b.routeId;var c=document.getElementById("permalinkTextArea");c.value="http://www.milano-italia.it/route/"+escape(b.routeId).replace(/\+/,"%2B")+"/"+b.routeNormName+".html"}else alert(b.resultMessage)})}var startico=new GIcon;startico.image="http://maps.google.com/mapfiles/dd-start.png";startico.shadow="http://maps.google.com/intl/it_ALL/mapfiles/shadow50.png";
startico.iconSize=new GSize(20,34);startico.shadowSize=new GSize(37,34);startico.iconAnchor=new GPoint(9,34);startico.infoWindowAnchor=new GPoint(9,2);var endico=new GIcon;endico.image="http://maps.google.com/mapfiles/dd-end.png";endico.shadow="http://maps.google.com/intl/it_ALL/mapfiles/shadow50.png";endico.iconSize=new GSize(20,34);endico.shadowSize=new GSize(37,34);endico.iconAnchor=new GPoint(9,34);endico.infoWindowAnchor=new GPoint(9,2);var blueicon=new GIcon;blueicon.image="http://labs.google.com/ridefinder/images/mm_20_blue.png";
blueicon.shadow="http://labs.google.com/ridefinder/images/mm_20_shadow.png";blueicon.iconSize=new GSize(12,20);blueicon.shadowSize=new GSize(22,20);blueicon.iconAnchor=new GPoint(6,20);blueicon.infoWindowAnchor=new GPoint(5,1);var diricon=new GIcon;diricon.image="/images/aim.png";diricon.shadow="/images/aim_shadow.png";diricon.iconSize=new GSize(16,16);diricon.shadowSize=new GSize(16,16);diricon.iconAnchor=new GPoint(9,14);diricon.infoWindowAnchor=new GPoint(14,4);var redicon=new GIcon;
redicon.image="/images/steppin.png";redicon.iconSize=new GSize(12,13);redicon.shadowSize=new GSize(0,0);redicon.iconAnchor=new GPoint(5,6);redicon.infoWindowAnchor=new GPoint(5,6);var chlnicon1=new GIcon;chlnicon1.image="/images/chln1.png";chlnicon1.shadow="";chlnicon1.iconSize=new GSize(32,40);chlnicon1.shadowSize=new GSize(0,0);chlnicon1.iconAnchor=new GPoint(15,35);chlnicon1.infoWindowAnchor=new GPoint(15,12);var chlnicon2=new GIcon;chlnicon2.image="/images/chln2.png";chlnicon2.shadow="";
chlnicon2.iconSize=new GSize(32,40);chlnicon2.shadowSize=new GSize(0,0);chlnicon2.iconAnchor=new GPoint(15,35);chlnicon2.infoWindowAnchor=new GPoint(15,12);var chlnicon3=new GIcon;chlnicon3.image="/images/chln3.png";chlnicon3.shadow="";chlnicon3.iconSize=new GSize(32,40);chlnicon3.shadowSize=new GSize(0,0);chlnicon3.iconAnchor=new GPoint(15,35);chlnicon3.infoWindowAnchor=new GPoint(15,12);var chlnicon5=new GIcon;chlnicon5.image="/images/chln5.png";chlnicon5.shadow="";
chlnicon5.iconSize=new GSize(32,40);chlnicon5.shadowSize=new GSize(0,0);chlnicon5.iconAnchor=new GPoint(15,35);chlnicon5.infoWindowAnchor=new GPoint(15,12);var chlnicon6=new GIcon;chlnicon6.image="/images/chln6.png";chlnicon6.shadow="";chlnicon6.iconSize=new GSize(32,40);chlnicon6.shadowSize=new GSize(0,0);chlnicon6.iconAnchor=new GPoint(15,35);chlnicon6.infoWindowAnchor=new GPoint(15,12);var chlnicon7=new GIcon;chlnicon7.image="/images/chln7.png";chlnicon7.shadow="";
chlnicon7.iconSize=new GSize(32,40);chlnicon7.shadowSize=new GSize(0,0);chlnicon7.iconAnchor=new GPoint(15,35);chlnicon7.infoWindowAnchor=new GPoint(15,12);var baseIcon=new GIcon(G_DEFAULT_ICON);baseIcon.shadow="http://www.google.com/mapfiles/shadow50.png";baseIcon.iconSize=new GSize(20,34);baseIcon.shadowSize=new GSize(37,34);baseIcon.iconAnchor=new GPoint(9,34);baseIcon.infoWindowAnchor=new GPoint(9,2);
function createNumberMarker(a,d,b,c){a=new GLatLng(a,d);d=new GIcon(baseIcon);d.image="http://maps.google.it/intl/it_it/mapfiles/icon_yellow"+b+".png";markerOptions={icon:d};var e=new GMarker(a,markerOptions);GEvent.addListener(e,"click",function(){e.openInfoWindowHtml(c)});return e}
function randomColor(){var a=new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"),d=new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"),b=new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"),c=new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"),e=new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"),g=new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F");return a="#"+
a[Math.floor(Math.random()*a.length)]+d[Math.floor(Math.random()*d.length)]+b[Math.floor(Math.random()*b.length)]+c[Math.floor(Math.random()*c.length)]+e[Math.floor(Math.random()*e.length)]+g[Math.floor(Math.random()*g.length)]}function toggleGroup(a){for(var d=0;d<lines[a].length;d++){var b=lines[a][d];b.isHidden()?b.show():b.hide()}a=polies[a];a[0].isHidden()?a[0].show():a[0].hide()}
function createRedMarker(a){var d=new GLatLng(a.latitude,a.longitude),b=new GMarker(d,{icon:redicon,draggable:false,title:a.name+"\n"+a.address});GEvent.addListener(b,"click",function(){var c=document.createElement("div"),e=document.createElement("div");e.innerHTML="<b>"+a.name+"</b> <br/>"+a.address+"<br>["+a.lineNumber+"] "+a.startDirection+" - "+a.stopDirection;c.appendChild(e);e=document.createElement("div");e.setAttribute("id","pano"+a.id);e.setAttribute("style","width:500px; height:280px");
c.appendChild(e);b.openInfoWindow(c);c=new GStreetviewPanorama(e);myPOV={yaw:370.64659986187695,pitch:0};c.setLocationAndPOV(d,myPOV);GEvent.addListener(c,"error",handleNoFlash)});return b}function handleNoFlash(a){a==603&&alert("Error: Flash doesn't appear to be supported by your browser")}
function createBlueMarker(a){var d=new GLatLng(a.latitude,a.longitude),b=new GMarker(d,{icon:blueicon,draggable:false,title:a.id+a.name}),c="<b>"+a.name+"</b> <br/>"+a.address+"<br> linea: "+a.lineid;GEvent.addListener(b,"click",function(e){b.openInfoWindowHtml(c)});return b}function gup(a){a=a.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");a="[\\?&]"+a+"=([^&#]*)";a=new RegExp(a);a=a.exec(window.location.href);return a==null?"":a[1]};
