
Asset.css("/5t/js/geo3/css/5tgeo.css");

/** Google API extensions */ 
google.maps.LatLng.prototype.distanceFrom=function(b){var i=[this.lat(),b.lat()];var k=[this.lng(),b.lng()];var e=6378137;var g=(i[1]-i[0])*Math.PI/180;var j=(k[1]-k[0])*Math.PI/180;var l=Math.sin(g/2)*Math.sin(g/2)+Math.cos(i[0]*Math.PI/180)*Math.cos(i[1]*Math.PI/180)*Math.sin(j/2)*Math.sin(j/2);var h=2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l));var f=e*h;return Math.round(f)};google.maps.LatLng.prototype.getMiddle=function(c){var b=(this.lat()+c.lat())/2;var a=this.lng()-c.lng();if(a<=180&&a>=-180){a=(this.lng()+c.lng())/2}else{a=(this.lng()+c.lng()+360)/2}return new google.maps.LatLng(b,a)};google.maps.Marker.prototype.distanceFrom=function(a){return this.getPosition().distanceFrom(a.getPosition())};google.maps.Marker.prototype.getMiddle=function(a){return this.getPosition().getMiddle(a.getPosition())};google.maps.Polyline.prototype.deleteVertex=function(a){this.getPath().removeAt(a)};google.maps.Polyline.prototype.getBounds=function(){var c=new google.maps.LatLngBounds();var b=this.getPath();
for(var a=0;a<b.getLength();a++){c.extend(b.getAt(a))}return c};google.maps.Polyline.prototype.getLength=function(){var c=0;var b=this.getPath();var e;for(var a=0;a<b.getLength()-1;a++){e=[b.getAt(a),b.getAt(a+1)];c+=e[0].distanceFrom(e[1])}return c};google.maps.Polyline.prototype.getVertex=function(a){return this.getPath().getAt(a)};google.maps.Polyline.prototype.getVertexCount=function(){return this.getPath().getLength()};google.maps.Polyline.prototype.getVisible=function(){return(this.getMap())?true:false};google.maps.Polyline.prototype.insertVertex=function(a,b){this.getPath().insertAt(a,b)};google.maps.Polyline.prototype.lastMap=false;google.maps.Polyline.prototype.setVertex=function(a,b){this.getPath().setAt(a,b)};google.maps.Polyline.prototype.setVisible=function(a){if(a===true&&!this.getVisible()){this.setMap(this.lastMap)}else{if(a===false&&this.getVisible()){this.lastMap=this.getMap();this.setMap(null)}}};google.maps.Polygon.prototype.deleteVertex=function(a){this.getPath().removeAt(a)
};google.maps.Polygon.prototype.getBounds=function(){var c=new google.maps.LatLngBounds();var b=this.getPath();for(var a=0;a<b.getLength();a++){c.extend(b.getAt(a))}return c};google.maps.Polygon.prototype.getPerimeter=function(){var e=0;var b=this.getPath();var f,c;if(b.getLength()){c=b.getAt(1)}for(var a=0;a<b.getLength();a++){if(a<b.getLength()-1){f=[b.getAt(a),b.getAt(a+1)]}else{if(c==b.getAt[a]){break}else{f=[b.getAt(a),b.getAt(0)]}}e+=f[0].distanceFrom(f[1])}return e};google.maps.Polygon.prototype.getVertex=function(a){return this.getPath().getAt(a)};google.maps.Polygon.prototype.getVertexCount=function(){var b=this.getPath();var a=b.getLength();if(!b.getAt(0).equals(b.getAt(a-1))){return a}else{return a-1}};google.maps.Polygon.prototype.getVisible=function(){return(this.getMap())?true:false};google.maps.Polygon.prototype.insertVertex=function(a,b){this.getPath().insertAt(a,b)};google.maps.Polygon.prototype.lastMap=false;google.maps.Polygon.prototype.setVertex=function(a,b){this.getPath().setAt(a,b)
};google.maps.Polygon.prototype.setVisible=function(a){if(a===true&&!this.getVisible()){this.setMap(this.lastMap)}else{if(a===false&&this.getVisible()){this.lastMap=this.getMap();this.setMap(null)}}};

/** 5T Geo API  */
Jpackage("g5t.geo",{name:"5T Geo API",version:3});g5t.geo.MapOptions={zoom:13,mapTypeId:google.maps.MapTypeId.ROADMAP,scrollwheel:false,center:new google.maps.LatLng(45.07393,7.6722)};g5t.geo.MarkerOptions={object:null,position:null,map:null,title:null,zoomLevel:13,zoomFactor:0,infoTpl:null,zIndex:100,autoZoom:false,draggable:false,icon:"http://google.com/mapfiles/ms/micons/yellow-dot.png",iconSize:null,iconAnchor:null,shadow:"",shadowSize:null,binding:{id:"id",position:function(a){return new google.maps.LatLng(a.lat,a.lng)}}};g5t.geo.PolylineOptions={path:[],map:null,traceLine:false,strokeColor:"#FF0000",strokeWeight:5,strokeOpacity:0.8,gap:0,gapZoomLevel:0,clickable:true,geodesic:false,zoomFactor:0,autoZoom:false,traceMarker:{icon:null,iconSize:null,draggable:true},binding:{id:"id",path:"path"}};g5t.geo.RouteOptions=Jobject.merge(g5t.geo.PolylineOptions,{colors:["#FF0000","#0000FF","#00FF00","#FF00FF","#FF66CC","#336633","#33FF33"],infoTpl:null,openInfoWindowOnOver:false,noReplace:true,startMarker:{infoTpl:null,title:null,zoomFactor:0.1,zoomLevel:15,icon:null,iconSize:new google.maps.Size(39,34),shadow:null,shadowSize:new google.maps.Size(39,34)},endMarker:{infoTpl:null,title:null,zoomFactor:0.1,zoomLevel:15,icon:null,iconSize:new google.maps.Size(39,34),shadow:null,shadowSize:new google.maps.Size(39,34)}});
g5t.geo.JourneyOptions=Jobject.merge(g5t.geo.RouteOptions,{binding:{partialRoutes:"partialRoutes",routePoints:"routePoints"}});g5t.geo.MarkerImageOptions={url:"",size:null,origin:null,anchor:null,scaleSize:null};g5t.maps=g5t.geo;g5t.geo.Util={dec2deg:function(e){var a=(e>0)?"+":"";var d=parseInt(e,10);e=Math.abs(e-d);var b=parseInt((e*60),10);e=(e*60)%1;var c=Math.round(Math.abs(e*60)*100)/100;return a+d+"&deg; "+b+"&prime; "+c+"&Prime;"}};g5t.geo.IconMaker={createLabeledIcon:function(b){var d=b.primaryColor||"#DA7187";var k=b.strokeColor||"#000000";var g=b.starPrimaryColor||"#FFFF00";var l=b.starStrokeColor||"#0000FF";var h=this.escapeUserText_(b.label)||"";var i=b.labelColor||"#000000";var e=b.addStar||false;var j=(e)?"pin_star":"pin";var f="http://chart.apis.google.com/chart?cht=d&chdp=mapsapi&chl=";var a=f+j+"'i\\'["+h+"'-2'f\\hv'a\\]h\\]o\\"+d.replace("#","")+"'fC\\"+i.replace("#","")+"'tC\\"+k.replace("#","")+"'eC\\";if(e){a+=g.replace("#","")+"'1C\\"+l.replace("#","")+"'0C\\"}a+="Lauto'f\\";
var c=a+"&ext=.png";return c},createFlatIcon:function(b){var c=b.width||32;var m=b.height||32;var d=b.primaryColor||"#ff0000";var f=b.shadowColor||"#000000";var j=MapIconMaker.escapeUserText_(b.label)||"";var l=b.labelColor||"#000000";var e=b.labelSize||0;var h=b.shape||"circle";var k=(h==="circle")?"it":"itr";var g="http://chart.apis.google.com/chart?cht="+k;var a=g+"&chs="+c+"x"+m+"&chco="+d.replace("#","")+","+f.replace("#","")+"ff,ffffff01&chl="+j+"&chx="+l.replace("#","")+","+e;var i=a+"&chf=bg,s,00000000&ext=.png";return i},escapeUserText_:function(a){if(a===undefined){return null}a=a.replace(/@/,"@@");a=a.replace(/\\/,"@\\");a=a.replace(/'/,"@'");a=a.replace(/\[/,"@[");a=a.replace(/\]/,"@]");return encodeURIComponent(a)}};g5t.geo.LineString={parse:function(d){var g=d.split(",");var f=[];var a;var b;for(var c=0;c<g.length;c++){var j=g[c].split(" ");try{if(j.length==2){a=new google.maps.LatLng(parseFloat(j[1]),parseFloat(j[0]));if(a){f.push(a)}}}catch(h){alert(h)}}return f}};g5t.geo.Map=new Jnative({Extends:google.maps.Map,Implements:[Joptions],options:Jobject.clone(g5t.geo.MapOptions),constructor:function g5t$geo$Map(c,b){Joptions.call(this,b);
var a=new google.maps.Map($(c),this.options);return a},addOverlay:function(a){a.setMap(this)},removeOverlay:function(a){a.setMap(null)},checkResize:function(){google.maps.event.trigger(this,"resize");this.setZoom(this.getZoom())}});g5t.geo.Binder=new Jclass({Implements:[Joptions],id:null,options:{binding:{}},constructor:function(b,a){Joptions.call(this,b);this.bind(a)},bind:function(b,a){a=a||this.options;if(b){this.object=b;for(var e in a.binding){var d=null;var c=true;if(a.binding[e] instanceof Jtemplate){d=a.binding[e].apply(b)}else{if(typeof a.binding[e]=="string"&&/\{[^\}]+\}/.test(a.binding[e])&&!(a.binding[e] in b)){d=new Jtemplate(a.binding[e]).apply(b);if(d==a.binding[e]){c=false}}else{if(typeof a.binding[e]=="function"){d=a.binding[e].call(this,b)}else{if(a.binding[e] in b){d=b[a.binding[e]]}else{c=false}}}}if(c){if(e in a){a[e]=d}if(e in this){this[e]=d}}}}}});g5t.geo.Overlay=new Jclass({id:null,Implements:[Events,Joptions,g5t.geo.Binder],options:{binding:{}},constructor:function(a){Joptions.call(this,a)
},setZoom:function(a){alert("Abstract method setZoom is not implemented yet!");throw new Error("Abstract method setZoom is not implemented yet!")},openInfoWindowHtml:function(d,a){var c=this;a=a||this;if(this.options.infoTpl){if(this.getMap().infoWindowOverlay){this.getMap().infoWindowOverlay.closeInfoWindow();this.getMap().infoWindowOverlay=null}var b="";if(!(this.options.infoTpl instanceof Jtemplate)){this.options.infoTpl=new Jtemplate(this.options.infoTpl)}b=this.options.infoTpl.apply(this.object);if(this.infoWindow){this.infoWindow.setContent(b)}else{this.infoWindow=new google.maps.InfoWindow({content:b,maxWidth:"500",pixelOffset:new google.maps.Size(5,0)})}this.infoWindow.open(this.getMap(),a);this.getMap().infoWindowOverlay=this;google.maps.event.addListener(this.infoWindow,"closeclick",function(){c.closeInfoWindow(true)});if(!c.mapListener){c.mapListener=google.maps.event.addListener(c.getMap(),"click",function(f){var h=f.latLng;var e=(c.getMap().getZoom()<=15?0.004:0.0005),g=(c.getMap().getZoom()<=15?0.004:0.0005);
if(c.getPosition().lat()>(h.lat()+e)||c.getPosition().lat()<(h.lat()-e)||c.getPosition().lng()>(h.lng()+g)||c.getPosition().lng()<(h.lng()-g)){c.closeInfoWindow()}})}google.maps.event.trigger(this,"infowindowopen",this.infoWindow)}},closeInfoWindow:function(b){if(this.infoWindow){var a=this.infoWindow;this.infoWindow=null;if(this.mapListener){google.maps.event.removeListener(this.mapListener);this.mapListener=null}if(!b){a.close(this.getMap(),this)}}}});

