function get_text_content(a){if(typeof a.text!="undefined"){return a.text}else{return a.textContent}}function Converter(a,b){this.xml_object=a;this.landing_stops=b;this.findPlaceIdByPlaceCode=function(c){var f=this.xml_object.getElementsByTagName("point");var g;for(var e=0;e<f.length;e++){if(parseInt(get_text_content(f[e].getElementsByTagName("code")[0]))==c){g=parseInt(get_text_content(f[e].getElementsByTagName("stop")[0].getElementsByTagName("code")[0]))}}var d=this.landing_stops.findStopByCode(g);if(typeof d!="undefined"){return d.place_id}return null};this.findPlaceCodeByPlaceId=function(c){var g=this.xml_object.getElementsByTagName("point");var f=this.landing_stops.findStopByPlaceId(c);for(var e=0;e<g.length;e++){var h=g[e].getElementsByTagName("stop");for(var d=0;d<h.length;d++){if(parseInt(get_text_content(h[d].getElementsByTagName("code")[0]))==f.code){return parseInt(get_text_content(g[e].getElementsByTagName("code")[0]))}}}return null}}function Route(d,c,a,b,e){this.name=d;this.places=c;this.color=a;this.reverse=b;this.type=e;this.findShortestPath=function(g,h){length=c.lengh;newroute=new Array();for(var f=0;f<c.lengh;f++){newroute[f]=c[f];newroute[f+length]=c[f]}route1=new Array();starting_pos=-1;ending_pos=-1;for(var f=0;f<c.length;f++){if(c[f]==g){starting_pos=f}if(c[f]==h){ending_pos=f}if(starting_pos!=-1&&ending_pos!=-1){break}}if(starting_pos<ending_pos){for(var f=starting_pos+1;f<=ending_pos-1;f++){between.push(c[f])}}else{for(var f=ending_pos-1;f>=starting_pos+1;f--){between.push(c[f])}}return between};this.findInnerSet=function(j,k){var h=new Array();var g=false;var l=false;var m=false;if(this.reverse){starting_pos=-1;ending_pos=-1;for(var f=0;f<c.length;f++){if(c[f]==j){starting_pos=f}if(c[f]==k){ending_pos=f}if(starting_pos!=-1&&ending_pos!=-1){break}}if(starting_pos<ending_pos){for(var f=starting_pos+1;f<=ending_pos-1;f++){h.push(c[f])}}else{for(var f=ending_pos-1;f>=starting_pos+1;f--){h.push(c[f])}}return h}else{starting_pos=-1;ending_pos=-1;for(var f=0;f<c.length;f++){if(c[f]==j){starting_pos=f}if(c[f]==k){ending_pos=f}if(starting_pos!=-1&&ending_pos!=-1&&starting_pos<ending_pos){break}}for(var f=starting_pos+1;f<=ending_pos-1;f++){h.push(c[f])}return h}};this.findInnerSet2=function(h,j){var g=new Array();for(var f=1;f<c.length-1;f++){g.push(c[f])}return g};this.findInnerSetBase=function(j,l){var h=new Array();var k=false;var f=false;for(var g=0;g<c.length&&!k;g++){if(c[g]==j){f=true}else{if(c[g]==l){k=true}else{if(f){h.push(c[g])}}}}return h};this.findOrder=function(h,f){if(typeof b!="undefined"&&b){for(var g=0;g<c.length;g++){if(c[g]==h){return 0}else{if(c[g]==f){return -1}}}}else{return 0}}}function Routes(){this.routes=new Array();this.addRoute=function(d,c,a,b,e){this.routes.push(new Route(d,c,a,b,e))};this.findRouteByRouteName=function(a){for(var b=0;b<this.routes.length;b++){if(this.routes[b].name==a){return this.routes[b]}}return null}}function LandingStop(e,d,b,a,f,c,g){this.code=e;this.description=d;this.place_id=b;this.place_code=a;this.place_description=f;this.place_lat=c;this.place_lng=g}function LandingStops(){this.stops=new Array();this.addStop=function(d,c,b,a,e){this.stops[d]=new LandingStop(d,c,b,a,e)};this.findStopByCode=function(a){return this.stops[a]};this.findStopByPlaceDescription=function(b){for(var a=0;a<this.stops.length;a++){if(typeof this.stops[a]!="undefined"){if(this.stops[a].place_description==b){return this.stops[a]}}}};this.findStopsByPlaceDescription=function(c){var b=new Array();for(var a=0;a<this.stops.length;a++){if(typeof this.stops[a]!="undefined"){if(this.stops[a].place_description==c){b.push(new LandingStop(this.stops[a].code,this.stops[a].description,this.stops[a].place_id,this.stops[a].place_code,this.stops[a].place_description))}}}return b};this.findStopByPlaceCode=function(b){for(var a=0;a<this.stops.length;a++){if(typeof this.stops[a]!="undefined"){if(this.stops[a].place_code==b){return this.stops[a]}}}};this.findStopsByPlaceCode=function(c){var b=new Array();for(var a=0;a<this.stops.length;a++){if(typeof this.stops[a]!="undefined"){if(this.stops[a].place_code==c){b.push(new LandingStop(this.stops[a].code,this.stops[a].description,this.stops[a].place_id,this.stops[a].place_code,this.stops[a].place_description))}}}return b};this.findStopByPlaceId=function(a){for(var b=0;b<this.stops.length;b++){if(typeof this.stops[b]!="undefined"){if(this.stops[b].place_id==a){return this.stops[b]}}}}}function LandingPlace(f,d,c,e,a,b){this.id=f;this.code=d;this.description=c;this.lat=e;this.lng=a;this.stops=b}function LandingPlaces(){this.places=new Array();this.addPlace=function(f,d,c,e,a,b){this.places[f]=new LandingPlace(f,d,c,e,a,b)};this.findPlaceById=function(a){return this.places[a]}}function Polyline(d,a,b,c){this.start=d;this.end=a;this.polyline=b;this.points=c;this.encode=function(){};this.decode=function(){}}function RoutePolylines(a,b){this.name=a;this.polylines=b;this.addPolyline=function(f,c,d,e){this.polylines.push(new Polyline(f,c,d,e))};this.findPolylineByStartPlaceId=function(d){for(var c=0;c<this.polylines.length;c++){if(this.polylines[c].start==d){return this.polylines[c]}}return null};this.findPolylineByStartPlaceIdImproved=function(f,c){c=typeof(c)!="undefined"?c:0;var e=0;for(var d=0;d<this.polylines.length;d++){if(this.polylines[d].start==f){if(e==c){return this.polylines[d]}else{e+=1}}}return null};this.findPolylineByStartPlaceAndEndPlace=function(d,e){for(var c=0;c<this.polylines.length;c++){if(this.polylines[c].start==d&&this.polylines[c].end==e){return this.polylines[c]}}alert("non ho trovato nulla tra "+d+" e "+e);return null}}function Polylines(){this.route_polylines=new Array();this.addRoutePolylines=function(a,b){this.route_polylines.push(new RoutePolylines(a,b))};this.findRoutePolylinesByRouteName=function(a){for(var b=0;b<this.route_polylines.length;b++){if(this.route_polylines[b].name==a){return this.route_polylines[b]}}return null}}function PathPoint(c,b,a){this.id=c;this.type=b;this.route_name=a;this.equals=function(d){if(typeof d.id!="undefined"&&typeof d.type!="undefined"){if(this.id==d.id&&this.type==d.type){if(this.type=="landing"&&!(typeof this.route_name=="undefined"||typeof d.route_name=="undefined")){return this.route_name==d.route_name}else{return true}}else{return false}}else{return false}}}function PathPolyline(c,a,b){this.start_point=c;this.end_point=a;this.points=b}function Path(a,b,d,c){this.name=a;this.points=b;this.description=d;this.category_id=c;this.polylines=new Array();this.addPathPoint=function(g,f,e){this.points.push(new PathPoint(g,f,e))};this.addPathPolyline=function(g,e,f){this.polylines.push(new PathPolyline(g,e,f))};this.findPolylineByStartPoint=function(f){if(this.polylines!=null){for(var e=0;e<this.polylines.length;e++){if(this.polylines[e].start_point.id==f.id&&this.polylines[e].start_point.type==f.type){return this.polylines[e]}}}return null}}function Paths(){this.paths=new Array();this.addPath=function(a,b,d,c,e){this.paths[e]=new Path(a,b,d,c)};this.findPathByPathName=function(a){for(var b=0;b<this.paths.length;b++){if(this.paths[b].name==a){return this.paths[b]}}return null}};
