function POIManager(E){var P=50;var K=this;var C=[];var I={};var B={};var R=1;var T={};var O=[];var S=E;function L(){C={};I={};B={};R=1;T={}}this.getPoiList=function(){return C};function M(V){if(B[V.layerId]===undefined){B[V.layerId]={}}if(B[V.layerId][V.lat]===undefined){B[V.layerId][V.lat]={}}var U=B[V.layerId][V.lat][V.lng];
if(U===undefined){return -1}return U}function A(U){var V=R++;if(B[U.layerId]===undefined){B[U.layerId]={}}if(B[U.layerId][U.lat]===undefined){B[U.layerId][U.lat]={}}B[U.layerId][U.lat][U.lng]=V;U.id=V;if(I[U.layerId]===undefined){I[U.layerId]={}}I[U.layerId][V]=1;C[V]=U;markersOnMap.push({"lat":U.lat,"lng":U.lng,"name":U.attr.NAME_GQ});
return V}function F(V){var U=C[V];removeFromMarkersOnMap(U.lat,U.lng);if(C[V]!=undefined){delete C[V];delete B[U.layerId][U.lat][U.lng];delete I[U.layerId][V]}}function H(Z){var X="<br>";var a=C[Z];var W=poiLayerIdToCategoryId[a.layerId];var U=poiCategories[W];X+="<b>"+U+": "+poiCategoryLayerInfo[W][a.layerId].layerName+"</b><br />";
if(version==200706){X+=a.attr.NAME_GR_GQ+"<br />";var V=a.attr.POI_PHONE}else{if(version==200806){X+=a.attr.NAME_GQ+"<br />";var V=a.attr.POI_PHONE_GQ}}if(V>0.01){X+="Τηλ: "+Math.round(V)+"<br />"}else{if((V!="0.0")&&(V!="")&&(V!=undefined)){X+="Τηλ: "+V+"<br />"}}var Y="";if(a.url!=""){Y=a.url}else{if(poiCategoryLayerInfo[W][a.layerId].url!=""){Y=poiCategoryLayerInfo[W][a.layerId].url
}}if(Y==null){Y=""}if(trim(Y)!=""){if(Y.indexOf("http://")<0){Y="http://"+Y}if(a.layerId==1008){X+='<a target="_new" href="'+Y+'">Κλείστε δωμάτιο online...</a><br>'}else{X+='<a target="_new" href="'+Y+'">'+Y+"</a><br>"}}return X}function G(W){var V=[];for(var U=0;U<W.length;U++){if(T[W[U]]!==undefined){V.push(W[U])
}}return V}function D(V,c,a){for(var W in V.poiList){poi=V.poiList[W];var U=M(poi);if(U<0){U=A(poi);if(T[poi.layerId]===undefined){continue}var X=poiLayerIdToCategoryId[poi.layerId];var Z=iconPerCategoryId[X];var Y=new GMarker(new GLatLng(poi.lat,poi.lng),Z);Y.poiId=U;Y.infoWindowHtml=H(U);S.addOverlay(Y);
poi.marker=Y}}if(V.remaining>0){var b={"sessionid":V.sessionid,"layerids":c,"gbounds":a};O.push(b)}N()}function Q(W){delete T[W];var V=I[W];if(V!==undefined){for(var U in V){if(C[U].marker!==undefined){S.removeOverlay(C[U].marker)}F(C[U].id)}}}function J(V,X,W){if(X.length==0){return }var U={};U.sessionid=V;
U.count=P;if(V==0){U.layerids=X.join(",");U.sw_lat=W.southwest.lat;U.sw_lng=W.southwest.lng;U.ne_lat=W.northeast.lat;U.ne_lng=W.northeast.lng}jQuery.ajax({type:"POST",url:"functs/getSessionPoiList.jsp",data:U,dataType:"json",success:function(Y){D(Y,X,W)}})}this.getPOIs=function(g,c){var Z,Y,X,W;var e=[];
for(Z=0;Z<g.length;Z++){var l=false;for(Y=0;Y<e.length;Y++){var a=false;for(X=0;X<e[Y].length;X++){if(e[Y][X]==g[Z]){a=true;break}}if(a){l=true;break}else{var V=T[g[Z]];var U=T[e[Y][0]];if(V===undefined){if(U===undefined){e[Y].push(g[Z]);l=true;break}}else{if(U!==undefined){if(compareRectangles(V,U)){e[Y].push(g[Z]);
l=true;break}}}}}if(!l){e.push([g[Z]])}}for(Z=0;Z<e.length;Z++){var b=e[Z][0];var h=[c];if(T[b]!==undefined){h=getRectangleDiff(T[b],c)}for(Y=0;Y<h.length;Y++){var d={"sessionid":0,"layerids":e[Z],"gbounds":h[Y]};O.push(d)}for(Y=0;Y<e[Z].length;Y++){T[e[Z][Y]]=c}}N()};function N(){if(O.length>0){var U=O.shift();
J(U.sessionid,G(U.layerids),U.gbounds)}}this.removePOIsByLayer=function(U){Q(U)};this.getPOIById=function(U){return C[U]}}var displayedLayers={};function togglePOICategory(G,C){var A=poiCategoryLayerInfo[C];if(jQuery("#poicheck_"+C).get(0).checked){var F=[];for(var D in A){jQuery("#poicheck_"+C+"_"+A[D].layerID).get(0).checked=true;
displayedLayers[A[D].layerID]=1;F.push(A[D].layerID)}var B=map.getBounds();var E={"northeast":{"lat":B.getNorthEast().lat(),"lng":B.getNorthEast().lng()},"southwest":{"lat":B.getSouthWest().lat(),"lng":B.getSouthWest().lng()}};G.getPOIs(F,E)}else{for(var D in A){jQuery("#poicheck_"+C+"_"+A[D].layerID).get(0).checked=false;
delete displayedLayers[A[D].layerID];G.removePOIsByLayer(A[D].layerID)}}}function togglePOIItem(G,B,H){if(jQuery("#poicheck_"+B+"_"+H).get(0).checked){jQuery("#poicheck_"+B).get(0).checked=true;displayedLayers[H]=1;var A=map.getBounds();var F={"northeast":{"lat":A.getNorthEast().lat(),"lng":A.getNorthEast().lng()},"southwest":{"lat":A.getSouthWest().lat(),"lng":A.getSouthWest().lng()}};
G.getPOIs([H],F)}else{var D=false;var E=poiCategoryLayerInfo[B];for(var C in E){D=D||jQuery("#poicheck_"+B+"_"+E[C].layerID).get(0).checked}if(!D){jQuery("#poicheck_"+B).get(0).checked=false}delete displayedLayers[H];G.removePOIsByLayer(H)}}function getDisplayedLayersArray(){var B=[];for(var A in displayedLayers){B.push(A)
}return B}function containsPoint(A,C){var B={"lat":Number(C.lat),"lng":Number(C.lng)};return((Number(A.southwest.lat)<=B.lat)&&(Number(A.southwest.lng)<=B.lng)&&(Number(A.northeast.lat)>B.lat)&&(Number(A.northeast.lng)>B.lng))}function getRectangleDiff(C,B){var A={"lat":B.southwest.lat,"lng":B.northeast.lng};
var D={"lat":B.northeast.lat,"lng":B.southwest.lng};if(containsPoint(C,B.southwest)){if(containsPoint(C,B.northeast)){return[]}else{if(containsPoint(C,A)){return[{"southwest":{"lat":C.northeast.lat,"lng":B.southwest.lng},"northeast":B.northeast}]}else{if(containsPoint(C,D)){return[{"southwest":{"lat":B.southwest.lat,"lng":C.northeast.lng},"northeast":B.northeast}]
}else{return[{"southwest":{"lat":B.southwest.lat,"lng":C.northeast.lng},"northeast":B.northeast},{"southwest":{"lat":C.northeast.lat,"lng":B.southwest.lng},"northeast":{"lat":B.northeast.lat,"lng":C.northeast.lng}}]}}}}else{if(containsPoint(C,B.northeast)){if(containsPoint(C,D)){return[{"southwest":B.southwest,"northeast":{"lat":C.southwest.lat,"lng":B.northeast.lng}}]
}else{if(containsPoint(C,A)){return[{"southwest":B.southwest,"northeast":{"lat":B.northeast.lat,"lng":C.southwest.lng}}]}else{return[{"southwest":B.southwest,"northeast":{"lat":B.northeast.lat,"lng":C.southwest.lng}},{"southwest":{"lat":B.southwest.lat,"lng":C.southwest.lng},"northeast":{"lat":C.southwest.lat,"lng":B.northeast.lng}}]
}}}else{if(containsPoint(C,A)){return[{"southwest":B.southwest,"northeast":{"lat":B.northeast.lat,"lng":C.southwest.lng}},{"southwest":{"lat":C.northeast.lat,"lng":C.southwest.lng},"northeast":B.northeast}]}else{if(containsPoint(C,D)){return[{"southwest":B.southwest,"northeast":{"lat":C.southwest.lat,"lng":C.northeast.lng}},{"southwest":{"lat":B.southwest.lat,"lng":C.northeast.lng},"northeast":B.northeast}]
}else{if(containsPoint(B,C.southwest)){return[{"southwest":B.southwest,"northeast":{"lat":C.southwest.lat,"lng":B.northeast.lng}},{"southwest":{"lat":C.northeast.lat,"lng":B.southwest.lng},"northeast":B.northeast},{"southwest":{"lat":C.southwest.lat,"lng":C.northeast.lng},"northeast":{"lat":C.northeast.lat,"lng":B.northeast.lng}},{"southwest":{"lat":C.southwest.lat,"lng":B.southwest.lng},"northeast":{"lat":C.northeast.lat,"lng":C.southwest.lng}}]
}else{return[B]}}}}}}function compareRectangles(B,A){return((Number(B.southwest.lat)==Number(A.southwest.lat))&&(Number(B.southwest.lng)==Number(A.southwest.lng))&&(Number(B.northeast.lat)==Number(A.northeast.lat))&&(Number(B.northeast.lng)==Number(A.northeast.lng)))}function findRectangleInList(A,C){for(var B=0;
B<C.length;B++){if(compareRectangles(A,C[B])){return true}}return false}function compareRectangleLists(G,F){if(G.length!=F.length){return false}var E=[],D=[];var C,B,A;for(C=0;C<G.length;C++){E.push(C);D.push(C)}C=0;while(C<E.length){B=0;A=true;while(B<D.length){if(compareRectangles(G[E[C]],F[D[B]])){E.splice(C,1);
D.splice(B,1);A=false}else{B++}}if(A){C++}}return((E.length==0)&&(D.length==0))}function RevGeoResults(A,F,C,E){if(E!=undefined){var D=poiManager.getPOIById(A.poiId);var B="";$.ajax({type:"POST",url:"functs/revGeoResults.jsp",data:{"pointX":F,"pointY":C},dataType:"json",success:function(I){if(I.revGeoResults[0]){B+="<font size='2'>"+I.revGeoResults[0].roadName+" ";
if(I.revGeoResults[0].roadNumber1!=0){B+=I.revGeoResults[0].roadNumber1+" "}if(I.revGeoResults[0].roadNumber2!=0){B+=I.revGeoResults[0].roadNumber2+" "}B+="<br>"+I.revGeoResults[0].roadMunicipality+", "+I.revGeoResults[0].roadZip+"</font><br>";if(clear_state==0){if((D.image_url!="")||(D.free_text!="")){B+='<div id="showmore"><a href="javascript:map.getInfoWindow().maximize();"><i>περισσότερα...</i></a></div><br>'
}B+="<a href=\"javascript:setRoutePointFrom('"+D.lat+"','"+D.lng+"')\">";B+='<img src="images/start_hex.png" style="border:0px; margin-right:3px;" title="Διαδρομή από" alt="Διαδρομή από" />';B+="</a>";B+="<a href=\"javascript:setRoutePointTo('"+D.lat+"','"+D.lng+"')\">";B+='<img src="images/stop_hex.png" style="border:0px; margin-right:3px;" title="Διαδρομή έως" alt="Διαδρομή έως" /></a>'
}var H="<br><br><table>";if(D.image_url!=""){H+='<tr><td colspan="3" align="center"><img height="100px" src="'+D.image_url+'"></td></tr>';H+='<tr><td colspan="3">&nbsp;</td></tr>'}if(D.free_text!=""){H+='<tr><td colspan="2" valign="middle">'+D.free_text+"</td></tr>"}H+="</table><br>"}var G='<br><iframe src="js/adds.html" height="80px" width="260px" frameborder="0" border="0" cellspacing="0" scrolling="no">';
A.infoWindowHTML=E+B;if((D.image_url!="")||(D.free_text!="")){A.openInfoWindow(A.infoWindowHTML,{maxTitle:"Αναλυτικά Στοιχεία Σ. Ενδιαφέροντος",maxContent:E+B+H})}else{A.openInfoWindow(A.infoWindowHTML)}GEvent.addListener(map.getInfoWindow(),"maximizeend",function(){$("#showmore").html('<div id="showmore"><a href="javascript:map.getInfoWindow().restore()"><i>κλείσιμο...</i></a></div>')
});GEvent.addListener(map.getInfoWindow(),"restoreend",function(){$("#showmore").html('<div id="showmore"><a href="javascript:map.getInfoWindow().maximize()"><i>περισσότερα...</i></a></div>')});D.reverseGeoText=1}})}}function testGetRectangleDiff(){function C(G,F,E,I){var H=getRectangleDiff(F,E);if(!compareRectangleLists(H,I)){alert("PROBLEM: "+G+"\nExpected: "+toJSONString(I)+"\nFound: "+toJSONString(H));
return false}return true}var B,A,D;B={"southwest":{"lat":10,"lng":20},"northeast":{"lat":30,"lng":40}};A={"southwest":{"lat":5,"lng":35},"northeast":{"lat":15,"lng":45}};D=[{"southwest":{"lat":5,"lng":40},"northeast":{"lat":15,"lng":45}},{"southwest":{"lat":5,"lng":35},"northeast":{"lat":10,"lng":40}}];
if(!C("100,000,000",B,A,D)){return false}A={"southwest":{"lat":15,"lng":35},"northeast":{"lat":25,"lng":45}};D=[{"southwest":{"lat":15,"lng":40},"northeast":{"lat":25,"lng":45}}];if(!C("010,000,000",B,A,D)){return false}A={"southwest":{"lat":25,"lng":35},"northeast":{"lat":35,"lng":45}};D=[{"southwest":{"lat":30,"lng":35},"northeast":{"lat":35,"lng":40}},{"southwest":{"lat":25,"lng":40},"northeast":{"lat":35,"lng":45}}];
if(!C("001,000,000",B,A,D)){return false}A={"southwest":{"lat":5,"lng":25},"northeast":{"lat":15,"lng":35}};D=[{"southwest":{"lat":5,"lng":25},"northeast":{"lat":10,"lng":35}}];if(!C("000,100,000",B,A,D)){return false}A={"southwest":{"lat":15,"lng":25},"northeast":{"lat":25,"lng":35}};D=[];if(!C("000,010,000",B,A,D)){return false
}A={"southwest":{"lat":25,"lng":25},"northeast":{"lat":35,"lng":35}};D=[{"southwest":{"lat":30,"lng":25},"northeast":{"lat":35,"lng":35}}];if(!C("000,001,000",B,A,D)){return false}A={"southwest":{"lat":5,"lng":15},"northeast":{"lat":15,"lng":25}};D=[{"southwest":{"lat":5,"lng":15},"northeast":{"lat":15,"lng":20}},{"southwest":{"lat":5,"lng":20},"northeast":{"lat":10,"lng":25}}];
if(!C("000,000,100",B,A,D)){return false}A={"southwest":{"lat":15,"lng":15},"northeast":{"lat":25,"lng":25}};D=[{"southwest":{"lat":15,"lng":15},"northeast":{"lat":25,"lng":20}}];if(!C("000,000,010",B,A,D)){return false}A={"southwest":{"lat":25,"lng":15},"northeast":{"lat":35,"lng":25}};D=[{"southwest":{"lat":25,"lng":15},"northeast":{"lat":35,"lng":20}},{"southwest":{"lat":30,"lng":20},"northeast":{"lat":35,"lng":25}}];
if(!C("000,000,001",B,A,D)){return false}A={"southwest":{"lat":5,"lng":15},"northeast":{"lat":35,"lng":45}};D=[{"southwest":{"lat":5,"lng":15},"northeast":{"lat":10,"lng":45}},{"southwest":{"lat":10,"lng":40},"northeast":{"lat":30,"lng":45}},{"southwest":{"lat":30,"lng":15},"northeast":{"lat":35,"lng":45}},{"southwest":{"lat":10,"lng":15},"northeast":{"lat":30,"lng":20}}];
if(!C("111,101,111",B,A,D)){return false}return true};