/**
 * 5T geo service context path
 */
g5t.contextPath="/5t";
g5t.webPath="/5t/";
g5t.imgPath="/5t/img";

/**/
g5t.maps.ContextMenu=new Jclass({Implements:Joptions,options:{map:null,html:null,handles:null},constructor:function(c,a){Joptions.call(this,a);this.element=$(c);if(this.element&&this.options.map){$(this.options.map.getDiv()).appendChild(this.element);var d=this;var b=d.element;d.element.addEvent("click",d.onselect.bind(d));google.maps.event.addListener(this.options.map,"rightclick",function(h){b.hide();var g=$(d.options.map.getDiv()),f=h.pixel.x,i=h.pixel.y;d.clickedLatLng=h.latLng;if(f>g.getSize().x-b.getSize().x){f-=b.getSize().x}if(i>g.getSize().y-b.getSize().y){i-=b.getSize().y}b.setStyle("top",i);b.setStyle("left",f);b.morph({opacity:[0,1],display:"block"})});"click dragstart zoom_changed maptypeid_changed".split(" ").each(function(e){google.maps.event.addListener(d.options.map,e,function(){b.hide()})})}},hide:function(){this.element.hide()},onselect:function(d){if(d.target&&d.target.tagName=="A"){var b=(d.target.href);var a=b.split("#");if(a.length>0){var c=a[a.length-1];if(this.options.handles&&this.options.handles[c]){this.options.handles[c](this.clickedLatLng)
}}}this.hide()}});

/**/
Jpackage("g5t.geo");g5t.geo.Marker=new Jclass({Extends:google.maps.Marker,Implements:[g5t.geo.Overlay],options:Jobject.clone(g5t.geo.MarkerOptions),constructor:function(b,a){this.bind(a,b);Joptions.call(this,b);b=Jobject.clone(this.options);b=this.compileOptions(b,a);var c=this;google.maps.Marker.call(this,b);this.object=a||this.options.object;if(this.options.infoTpl){google.maps.event.addListener(this,"click",this.openInfoWindowHtml)}if(this.getMap()&&this.options.zoomFactor&&this.options.autoZoom){google.maps.event.addListener(this.getMap(),"zoom_changed",function(){if(c.getMap()){c.setZoom(c.getMap().getZoom())}})}},compileOptions:function(m,a){var f=this;a=a||this.object;m=m||Jobject.clone(this.options);var g=["icon","shadow"];for(var c=0;c<g.length;c++){var h=g[c];if(m[h]&&typeof m[h]=="string"){var e=m[h];var d=m[h+"Anchor"];var l=m[h+"Size"];var k=(f.options.map?f.options.map.getZoom():0);l=f.getIconSize(k,l);if(l){var j,b;m[h+"Size"]=l;m[h]=new google.maps.MarkerImage(e,l,j,d,b)
}else{m[h]=new google.maps.MarkerImage(e)}}}return m},getIconSize:function(f,a){a=a||this.options.iconSize;if(!a){return null}var b=this.options.zoomFactor;if(!f){return a}if(b){var e=f-this.options.zoomLevel;if(e!=0){var c=a.width,g=a.height;c+=(c*(e*b));g+=(g*(e*b));a=new google.maps.Size(c,g)}return a}else{return a}},setZoom:function(b){if(this.options.zoomFactor){var a=this.getIconSize(b);this.setIconSize(a)}if(this.Jsuper&&this.Jsuper.setZoom){this.Jsuper.setZoom.call(this,b)}},setIconSize:function(a){if(!a){return}var b=new google.maps.MarkerImage(this.options.icon,a,new google.maps.Point(0,0),new google.maps.Point(0,a.width),a);this.setIcon(b)},hide:function(){this.setVisible(false);if(this.infoWindow){this.closeInfoWindow()}},show:function(){this.setVisible(true)}});g5t.geo.CustomMarkerCount=0;g5t.geo.CustomMarker=new Jclass({Extends:[google.maps.OverlayView],Implements:[g5t.geo.Overlay,Events],data:null,options:Jobject.extend(Jobject.clone(g5t.geo.MarkerOptions),{cls:"w-marker",iconCls:"w-marker-icon",bodyCls:"w-marker-body",headerCls:"w-marker-header",footerCls:"w-marker-footer",html:["<div class='{cls}'>","    <img class='{iconCls}' src='{icon}' ></img>","</div>"],events:{click:null,mouseover:null,mouseout:null,positionchanged:null,contentupdated:null}}),constructor:function g5t$geo$CustomMarker(b,a){Joptions.call(this,b);
this.bind(a,this.options);var c=this.options.map;this.position_=this.options.position;this.addToMap(c)},addToMap:function(b){this.setMap(b);var a=this;if(this.options.infoTpl){google.maps.event.addListener(a,"click",function(){a.openInfoWindowHtml()})}},getEl:function(){return $(this.div_)},getDraggable:function(){return this.options.draggable},draw:function(){var g=this;var a=this.div_;if(!a){var f=this.getIconSize(g.getMap().getZoom());var b="_CUSTOM_MARKER_"+(++g5t.geo.CustomMarkerCount);a=this.div_=new Element("DIV",{id:b,style:{border:"none",padding:"0px"}});a.style.position="absolute";a.style.cursor="pointer";a.style.zIndex=this.options.zIndex;a.title=new Jtemplate(this.options.title).apply(this.data);var e=new Jtemplate(this.options.html);var d=e.apply(this.options);a.set("html",d);var c=a.getElement("."+this.options.iconCls);if(c&&f){c.style.width=f.width+"px";c.style.height=f.height+"px"}google.maps.event.addDomListener(a,"click",function(j){google.maps.event.trigger(g,"click")
});var h=this.getPanes();h.overlayImage.appendChild(a)}var i=this.getProjection().fromLatLngToDivPixel(this.position_);if(i){a.setStyle("left",i.x+"px");a.setStyle("top",i.y+"px")}if(this.getMap()&&this.options.autoZoom&&this.options.zoomFactor){google.maps.event.addListener(this.getMap(),"zoom_changed",function(k,j){g.setZoom(g.getMap().getZoom())})}},getIconSize:function(f){var b=this.options.zoomFactor;if(b){var e=f-this.options.zoomLevel;var a=this.options.iconSize;if(e!=0){var c=a.width,g=a.height;c+=(c*(e*b));g+=(g*(e*b));a=new google.maps.Size(c,g)}return a}else{return this.options.iconSize}},setZoom:function(a){this.resizeIcon(a)},resizeIcon:function(b){if(this.options.zoomFactor){var a=this.getIconSize(b);this.setIconSize(a)}},setIconSize:function(b){var a=this.getEl().getElement("."+this.options.iconCls);a.style.width=b.width+"px";a.style.height=b.height+"px"},remove:function(){if(this.div_){this.div_.parentNode.removeChild(this.div_);this.div_=null}},getPosition:function(){return this.position_
},hide:function(){this.getEl().hide()},show:function(){this.getEl().show()}});g5t.geo.MarkerImage=new Jclass({Extends:google.maps.MarkerImage,Implements:[Joptions],options:Jobject.clone(g5t.geo.MarkerImageOptions),constructor:function(a){a.scaleSize=a.scaleSize||a.size;if(a.size){a.anchor=a.anchor||new google.maps.Point(0,a.size.width);a.origin=a.origin||new google.maps.Point(0,0)}Joptions.call(this,a);return new google.maps.MarkerImage(this.options.url,this.options.size,this.options.origin,this.options.anchor,this.options.scaledSize)}});

