function OASA(C,D,B){this.map=C;this.serverURL=D;this.imageURL=B;this.stops={};this.stopDetails={};this.stopsVisible=false;this.stopsLoaded=false;this.routeid=null;this.routeStops={};this.routeBounds=null;this.linesarealement=null;this.panToLine=false;this.areaLines=null;this.stopIconBusTrolley=null;
this.stopIconBus=null;this.stopIconMetro=null;this.stopIconProastiakos=null;this.stopIconTram=null;this.stopIconTrolley=null;this.id=OASA.instanceIdx++;OASA.instance[this.id]=this;this.getType=function(){return"OASARoute"};this.getStopInfo=function(J){var H=this.stops[J];var G=undefined;if(H!==undefined){if(H.count===undefined){G='<div class="myInfoBox">';
G+='<div class="infoBox-inner">';G+="<b>Στάση: "+H.name+"</b> ("+J+")<br />";G+="<b>Οδός: </b>"+H.street+"<br />";G+="<b>Περιοχή: </b>"+H.municipality+"<br />";if(this.stopDetails[J]!==undefined){G+="<br />";G+='<table border="0">';var I=null;for(var F=0;F<this.stopDetails[J].length;F++){var E=this.stopDetails[J][F];
if(I!=null){if(I.groupname!=E.groupname){G+='<tr><td colspan="2"><b>'+E.groupname+"</b></td></tr>"}}else{G+='<tr><td colspan="2"><b>'+E.groupname+"</b></td></tr>"}G+="<tr>";G+="<td>";G+="<a href=\"javascript:showOASARoute('"+E.routeid+"','"+E.lid+"')\">"+E.lineid+"</a>";G+="</td>";G+="<td>&nbsp;"+E.name;
if(E.direction=="a"){G+=" (προς: "+E.start_name+")"}else{if(E.direction=="t"){G+=" (προς: "+E.end_name+")"}}G+="</td>";G+="</tr>";I=E}G+="</table>"}else{G+='<div style="text-align:center;"><img src="images/loader.gif" style="border:0px;" /> </div>';this.getStopDetails(J)}G+="</div>"}else{G='<div align="left">';
G+="Στην περιοχή αυτή βρίσκονται "+H.count+" στάσεις. ";G+="Για να τις δείτε αναλυτικά, αυξήστε το zoom του χάρτη."}G+="</div>";G+='<div class="infoBox-bottom"></div>'}return G};this.setAreaLinesElement=function(E){this.linesarealement=E};this.getAreaLines=function(){if(this.linesarealement&&$("#MMM").is(":visible")){var E=this.linesarealement;
jQuery(E).html('<div style="text-align:center;"><img src="images/new/various/loading.gif" style="border:0px; vertical-align:middle;" /></div>');jQuery.ajax({type:"POST",url:"functs/oasa_getarealines.jsp",data:{"sw_lat":this.map.getBounds().getSouthWest().lat(),"sw_lng":this.map.getBounds().getSouthWest().lng(),"ne_lat":this.map.getBounds().getNorthEast().lat(),"ne_lng":this.map.getBounds().getNorthEast().lng(),"reqid":this.id},dataType:"json",success:function(F){if(F.status==0){OASA.instance[F.restoid].areaLines=F;
OASA.instance[F.restoid].processAreaLines(0)}}})}};this.processAreaLines=function(E){var K=this.linesarealement;if(K){var I='<table style="border:0px;">';if(this.areaLines.lines.length>0){var F=A(this.areaLines.lines.length,E,"pageThroughOASALines");var G=E+SEARCH_RESULTS_PER_PAGE;if(G>this.areaLines.lines.length){G=this.areaLines.lines.length
}for(var J=E;J<G;J++){I+="<tr>";I+='<td valign="top" align="right"><b>';I+=this.areaLines.lines[J].lineid+"&nbsp;&nbsp;";I+="</b></td><td>";if(this.areaLines.lines[J].routeid){I+="<a href=\"javascript:showOASARoute('"+this.areaLines.lines[J].routeid+"','"+this.areaLines.lines[J].lid+"')\">";I+=this.areaLines.lines[J].name;
I+="</a>"}if(this.areaLines.lines[J].to.length>0){I+=" προς: ";for(var H=0;H<this.areaLines.lines[J].to.length;H++){if(H>0){I+=", προς: "}I+="<a href=\"javascript:showOASARoute('"+this.areaLines.lines[J].to[H].routeid+"','"+this.areaLines.lines[J].lid+"')\">";I+=this.areaLines.lines[J].to[H].name+"</a>"
}}I+="</td>";I+="</tr>"}if(this.areaLines.linecount>this.areaLines.lines.length){I+='<tr><td colspan="2">...από σύνολο '+this.areaLines.linecount+" γραμμών</td></tr>"}I=F+I}else{I+='<tr><td colspan="2">Δεν υπάρχουν γραμμές στην περιοχή</td></tr>'}I+="</table>";jQuery(K).html(I)}};function A(J,E,I){var G=E+SEARCH_RESULTS_PER_PAGE;
if(G>J){G=J}var F="";if((E>0)||(G<J)){F+='<table align="center" width="100%">';F+='<tr style="background-image:url(images/new/various/mmm-header-back.png);background-repeat:no-repeat;background-position:center;"><td align="center" style="padding-top:5px;">';if(E>0){var H=E-SEARCH_RESULTS_PER_PAGE;if(H<0){H=0
}F+='<a href="javascript:'+I+"("+H+')">';F+='<img src="images/new/various/velaki_aristera.png" style="border:0px;" title="Προηγούμενη σελίδα" alt="Προηγούμενη σελίδα" />';F+="</a>"}else{F+='<img src="images/new/various/velaki_aristera_gray.png" style="border:0px;" />'}F+='</td><td align="center" width="80%">';
F+="<b>Γραμμές στην περιοχή:</b> "+(E+1)+"-"+G+"/"+J;F+='</td><td align="center">';if(G<J){F+='<a href="javascript:'+I+"("+G+')">';F+='<img src="images/new/various/velaki_deksia.png" style="border:0px;" title="Επόμενη σελίδα" alt="Επόμενη σελίδα" />';F+="</a>"}else{F+='<img src="images/new/various/velaki_deksia_gray.png" style="border:0px;" />'
}F+="</td></tr>";F+="</table>"}else{F+='<table align="center" width="100%">';F+='<tr><td align="center">';F+="<b>Γραμμές στην περιοχή: </b>"+J;F+="</td></tr>";F+="</table>"}return F}this.getStopDetails=function(E){jQuery.ajax({type:"POST",url:"functs/oasa_getstopdetails.jsp",data:{"stopid":E,"reqid":this.id},dataType:"json",success:function(F){if(F.status==0){OASA.instance[F.restoid].processStopDetails(F.stopid,F.info)
}}})};this.processStopDetails=function(G,F){infowindow2.close();this.stopDetails[G]=F;var E=this.stops[G].marker;infowindow.setContent(this.getStopInfo(G));infowindow.open(map,E)};this.getStops=function(F,G){if((F==null)&&(this.routeid==null)){return }var E={"zoom":this.map.getZoom(),"reqid":this.id};
if(this.routeid!=null){E["routeid"]=this.routeid}if(F!=null){E["sw_lat"]=F.southwest.lat;E["sw_lng"]=F.southwest.lng;E["ne_lat"]=F.northeast.lat;E["ne_lng"]=F.northeast.lng}if(G!=null){E["esw_lat"]=G.southwest.lat;E["esw_lng"]=G.southwest.lng;E["ene_lat"]=G.northeast.lat;E["ene_lng"]=G.northeast.lng}jQuery.ajax({type:"POST",url:"functs/oasa_getstops.jsp",data:E,dataType:"json",success:function(H){if(H.status==0){OASA.instance[H.restoid].processStops(H.stops,H.stopsoperators)
}}})};this.checkStopDisplay=function(){var E=false;if(this.stopsVisible){if(this.map.getZoom()>=16){jQuery("#oasa_notification").slideUp();E=true}else{jQuery("#oasa_notification").slideDown()}}else{jQuery("#oasa_notification").slideUp()}return E};this.processStops=function(I,F){if((this.stopsVisible)||(this.routeid!=null)){var J=false;
for(var H in I){var G=I[H];G.operators=F[G.stopid];var E=new google.maps.LatLng(G.lat,G.lng);if(!J){if(this.map.getBounds().contains(E)){J=true}}this.addStop(G)}if(!J){if(this.panToLine){this.map.setCenter(new google.maps.LatLng(I[0].lat,I[0].lng))}}}};this.getStopIconParams=function(){var E=new google.maps.MarkerImage({url:this.imageURL+"/stopshadow.png",size:new google.maps.Size(15,39),anchor:new google.maps.Point(8,36)});
return E};this.initStopIcons=function(){this.stopIconBusTrolley=this.getStopIconParams();this.stopIconBus=this.getStopIconParams();this.stopIconMetro=this.getStopIconParams();this.stopIconProastiakos=this.getStopIconParams();this.stopIconTram=this.getStopIconParams();this.stopIconTrolley=this.getStopIconParams();
this.stopIconBusTrolley.url=this.imageURL+"/stopbus_trolley.png";this.stopIconBus.url=this.imageURL+"/stopbus.png";this.stopIconMetro.url=this.imageURL+"/stopmetro.png";this.stopIconProastiakos.url=this.imageURL+"/stopproastiakos.png";this.stopIconTram.url=this.imageURL+"/stoptram.png";this.stopIconTrolley.url=this.imageURL+"/stoptrolley.png"
};this.addStop=function(F){var H=null;if(this.stops[F.stopid]===undefined){H=new google.maps.LatLng(F.lat,F.lng);this.stops[F.stopid]=F;var E;if(F.count===undefined){var G=this.stopIconBus;if(F.operators!==undefined){if(F.operators.am==1){G=this.stopIconMetro}else{if(F.operators.isap==1){G=this.stopIconMetro
}else{if(F.operators.ose==1){G=this.stopIconProastiakos}else{if(F.operators.tram==1){G=this.stopIconTram}else{if(F.operators.ilpap==1){if(F.operators.ethel==1){G=this.stopIconBusTrolley}else{G=this.stopIconTrolley}}}}}}}E=new google.maps.Marker({map:map,position:H,icon:G})}else{E=new ClusterMarker(H,F.count,0)
}F.marker=E;E.oasahandler=this;E.oasaid=F.stopid;google.maps.event.addListener(E,"click",function(){infowindow2.close();infowindow.setContent(this.oasahandler.getStopInfo(this.oasaid));infowindow.open(map,E)});google.maps.event.addListener(map,"click",function(){infowindow.close()});E.setMap(map)}if(this.routeid!=null){if(F.routeid==this.routeid){if(H==null){H=new google.maps.LatLng(F.lat,F.lng)
}if(this.routeBounds==null){this.routeBounds=new google.maps.LatLngBounds()}this.routeStops[F.stopid]=true;this.routeBounds.extend(H)}}};this.clearStops=function(){if(this.routeid==null){for(var F in this.stops){if(this.stops[F].marker){this.stops[F].marker.setMap(null)}}this.stops={};this.stopDetails={}
}else{var G=[];for(var F in this.stops){if(!this.routeStops[F]){G.push(F)}}for(var F in G){var E=G[F];this.stops[E].marker.setMap(null);delete this.stops[E];delete this.stopDetails[E]}}this.stopsRequestBounds=null;this.stopsLoaded=false};this.clearRoutes=function(){removeCurrentOASARoutes(map);this.routeid=null;
this.routeStops={};this.routeBounds=null;if(!this.stopsVisible){this.clearStops()}};this.showStops=function(){var F=null;if(!this.stopsVisible){var E=this.map.getBounds();F={"southwest":{"lat":E.getSouthWest().lat(),"lng":E.getSouthWest().lng()},"northeast":{"lat":E.getNorthEast().lat(),"lng":E.getNorthEast().lng()}};
this.stopsRequestBounds=F;this.stopsVisible=true}if(this.checkStopDisplay()){this.getStops(F,null);this.stopsLoaded=true}};this.hideStops=function(){if(this.stopsVisible){this.stopsVisible=false;this.clearStops();this.checkStopDisplay()}};this.updateStops=function(){if(this.stopsVisible){var E=this.map.getBounds();
var G={"southwest":{"lat":E.getSouthWest().lat(),"lng":E.getSouthWest().lng()},"northeast":{"lat":E.getNorthEast().lat(),"lng":E.getNorthEast().lng()}};var F;if(this.stopsRequestBounds!=null){F=getRectangleDiff(this.stopsRequestBounds,G)}else{F=[G]}if(this.checkStopDisplay()){if(F.length==0){if(!this.stopsLoaded){this.getStops(G,null);
this.stopsLoaded=true}}else{this.getStops(G,this.stopsRequestBounds);this.stopsRequestBounds=G;this.stopsLoaded=true}}else{this.clearStops()}}else{this.checkStopDisplay()}this.getAreaLines()};this.showRoute=function(E){if(this.routeid!=null){this.clearRoutes()}addOASARoute(map,E);this.routeid=E;this.panToLine=true;
this.getStops(null)};this.zoomToRoute=function(){if(this.routeBounds!=null){var E=this.map.getZoom(this.routeBounds);this.map.fitBounds(this.routeBounds);this.map.panTo(this.routeBounds.getCenter())}};this.toJSONString=function(F,G){var E={"type":"transport","text":G,"routeid":F};return toJSONString(E)
};this.initStopIcons()}OASA.instanceIdx=0;OASA.instance={};function toggleOASAStops(A){if(A.checked){if(oasaManager){oasaManager.showStops()}}else{if(oasaManager){oasaManager.hideStops()}}}function getOASALineRoutes(D,C,E){if(D.length>0){var B={"lid":D};if(E!==undefined){B.routeid=E}jQuery.ajax({type:"POST",url:"functs/oasa_routes.jsp",data:B,dataType:"json",success:function(I){if(I.status==0){var H=document.getElementById(C);
H.options.length=0;if(I.routes.length<1){H.options[0]=new Option("Δεν υπάρχουν διαδρομές!","",true,true)}else{if(I.routes.length==1){H.options[0]=new Option("Επιλέξτε...","",true,true);H.options[1]=new Option(I.routes[0].dir,I.routes[0].routeid,true,true)}else{H.options[0]=new Option("Επιλέξτε...","",true,true);
for(var G in I.routes){H.options[H.options.length]=new Option(I.routes[G].dir,I.routes[G].routeid,false,false)}}}if(I.selrouteid!==undefined){var F=0;for(var G=0;G<H.options.length;G++){if(I.selrouteid==H.options[G].value){$("#selectoasa_routes").html(H.options[G].text);F=G;break}}H.selectedIndex=F}else{H.selectedIndex=0;
H.onchange()}}}})}else{var A=document.getElementById(C);A.options.length=0;if(oasaManager){oasaManager.clearRoutes()}}}function showOASARoute(D,C){if(D.length>0){if(oasaManager){oasaManager.showRoute(D);addSelectionEntry(oasaManager,$("#oasa_lines option:selected").text(),D)}if(C!==undefined){var B=document.getElementById("oasa_lines");
for(var A=0;A<B.options.length;A++){if(B.options[A].value==C){$("#selectoasa_lines").text(B.options[A].text);B.selectedIndex=A;break}}getOASALineRoutes(C,"oasa_routes",D)}}else{if(oasaManager){oasaManager.clearRoutes()}}}function zoomToOASARoute(){if(oasaManager){oasaManager.zoomToRoute()}}function pageThroughOASALines(A){if(oasaManager){oasaManager.processAreaLines(A)
}};
