function RoadPoint(A,B){this.latlng=new google.maps.LatLng(A.pointY,A.pointX);this.response=A;this.marker=null;this.text=B;this.show=function(){map.setCenter(this.latlng);map.panTo(this.latlng)};this.remove=function(){infowindow.close();this.marker.setMap(null)};this.getInfoWindowHtml=function(){var D='<div class="myInfoBox">';
D+='<div class="infoBox-inner">';if(this.text!=""){D+="<b>"+this.text+"</b><br/>";D+=this.response.division}else{D+="<b>"+this.response.foundAs+" "+this.response.street_number+"</b><br/>";D+=this.response.municipality+", "+this.response.division+", "+this.response.zip+"<br/>"}var C=this.response.foundAs;
if(this.response.street_number!=null&&this.response.street_number!=undefined&&this.response.street_number!=""){C+=" "+this.response.street_number}C+=", "+this.response.municipality;D+='<div class="info-route">';D+="<a href=\"javascript:setRouteDirection('"+this.latlng.lat()+"','"+this.latlng.lng()+"','from','"+C+"')\">";
D+='<img src="images/new/various/start-route.png" style="border:0px; margin-right:3px;" title="Διαδρομή από" alt="Διαδρομή από" />Διαδρομή από</a>';D+="<a href=\"javascript:setRouteDirection('"+this.latlng.lat()+"','"+this.latlng.lng()+"','to','"+C+"')\">";D+='<img src="images/new/various/stop-route.png" style="border:0px; margin-right:3px;" title="Διαδρομή προς" alt="Διαδρομή προς" />Διαδρομή προς</a>';
D+="</div>";D+="</div>";D+='<div class="infoBox-bottom"></div>';return D};this.getHtml=function(){var C="<div>";C+='<a href="javascript:showPointOnMap('+this.latlng.lat()+","+this.latlng.lng()+')">';C+=this.response.foundAs+", "+this.response.municipality;C+="</a>";C+="</div>";return C};this.getFirstClildHtml=function(){var C=this.response.foundAs;
if(this.response.street_number!=null&&this.response.street_number!=undefined&&this.response.street_number!=""){C+=" "+this.response.street_number}C+=", "+this.response.municipality;var D="";D+='<div id="result_route">';D+='<div id="selecte_result"><a href="javascript:showPointOnMap('+this.latlng.lat()+","+this.latlng.lng()+')">'+this.response.foundAs+", "+this.response.municipality+"</a></div>";
D+='<input type="image" src="images/new/various/result_route_from.png" onclick="javascript:setRouteDirection(\''+this.latlng.lat()+"','"+this.latlng.lng()+"','from','"+C+'\')" id="result_route_from" name="result_route_from">';D+='<input type="image" src="images/new/various/result_route_to.png" onclick="javascript:setRouteDirection(\''+this.latlng.lat()+"','"+this.latlng.lng()+"','to','"+C+'\')" id="result_route_to" name="result_route_to">';
D+="</div>";return D};this.getRouteInfo=function(E,C){var G="<div>";if(E=="#route_road_text1"){var D="from"}else{if(E=="#route_road_text2"){var D="to"}}var F=this.response.foundAs+", "+this.response.municipality;F=F.replace("'","");G+='<a href="javascript:setRouteDirectionAndClearResulst('+this.latlng.lat()+","+this.latlng.lng()+",'"+D+"',"+"'"+C+"','"+F+"')\">";
G+=this.response.foundAs+", "+this.response.municipality;G+="</a>";G+="</div>";return G};this.getType=function(){return"RoadPoint"};this.getGuidance=function(){var C="<span>"+this.response.foundAs+", "+this.response.municipality;+"</span>";return C};this.toJSONString=function(){var C={"type":"roadpoint","latlng":{"lat":this.latlng.lat(),"lng":this.latlng.lng()},"request":this.request,"response":this.response};
return toJSONString(C)};this.init=function(){if(infowindow2!=undefined){infowindow2.close()}if(toPrint){var E="images/new/various/default-marker.png";if(guidanceCounter<70){E="images/new/markers/marker-"+(guidanceCounter+1)+".png"}this.marker=new google.maps.Marker({map:map,position:this.latlng,optimized:false,icon:E,optimized:false,zIndex:100})
}else{this.marker=new google.maps.Marker({map:map,position:this.latlng,optimized:false,icon:getDefaultMarkerImage(),optimized:false,zIndex:100})}var C=this;var D=this.getInfoWindowHtml();if(infowindow==undefined){initInfoWindow()}infowindow.setContent(D);infowindow.open(map,this.marker);google.maps.event.addListener(C.marker,"click",function(){if(infowindow2!=undefined){infowindow2.close()
}infowindow.setContent(C.getInfoWindowHtml());infowindow.open(map,C.marker)});google.maps.event.addListener(map,"click",function(){infowindow.close()});this.marker.setMap(map);map.panTo(this.latlng)}}RoadPoint.prototype.fromJSONString=function(D,C){var B=new google.maps.LatLng(D.latlng.lat,D.latlng.lng);
var A=new RoadPoint(B,D.request,D.response,-1);A.init(C);return A};function showPointOnMap(C,A){var B=findRoadPointInSelectedPoints(C,A);if(B!=-1){showSelectedPoint(B.ident);removeSelectedPointOnList("#find_road_results");setSelectedPointOnList(B.obj,"#find_road_results")}else{addRoadPoint(C,A)}}function addRoadPoint(D,A){for(var B in geoResultsMap){var C=geoResultsMap[B];
if(cutCoordinate(C.latlng.lat())==cutCoordinate(D)&&cutCoordinate(C.latlng.lng())==cutCoordinate(A)){C.init();var E="";if(C.text!=""){E=C.text}else{E=C.response.foundAs+", "+C.response.municipality}addSelectionEntry(C,E,C.response);markersOnMap.push({"lat":D,"lng":A,"name":E,"marker":C.marker});removeSelectedPointOnList("#find_road_results");
setSelectedPointOnList(C,"#find_road_results")}}}function findRoadPointInSelectedPoints(D,B){for(var A=0;A<selectedPoints.length;A++){var C=selectedPoints[A];if(C.obj.getType()=="RoadPoint"){if(C.obj.latlng.lat()==D&&C.obj.latlng.lng()==B){return C}}}return -1}function removeSelectedPointOnList(A){var C="";
var B="<div>"+$("#selecte_result").html()+"</div>";$(A).children().each(function(){var D=$(this);if(D.attr("id")=="result_route"){$(D).remove();C+=B}else{C+="<div>"+$(D).html()+"</div>"}});$(A).html(C)}function setSelectedPointOnList(D,B){var A="";var C=D.response.foundAs+", "+D.response.municipality;
A+='<div id="result_route">';A+='<div id="selecte_result"><a href="javascript:showPointOnMap('+D.latlng.lat()+","+D.latlng.lng()+')">'+D.response.foundAs+", "+D.response.municipality+"</a></div>";A+='<input type="image" src="images/new/various/result_route_from.png" onclick="javascript:setRouteDirection(\''+D.latlng.lat()+"','"+D.latlng.lng()+"','from','"+C+'\')" id="result_route_from" name="result_route_from">';
A+='<input type="image" src="images/new/various/result_route_to.png" onclick="javascript:setRouteDirection(\''+D.latlng.lat()+"','"+D.latlng.lng()+"','to','"+C+'\')" id="result_route_to" name="result_route_to">';A+="</div>";var E="";$(B).children().each(function(){var F=$(this);var G=D.response.foundAs+", "+D.response.municipality;
if(F.text()==G){$(F).remove();E+=A}else{E+="<div>"+$(F).html()+"</div>"}});$(B).html(E)}function updateRoadSearchResults(H,E){$("#res-scroll").show();$("#close-results").hide();$("#nores").hide();$("#results").hide();geoResultsMap.splice(0,geoResultsMap.length);var A=[];var I=$(H).val();var D=$("#city").val();
var F=getDivisionFromCity(D);var G="";var B="";if($("#more-options").is(":visible")){G="old";F=$("#division_road").val();B=$("#area_road").val()}else{G="new"}if(I==""){if(F!=""&&B!=""){}else{return }}$("#loading_search").show();if(isIntersection(I)){A=parseIntersectionInput(I);jQuery.ajax({type:"POST",url:"functs/geoResults2New_corner.jsp",data:{"division":F,"address":A[0].address,"zipcode":A[0].zipcode,"token":A[0].token,"type":G,"area":B,"type":G},dataType:"json",success:function(M){$("#nores").hide();
$("#results").hide();$("#smart_search_results").hide();$(E).html("");var N="";var J=M.response_data;if(J.length<=0){N+='<div id="noresults" align="center"><b>Δυστυχώς, δε βρέθηκαν αποτελέσματα</b></div>';if(!($("#more-options").is(":visible"))){N+='<div><a style="margin-left:5px; color:#e88e00;" href="javascript:showMoreSearchOptions()">Δοκιμάστε με περισσότερες περιοχές</a></div>'
}$("#nores").html(N);$("#loading_search").hide();$("#nores").show()}else{for(i in J){var L=J[i];var K=new RoadPoint(L,"");geoResultsMap.push(K);N+=K.getHtml()}$("#find_road_results").html(N);$("#loading_search").hide();$("#results").show();$(".scroll-pane").jScrollPane({showArrows:true,horizontalGutter:10});
$("#close-results").show()}}})}else{A=parseSearchInput(I);for(var C in A){jQuery.ajax({type:"POST",url:"functs/geoResults2New.jsp",data:{"division":trim(F),"address":A[C].address,"street_number":A[C].streetNumber,"zipcode":A[C].zipcode,"id":0,"type":G,"area":B},dataType:"json",success:function(N){$("#smart_search_results").hide();
$("#results").hide();$(E).html("");if(N.status==0){$("#nores").hide();var O="";var J=N.response_data;if(J.length<=0){O+='<div id="noresults" align="center"><b>Δυστυχώς, δε βρέθηκαν αποτελέσματα</b></div>';if(!($("#more-options").is(":visible"))){O+='<div><a style="margin-left:5px; color:#e88e00;" href="javascript:showMoreSearchOptions()">Δοκιμάστε με περισσότερες περιοχές</a></div>'
}$("#nores").html(O);$("#loading_search").hide();$("#nores").show()}else{for(var K in J){var M=J[K];var L=new RoadPoint(M,"");geoResultsMap.push(L);O+=L.getHtml()}$(E).append(O);$("#loading_search").hide();$("#results").show();$("#find_road_results").show();$(".scroll-pane").jScrollPane({showArrows:true,horizontalGutter:10});
$(".scroll-pane").css("border","1px solid #939393");$("#close-results").show()}}}})}}};