/**/
g5t.geo.ParallelLines=new Jclass({Extends:new google.maps.OverlayView(),constructor:function ParallelLines(a){this.gapPx=a.gap;this.points=a.points;this.polyline=a.polyline;this.color=a.color;this.weight=a.weight;this.opacity=a.opacity;this.gapZoomLevel=a.gapZoomLevel;this.side=a.side||"both";this.prj=null;this.line1=null;this.line2=null;this.zoomListener=null},onAdd:function(){this.setProjection();var b=this;var a=function(){if(!this.prj){b.setProjection()}};if(!this.gapZoomLevel){this.zoomListener=google.maps.event.addListener(this.map,"zoom_changed",a)}},setProjection:function(){this.map=this.getMap();this.prj=this.getProjection()},onRemove:function(){if(this.line2){this.line2.setMap(null);this.line2=null}if(this.line1){this.line1.setMap(null);this.line1=null}if(this.prj){this.prj=null}if(this.zoomListener!=null){google.maps.event.removeListener(this.zoomListener)}},draw:function(a){if(this.line2){this.line2.setMap(null);this.line2=null}if(this.line1){this.line1.setMap(null);this.line1=null
}this.recalc();return},redraw:function(a){return},recalc:function(){var a=this.map.getZoom();if(this.gapZoomLevel&&(this.leftLine||this.rightLine)){if(this.gapZoomLevel<a){if(this.polyline){this.polyline.setPath(this.points)}}else{if(this.leftLine){this.polyline.setPath(this.leftLine)}else{this.polyline.setPath(this.rightLine)}}return}var H=new Array();var G=new Array();var x=(this.gapPx+this.weight)/2;var z,t;for(var B=1;B<this.points.length;B++){var e;var q;var j;var y;var u;var c=this.prj.fromLatLngToContainerPixel(this.points[B-1]);var b=this.prj.fromLatLngToContainerPixel(this.points[B]);var k=Math.atan2(c.x-b.x,c.y-b.y)+(Math.PI/2);var A=Math.sqrt(((c.x-b.x)*(c.x-b.x))+((c.y-b.y)*(c.y-b.y)));if(k>Math.PI){k-=Math.PI*2}var n=Math.round(x*Math.sin(k));var l=Math.round(x*Math.cos(k));var h=new google.maps.Point(c.x+n,c.y+l);var d=new google.maps.Point(c.x-n,c.y-l);z=new google.maps.Point(b.x+n,b.y+l);t=new google.maps.Point(b.x-n,b.y-l);if(B==1){H.push(this.prj.fromContainerPixelToLatLng(h));
G.push(this.prj.fromContainerPixelToLatLng(d))}else{if(k==u){H.push(this.prj.fromContainerPixelToLatLng(h));G.push(this.prj.fromContainerPixelToLatLng(d))}else{var m=this.intersect(e,j,h,z);var p=this.intersect(q,y,d,t);var f=(m.x-c.x);var w=(m.y-c.y);var v=(p.x-c.x);var E=(p.y-c.y);var C=Math.sqrt((v*v)+(E*E));var r=x/C;var D=k-u;if(D<(Math.PI*2)){D+=Math.PI*2}if(D>(Math.PI*2)){D-=Math.PI*2}if(D<Math.PI){H.push(this.prj.fromContainerPixelToLatLng(j));H.push(this.prj.fromContainerPixelToLatLng(new google.maps.Point(c.x+(r*f),c.y+(r*w)),a));H.push(this.prj.fromContainerPixelToLatLng(h))}else{if(C<A){H.push(this.prj.fromContainerPixelToLatLng(m))}else{H.push(this.prj.fromContainerPixelToLatLng(j));H.push(this.prj.fromContainerPixelToLatLng(h))}}var F=(p.x-c.x)*(p.x-c.x);var g=(p.y-c.y)*(p.y-c.y);if(D>Math.PI){G.push(this.prj.fromContainerPixelToLatLng(y));G.push(this.prj.fromContainerPixelToLatLng(new google.maps.Point(c.x+(r*v),c.y+(r*E)),a));G.push(this.prj.fromContainerPixelToLatLng(d))
}else{if(C<A){G.push(this.prj.fromContainerPixelToLatLng(p))}else{G.push(this.prj.fromContainerPixelToLatLng(y));G.push(this.prj.fromContainerPixelToLatLng(d))}}}}e=h;q=d;j=z;y=t;u=k}H.push(this.prj.fromContainerPixelToLatLng(z));G.push(this.prj.fromContainerPixelToLatLng(t));if(this.side=="left"||this.side=="both"){if(!this.polyline){if(this.line1){this.line1.setMap(null)}this.line1=new google.maps.Polyline({path:H,strokeColor:this.color,strokeOpacity:this.opacity,strokeWeight:this.weight});this.line1.setMap(this.map)}else{this.leftLine=H;this.polyline.setPath(H)}}if(this.side=="right"||this.side=="both"){if(!this.polyline){if(this.line2){this.line1.setMap(null)}this.line2=new google.maps.Polyline({path:G,strokeColor:this.color,strokeOpacity:this.opacity,strokeWeight:this.weight});this.line2.setMap(this.map)}else{this.rightLine=G;this.polyline.setPath(G)}}},intersect:function(g,e,d,b){var w,m,p,v,l,o,j,c,a;var t=g.x;var k=g.y;var s=e.x;var i=e.y;var r=d.x;var h=d.y;var q=b.x;var f=b.y;
if((s-t)!=0){c=(i-k)/(s-t)}else{c=10000000000}if((q-r)!=0){a=(f-h)/(q-r)}else{a=10000000000}w=c;v=a;m=-1;l=-1;p=(k-c*t);o=(h-a*r);j=1/(w*l-v*m);var n=((m*o-l*p)*j);var u=((v*p-w*o)*j);return new google.maps.Point(Math.round(n),Math.round(u))}});
 
