var hospitalsOnCall={};var hospitalsOnMap=[];var clinics_visible=[];var hospitalsCounter=0;function clearHospitals(){for(var A in hospitalsOnCall){var B=hospitalsOnCall[A];B.marker.setMap(null);removeFromMarkersOnMap(B.lat,B.lng);delete hospitalsOnCall[A]}hospitalsOnCall={};hospitalsOnMap=[];hospitalsCounter=0;
hospitalsRequestBounds=null;$("#hospitals_ico").attr("src","images/markers/ico_hospitals.png");$("#hospitals_href").css("font-style","normal")}function toggleHospitals(B){if(B){var A=map.getBounds();var C={"southwest":{"lat":A.getSouthWest().lat(),"lng":A.getSouthWest().lng()},"northeast":{"lat":A.getNorthEast().lat(),"lng":A.getNorthEast().lng()}};
getNewHospitals(C);jQuery("#hospitals").get(0).checked=true;$("#hospitals_ico").attr("src","images/markers/ico_hospitals_pressed.png");$("#hospitals_href").css("font-style","italic")}else{clearHospitals()}}function getNewHospitals(B){var A=0;jQuery.ajax({type:"POST",url:"functs/hospitals.jsp",data:{"sw_lat":B.southwest.lat,"sw_lng":B.southwest.lng,"ne_lat":B.northeast.lat,"ne_lng":B.northeast.lng,"clinic_id":0},dataType:"json",success:function(D){hospitals=D.duties;
for(var C in hospitals){var E=hospitals[C];if(hospitalsOnCall[E.hospId]==undefined){addHospital(E,A)}}}})}function showHospitals(A){var C;if(A){C=hospitalsOnCall[A]}else{for(i in hospitalsOnCall){C=hospitalsOnCall[i];break}}var B=getHospitalInfo(C);$("#about_td").html(B);show_td(3)}function addHospital(D,B){D.clinics.push({"id":B,"visible":true});
hospitalsOnCall[D.hospId]=D;hospitalsOnMap[hospitalsCounter]=D;hospitalsCounter++;var C=iconPerCategoryId[HOSPITAL_ICON];var A=new google.maps.Marker({position:new google.maps.LatLng(D.lat,D.lng),map:map,icon:C,title:D.hospName});A.hospitaldata=D;A.hospitaldata.clinic_id=B;google.maps.event.addListener(A,"click",function(){showHospitals(D.hospId)
});markersOnMap.push({"lat":D.lat,"lng":D.lng,"name":D.hospName});hospitalsOnCall[D.hospId].marker=A;hospitalsOnCall[D.hospId].clinic_id=B}function showHospital(B){var A=hospitalsOnCall[B];show_td(0);map.setZoom(16);map.setCenter(new google.maps.LatLng(A.lat,A.lng))}function getHospitalInfo(G){var F;
var E;var A;for(i=0;i<hospitalsCounter;i++){if(hospitalsOnMap[i].hospId==G.hospId){A=i;break}}F=A-1;E=A+1;if(F<0){F=hospitalsCounter-1}var H=hospitalsOnMap[F].hospId;if(E>hospitalsCounter-1){E=0}var D=hospitalsOnMap[E].hospId;var C='<div align="center"><table width="100%"><tr><td align="left"><a href="javascript:showHospitals('+H+')"><img src="images/velaki_aristera.png" style="border:0px;" title="Προηγούμενo" alt="Προηγούμενo" /></a>&nbsp;</td>';
C+='<td align="center"><b><a href="javascript:showHospital('+G.hospId+')">'+G.hospName+'</a></b>&nbsp;</td><td align="right"><a href="javascript:showHospitals('+D+')"><img src="images/velaki_deksia.png" style="border:0px;" title="Επόμενo" alt="Επόμενo" /></a></td></tr></table><br />';var B=G.phone;if(B>0.01){C+="<b>Τηλ: </b>"+Math.round(B)+"<br />"
}else{if((B!="0.0")&&(B!="")&&(B!=undefined)){C+="Τηλ: "+B+"<br />"}}C+="<b>Εφημερία από:</b> "+G.start_date+"<br />";C+="<b>Εφημερία έως:</b> "+G.end_date+"<br />";C+='<div id="hosp_address" align="center"></div>';C+="<a href=\"javascript:setRoutePointFrom('"+G.lat+"','"+G.lng+"')\">";C+='<img src="images/start_hex.png" style="border:0px; margin-right:3px;" title="Διαδρομή από" alt="Διαδρομή από" />';
C+="</a>";C+="<a href=\"javascript:setRoutePointTo('"+G.lat+"','"+G.lng+"')\">";C+='<img src="images/stop_hex.png" style="border:0px; margin-right:3px;" title="Διαδρομή έως" alt="Διαδρομή έως" /></a><br>&nbsp;';if((G.clinics)&&(G.clinics.length>0)){C+="<b>Κλινικές:</b><br>"}for(j in G.clinics){if(G.clinics[j].id!=0){C+=clinics[G.clinics[j].id]+"<br />"
}}C+="</div>";$.ajax({type:"POST",url:"functs/revGeoResults.jsp",data:{"pointX":G.lng,"pointY":G.lat},dataType:"json",success:function(J){if(J.revGeoResults[0]){var I="<font size='2'>"+J.revGeoResults[0].roadName+" ";if(J.revGeoResults[0].roadNumber1!=0){I+=J.revGeoResults[0].roadNumber1+" "}if(J.revGeoResults[0].roadNumber2!=0){I+=J.revGeoResults[0].roadNumber2+" "
}I+="<br>"+J.revGeoResults[0].roadMunicipality+", "+J.revGeoResults[0].roadZip+"</font><br>"}$("#hosp_address").html(I)}});return C}function updateHospitals(){if(jQuery("#hospitals").get(0).checked){var D=[0];var B=D.join(",");var A=map.getBounds();var C={"southwest":{"lat":A.getSouthWest().lat(),"lng":A.getSouthWest().lng()},"northeast":{"lat":A.getNorthEast().lat(),"lng":A.getNorthEast().lng()}};
getNewHospitals(C)}};
