var poiList=[];var poiLayerIdToPOIId={};var poiMap={};var poiMapIdCount=1;var rectPerLayer={};var invocationQueue=[];var MAX_POI_COUNT=50;var poiCategoriesSelected=[];var poisOnMap=[];var poisOnMapCounter=0;var displayedLayers={};function getPOIById(A){return poiList[A]}function togglePOICategory(B,A){if(B){var E;
for(i in poiLayers){if(poiLayers[i].cat==A){E=poiLayerIdToCategoryId[poiLayers[i].layers[0]];if(B){poiCategoriesSelected.push({"catid":E,"cat_name":poiCategories[E],"cat":poiLayers[i].cat})}for(j in poiLayers[i].layers){displayedLayers[poiLayers[i].layers[j]]=1}var D=i;break}}var C=map.getBounds();var F={"northeast":{"lat":C.getNorthEast().lat(),"lng":C.getNorthEast().lng()},"southwest":{"lat":C.getSouthWest().lat(),"lng":C.getSouthWest().lng()}};
getPOIs(poiLayers[D].layers,F)}else{for(c in poiLayers){if(poiLayers[c].cat==A){for(k in poiCategoriesSelected){if(poiCategoriesSelected[k].catid==poiLayerIdToCategoryId[poiLayers[c].layers[0]]){poiCategoriesSelected.splice(k,1);break}}for(m in poiLayers[c].layers){clearPOIsByLayer(poiLayers[c].layers[m])
}}}}}function getPOIs(L,I){var F,E,D,C;var K=[];for(F=0;F<L.length;F++){var N=false;for(E=0;E<K.length;E++){var G=false;for(D=0;D<K[E].length;D++){if(K[E][D]==L[F]){G=true;break}}if(G){N=true;break}else{var B=rectPerLayer[L[F]];var A=rectPerLayer[K[E][0]];if(B===undefined){if(A===undefined){K[E].push(L[F]);
N=true;break}}else{if(A!==undefined){if(compareRectangles(B,A)){K[E].push(L[F]);N=true;break}}}}}if(!N){K.push([L[F]])}}for(F=0;F<K.length;F++){var H=K[F][0];var M=[I];if(rectPerLayer[H]!==undefined){M=getRectangleDiff(rectPerLayer[H],I)}for(E=0;E<M.length;E++){var J={"sessionid":0,"layerids":K[F],"gbounds":M[E]};
invocationQueue.push(J)}for(E=0;E<K[F].length;E++){rectPerLayer[K[F][E]]=I}}processInvocationQueue()}function removePOI(B){var A=poiList[B];removeFromMarkersOnMap(A.lat,A.lng);for(i in poisOnMap){if(poisOnMap[i].id==B){poisOnMap.splice(i,1);poisOnMapCounter--;break}}if(poiList[B]!=undefined){delete poiList[B];
delete poiMap[A.layerId][A.lat][A.lng];delete poiLayerIdToPOIId[A.layerId][B]}}function getPOIId(B){if(poiMap[B.layerId]===undefined){poiMap[B.layerId]={}}if(poiMap[B.layerId][B.lat]===undefined){poiMap[B.layerId][B.lat]={}}var A=poiMap[B.layerId][B.lat][B.lng];if(A===undefined){return -1}return A}function filterDisabledLayers(C){var B=[];
for(var A=0;A<C.length;A++){if(rectPerLayer[C[A]]!==undefined){B.push(C[A])}}return B}function processInvocationQueue(){if(invocationQueue.length>0){var A=invocationQueue.shift();getNewPOIs(A.sessionid,filterDisabledLayers(A.layerids),A.gbounds)}}function addPOI(A){var B=poiMapIdCount++;if(poiMap[A.layerId]===undefined){poiMap[A.layerId]={}
}if(poiMap[A.layerId][A.lat]===undefined){poiMap[A.layerId][A.lat]={}}poiMap[A.layerId][A.lat][A.lng]=B;A.id=B;if(poiLayerIdToPOIId[A.layerId]===undefined){poiLayerIdToPOIId[A.layerId]={}}poiLayerIdToPOIId[A.layerId][B]=1;poiList[B]=A;poisOnMapCounter++;poisOnMap[poisOnMapCounter]=A;markersOnMap.push({"lat":A.lat,"lng":A.lng,"name":A.attr.NAME_GQ});
return B}function getNewPOIs(B,D,C){if(D.length==0){return }var A={};A.sessionid=B;A.count=MAX_POI_COUNT;if(B==0){A.layerids=D.join(",");A.sw_lat=C.southwest.lat;A.sw_lng=C.southwest.lng;A.ne_lat=C.northeast.lat;A.ne_lng=C.northeast.lng}jQuery.ajax({type:"POST",url:"functs/getSessionPoiList.jsp",data:A,dataType:"json",success:function(E){processPOIData(E,D,C)
}})}function clearPOIsByLayer(C){delete rectPerLayer[C];displayedLayers[C]=0;var B=poiLayerIdToPOIId[C];if(B!==undefined){for(var A in B){if(poiList[A].marker!==undefined){poiList[A].marker.setMap(null)}removePOI(poiList[A].id)}}}function getPOIHtml(F){var D="<br>";var G=poiList[F];var C=poiLayerIdToCategoryId[G.layerId];
var A=poiCategories[C];D+="<b>"+A+": "+poiCategoryLayerInfo[C][G.layerId].layerName+"</b><br />";if(version==200706){D+=G.attr.NAME_GR_GQ+"<br />";var B=G.attr.POI_PHONE}else{if(version==200806){D+=G.attr.NAME_GQ+"<br />";var B=G.attr.POI_PHONE_GQ}}if(B>0.01){D+="Τηλ: "+Math.round(B)+"<br />"}else{if((B!="0.0")&&(B!="")&&(B!=undefined)){D+="Τηλ: "+B+"<br />"
}}var E="";if(G.url!=""){E=G.url}else{if(poiCategoryLayerInfo[C][G.layerId].url!=""){E=poiCategoryLayerInfo[C][G.layerId].url}}if(E!=""){if(E.indexOf("http://")<0){E="http://"+E}if(G.layerId==1008){D+='<a target="_new" href="'+E+'">Κλείστε δωμάτιο online...</a><br>'}else{D+='<a target="_new" href="'+E+'">'+E+"</a><br>"
}}return D}function processPOIData(B,I,F){for(var C in B.poiList){poi=B.poiList[C];var A=getPOIId(poi);if(A<0){A=addPOI(poi);var D=poiLayerIdToCategoryId[poi.layerId];var E=iconPerCategoryId[D];var G=new google.maps.Marker({position:new google.maps.LatLng(poi.lat,poi.lng),map:map,icon:E,title:poi.attr.NAME_GQ});
addInfoWin(G,A);poi.marker=G}}if(B.remaining>0){var H={"sessionid":B.sessionid,"layerids":I,"gbounds":F};invocationQueue.push(H)}processInvocationQueue()}function addInfoWin(A,B){google.maps.event.addListener(A,"click",function(){showPOIs(B)})}function getDisplayedLayersArray(){var B=[];for(var A in displayedLayers){if(displayedLayers[A]==1){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 showPOI(A){var B=poiList[A];show_td(0);map.setZoom(16);map.setCenter(new google.maps.LatLng(B.lat,B.lng))}function showPOIs(C,B){var A;if((B==undefined)||(B<0)){A=getPOIInfo(C)}else{for(i in poisOnMap){if(poiLayerIdToCategoryId[poisOnMap[i].layerId]==B){A=getPOIInfo(poisOnMap[i].id);
break}}}$("#about_td").html(A);show_td(3)}function getPOIInfo(C){var L="<br>";var B=poiList[C];if(B==undefined){for(i in poisOnMap){if(poisOnMap[i].id==C){B=poisOnMap[i];alert(B.layerId);break}}}var E=poiLayerIdToCategoryId[B.layerId];var I=poiCategories[E];var J=0;var H;var A;var D;var F;for(cn in poisOnMap){if(poisOnMap[cn].id==C){A=cn;
break}}D=F=A;D--;F++;if(D<1){D=poisOnMap.length-1}while(poiLayerIdToCategoryId[poisOnMap[D].layerId]!=E){D--;if(D<1){D=poisOnMap.length-1}}J=poisOnMap[D].id;if(F>poisOnMap.length-1){F=1}while(poiLayerIdToCategoryId[poisOnMap[F].layerId]!=E){F++;if(F>poisOnMap.length-1){F=1}}H=poisOnMap[F].id;L+='<div align="center"><table width="100%">';
L+='<tr><td></td><td align="center"><b>'+I+"</b></td><td></td></tr>";L+='<tr><td align="left"><a href="javascript:showPOIs('+J+')"><img src="images/velaki_aristera.png" style="border:0px;" title="Προηγούμενo" alt="Προηγούμενo" /></a>&nbsp;</td>';L+='<td align="center"><b><a href="javascript:showPOI('+C+')">'+B.attr.NAME_GQ+'</a></b>&nbsp;</td><td align="right"><a href="javascript:showPOIs('+H+')"><img src="images/velaki_deksia.png" style="border:0px;" title="Επόμενo" alt="Επόμενo" /></a></td></tr>';
L+='<tr><td></td><td align="center"><b>'+poiLayerInfo[B.layerId]+"</b></td><td></td></tr>";var G=B.attr.POI_PHONE_GQ;if(G>0.01){L+='<tr><td></td><td align="center">Τηλ: '+Math.round(G)+"</td><td></td></tr>"}else{if((G!="0.0")&&(G!="")&&(G!=undefined)){L+='<tr><td></td><td align="center">Τηλ: '+G+"</td></tr>"
}}var K="";if(K!=""){if(K.indexOf("http://")<0){K="http://"+K}if(B.layerId==1008){L+='<tr><td></td><td align="center"><a target="_new" href="'+K+'">Κλείστε δωμάτιο online...</a></td><td></td></tr>'}else{L+='<tr><td></td><td><a target="_new" href="'+K+'">'+K+"</a></td><td></td></tr>"}}L+='<tr><td></td><td><div id="poi_address" align="center"></div></td><td></td></tr>';
L+='<tr><td></td><td align="center"><a href="javascript:setRoutePointFrom(\''+B.lat+"','"+B.lng+"')\">";L+='<img src="images/start_hex.png" style="border:0px; margin-right:3px;" title="Διαδρομή από" alt="Διαδρομή από" />';L+="</a>&nbsp;&nbsp;&nbsp;";L+="<a href=\"javascript:setRoutePointTo('"+B.lat+"','"+B.lng+"')\">";
L+='<img src="images/stop_hex.png" style="border:0px; margin-right:3px;" title="Διαδρομή έως" alt="Διαδρομή έως" /></a></td><td></td></tr></table><br>&nbsp;';$.ajax({type:"POST",url:"functs/revGeoResults.jsp",data:{"pointX":B.lng,"pointY":B.lat},dataType:"json",success:function(N){if(N.revGeoResults[0]){var M="<font size='2'>"+N.revGeoResults[0].roadName+" ";
if(N.revGeoResults[0].roadNumber1!=0){M+=N.revGeoResults[0].roadNumber1+" "}if(N.revGeoResults[0].roadNumber2!=0){M+=N.revGeoResults[0].roadNumber2+" "}M+="<br>"+N.revGeoResults[0].roadMunicipality+", "+N.revGeoResults[0].roadZip+"</font><br>"}$("#poi_address").html(M)}});return L}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};