/**/
Jpackage("g5t.geo");g5t.geo.Polyline=new Jclass({Extends:google.maps.Polyline,Implements:[g5t.geo.Overlay],options:Jobject.clone(g5t.geo.PolylineOptions),constructor:function g5t$geo$Polyline(b,a){var d=this;Joptions.call(this,b);b=(this.options);this.bind(a,b);if(typeof b.path=="string"){b.path=g5t.geo.Polyline.decode(b.path)}google.maps.Polyline.call(this,b);if(this.options.gap){var c={points:b.path,polyline:this,gap:this.options.gap,gapZoomLevel:this.options.gapZoomLevel,weight:this.options.strokeWeight,map:this.options.map,side:"right"};this.options.points=b.path;this.parallelLine=new g5t.geo.ParallelLines(c);this.parallelLine.setMap(b.map)}this.object=a||b.object;if(this.options.infoTpl){google.maps.event.addDomListener(this,"click",this.openInfoWindowHtml)}if(this.options.traceLine&&this.getTracer()){google.maps.event.addDomListener(this,"mouseover",function(e){d.showTracer(e.latLng)});google.maps.event.addDomListener(this,"mouseout",function(e){d.hideTracer()})}if(this.getMap()&&this.options.autoZoom&&this.options.zoomFactor){google.maps.event.addListener(this.getMap(),"zoom_changed",function(){d.setZoom(d.getMap().getZoom())
})}},getStrokeWeight:function(b,c){c=c||this.options.strokeWeight;var a=this.options.zoomFactor;if(b&&a){var e=b-this.options.zoomLevel;if(e){c+=(c*(e*a))}}return c},setZoom:function(a){this.setOptions({strokeWeight:this.getStrokeWeight(a)})},getBounds:function(){var c=this.getPath().getArray();var a={lat:c[0].lat(),lng:c[0].lng()},d={lat:c[0].lat(),lng:c[0].lng()};for(var b=0;b<c.length;b++){if(a.lng>c[b].lng()){a.lng=c[b].lng()}if(a.lat>c[b].lat()){a.lat=c[b].lat()}if(d.lat<c[b].lat()){d.lat=c[b].lat()}if(d.lng<c[b].lng()){d.lng=c[b].lng()}}return new google.maps.LatLngBounds(new google.maps.LatLng(a.lat,a.lng),new google.maps.LatLng(d.lat,d.lng))},getTracer:function(){var b=this;var a=this.options.traceMarker.icon;if(a&&!this.tracer){var c={position:this.getPath().getAt(this.getPath().getLength()/2)};if(this.options.traceMarker&&this.options.traceMarker.icon){if(typeof this.options.traceMarker.icon=="function"){this.options.traceMarker.icon=this.options.traceMarker.icon.call(this,this.object)
}Jobject.apply(this.options.traceMarker,c)}c.infoTpl=this.options.infoTpl;this.tracer=new g5t.geo.Marker(c,this.object);if(this.getMap()){this.tracer.setMap(this.getMap());this.tracer.hide()}}return this.tracer},showTracer:function(a){if(this.getTracer()){a=this.getProximity(a)||a;this.getTracer().setPosition(a);this.getTracer().show()}},hideTracer:function(){if(this.getTracer()){this.getTracer().hide()}},openInfoWindowHtml:function(d,a){var c=this.getTracer();if(c){c.setMap(this.getMap());c.show();var b=this.getProximity(d.latLng)||d.latLng;c.setPosition(b)}g5t.maps.Overlay.prototype.openInfoWindowHtml.call(this,d,c)},closeInfoWindow:function(){var a=this.getTracer();if(a){a.hide()}g5t.maps.Overlay.prototype.closeInfoWindow.apply(this,arguments)},getLength:function(){var c=0;var b=this.getPath();var e;for(var a=0;a<b.getLength()-1;a++){e=[b.getAt(a),b.getAt(a+1)];c+=e[0].distanceFrom(e[1])}return c},getProjection:function(){if(!this.overlayView){this.overlayView=new google.maps.OverlayView();
this.overlayView.draw=function(){};this.overlayView.setMap(this.getMap())}return this.overlayView.getProjection()},createRouteNodes:function(c,l){c=c||this.getProjection();l=l||this;var m=this.getMap().getZoom();var f=true;if(f){var g=0;l.nodes=[];var h,b=0;try{var n=l.getPath().getArray();for(var a=0;a<n.length;a++){var k=c.fromLatLngToContainerPixel(n[a]);k.x=parseInt(0.5+k.x);k.y=parseInt(0.5+k.y);if(a==0||h.x!=k.x||h.y!=k.y){l.nodes.push(k.x);l.nodes.push(k.y);h=k}}}catch(d){throw d}}},getProximity:function(b,F,D,q){q=q||300;F=F||this.getProjection();D=D||this;if(!D.getBounds().contains(b)){return}this.createRouteNodes(F,D);var v=D.nodes.length;var E=F.fromLatLngToContainerPixel(b);var h=E.x;var g=E.y;var j=D.nodes[0];var i=D.nodes[1];var C=j;var B=i;var a=99999;var f=2;for(var t=f;t<v;t+=f){var z=j;var e=i;j=D.nodes[t];i=D.nodes[t+1];if((j<h-50&&z<h-50)||(j>h+50&&z>h+50)){continue}if((i<g-50&&e<g-50)||(i>g+50&&e>g+50)){continue}var m=j-z;var k=i-e;var A=m*m+k*k;var o=((h-j)*m+(g-i)*k)/A;
var w=j+(o*m);var c=i+(o*k);var s=(h-w)*(h-w)+(g-c)*(g-c);if(a>s){var H=(h-z)*(h-z)+(g-e)*(g-e);var G=(h-j)*(h-j)+(g-i)*(g-i);if((H-s)+(G-s)>A){if(H<G){s=H;w=z;c=e}else{s=G;w=j;c=i}}}if(a>s){a=s;C=w;B=c}}if(a<=q){var r=F.fromContainerPixelToLatLng(new google.maps.Point(C,B));return r}}});Jobject.extend(g5t.geo.Polyline,{createEncodings:function(a){return this.encode(a)},encode:function(b){var h=function(n){var i="";while(n>=32){i+=(String.fromCharCode((32|(n&31))+63));n>>=5}i+=(String.fromCharCode(n+63));return i};var g=function(i){var n=i<<1;if(i<0){n=~(n)}return(h(n))};var c=0;var e=0;var f=0;var d="";for(var c=0;c<b.getVertexCount();c++){var l=b.getVertex(c);var j=l.lat();var k=l.lng();var a=Math.round(j*100000);var m=Math.round(k*100000);dlat=a-e;dlng=m-f;e=a;f=m;d+=g(dlat)+g(dlng)}return d},toLineString:function(f){var a=function(h,i){var g=Math.round(h*Math.pow(10,i))/Math.pow(10,i);return g};var d=f;var b="";for(var c=0;c<d.getVertexCount();c++){var e=d.getVertex(c);if(b.length>0){b+=","
}b+=a(e.lng(),5)+" "+a(e.lat(),5)}return b},decode:function(f){if(f.indexOf(" ")>0&&f.indexOf(",")>0){var e=f.split(",");var d=[];for(var a=0;a<e.length;a++){var c=e[a].split(" ");var b=[parseFloat(c[1]),parseFloat(c[0])];d.push(new google.maps.LatLng(b[0],b[1]))}return d}var d=google.maps.geometry.encoding.decodePath(f);return d}});
 
/**/
g5t.maps.CustomControl=new Jclass({Extends:new google.maps.OverlayView(),Implements:[Joptions,Events],options:{map:null,element:null,controlPosition:google.maps.ControlPosition.BOTTOM_CENTER,anchor:new google.maps.Point(0,0)},constructor:function g5t$maps$CustomControl(a){Joptions.call(this,a);this.createElement(this.options.element);this.addToMap(this.options.map)},createElement:function(a){if(!a){this.element=new Element("div",{style:{position:"absolute"}})}else{if(a.constructor==Object){this.element=new Element("div",a)}else{this.element=$(a)}}return this.element},draw:function(){},addToMap:function(a){if(!a){return}this.setMap(a);if(this.options.controlPosition){a.controls[this.options.controlPosition].push(this.element)}this.set("visible",true)}});

/**/
g5t.maps.LocationControl=new Jclass({Extends:new google.maps.OverlayView(),Implements:[Joptions,Events],options:{map:null,visibility:"visible",controlPosition:google.maps.ControlPosition.TOP_CENTER,position:null,anchor:new google.maps.Point(8,8)},constructor:function g5t$maps$LocationControl(a){Joptions.call(this,a);this.ANCHOR_OFFSET_=this.options.anchor;this.node_=this.createHtmlNode_();var b=this.options.map;this.addToMap(b)},draw:function(){},addToMap:function(b){if(!b){return}this.setMap(b);if(this.options.controlPosition){b.controls[this.options.controlPosition].push(this.node_)}if(this.options.position){this.node_.style.left=this.options.position.x+this.ANCHOR_OFFSET_.x+"px";this.node_.style.top=this.options.position.y+this.ANCHOR_OFFSET_.y+"px"}this.set("visible",false);var a=this;google.maps.event.addListener(b,"mouseover",function(c){a.set("visible",true)});google.maps.event.addListener(b,"mouseout",function(c){a.set("visible",false)});google.maps.event.addListener(b,"mousemove",function(c){a.updatePosition(c.latLng,"location")
})},createHtmlNode_:function(){var a=document.createElement("div");a.className="w-latlng-control";a.index=100;return a},visible_changed:function(){if(this.options.visibility=="visible"){this.node_.style.display=this.get("visible")?"":"none"}else{this.node_.style.display="none"}},fromLatLngToContainerPixel:function(c){var b=this.getProjection();var a=b.fromLatLngToContainerPixel(c);return a},updatePosition:function(d,e){this.fireEvent("positionchanged",a);if(!this.options.position){var b=this.getProjection();var a=b.fromLatLngToContainerPixel(d);this.node_.style.left=a.x+this.ANCHOR_OFFSET_.x+"px";this.node_.style.top=a.y+this.ANCHOR_OFFSET_.y+"px"}else{this.node_.style.left=this.options.position.x+this.ANCHOR_OFFSET_.x+"px";this.node_.style.top=this.options.position.y+this.ANCHOR_OFFSET_.y+"px"}var f,c;f=g5t.geo.Util.dec2deg(d.lat());c=g5t.geo.Util.dec2deg(d.lng());$(this.node_).set("html",['<span style="font-size:7pt;font-style:italic;">',d.toUrlValue(4),"<br/>",f,",",c,"</span>"].join(""))
}});

/**/
g5t.maps.GeocoderControl=new Jclass({Extends:new google.maps.OverlayView(),Implements:[Joptions,Events],options:{visibility:"visible",controlPosition:google.maps.ControlPosition.TOP_LEFT,position:null,anchor:new google.maps.Point(8,0),geocoder:null},constructor:function g5t$maps$GeocoderControl(a){Joptions.call(this,a);this.ANCHOR_OFFSET_=this.options.anchor;this.node_=this.createHtmlNode_();if(!this.options.geocoder){this.geocoder=new g5t.maps.GoogleGeocoder()}else{this.geocoder=this.options.geocoder}this.addToMap(this.options.map)},addToMap:function(b){if(!b){return}if(this.options.controlPosition){b.controls[this.options.controlPosition].push(this.node_)}if(this.options.position){this.node_.style.left=this.options.position.x+this.ANCHOR_OFFSET_.x+"px";this.node_.style.top=this.options.position.y+this.ANCHOR_OFFSET_.y+"px"}this.setMap(b);this.set("visible",false);var a=this;google.maps.event.addListener(b,"mouseover",function(c){a.set("visible",true);a.fireEvent("mouseover",c)});google.maps.event.addListener(b,"mouseout",function(c){a.set("visible",false);
a.fireEvent("mouseover",c)});google.maps.event.addListener(b,"mousemove",function(c){a.updatePosition(c.latLng)})},draw:function(){},createHtmlNode_:function(){var a=document.createElement("div");a.className="w-latlng-control";a.index=100;return a},visible_changed:function(){if(this.options.visibility=="visible"){this.node_.style.display=this.get("visible")?"":"none"}else{this.node_.style.display="none"}},fromLatLngToContainerPixel:function(c){var b=this.getProjection();var a=b.fromLatLngToContainerPixel(c);return a},updatePosition:function(d,f,e){this.fireEvent("positionchanged",a);if(!this.options.position){var b=this.getProjection();var a=b.fromLatLngToContainerPixel(d);this.node_.style.left=a.x+this.ANCHOR_OFFSET_.x+"px";this.node_.style.top=a.y+this.ANCHOR_OFFSET_.y+"px"}else{this.node_.style.left=this.options.position.x+this.ANCHOR_OFFSET_.x+"px";this.node_.style.top=this.options.position.y+this.ANCHOR_OFFSET_.y+"px"}var c=this;if(!e){$(this.node_).set("html","");if(c.delay){window.clearInterval(c.delay);
c.delay=0}c.delay=c.geocoder.geocode.delay(500,c.geocoder,[{location:d},function(h,g){c.updateData(h)}])}},updateData:function(a){if(!a||!a[0]){return}this.data=a;address=this.data[0];$(this.node_).set("html",['<div style="font-size:7pt;font-style:italic;background-color:white;opacity:0.8;">',"<center>{address},{number}<br/>{postalCode} - {locality}","</center>","</div>"].join("").formats(address))}});

/**/
g5t.geo.Route=new Jclass({Extends:g5t.maps.Polyline,wayPoints:null,options:Jobject.clone(g5t.geo.RouteOptions),constructor:function g5t$geo$Route(b,a){g5t.geo.Polyline.call(this,b,a)},getWayPoints:function(){if(!this.wayPoints){this.wayPoints=[]}return this.wayPoints}});

/**/
g5t.geo.Journey=new Jclass({Extends:g5t.maps.Polyline,partialRoutes:[],routePoints:[],options:Jobject.clone(g5t.geo.JourneyOptions),constructor:function g5t$geo$Journey(b,a){g5t.geo.Polyline.call(this,b,a)},getRoutePoints:function(){if(!this.routePoints){this.routePoints=[]}return this.routePoints},getPartialRoutes:function(){if(!this.partialRoutes){this.partialRoutes=[]}return this.partialRoutes}});

/**/
g5t.geo.OverlayController=new Class({Extends:google.maps.OverlayView,Implements:[Joptions,Events],gmap:null,options:{url:null,proxiDistance:300,nodeIconSize:new google.maps.Size(10,10),traceRoute:false,categories:{Polyline:{type:g5t.geo.Polyline,baseCategory:null,options:Jobject.merge(g5t.geo.PolylineOptions,{binding:{path:"points"}})},Marker:{type:g5t.geo.Marker,baseCategory:null,options:Jobject.clone(g5t.geo.MarkerOptions)},Route:{type:g5t.geo.Route,baseCategory:"Polyline",options:Jobject.merge(g5t.geo.RouteOptions,{binding:{wayPoints:"stopPoints"}}),binding:{wayPoints:{category:"Marker"}}}}},overlays:{},initialize:function g5t$geo$OverlayController(f,e){google.maps.OverlayView.call(this);if(!f){throw new Error("The parameter: gmap (google map) cannot be null!")}this.setJoptions(e);for(var b in this.options.categories){var a=this.options.categories[b];if(a.baseCategory){if(this.options.categories[a.baseCategory]){var d=this.options.categories[a.baseCategory];Jobject.apply(d,a,Japply.merge|Japply.onlyIfNull)
}else{throw new Error("Overlay base category not defined: "+a.baseCategory+"!")}}}this.categories=this.options.categories;this.gmap=f;var c=this;google.maps.event.addListener(this.gmap,"zoom_changed",function(h,g){c.zoomOverlays()});if(this.options.traceRoute){google.maps.event.addListener(this.gmap,"mousemove",function(g){c.getProximity(g)})}},getProjection:function(){if(this.getProjection){if(!this.overlayView){this.overlayView=new google.maps.OverlayView();this.overlayView.draw=function(){};this.overlayView.setMap(this.gmap)}return this.overlayView.getProjection()}},drawn:function(){},mergeOptions:function(b,a){b=b||{};Jobject.apply(a,b,Japply.merge|Japply.onlyIfNull);return b},loadData:function(d,c,a){if(d){d=Jobject.splat(d);for(var b=0;b<d.length;b++){this.createOverlay(d[b],c,a)}}},removeData:function(e,d){if(e){var b=new g5t.geo.Overlay({});var a=this.getCategoryOptions(d);var b=new g5t.geo.Overlay(a);e=Jobject.splat(e);for(var c=0;c<e.length;c++){b.bind(e[c]);if(b.id){this.removeOverlay(null,b.id,d)
}}}},centerPolyline:function(a){var b=a.getBounds();this.gmap.fitBounds(b);this.gmap.setCenter(b.getCenter())},get:function(d){var a=this;var b={url:d.url||this.options.url,onSuccess:d.onSuccess||function(e,f){if(!e){e=JSON.decode(f)}if(d.onLoad){d.onLoad(e)}else{a.loadData(e,d.category)}},onFailure:d.onFailure,onException:d.onException};var c=new Request.JSON(b);c.get(d.data||d)},addOverlay:function(a,c,b){b=b||"Overlay";c=this.getOverlayId(c,b);if(!this.overlays[b]){this.overlays[b]={}}if(c&&this.overlays[b][c]){this.gmap.removeOverlay(this.overlays[b][c])}this.gmap.addOverlay(a);if(c){this.overlays[b][c]=a}},getOverlay:function(b,a){a=a||"Overlay";b=this.getOverlayId(b,a);if(this.overlays[a]){return this.overlays[a][b]}},getOverlayCount:function(b){if(!this.overlays[b]){return 0}else{var a=0;for(var c in this.overlays[b]){if(this.overlays[b][c]){a++}}return a}},getCurrentOverlay:function(a){if(this.categories[a]&&this.categories[a].currentOverlay){return this.categories[a].currentOverlay
}else{return this.getFirstOverlay(a)}},setCurrentOverlay:function(a,b){if(this.categories[b]){this.categories[b].currentOverlay=a}},getOverlayId:function(b,a){a=a||"Overlay";if(!b){b=a+"-"+this.getOverlayCount(a)}if(b&&/^[0-9]+$/.test(b)){b=a+"-"+b}b=b+"";if(!b.match("^"+a+"-")){b=a+"-"+b}return b},removeOverlay:function(a,d,c){c=c||"Overlay";if(this.overlays[c]){var b=this.overlays[c];d=this.getOverlayId(d,c);if(d&&b[d]){this.removeComponents(b[d],c);this.gmap.removeOverlay(b[d]);b[d]=null;return}}if(a){this.removeComponents(a,c);this.gmap.removeOverlay(a)}},getOverlay:function(c,b){b=b||"Overlay";var a=this.getOverlays(b);if(a){c=this.getOverlayId(c,b);return a[c]}},getOverlays:function(a){if(this.overlays[a]){return this.overlays[a]}else{return{}}},getFirstOverlay:function(b){if(this.overlays[b]){var a=[];for(var c in this.overlays[b]){if(this.overlays[b][c]){return this.overlays[b][c]}}}},getCreator:function(a){var b=this.getCategory(a).baseCategory;if(typeof this["create"+a]=="function"){return{category:a,method:"create"+a}
}else{if(b){return this.getCreator(b)}}},getCategoryType:function(a){var b=this.getCategory(a).baseCategory;if(this.getCategory(a).type){return this.getCategory(a).type}else{if(b){return this.getCategoryType(b)}}},createOverlay:function(c,f,b){b=b||{};if(this.getCategory(f)){var e=this.getCreator(f);var a;if(e){b=this.mergeOptions(b,this.getCategory(f).options);a=this[e.method](c,f,b);if(e.category!=f){this.createComponents(c,f,b)}return a}else{var d=this.getCategoryType(f);b=this.mergeOptions(b,this.getCategory(f).options);b.map=this.gmap;a=new d(b,c);this.addOverlay(a,a.id,f);this.fireEvent(f+"Added",a);this.createComponents(c,f,b);return a}}else{alert("The overlay category: "+f+" is not defined!")}},createComponents:function(f,c,o){var e=this.getCategory(c);if(e&&e.binding){var l=e.binding;for(var a in l){var k=l[a],d;if(k.category&&(d=Jobject.get(f,a))){d=Jobject.splat(d);for(var g=0;g<d.length;g++){var i=d[g];var m=k.category;if(i.category&&g!=0&&g!=(d.length-1)){m=i.category}var o={};
var n=Jobject.clone(this.getCategoryOptions(m));if(g==0){if(e.options["start"+k.category]){o=Jobject.clone(e.options["start"+k.category])}}else{if(g==(d.length-1)){if(e.options["end"+k.category]){o=Jobject.clone(e.options["end"+k.category])}}}if(o&&o.icon){i.icon=o.icon}o.binding=o.binding||n.binding||{};var b=o.binding.id||"{id}";if(b=="id"){b="{id}"}o.binding.id=b;o.binding.id=f.id+"-"+o.binding.id;var h=this.createOverlay(i,m,o);i.overlay=h}}}}},removeComponents:function(c,d){var h=this.getCategory(d);if(c&&h&&h.binding){var e=h.binding;for(var b in e){var g=e[b],f;if(g.category&&(f=Jobject.get(c,b))){f=Jobject.splat(f);for(var a=0;a<f.length;a++){this.removeOverlay(f[a].overlay,f[a].overlay.id,g.category)}}}}},getCategory:function(a){return this.options.categories[a]},getCategoryOptions:function(b){var a=this.getCategory(b).options;return a},getRouteOptions:function(){return this.getCategoryOptions("Route")},getPolylineOptions:function(){return this.getCategoryOptions("Polyline")},createPolyline:function(c,d,b){b=b||{};
d=d||"Polyline";b=this.mergeOptions(b,this.getCategoryOptions(d));b.map=this.gmap;var a=new g5t.geo.Polyline(b,c);this.addOverlay(a,a.id,d);this.fireEvent(d+"Added",a);if(b.centerOnMap){this.centerPolyline(a)}return a},removeRoute:function(d,c){c=c||"Route";var b=this.getOverlay(d,c);var a=this;if(b){this.removeComponents(b,c);this.removeOverlay(b,d,c)}},createRoute:function(e,g,d){d=d||{};var h=d.strokeColor;g=g||"Route";d=this.mergeOptions(d,this.getCategoryOptions(g));if(!h&&d.colors&&d.colors.length>0){var f=this.getOverlayCount(g);if(f>0){f=f%d.colors.length;d.strokeColor=d.colors[f]}else{d.strokeColor=d.colors[0]}}var a=new g5t.geo.Binder(d,e);var c=this.getOverlay(a.id,g);var b;if(!c||!d.noReplace){d.map=this.gmap;b=new g5t.geo.Route(d,e);this.addOverlay(b,b.id,g);this.fireEvent(g+"Added",b);this.createComponents(b,g,d)}else{b=c}return b},createMarker:function(c,e,b,d){e=e||"Marker";b=b||{};b=this.mergeOptions(b,this.getCategoryOptions(e));b.map=this.gmap;var a=new g5t.geo.Marker(b,c);
if(!d){this.addOverlay(a,a.id,e);this.fireEvent(e+"Added",a)}return a},clearOverlays:function(a){try{for(var f in this.overlays){if((!a||f==a)&&this.overlays[f]){for(var d in this.overlays[f]){try{if(this.overlays[f][d]){if(typeof this["remove"+a]=="function"){this["remove"+a](d)}else{this.removeOverlay(this.overlays[f][d],d,f)}this.overlays[f][d]=null}}catch(b){}}if(a){this.overlays[f]={};break}}}if(!a){this.overlays={}}}catch(b){alert(b)}},zoomOverlays:function(){for(var d in this.overlays){if(this.overlays[d]){var b=this.overlays[d];for(var c in b){var a=b[c];if(a&&a.options&&!a.options.autoZoom&&a.options.zoomFactor&&a.setZoom){a.setZoom(this.gmap.getZoom())}}}}},createRouteNodes:function(g){var k=this.gmap.getZoom();if(true||!g.nodes||g.nodes.length==0){var d=0;g.nodes=[];var f,b=0;try{var l=g.getPath().getArray();for(var a=0;a<l.length;a++){var h=this.getProjection().fromLatLngToContainerPixel(l[a]);if(a==0||f.x!=h.x||f.y!=h.y){g.nodes.push(h.x);g.nodes.push(h.y);g.nodes.push(b);f=h
}}}catch(c){throw c}}},getProximity:function(j,P){try{var m=j.latLng;var N=this.gmap.getZoom(),w;var k=!P,R;if(!P){R=this.getCurrentOverlay("Route");if(!R){return}}P=P||[R];for(var H=0;H<P.length;H++){R=P[H];if(!R.getBounds().contains(m)){continue}this.createRouteNodes(R);this.getDragger();var M=R.nodes.length;if(!m||M<=1||this.isDragged>0){return}var z=this.getProjection().fromLatLngToContainerPixel(m);var B=z.x;var A=z.y;var D=R.nodes[0];var C=R.nodes[1];var F=D;var E=C;var t=99999;for(var K=3;K<M;K+=3){var s=D;var a=C;D=R.nodes[K];C=R.nodes[K+1];if((D<B-50&&s<B-50)||(D>B+50&&s>B+50)){continue}if((C<A-50&&a<A-50)||(C>A+50&&a>A+50)){continue}var c=D-s;var b=C-a;var T=c*c+b*b;var G=((B-D)*c+(A-C)*b)/T;var o=D+(G*c);var U=C+(G*b);var g=(B-o)*(B-o)+(A-U)*(A-U);if(t>g){var L=(B-s)*(B-s)+(A-a)*(A-a);var J=(B-D)*(B-D)+(A-C)*(A-C);if((L-g)+(J-g)>T){if(L<J){g=L;o=s;U=a}else{g=J;o=D;U=C}}}if(t>g){t=g;F=o;E=U}}var v=0;if(t>this.options.proxiDistance){this.getDragger().hide()}else{if(R.getWayPoints()){for(var K=R.getWayPoints().length;
--K>=0;){var h=this.getProjection().fromLatLngToContainerPixel(R.getWayPoints()[K].marker.getPosition());c=h.x-F;b=h.y-E;if(c*c+b*b<25){this.getDragger().hide();return}}}var I=this.getProjection().fromContainerPixelToLatLng(new google.maps.Point(F,E));this.getDragger().setPosition(I);var O=this.getRouteOptions().infoTpl;if(O){R.object.infoTpl=new Jtemplate(O)}this.getDragger().show();var f=(!this.getDragger().object||this.dragger.object!=R.object);this.dragger.object=R.object;if(this.getRouteOptions().openInfoWindowOnOver&&f){this.dragger.openInfoWindowHtml()}this.setCurrentOverlay(R,"Route");return true}}if(k){var q=this.getOverlays("Route");P=[];for(var Q in q){if(R!=q[Q]&&q[Q]){P.push(q[Q])}}return this.getProximity(m,P)}}catch(S){throw S}},getDragger:function(){if(!this.dragger){this.createDragger()}return this.dragger},createDragger:function(){var a=this;var c=this.gmap.getCenter();var b={icon:this.options.nodeIcon,iconSize:this.options.nodeIconSize,zIndex:100,map:this.gmap,draggable:true};
b.infoTpl=this.getRouteOptions().infoTpl;this.dragger=this.createMarker({lat:c.lat(),lng:c.lng()},null,b,true);this.dragger.show();this.dragger.hide()},startDragNode:function(a){var b=this;a=a||b.dragger;a.show();if(b.isDragged==2){b.markerDragged=a;return}},endDragNode:function(b){var a=this;b=b||a.dragger}});


/*** geocoder di 5t */
Jpackage("g5t.geo");g5t.geo.Geocoder=new Jclass({Implements:[Jevents,Joptions],options:{url:g5t.contextPath+"/Geocoder",async:true,googleFilter:true},constructor:function g5t$geo$Geocoder(a){this.setOptions(a)},filterResponse:function(f,c){if(!c||c.status=="NO_ADDRESS"||c.status=="NO_CITY"){c&&(c.Status={code:400})}else{c.Status={code:200};if(c.results){for(var e=0;e<c.results.length;e++){var b=c.results[e];var a=new google.maps.LatLng(b.y/100000,b.x/100000);var d=new g5t.geo.Placemark({origLat:a.lat(),origLng:a.lng(),lat:a.lat(),lng:a.lng(),address:b.address,number:b.number!="nd"?b.number:"",locality:b.city});c.results[e]=d}}c.Placemark=c.results}if(f){f(c)}return c},getLocations:function(c,e){if(c instanceof google.maps.LatLng){var b=new g5t.geo.GoogleGeocoder();b.geocode({location:c},e)}else{var d=this.filterResponse.binds(this,e);c.action=c.action||"resolve";var a=new Request.JSON({url:this.options.url,onSuccess:d,async:this.options.async,method:"post",data:c});a.send()}},getLatLng:function(a,c){var b=new g5t.geo.GoogleGeocoder();
b.getLatLng(a,c)}});g5t.geo.GoogleGeocoder=Jclass({Extends:google.maps.Geocoder,constructor:function g5t$geo$GoogleGeocoder(){google.maps.Geocoder.call(this)},process:function(f,a,h){var e=f;if(a==google.maps.GeocoderStatus.OK){e=[];for(var d=0;d<f.length;d++){var g=f[d];var c={};for(var b=0;b<g.address_components.length;b++){if(g.address_components[b].types[0]=="street_number"){c.number=g.address_components[b].long_name}else{if(g.address_components[b].types[0]=="route"){c.address=g.address_components[b].long_name}else{if(g.address_components[b].types[0]=="locality"){c.locality=g.address_components[b].long_name}else{if(g.address_components[b].types[0]=="postal_code"){c.postalCode=g.address_components[b].long_name}else{if(g.address_components[b].types[0]=="country"){c.country=g.address_components[b].long_name}}}}}}if(g.geometry&&g.geometry.location){c.lat=g.geometry.location.lat();c.lng=g.geometry.location.lng()}e.push(new g5t.geo.Placemark(c))}}if(h){h(e,a)}},geocode:function(b,c){var a=this;
google.maps.Geocoder.prototype.geocode.call(this,b,function(e,d){a.process(e,d,c)})}});

/*** placemark */
Jpackage("g5t.geo");g5t.geo.Placemark=new Jclass({id:null,fullAddress:"",address:"",number:"",locality:"",country:"",postalCode:"",origLat:0,origLng:0,lat:0,lng:0,index:-1,constructor:function g5t$geo$Placemark(a){Jclass.apply(a,this);this.setAddress(a.address)},toLatLng:function(){return new google.maps.LatLng(this.lat,this.lng)},getFullAddress:function(){if(this.fullAddress&&this.fullAddress.length>0){return this.fullAddress}this.fullAddress="";var a=this;["address","number","locality","country"].each(function(b){if(b&&a[b]&&a[b]!=""){if(a.fullAddress.length>0){a.fullAddress+=","}a.fullAddress+=a[b]}});return a.fullAddress},setAddress:function(a){if(!a){this.address="";return}var b=a.split(",");if(b.length>1){this.fullAddress=a}else{this.fullAddress=a;this.setNumber(this.number);this.number&&(this.fullAddress+=", "+this.number);this.fullAddress+=", "+this.locality}switch(b.length){case 4:this.setNumber(b[1].trim());default:this.address=b[0].trim();break}},setNumber:function(b){this.number="";
try{this.number=parseInt(b);if(isNaN(this.number)){this.number=""}}catch(a){this.number=""}},toString:function(){return this.getString()},getString:function(){var a="{address}";a+=", {number}";a+=",";if(this.postalCode&&this.postalCode.length>0){a+=" {postalCode} - "}a+="{locality}";return a.formats(this)}});

/** StopPoint.js */
StopPoint=new Jclass({constructor:function StopPoint(a){Jclass.apply(a,this)}});

/** TransportCtrl.js */
Jpackage("g5t.geo");var stopInfoTpl='<div id="infow"><div style="margin-bottom:15px"><img width="25" src="'+g5t.imgPath+'/stop.png"  style="vertical-align:middle;margin-right:5px;"/><b>Fermata:<span style="color:#1662ad">{shortName}&nbsp;{name}</span></b></div> <img src="'+g5t.imgPath+'/spinner.gif"/> </div>';var lineBranchInfoTpl=["<b>Linea&nbsp;{lineName}</b><br/><i>{routeDescription}</i>"];var placemarkInfoTpl=["<div>","<b>Indirizzo: </b>{fullAddress}.<br/>","<i style='font-size:80%;'>[{lat},{lng}]</i>","</div>"];var vehicleInfoTpl=["<div>"," <div style='float:left;margin-right:2px;'>","  <img width='50' src='"+g5t.imgPath+"/bus-run-{direction}.png'></img>"," </div>"," <div style='float:left;'>","  <b>Veicolo: {vehicleId} - linea {line}</b><br/>","  Data ed ora: {timestamp}<br/>","  Coordinate: {lat},{lng}<br/>","  Direzione: {direction}<br/>","  Evento: {eventType}","</div>","</div>"];var rivenditaInfoTpl=["<div id='rivendita{id}Info' style='margin-right:5px'>","<div style='float:left;margin-right:2px;'>","<img width='50' src='"+g5t.imgPath+"/ticket-icon.png'></img>","</div>"," <div style='float:left;'>","<b>Rivendita: {id}</b><br/>{indirizzo}.","</div>","</div>"];
var minZoomLevel=17;var stopImg=g5t.imgPath+"/stop.png";var stopIconWidth=17,stopIconHeight=17;g5t.LineBranch=new Class({initialize:function(a){a=a||{};$extend(this,a)}});g5t.TransportCtrl=new Class({Extends:g5t.geo.OverlayController,options:{url:"",nodeIcon:g5t.webPath+"/img/node.gif",nodeIconSize:new google.maps.Size(10,10),categories:{Route:{binding:{wayPoints:{category:"StopPoint"}},options:{infoTpl:null,nodeIcon:null,nodeIconSize:new google.maps.Size(25,35),startStopPoint:{icon:g5t.webPath+"/img/ico-start.png",infoTpl:stopInfoTpl,iconSize:new google.maps.Size(20,30),zoomFactor:0.1,zoomLevel:15,autoZoom:true,zIndex:200,binding:{title:"Fermata {shortName} - {name}",icon:"{icon}",id:"{shortName}"}},endStopPoint:{icon:g5t.webPath+"/img/ico-end.png",iconSize:new google.maps.Size(20,30),infoTpl:stopInfoTpl,zoomFactor:0.1,zoomLevel:15,autoZoom:true,zIndex:200,binding:{title:"Fermata {shortName} - {name}",icon:"{icon}",id:"{shortName}"}},traceMarker:{icon:function(b){var a=(this.options&&this.options.strokeColor)||"#FFFF00";
return g5t.geo.IconMaker.createLabeledIcon({label:b.lineName,primaryColor:a,strokeColor:"#FFFFFF",labelColor:"#FFFFFF"})}},binding:{path:"points",wayPoints:"stopPoints"}}},StopPoint:{baseCategory:"Marker",options:{infoTpl:stopInfoTpl,zoomFactor:0.15,zoomLevel:minZoomLevel,icon:stopImg,iconSize:new google.maps.Size(stopIconWidth,stopIconHeight),iconAnchor:new google.maps.Point(stopIconWidth/2,stopIconHeight/2),binding:{title:"Fermata {shortName} - {name}",id:"{shortName}"}}},RouteStopPoint:{baseCategory:"Marker",options:{infoTpl:"<div class='info'><b>Fermata {code} - {shortName}</b><br/><span>{address}</span></div>",zoomFactor:0.15,zoomLevel:minZoomLevel,icon:stopImg,iconSize:new google.maps.Size(stopIconWidth-3,stopIconHeight-3),iconAnchor:new google.maps.Point(stopIconWidth/2,stopIconHeight/2),binding:{title:"Fermata {shortName} - {name}",id:"{id}",infoTpl:"{infoTpl}"}}},Placemark:{baseCategory:"Marker",options:{infoTpl:placemarkInfoTpl,zoomFactor:0.15,zoomLevel:minZoomLevel,iconSize:new google.maps.Size(20,30),shadowSize:new google.maps.Size(20,30),binding:{title:"indirizzo: {address} - {city}",id:"{lat}X{lng}"}}},Rivendita:{type:g5t.geo.Marker,baseCategory:"Marker",options:{infoTpl:rivenditaInfoTpl,zoomFactor:0.1,zoomLevel:minZoomLevel,icon:g5t.webPath+"/img/ticket-icon.png",iconSize:new google.maps.Size(15,25),shadowSize:new google.maps.Size(15,25),binding:{title:"Rivendita {id}  - {indirizzo}"}}},VehicleInfo:{baseCategory:"Marker",options:{infoTpl:vehicleInfoTpl,zoomFactor:0.1,zoomLevel:minZoomLevel,icon:g5t.webPath+"/img/bus-run.png",iconSize:new google.maps.Size(20,25),shadowSize:new google.maps.Size(20,25),zIndex:1000,binding:{title:"Veicolo: {id}, linea: {line}\ndata e ora: {timestamp}",icon:g5t.webPath+"/img/bus-run-{direction}.png",id:"{vehicleId}"}}},PartialRoute:{baseCategory:"Route",binding:{wayPoints:{category:"RoutePoint"}},options:{traceLine:false,infoTpl:null,startMarker:null,endMarker:null,strokeColor:null,binding:{wayPoints:"routePoints",path:"path",strokeColor:"color"}}},RoutePoint:{baseCategory:"Marker",options:{infoTpl:"{infoTpl}",zoomFactor:0.1,zoomLevel:minZoomLevel,autoZoom:true,iconSize:new google.maps.Size(20,20),binding:{title:"{name}",infoTpl:"{infoTpl}",icon:"{icon}",id:"{id}"}}},Journey:{binding:{routePoints:{category:"RoutePoint"},partialRoutes:{category:"PartialRoute"}},options:{nodeIcon:null,traceLine:false,nodeIconSize:new google.maps.Size(25,35),centerOnMap:true,startRoutePoint:{icon:g5t.webPath+"/img/ico-start.png",infoTpl:stopInfoTpl,iconSize:new google.maps.Size(20,23),zoomFactor:0.1,zoomLevel:13,autoZoom:true,zIndex:200,binding:{title:"{name}",icon:"{icon}",id:"{id}",infoTpl:"{infoTpl}"}},endRoutePoint:{icon:g5t.webPath+"/img/ico-end.png",iconSize:new google.maps.Size(20,23),infoTpl:stopInfoTpl,zoomFactor:0.1,zoomLevel:13,autoZoom:true,zIndex:200,binding:{title:"{name}",icon:"{icon}",id:"{id}",infoTpl:"{infoTpl}"}},binding:{path:"path",routePoints:"routePoints",partialRoutes:"partialRoutes",strokeColor:"color",centerOnMap:"centerOnMap"}}}}},initialize:function(b,a){this.parent(b,a)
},loadData:function(e,d,b){if(!d){for(var c=0;c<e.length;c++){var f=new g5t.LineBranch(e[c]);var a=this.createRoute(f,"Route",b)}}else{g5t.geo.OverlayController.prototype.loadData.call(this,e,d,b)}},createStopPoint:function(c,b,a){b=b||"StopPoint";return this.createMarker(c,b,a)},createJourney:function(d,f,c,a){c=c||{};f=f||"Journey";c=this.mergeOptions(c,this.getCategoryOptions(f));if((!c.strokeColor&&!d.color)&&c.colors&&c.colors.length>0){var e=this.getOverlayCount(f);if(e>0){e=e%c.colors.length;c.strokeColor=c.colors[e]}else{c.strokeColor=c.colors[0]}}c.map=this.gmap;var b=new g5t.geo.Journey(c,d);this.addOverlay(b,b.id,f);this.fireEvent(f+"Added",b);if(!a&&c.centerOnMap){this.centerPolyline(b)}this.createComponents(b,f,c);return b}});g5t.LineBranchCtrl=g5t.TransportCtrl;

/** TrafficCtrl.js */
Jpackage("g5t.geo");var ParkInfoTpl="<div _style='height:100px'><img src='"+g5t.imgPath+"/ico-parcheggio-pagamento.png'> <b> {nome}</b><br><br>posti liberi: {postiLiberi}<br />posti totali: {postiTotali}<br><br><span style='padding-left:20px;'> <a href='parcheggio-dettaglio.jsp?id={id}'>scheda parcheggio</a></span></div>";var ParkInfoTpl2="<div><img src='"+g5t.imgPath+"/ico-parcheggio-gratuito.png'> <b> {nome}</b><br><br>posti totali: {postiTotali} </div>";var ParkInfoTpl3="<div><img src='"+g5t.imgPath+"/ico-parcheggio-noconn.png'> <b> {nome}</b><br><br>posti totali: {postiTotali} </div>";var icoVms=g5t.imgPath+"/ico-vms.png";var icoVmsSize=12;var vmsInfoTpl="<div style='margin:0 10px; text-align:center'><img src='http://www.5t.torino.it/panel?v={id}' /></div>";var icoEventoInfomobile=g5t.imgPath+"/ico-road-closed.png";var icoEventoInfomobileSize=20;var eventoInfomobileInfoTpl="<table bgcolor='#ffffe0' width='280' cellspacing='0' cellpadding='2'><col width='80'/><col width='200'/><tr> <td rowspan='5' align='center' valign='center'> <img src='"+icoEventoInfomobile+"'/></td><td><b>{descr}</b></td> </tr><tr> <td><b>{strada}</b> {descrStrada}</td> </tr><tr> <td>tra km {daKm} e km {aKm}</td> </tr><tr> <td><b>dal</b> {startTime}</td> </tr><tr> <td> &nbsp; <b>al</b> {endTime}</td> </tr></table>";
var minZoomLevel=10;g5t.TrafficCtrl=new Class({Extends:g5t.geo.OverlayController,options:{url:"",nodeIcon:g5t.webPath+"/img/node.gif",nodeIconSize:new google.maps.Size(10,10),categories:{Vms:{baseCategory:"Marker",options:{infoTpl:vmsInfoTpl,zoomFactor:0.15,zoomLevel:minZoomLevel,icon:icoVms,iconSize:new google.maps.Size(icoVmsSize,icoVmsSize),binding:{title:" Pannello {societa} ",id:"{id}"}}},EventoInfomobile:{baseCategory:"Marker",options:{infoTpl:eventoInfomobileInfoTpl,zoomFactor:0.15,zoomLevel:minZoomLevel,icon:icoEventoInfomobile,iconSize:new google.maps.Size(icoEventoInfomobileSize,icoEventoInfomobileSize),binding:{title:" {descr} ",id:"{idEvento}"}}}}},initialize:function(b,a){this.parent(b,a)}});

/** styledMapType5T.js */
var greyStyle=[{featureType:"all",stylers:[{saturation:-100}]},{featureType:"transit",stylers:[{visibility:"off"}]},{featureType:"poi",stylers:[{visibility:"off"}]}];var styledMapType5T=new google.maps.StyledMapType(greyStyle,{name:"5T"});var zoomCtlOpt={position:google.maps.ControlPosition.RIGHT_TOP,style:google.maps.ZoomControlStyle.SMALL};var mapOptions5T={zoom:13,mapTypeControlOptions:{mapTypeIds:["_5T",google.maps.MapTypeId.ROADMAP,google.maps.MapTypeId.SATELLITE]},mapTypeId:"_5T",zoomControl:true,zoomControlOptions:zoomCtlOpt,panControl:false};var mapOptions=mapOptions5T;

