﻿var domain = 'http://www.letsgo.gr'; var myMap; var pinsLayer; var RouteLayer; var balloonLayer; var geocoder; var router; var flagContext = 0; var flagBalloon = 0; var flagLocRoute = 0; var mapbounds; var mapZoom; var avoidedTypes = null; var geocodePrint; var totaltime = null; var totaldistance = null; var routeInstructions = null; var routePoints = null; var centerX = null; var centerY = null; var centerZoom = null; var startX = null; var startY = null; var endX = null; var endY = null; var viaX = null; var viaY = null; var locX = null; var locY = null; var locTip = null; var a = null; var b = null; var address = null; var height = document.documentElement.clientHeight; var headerHeight = 67; var menuHeight = 17; var footerHeight = 40; var calculatedHeight = height - (headerHeight + menuHeight + footerHeight) - 1; function findOpen() { var ret = -1; $('.Content').each(function(i) { if ($(this).is(':visible')) { ret = i; } }); return ret; }
function openLocation() { $('.Content').hide(); $('.Content').each(function(i) { if (i == 0) { $(this).show(); } }); }
function openRouting() { $('.Content').hide(); $('.Content').each(function(i) { if (i == 1) { $(this).show(); } }); }
function openMenu(index) { $('.Content').hide(); $('.Content').each(function(i) { if (i == parseInt(index)) { $(this).show(); } }); }
function LocationParsing() {
    var QueryString = location.search.substring(1); subQuery = QueryString.substring(7, 0); document.getElementById('expand_menu').style.visibility = 'hidden'; document.getElementById('collapse_menu').style.visibility = 'visible'; $('.scroll').css({ overflow: 'auto', maxHeight: '450px' }); if (isIE()) { document.getElementById('geoInstructions').style.height = '0px'; $('#geoInstructions').css({ styleFloat: 'left', display: 'none' }); $('#points').css({ clear: 'both' }); }
    openMenu($("#MenuHfd").attr("value")); if (subQuery == 'textbox') { address = QueryString.split('=')[1]; for (var i = 0; i <= 150; i++) { address = address.replace('%20', ' '); } }
    if (QueryString != '') {
        var mapcenter = QueryString.split('&')[0]; centerY = parseFloat(mapcenter.split(':')[0]); centerX = parseFloat(mapcenter.split(':')[1]); centerZoom = parseInt(QueryString.split('&')[1]); if (QueryString.split('&').length == 2) { initialize(); }
        if (QueryString.split('&').length == 3) { var loc = QueryString.split('&')[2]; locY = parseFloat(loc.split(':')[0]); locX = parseFloat(loc.split(':')[1]); locTip = loc.split(':')[2].toString(); a = loc.split('%20')[0].toString(); a = a.split(':')[2].toString(); b = loc.split('%20')[1].toString(); locTip = a + " " + b; }
        if (QueryString.split('&').length > 3) {
            var start = QueryString.split('&')[2]; startY = parseFloat(start.split(':')[0]); startX = parseFloat(start.split(':')[1]); ptStart = new telenavis.WorldPoint(startX, startY, telenavis.Projector.WGSSrid); var end = QueryString.split('&')[3]; endY = parseFloat(end.split(':')[0]); endX = parseFloat(end.split(':')[1]); ptEnd = new telenavis.WorldPoint(endX, endY, telenavis.Projector.WGSSrid); if (QueryString.split('&').length == 5) { var via = QueryString.split('&')[4]; viaY = parseFloat(via.split(':')[0]); viaX = parseFloat(via.split(':')[1]); ptMiddle = new telenavis.WorldPoint(viaX, viaY, telenavis.Projector.WGSSrid); document.getElementById('middle').style.display = 'block'; }
            initialize(); route();
        }
        if (QueryString.split('&').length == 3) { initialize(); route(); addPin('locPin', locTip, locX, locY, 'Assets/Images/pin2.gif', pinsLayer); }
        else if (address != null) { centerX = 23.72631435; centerY = 37.97507208; centerZoom = 6; initialize(); route(); FindLoc(address); } 
    }
    else { centerX = 23.72631435; centerY = 37.97507208; centerZoom = 6; initialize(); } 
}
function initialize() {
    document.getElementById('TimeDate').style.display = 'none'; document.getElementById('Instructions').style.display = 'none'; document.getElementById('Candidates').style.display = 'none'; var toolbar = document.getElementById('mapControl'); resizeMapDiv(); window.onresize = function() { resizeMapDiv(); }
    myMap = new telenavis.jsMap('map', 'divMap', new telenavis.WorldPoint(centerX, centerY, telenavis.Projector.WGSSrid), centerZoom); myMap.initialize(); myMap.navbar.hide(); myMap.getDiv(toolbar); RouteLayer = new telenavis.Layer('routeLayer', 1); myMap.addLayer(RouteLayer); pinsLayer = new telenavis.Layer('pinsLayer', 2); myMap.addLayer(pinsLayer); balloonLayer = new telenavis.Layer('balloonLayer', 20); myMap.addLayer(balloonLayer); document.getElementById('copyright_map').style.display = 'none'; document.getElementById('MenuImg').onclick = function() { setTimeout(resizeMap, 1000); }
    document.getElementById('expImg').onclick = function() { setTimeout(resizeMap, 1000); }
    geocoder = new telenavis.Geocoder('g'); geocoder.method = telenavis.Geocoder.methodsEnum.ADDRESS | telenavis.Geocoder.methodsEnum.LOCATION; router = new telenavis.Router('router'); router.addEventListener(telenavis.Router.events.ROUTE_CREATED, callbackroute); document.getElementById('SLOCTbx1').onkeypress = geocdeKeyPress; document.getElementById('SLOCTbx').onkeypress = geocdeKeyPress; document.getElementById('EndTbx').onkeypress = routeKeyPress; document.getElementById('StartTbx').onkeypress = routeKeyPress; document.getElementById('MiddleTbx').onkeypress = routeKeyPress; myMap.addEventListener(telenavis.jsMap.events.CONTEXT_MENU, onContextMenu); myMap.addEventListener(telenavis.jsMap.events.CLICK, onClickMenu); myMap.addEventListener(telenavis.jsMap.events.ZOOM_CHANGED, onZoomChanged); myMap.addEventListener(telenavis.jsMap.events.CENTER_CHANGED, onCenterChanged); addClickEventToPOis(); CheckZoom();
}
function onCenterChanged() {
    mapbounds = myMap.getViewRect(); if (flagBalloon) { var divBalloon = document.getElementById('divBalloon'); divBalloon.parentNode.removeChild(divBalloon); flagBalloon = 0; }
    CheckZoom(); POIsHandling();
}
function convertMinutesToHours(TotalMinutes) {
    var result; if (TotalMinutes == 60) { result = 1 + ' ώρα'; }
    if (TotalMinutes < 60) {
        var minutes = TotalMinutes.toString().substring(0, 2); if (minutes < 10) { result = minutes.substring(0, 1) + ' λεπτά'; }
        else { result = minutes + ' λεπτά'; } 
    }
    if (TotalMinutes > 60) {
        var divide = TotalMinutes / 60; var hours = divide.toString().split('.')[0]; var minutes = ((divide.toString().split('.')[1].substring(0, 2)) * 0.6); if (minutes < 10) { minutes = minutes.toString().substring(0, 1); }
        else { minutes = minutes.toString().substring(0, 2); }
        result = hours + ' ώρες ' + minutes + ' λεπτά';
    }
    if (TotalMinutes < 1) {
        var seconds = (TotalMinutes * 60); if (seconds < 10) { seconds = seconds.toString().substring(0, 1); }
        else { seconds = seconds.toString().substring(0, 2); }
        result = seconds + ' δευτερόλεπτα'
    }
    return result;
}
function convertToKm(totaldistance) {
    var distance; if (totaldistance >= 1000) {
        var km = totaldistance / 1000; var meters = totaldistance % 1000; if (meters > 0) { distance = km.toString().split('.')[0] + ',' + km.toString().split('.')[1].substring(0, 2) + ' χλμ. '; }
        else { distance = km + ' χλμ.'; } 
    }
    else { distance = totaldistance + ' μέτρα'; }
    return distance;
}
function geocdeKeyPress(e) {
    var browser = navigator.appName; if (browser == 'Netscape') {
        e = e ? e : window.event; if (e.keyCode == 13 && this.value != '') { FindLoc(this.value); return false; }
        else if (e.keyCode == 13)
        { return false; } 
    }
    else { e = e ? e : window.event; if (e.keyCode == 13 && this.value != '') { FindLoc(this.value); } } 
}
function resizeMap() { myMap.resize(); }
function resizeMapDiv() {
    var height = document.documentElement.clientHeight; var width = document.documentElement.clientWidth; var menuWidth = 282; var headerHeight = 67; var menuHeight = 17; var footerHeight = 40; var height2 = (calculatedHeight - 90 - (4 * 26)) + 'px'; var calculatedHeight = height - (headerHeight + menuHeight + footerHeight) - 1; if (calculatedHeight < 620) { document.getElementById('Tip').style.display = 'none'; }
    if (calculatedHeight > 124) { document.getElementById('divMap').style.height = calculatedHeight + 'px'; document.getElementById('menuTest').style.height = calculatedHeight + 'px'; document.getElementById('MenuPnl').style.height = calculatedHeight + 'px'; }
    document.getElementById('emailform').style.top = (height - 288) / 2 + 'px'; document.getElementById('emailform').style.left = (width - 450) / 2 + 'px'; document.getElementById('Greeting').style.top = (height - 241) / 2 + 'px'; document.getElementById('Greeting').style.left = (width - 138) / 2 + 'px'; if (calculatedHeight < 350)
    { document.getElementById('menuTest').style.height = '350px'; document.getElementById('MenuPnl').style.height = '350px'; document.getElementById('divMap').style.height = '350px'; }
    if (isIE()) {
        if (calculatedHeight < 350)
        { document.getElementById('menuTest').style.height = '475px'; document.getElementById('MenuPnl').style.height = '475px'; document.getElementById('divMap').style.height = '475px'; } 
    }
    adjustMenu();
}
function calculateMenuHeight()
{ return $('#menuTest').css('height'); }
function leftMenuHeight() {
    var height = document.documentElement.clientHeight; var width = document.documentElement.clientWidth; var menuWidth = 282; var headerHeight = 67; var menuHeight = 17; var footerHeight = 40; var height2 = (calculatedHeight - 90 - (4 * 26)) + 'px'; var calculatedHeight = height - (headerHeight + menuHeight + footerHeight) - 1; var ContentHeight = 0; var tipHeight = 94; if (!$('#Tip').is(':visible')) { tipHeight = 0; }
    $('#menuTest .Content').each(function() {
        if ($(this).is(':visible')) {
            try {
                if (isIE()) {
                    var totalHeight = 0; document.getElementById('Tip').style.display = 'none'; $('#findLocat').children().each(function() { totalHeight += $(this).height(); }); if ($('#geoInstructions').height() == 0) { $('#routeTest').height(370); }
                    else { $('#routeTest').height(calculatedHeight - 4 * 29 - tipHeight); }
                    ContentHeight = totalHeight;
                }
                else { $(this).css({ 'height': 'auto' }); ContentHeight = $(this).height(); } 
            }
            catch (e) { } 
        } 
    }); return ContentHeight + 4 * 29 + 94;
}
function adjustMenu() {
    var menuWidth = 282; var width = document.documentElement.clientWidth; if ($('#menuTest').height() < leftMenuHeight()) {
        var tipHeight = 94; if (!$('#Tip').is(':visible')) { tipHeight = 0; }
        var targetValue = $('#menuTest').height() - 4 * 29 - tipHeight; $('#menuTest .Content').each(function() { if ($(this).is(':visible')) { $(this).height(targetValue); } });
    }
    if (isIE()) {
        if ($('#menuTest').is(':visible')) { document.getElementById('divMap').style.width = (width - menuWidth - 3) + 'px'; }
        else { document.getElementById('divMap').style.width = width + 'px'; } 
    } 
}
function onClick(world_point) { mapZoom = myMap.getZoom(); myMap.moveTo(world_point, (mapZoom + 1)); }
function onZoomChanged() {
    mapZoom = myMap.getZoom(); if (flagBalloon) { var divBalloon = document.getElementById('divBalloon'); divBalloon.parentNode.removeChild(divBalloon); flagBalloon = 0; }
    document.getElementById('Img1').style.top = 225 - ((mapZoom - 1) * 11) + 'px'; CheckZoom(); mapbounds = myMap.getViewRect(); POIsHandling();
}
function zoomTo(x, y, z) { var floatX = parseFloat(x); var floatY = parseFloat(y); var point = new telenavis.WorldPoint(floatX, floatY, telenavis.Projector.WGSSrid); myMap.moveTo(point, z); }
function addPin(id, tip, x, y, imgPin, layer) {
    var pin = new telenavis.Pin(id); var floatX = parseFloat(x); var floatY = parseFloat(y); pin.setWorldPos(new telenavis.WorldPoint(floatX, floatY, telenavis.Projector.WGSSrid)); pin.setImageSrc(imgPin); pin.setHotspot(new telenavis.Point(15, 25)); pin.setTip(tip); if ((tip != 'Αφετηρία') && (tip != 'Προορισμός') && (tip != 'Μέσω')) { pin.setHotspot(new telenavis.Point(8, 25)); pin.onClick = Balloon; }
    layer.addPin(pin);
}
function Balloon(pin) {
    flagBalloon = 1; var addr = pin.getTip(); var pinsLayer = pin.getLayer(); var worldPoint = pin.getWorldPos(); screenPos = myMap.screenPosAt(worldPoint); var divBalloon = document.getElementById('divBalloon'); if (divBalloon != null) { divBalloon.parentNode.removeChild(divBalloon); }
    CreateBalloon(addr, worldPoint);
}
function CreateBalloon(addr, worldPoint) {
    divBalloon = document.createElement('div'); divBalloon.id = 'divBalloon'; divBalloon.className = 'divBalloon'; divBalloon.style.left = screenPos.x - 20 + 'px'; divBalloon.style.top = screenPos.y - 98 + 'px'; var Balloonanchor = document.createElement('div'); var img = document.createElement('IMG'); img.id = 'imgStart'; img.className = 'imgStart'; img.src = 'Assets/Images/balloon/bt1.png'; var img2 = document.createElement('IMG'); img2.id = 'imgMiddle'; img2.className = 'imgMiddle'; img2.src = 'Assets/Images/balloon/bb2.png'; img2.onclick = function() { divBalloon.parentNode.removeChild(divBalloon); flagBalloon = 0; }
    var img3 = document.createElement('IMG'); img3.id = 'imgEnd'; img3.className = 'imgEnd'; img3.src = 'Assets/Images/balloon/bt3.png'; var img4 = document.createElement('IMG'); img4.id = 'imgLeft'; img4.className = 'imgLeft'; img4.src = 'Assets/Images/balloon/bl.png'
    var img5 = document.createElement('IMG'); img5.id = 'imgBottomStart'; img5.className = 'imgBottomStart'; img5.src = 'Assets/Images/balloon/bb1.png'; var img6 = document.createElement('IMG'); img6.id = 'imgBottomMiddle'; img6.className = 'imgBottomMiddle'; img6.src = 'Assets/Images/balloon/bt2.png'; var img7 = document.createElement('IMG'); img7.id = 'imgBottomEnd'; img7.className = 'imgBottomEnd'; img7.src = 'Assets/Images/balloon/bb3.png'; var img8 = document.createElement('IMG'); img8.id = 'imgRight'; img8.className = 'imgRight'; img8.src = 'Assets/Images/balloon/br.png'
    var img9 = document.createElement('IMG'); img9.id = 'img'; img9.className = 'img'; img9.src = 'Assets/Images/balloon/b1 e 1b.gif'; Balloonanchor.appendChild(img); Balloonanchor.appendChild(img2); Balloonanchor.appendChild(img3); Balloonanchor.appendChild(img4); Balloonanchor.appendChild(img5); Balloonanchor.appendChild(img6); Balloonanchor.appendChild(img7); Balloonanchor.appendChild(img8); Balloonanchor.appendChild(img9); var divAll = document.createElement('div'); divAll.id = 'divAll'; divAll.className = 'divAll'; Balloonanchor.appendChild(divAll); var divRoute = document.createElement('div'); divRoute.id = 'divRoute'; divRoute.className = 'divRoute'; divAll.appendChild(divRoute); var divTip = document.createElement('span'); divTip.id = 'divTip'; divTip.className = 'divTip'; divTip.appendChild(document.createTextNode(addr)); divRoute.appendChild(divTip); var br = document.createElement('br'); var divMitsos = document.createElement('div'); divMitsos.id = 'divMitsos'; divMitsos.className = 'divMitsos'; var divDrive = document.createElement('div'); divDrive.id = 'divDrive'; divDrive.className = 'divDrive'; divDrive.appendChild(document.createTextNode(' ΔΡΟΜΟΛΟΓΗΣΗ')); var divFrom = document.createElement('a'); divFrom.id = 'divFrom'; divFrom.className = 'divFrom'; divFrom.appendChild(document.createTextNode(' ΑΠΟ')); divFrom.href = '#'; divFrom.onclick = function() { routestartclick(worldPoint.x, worldPoint.y); }
    var divTo = document.createElement('a'); divTo.id = 'divTo'; divTo.className = 'divTo'; divTo.appendChild(document.createTextNode(' ΠΡΟΣ')); divTo.href = '#'; divTo.onclick = function() { routeendclick(worldPoint.x, worldPoint.y); }
    divMitsos.appendChild(divDrive); divMitsos.appendChild(divFrom); divMitsos.appendChild(divTo); divRoute.appendChild(divMitsos); Balloonanchor.appendChild(divRoute); divBalloon.appendChild(Balloonanchor); divBalloon.appendChild(br); pinsLayer.getDiv().appendChild(divBalloon);
}
var ptStart = null; var ptMiddle = null; var ptEnd = null; function FindByLandmark(name) { $.get("Handler.ashx", { n: name, mode: "landmarks" }, function(data) { if (data != null) { var ids = data.toString().split(':')[0]; var cat_ids = data.toString().split(':')[1]; var company = data.toString().split(':')[2]; var addresses = data.toString().split(':')[3]; var numbers = data.toString().split(':')[4]; var regions = data.toString().split(':')[5]; var zips = data.toString().split(':')[6]; var xcos = data.toString().split(':')[7]; var ycos = data.toString().split(':')[8]; } }); }
function JSONTest() {
    var the_object; var http_request = new XMLHttpRequest(); http_request.open("GET", "Handler.ashx", true); http_request.onreadystatechange = function() {
        if (http_request.readyState == 4) {
            if (http_request.status == 200) { the_object = eval("(" + http_request.responseText + ")"); } else { alert("There was a problem with the URL."); }
            http_request = null;
        } 
    }; http_request.send(null);
}
function FindLoc(address) {
    FindByLandmark(address); var width = document.documentElement.clientWidth; var menuWidth = 282; if ($('a#expand_menu')) { $('#menuTest').show(); document.getElementById('expand_menu').style.visibility = 'hidden'; document.getElementById('collapse_menu').style.visibility = 'visible'; }
    openLocation(); document.getElementById('LocRoute').style.display = 'none'; document.getElementById('lblGeocodePrint').innerHTML = 'Διεύθυνση Αναζήτησης: '; document.getElementById('lblFromPrint').innerHTML = 'Διεύθυνση Αφετηρίας: '; document.getElementById('lblToPrint').innerHTML = 'Διεύθυνση Τερματισμού: '; document.getElementById('lblGeocodePrint').style.display = 'block'; geocodePrint = document.getElementById('lblGeocodePrint').innerHTML; document.getElementById('lblFromPrint').style.display = 'none'; document.getElementById('lblViaPrint').style.display = 'none'; document.getElementById('lblToPrint').style.display = 'none'; document.getElementById('TimeDateP').style.display = 'none'; document.getElementById('RouteStepsP').style.display = 'none'; document.getElementById('TimeDate').style.display = 'none'; document.getElementById('Instructions').style.display = 'none'; ClearRouteSteps(); ClearPolylines(); ClearPins(); if (flagContext == 1) { document.getElementById('divContextMenu').style.display = 'none'; }
    if (flagBalloon == 1) { document.getElementById('divBalloon').style.display = 'none'; }
    ToggleGeocode(); geocoder.geocode(address, callbackFunction); setTimeout(ToggleGeocode, 3000); ToggleGeocode(true);
}
function ClearRouteSteps() { var pins = RouteLayer.getPinsArray(); for (var i = pins.length - 1; i >= 0; i--) { RouteLayer.removePin(pins[i].getId()); } }
function ClearPins() {
    var geopin = pinsLayer.getPinsArray(); for (var j = geopin.length - 1; j >= 0; j--) { pinsLayer.removePin(geopin[j].getId()); }
    var geopin = RouteLayer.getPinsArray(); for (var j = geopin.length - 1; j >= 0; j--) { RouteLayer.removePin(geopin[j].getId()); } 
}
function ClearPolylines() { var polylineIndex = RouteLayer.getPolylinesArray(); for (var i = polylineIndex.length - 1; i >= 0; i--) { RouteLayer.removePolyline(polylineIndex[i].getId()); } }
function ToggleGeocode(bool) {
    if (typeof (bool) == 'undefined') { ToggleGeocode(false); }
    document.getElementById('GeocodeBtn').disabled = bool;
}
function ToggleRoot(bool) {
    if (typeof (bool) == 'undefined') { ToggleRoot(false); ; }
    document.getElementById('RouteBtn').disabled = bool;
}
function handleClick(x, y, addr) { myMap.moveTo(new telenavis.WorldPoint(x, y, telenavis.Projector.WGSSrid), 16); document.getElementById('SLOCTbx').value = addr; document.getElementById('lblGeocodePrint').innerHTML = 'Διεύθυνση Αναζήτησης: '; document.getElementById('lblGeocodePrint').innerHTML += addr; addPin('locPin', addr, x, y, 'Assets/Images/pin2.gif', pinsLayer); document.getElementById('LocRoute').style.display = 'block'; actionFlag = 1; }
function callbackFunction(resp) { switch (resp.ResponseCode) { case 0: showGeocodingResult(resp.Candidates[0]); break; case 1: showGeocodingCandidates(resp.Candidates); break; case 5: alert('Δεν βρέθηκε η ζητούμενη διεύθυνση. Ελέγξτε την ορθογραφία ' + ' και επιβεβαιώστε οτι στη διεύθυνση συμπεριλαμβάνονται ο δήμος και ο νομός.'); break; case 6: alert('Ενα εσωτερικό σφάλμα συνέβη. Παρακαλώ προσπαθήστε αργότερα.'); break; } }
function callbackGeoStart(resp, obj) { switch (resp.ResponseCode) { case 0: document.getElementById('StartTbx').value = resp.Candidates[0].address; document.getElementById('lblFromPrint').innerHTML += resp.Candidates[0].address; ptStart = new telenavis.WorldPoint(resp.Candidates[0].x, resp.Candidates[0].y, telenavis.Projector.WGSSrid); performRoute(); break; case 1: showRouteGeocodingCandidates(resp.Candidates, 'start'); break; case 5: alert('Δεν βρέθηκε η ζητούμενη διεύθυνση. Ελέγξτε την ορθογραφία ' + ' και επιβεβαιώστε οτι στη διεύθυνση της Αφετηρίας συμπεριλαμβάνονται ο δήμος και ο νομός.'); break; case 6: alert('Ενα εσωτερικό σφάλμα συνέβη. Παρακαλώ προσπαθήστε αργότερα.'); break; } }
function callbackGeoMiddle(resp, obj) { document.getElementById('lblViaPrint').innerHTML = 'Διεύθυνση Ενδιάμεσου Προορισμού: '; switch (resp.ResponseCode) { case 0: document.getElementById('MiddleTbx').value = resp.Candidates[0].address; document.getElementById('lblViaPrint').innerHTML += resp.Candidates[0].address; ptMiddle = new telenavis.WorldPoint(resp.Candidates[0].x, resp.Candidates[0].y, telenavis.Projector.WGSSrid); performRoute(); break; case 1: showRouteGeocodingCandidates(resp.Candidates, 'middle'); break; case 5: alert('Δεν βρέθηκε η ζητούμενη διεύθυνση. Ελέγξτε την ορθογραφία  ' + ' και επιβεβαιώστε οτι στη διεύθυνση Ενδιάμεσου Προορισμού συμπεριλαμβάνονται ο δήμος και ο νομός.'); break; case 6: alert('Ενα εσωτερικό σφάλμα συνέβη. Παρακαλώ προσπαθήστε αργότερα.'); break; } }
function callbackGeoEnd(resp) { switch (resp.ResponseCode) { case 0: document.getElementById('EndTbx').value = resp.Candidates[0].address; document.getElementById('lblToPrint').innerHTML += resp.Candidates[0].address; ptEnd = new telenavis.WorldPoint(resp.Candidates[0].x, resp.Candidates[0].y, telenavis.Projector.WGSSrid); performRoute(); break; case 1: showRouteGeocodingCandidates(resp.Candidates, 'end'); break; case 5: alert('Δεν βρέθηκε η ζητούμενη διεύθυνση. Ελέγξτε την ορθογραφία  ' + ' και επιβεβαιώστε οτι στη διεύθυνση Ενδιάμεσου Προορισμού συμπεριλαμβάνονται ο δήμος και ο νομός.'); break; case 6: alert('Ενα εσωτερικό σφάλμα συνέβη. Παρακαλώ προσπαθήστε αργότερα.'); break; } }
function route() {
    if (ptStart != null && ptEnd != null) {
        document.getElementById('Candidates').style.display = "none"; var via = new telenavis.WorldPoint(23.79, 38, telenavis.Projector.WGSSrid); var points = new Array(); points.push(ptStart); addPin("StartPin", "Αφετηρία", ptStart.x, ptStart.y, 'Assets/Images/A.gif', RouteLayer); if (document.getElementById('middle').style.display == 'block') { points.push(ptMiddle); addPin("ViaPin", "Μέσω", ptMiddle.x, ptMiddle.y, 'Assets/Images/S.gif', RouteLayer); }
        points.push(ptEnd); addPin("EndPin", "Προορισμός", ptEnd.x, ptEnd.y, 'Assets/Images/T.gif', RouteLayer); router.getRoute(points, getStrategyType(), getRoutingType(), "el-GR", 8, avoidedTypes);
    } 
}
function callbackroute(resp) {
    var menuWidth = 282; var width = document.documentElement.clientWidth; var height = document.documentElement.clientHeight; var headerHeight = 67; var menuHeight = 17; var footerHeight = 40; var calculatedHeight = height - (headerHeight + menuHeight + footerHeight) - 1; if (resp.getRouteResults().ResponseCode == 1) { alert('Η δρομολόγηση δεν πραγματοποιήθηκε. Παρακαλώ προσπαθήστε αργότερα.'); }
    else {
        actionFlag = 2; document.getElementById('Candidates').style.display = "none"; document.getElementById('RouteSummary').style.display = "none"; document.getElementById('RouteSummary').style.display = "block"; document.getElementById('TimeDate').style.display = "block"; document.getElementById('Instructions').style.display = "block"; document.getElementById('reverseRoute').style.paddingRight = "0px"; document.getElementById('geoInstructions').style.maxHeight = "180px"; adjustMenu(); document.getElementById('geoInstructions').style.display = "block"; if (isIE()) { $("#geoInstructions").css({ styleFloat: "none" }); }
        totaltime = convertMinutesToHours(resp.getRouteResults().TotalMinutes); document.getElementById('spnTime').innerHTML = totaltime; document.getElementById('spnTimeP').innerHTML = totaltime; totaldistance = convertToKm(resp.getRouteResults().TotalDistance); document.getElementById('spnDistance').innerHTML = totaldistance; document.getElementById('spnDistanceP').innerHTML = totaldistance; var polyline = resp.getPolyline('routePolyline'); polyline.strokeColor = "blue"; polyline.strokeWidth = "5px"; polyline.fillColor = 'none'; polyline.fillOpacity = 0; RouteLayer.addPolyline(polyline); routeInstructions = resp.getRouteInstructions(); routePoints = resp.getRoutePoints(); GetTollStations(); var directions = ""; directions = "<ol>"; for (var i = 0; i < routeInstructions.length; i++) { directions += "<li>" + routeInstructions[i].directions.replace("«", "<strong>").replace("»", "</strong>"); var pt = routeInstructions[i].point; directions += "<img src='Assets/Images/external.png' id='imgZoom' title='Στο χάρτη' onclick='zoomTo(" + pt.x.toString() + "," + pt.y.toString() + ", 16);'/></li>"; myPin = new telenavis.Pin('direction' + i.toString()); myPin.setImageSrc('Assets/Images/routeStep.png'); myPin.setWorldPos(pt); myPin.setHotspot(new telenavis.Point(3, 3)); myPin.setTip(routeInstructions[i].directions); RouteLayer.addPin(myPin); }
        directions += "</ol>"; document.getElementById('spnDirections').innerHTML = directions; document.getElementById('spnDirectionsP').innerHTML = directions; var bounds = getRouteBounds(routeInstructions); var newX = (bounds.minX + bounds.maxX) / 2; var newY = (bounds.minY + bounds.maxY) / 2; var newCenter = new telenavis.WorldPoint(newX, newY, telenavis.Projector.WGSSrid); var fittingZoom = getFittingZoom(bounds); if (fittingZoom > telenavis.constants.maxZoom) { fittingZoom = telenavis.constants.maxZoom - 2; }
        myMap.moveTo(newCenter, fittingZoom);
    } 
}
function GetTollStations() { }
function showGeocodingResult(cand) { var div = document.getElementById('geocode'); var divContents = "Βρέθηκε ακριβής διεύθυνση <br/>"; divContents += "<a href='#' onclick='handleClick(" + cand.x + "," + cand.y + ",\"" + cand.address + "\");'>" + cand.address + "</a>"; handleClick(cand.x, cand.y, cand.address); div.innerHTML = divContents; }
function showGeocodingCandidates(candidates) {
    var div = document.getElementById('geocode'); var divContents = "Βρέθηκαν " + candidates.length + " διευθύνσεις <br/>"; for (var i = 0; i < candidates.length; i++) { divContents += "<a href='#' onclick='handleClick(" + candidates[i].x + "," + candidates[i].y + ",\"" + candidates[i].address + "\");'>" + candidates[i].address + "</a><br/>"; }
    div.innerHTML = divContents; adjustMenu();
}
function performRouteButton() {
    document.getElementById('Candidates').innerHTML = ""; document.getElementById('Tip').style.display = 'none'; ptStart = null; ptMiddle = null; ptEnd = null; ClearRouteSteps(); ClearPolylines(); ClearPins(); document.getElementById('lblGeocodePrint').innerHTML = 'Διεύθυνση Αναζήτησης: '; document.getElementById('lblFromPrint').innerHTML = 'Διεύθυνση Αφετηρίας: '; document.getElementById('lblViaPrint').innerHTML = ''; document.getElementById('lblToPrint').innerHTML = 'Διεύθυνση Τερματισμού: '; document.getElementById('lblGeocodePrint').style.display = 'none'; document.getElementById('lblFromPrint').style.display = 'block'; document.getElementById('lblViaPrint').style.display = 'block'; document.getElementById('lblToPrint').style.display = 'block'; document.getElementById('TimeDateP').style.display = 'block'; document.getElementById('RouteStepsP').style.display = 'block'; var a = findOpen(); if (a == 1) { performRoute(); }
    if (flagBalloon == 1) { document.getElementById('divBalloon').style.display = 'none'; }
    if (flagContext == 1) { document.getElementById('divContextMenu').style.display = 'none'; }
    document.getElementById('TimeDate').style.display = "none"; document.getElementById('Instructions').style.display = "none"; document.getElementById('Candidates').style.display = "none"; var div = document.getElementById("blankVia"); div.innerHTML = ''; if (isIE()) {
        var tipHeight = 94; if (!$("#Tip").is(":visible")) { tipHeight = 0; }
        $("#routeTest").height(calculatedHeight - 4 * 29 - tipHeight);
    } 
}
function performRoute() {
    if (ptStart != null && ptEnd != null) { route(); }
    if (ptStart == null) { var start = document.getElementById("StartTbx").value; geocodeStart(start); }
    else if ((document.getElementById('middle').style.display == 'block') && (ptMiddle == null)) {
        document.getElementById('Candidates').innerHTML = " "; var middle = document.getElementById("MiddleTbx").value; if (middle == "") { var div = document.getElementById("blankVia"); var msg = "* Προσθέστε Διεύθυνση Ενδιάμεσου Προορισμού ή πατήστε Διαγραφή"; div.appendChild(document.createTextNode(msg)); div.appendChild(document.createElement("br")); return; }
        geocodeMiddle(middle);
    }
    else if (ptEnd == null) { document.getElementById('Candidates').innerHTML = " "; var end = document.getElementById('EndTbx').value; geocodeEnd(end); } 
}
function geocodeStart(address) { var g = new telenavis.Geocoder('geocoder'); g.method = telenavis.Geocoder.methodsEnum.ADDRESS | telenavis.Geocoder.methodsEnum.LOCATION; g.geocode(address, callbackGeoStart); }
function geocodeMiddle(address) { var g = new telenavis.Geocoder('geocoder'); g.method = telenavis.Geocoder.methodsEnum.ADDRESS | telenavis.Geocoder.methodsEnum.LOCATION; g.geocode(address, callbackGeoMiddle); }
function geocodeEnd(address) { var g = new telenavis.Geocoder('geocoder'); g.method = telenavis.Geocoder.methodsEnum.ADDRESS | telenavis.Geocoder.methodsEnum.LOCATION; g.geocode(address, callbackGeoEnd); }
function showRouteGeocodingCandidates(candidates, isStartPoint) {
    var div = document.getElementById("Candidates"); if (div) {
        div.innerHTML = ""; var msg = "Βρέθηκαν " + candidates.length.toString() + " αποτελέσματα για "; if (isStartPoint == "start") { msg += " την αφετηρία." }
        else if (isStartPoint == "middle") { msg += " τον ενδιάμεσο προορισμό" }
        else { msg += " τον τελικό προορισμό" }
        div.appendChild(document.createTextNode(msg)); div.appendChild(document.createElement("br")); var tbl, tbd, tr, td; tbl = document.createElement('table'); tbd = document.createElement('tbody'); for (var i = 0; i < candidates.length; i++) {
            tr = document.createElement('tr'); td = document.createElement('td'); var href = document.createElement("a"); href.setAttribute('href', '#'); candidates[i].setAsRouteStart = function() { ptStart = new telenavis.WorldPoint(this.x, this.y, telenavis.Projector.WGSSrid); document.getElementById("StartTbx").value = this.address; document.getElementById('lblFromPrint').innerHTML += this.address; performRoute(); }
            candidates[i].setAsRouteMiddle = function() { ptMiddle = new telenavis.WorldPoint(this.x, this.y, telenavis.Projector.WGSSrid); document.getElementById("MiddleTbx").value = this.address; document.getElementById('lblViaPrint').innerHTML += this.address; performRoute(); }
            candidates[i].setAsRouteEnd = function() { ptEnd = new telenavis.WorldPoint(this.x, this.y, telenavis.Projector.WGSSrid); document.getElementById("EndTbx").value = this.address; document.getElementById('lblToPrint').innerHTML += this.address; performRoute(); }
            if (isStartPoint == "start") { href.onclick = createDelegate(candidates[i], "setAsRouteStart") }
            else if (isStartPoint == "middle") { href.onclick = createDelegate(candidates[i], "setAsRouteMiddle") }
            else { href.onclick = createDelegate(candidates[i], "setAsRouteEnd") }
            href.appendChild(document.createTextNode(candidates[i].address)); td.appendChild(href); tr.appendChild(td); tbd.appendChild(tr);
        }
        tbl.appendChild(tbd); div.appendChild(tbl); div.style.display = "block";
    } 
}
function resetPoint(isStart) {
    if (isStart) { ptStart = null; }
    else { ptEnd = null; } 
}
function createDelegate(object, methodName) {
    var func = function() { return object[methodName].apply(object, arguments); }
    return func;
}
function findPos(obj) {
    var curleft = curtop = 0; if (obj.offsetParent) { do { curleft += obj.offsetLeft; curtop += obj.offsetTop; } while (obj = obj.offsetParent); }
    return [curleft, curtop];
}
function onClickMenu(world_point) { if (flagContext == 1) { document.getElementById('divContextMenu').style.display = 'none'; } }
function onContextMenu(screenPoint, worldPoint) {
    flagContext = 1; worldPoint = myMap.worldPosAt(screenPoint); var mapPosition = findPos(document.getElementById('divMap')); if (flagBalloon == 1) { document.getElementById('divBalloon').style.display = 'none'; }
    var divContextMenu = document.getElementById('divContextMenu'); if (divContextMenu != null) { divContextMenu.parentNode.removeChild(divContextMenu); }
    divContextMenu = document.createElement("div"); divContextMenu.id = 'divContextMenu'; divContextMenu.className = 'divContextMenu'; divContextMenu.style.left = mapPosition[0] + screenPoint.x + "px"; divContextMenu.style.top = mapPosition[1] + screenPoint.y + "px"; var Startanchor = document.createElement("a"); var img = document.createElement("IMG"); img.id = "imgStart"; img.src = "Assets/Images/A.gif"; Startanchor.appendChild(img); Startanchor.appendChild(document.createTextNode("Aφετηρία")); Startanchor.href = "#"; Startanchor.onclick = function() { routestartclick(worldPoint.x, worldPoint.y); }
    var br = document.createElement("br"); var br = document.createElement("br"); var Endanchor = document.createElement("a"); var img2 = document.createElement("IMG"); img2.id = "imgEnd"; img2.src = "Assets/Images/T.gif"; Endanchor.appendChild(img2); Endanchor.appendChild(document.createTextNode(" Προορισμός")); Endanchor.href = "#"; Endanchor.onclick = function() { routeendclick(worldPoint.x, worldPoint.y); }
    var StartSpan = document.createElement("span"); StartSpan.id = 'startcontainer'; StartSpan.className = 'startcontainer'; var EndSpan = document.createElement("span"); EndSpan.id = 'endcontainer'; EndSpan.className = 'endcontainer'; divContextMenu.appendChild(StartSpan); StartSpan.appendChild(Startanchor); divContextMenu.appendChild(br); divContextMenu.appendChild(EndSpan); EndSpan.appendChild(Endanchor); document.body.appendChild(divContextMenu);
}
function routestartclick(x, y) {
    ClearPins(); var hotspot; var test = myMap.getLayersArray()[1].getPinsArray(); addPin(0, "Αφετηρία", x, y, 'Assets/Images/A.gif', RouteLayer); ptStart = new telenavis.WorldPoint(x, y, telenavis.Projector.WGSSrid); if (flagContext == 1) { document.getElementById('divContextMenu').style.display = 'none'; }
    if (flagBalloon == 1) { document.getElementById('divBalloon').style.display = 'none'; }
    RoutingByContextMenu();
}
function routeendclick(x, y) {
    ClearPins(); addPin(1, "Προορισμός", x, y, 'Assets/Images/T.gif', RouteLayer); ptEnd = new telenavis.WorldPoint(x, y, telenavis.Projector.WGSSrid); if (flagContext == 1) { document.getElementById('divContextMenu').style.display = 'none'; }
    if (flagBalloon == 1) { document.getElementById('divBalloon').style.display = 'none'; }
    RoutingByContextMenu();
}
function RoutingByContextMenu() {
    document.getElementById('lblFromPrint').innerHTML = ''; document.getElementById('lblViaPrint').innerHTML = ''; document.getElementById('lblToPrint').innerHTML = ''; if (ptStart != null && ptEnd != null) {
        ClearRouteSteps(); ClearPolylines(); if ($('a#expand_menu')) { $('#menuTest').show(); document.getElementById('expand_menu').style.visibility = "hidden"; document.getElementById('collapse_menu').style.visibility = "visible"; }
        openRouting(); document.getElementById('Tip').style.display = 'none'; performRoute();
    }
    else { return; } 
}
function distanceInKm(p1, p2) { var diff1 = 111 * (p2.y - p1.y); var diff2 = 111 * (p2.x - p1.x) * Math.cos(p1.y / 57.3); var d = Math.sqrt((diff1 * diff1) + (diff2 * diff2)); return d; }
function getRouteBounds(instructions) {
    var ptMin = new telenavis.Point(instructions[0].point.x, instructions[0].point.y); var ptMax = new telenavis.Point(instructions[0].point.x, instructions[0].point.y); for (var i = 0; i < instructions.length; i++) { var p = instructions[i].point; ptMin.x = Math.min(p.x, ptMin.x); ptMin.y = Math.min(p.y, ptMin.y); ptMax.x = Math.max(p.x, ptMax.x); ptMax.y = Math.max(p.y, ptMax.y); }
    return { minX: ptMin.x, minY: ptMin.y, maxX: ptMax.x, maxY: ptMax.y };
}
function getFittingZoom(bounds) {
    var hrzMapDistance = myMap.getHorizontalDistance() / 1000; var vrtMapDistance = myMap.getVerticalDistance() / 1000; var hrzRouteDistance = distanceInKm({ x: bounds.minX, y: bounds.minY }, { x: bounds.maxX, y: bounds.minY }); var vrtRouteDistance = distanceInKm({ x: bounds.minX, y: bounds.minY }, { x: bounds.minX, y: bounds.maxY }); var hrzFittingZoom = myMap.getZoom(); if (hrzRouteDistance == hrzMapDistance) { hrzFittingZoom = myMap.getZoom(); }
    else if (hrzRouteDistance > hrzMapDistance) { while (hrzRouteDistance > hrzMapDistance) { hrzMapDistance *= 2; hrzFittingZoom -= 1; } }
    else if (hrzRouteDistance < hrzMapDistance) { while (hrzRouteDistance < hrzMapDistance / 2) { hrzMapDistance /= 2; hrzFittingZoom += 1; } }
    var vrtFittingZoom = myMap.getZoom(); if (vrtRouteDistance == vrtMapDistance) { vrtFittingZoom = myMap.getZoom(); }
    else if (vrtRouteDistance > vrtMapDistance) { while (vrtRouteDistance > vrtMapDistance) { vrtMapDistance *= 2; vrtFittingZoom -= 1; } }
    else if (vrtRouteDistance < vrtMapDistance) { while (vrtRouteDistance < vrtMapDistance / 2) { vrtMapDistance /= 2; vrtFittingZoom += 1; } }
    return Math.min(hrzFittingZoom, vrtFittingZoom) - 1;
}
function CheckRoutingTYpe(type) {
    if (type == 'VEHICLE') { document.getElementById('wlkRadio').checked = false; }
    else if (type == 'PEDESTRIAN') { document.getElementById('vhclRadio').checked = false; } 
}
function getRoutingType() {
    if (document.getElementById('wlkRadio').checked == false) { return telenavis.Router.routeType.VEHICLE; }
    else { return telenavis.Router.routeType.PEDESTRIAN; } 
}
function getavoidedTypes() {
    if (document.getElementById('chkDaktilios').checked && document.getElementById('chkToll').checked) { avoidedTypes = telenavis.Router.avoidedRoadTypes.DAKTILIOS | telenavis.Router.avoidedRoadTypes.TOLL }
    else if (document.getElementById('chkDaktilios').checked) { avoidedTypes = telenavis.Router.avoidedRoadTypes.DAKTILIOS; }
    else if (document.getElementById('chkToll').checked) { avoidedTypes = telenavis.Router.avoidedRoadTypes.TOLL; }
    else { avoidedTypes = ""; } 
}
function CheckStrategyType(type) {
    if (type == 'TIME') { document.getElementById('distanceRadio').checked = false; }
    else if (type == 'DISTANCE') { document.getElementById('timeRadio').checked = false; } 
}
function getStrategyType() {
    if (document.getElementById('distanceRadio').checked == false) { return telenavis.Router.optimizationStrategy.TIME; }
    else { return telenavis.Router.optimizationStrategy.DISTANCE; } 
}
function via(display) {
    document.getElementById('middle').style.display = display; document.getElementById('lblViaPrint').style.display = display; if (document.getElementById('middle').style.display == 'none') { document.getElementById('via').style.display = "block"; document.getElementById('rmvVia').style.display = "none"; var div = document.getElementById("blankVia"); div.innerHTML = ''; }
    else { document.getElementById('via').style.display = "none"; document.getElementById('rmvVia').style.display = "block"; } 
}
function routeKeyPress(e) {
    var browser = navigator.appName; if (browser == "Netscape") {
        e = e ? e : window.event; var end = document.getElementById('EndTbx').value; var start = document.getElementById('StartTbx').value; if (e.keyCode == 13 && end != "" && start != "") { performRouteButton(); return false; }
        else if (e.keyCode == 13) { return false; } 
    }
    else { e = e ? e : window.event; var end = document.getElementById('EndTbx').value; var start = document.getElementById('StartTbx').value; if (e.keyCode == 13 && end != "" && start != "") { performRouteButton(); } } 
}
function compass(a) {
    mapCenter = myMap.getCenter(); screenPos = myMap.screenPosAt(mapCenter); mapZoom = myMap.getZoom(); var mapSize = myMap.getSize(); scrX = mapSize.width / 2; scrY = mapSize.height / 2; var hei = mapSize.height * 0.2; var width = mapSize.width * 0.2; if (a == 1) { screenPos.y = scrY - hei; screenPos.x = scrX; }
    else if (a == 2) { screenPos.x = scrX + width; screenPos.y = scrY; }
    else if (a == 3) { screenPos.x = scrX - width; screenPos.y = scrY; }
    else if (a == 4) { screenPos.y = scrY + hei; screenPos.x = scrX; }
    mapCenter = myMap.worldPosAt(screenPos); myMap.moveTo(mapCenter, mapZoom);
}
function toolbar(a, px) { document.getElementById('Img1').style.top = px; var mapCenter = myMap.getCenter(); myMap.moveTo(mapCenter, a); }
function toolZoom(z) {
    mapZoom = myMap.getZoom(); if ((z == 1) && (mapZoom < 18)) { var mapCenter = myMap.getCenter(); document.getElementById('Img1').style.top = 225 - (mapZoom * 11) + "px"; myMap.moveTo(mapCenter, (mapZoom + 1)); }
    else if ((z == 0) && (mapZoom > 1)) { var mapCenter = myMap.getCenter(); document.getElementById('Img1').style.top = 225 - ((mapZoom - 2) * 11) + "px"; myMap.moveTo(mapCenter, (mapZoom - 1)); }
    else { return; } 
}
function POIsHandling() {
    if (mapZoom > 5) {
        var values = ""; ReInitPOIsLayers(); $("#ContentCheckbox").find("input").each
(function() { if ($(this).attr('checked')) { var id = $(this).attr("value").toString().split(':')[0]; values += id + ","; } }); var points; if (values != "") { values = values.substring(0, values.length - 1); mapbounds = myMap.getViewRect(); $.get("Handler.ashx", { ids: values, x1: mapbounds.x1, x2: mapbounds.x2, y1: mapbounds.y1, y2: mapbounds.y2, mode: "pois" }, function(data) { var arrayItems = data.split(':'); var cat_ids = arrayItems[0].split(','); var images = arrayItems[1].split(','); var infos = arrayItems[2].split(','); var streets = arrayItems[3].split(','); var nos = arrayItems[4].split(','); var regions = arrayItems[5].split(','); var postcodes = arrayItems[6].split(','); var xcos = arrayItems[7].split(','); var ycos = arrayItems[8].split(','); var line = arrayItems[9].split(','); var order = arrayItems[10].split(','); var rowIds = arrayItems[11].split(','); setTimeout(delay, 2000); mapZoom = myMap.getZoom(); ShowPois(cat_ids, images, infos, streets, nos, regions, postcodes, xcos, ycos, mapZoom, line, order, rowIds); }); } 
    } 
}
function ShowPois(cat_ids, images, infos, streets, nos, regions, postcodes, xcos, ycos, mapzoom, line, order, rowId) {
    GeneratePOIsLayers(); var p = new Array(); for (var i = 0; i < xcos.length; i++) { if (xcos[i] != null && ycos[i] != null) { var x = parseFloat(xcos[i]); var y = parseFloat(ycos[i]); p.push(new telenavis.WorldPoint(x, y, telenavis.Projector.WGSSrid)); } }
    if (cat_ids != "") {
        var lines = new Array(); var isap = new Array(); var metro2 = new Array(); var metro3 = new Array(); var suburb4 = new Array(); var suburb6 = new Array(); for (var counter = 0; counter < p.length; counter++) {
            if (cat_ids[counter] == "24") { addresses = "<a target='_blank' href=Assets/Images/SnowMaps/" + streets[counter] + ">Χάρτης Χιονοδρομικού</a>" }
            else { addresses = streets[counter] + " " + nos[counter] + ", <br/>" + regions[counter] + ", " + postcodes[counter]; }
            var tipBalloon = addresses; addPOIsPin(rowId[counter], infos[counter], tipBalloon, p[counter].x, p[counter].y, "Assets/Images/POIs/" + images[counter], MatchLayer(cat_ids[counter] + '_layer'));
        }
        GetPolylinePoints();
    } 
}
function GetSelectedIds() {
    var values = new Array(); $("#ContentCheckbox").find("input").each
(function() { if ($(this).attr('checked')) { values.push($(this).attr("value")); } }); if (values.length > 0) { var Ids = values; var catIds = ""; for (var i = 0; i < Ids.length; i++) { var params = Ids[i].toString().split(':'); catIds += "," + params[0]; } }
    return catIds;
}
function GetPolylinePoints() {
    var ids = GetSelectedIds(); var params = ids.replace(',', ""); $.get("Handler.ashx", { n: params, mode: "polylines" }, function(data) {
        if (data != "") {
            var arrayItems = data.split(':'); var xcos = arrayItems[0].split(','); var ycos = arrayItems[1].split(','); var lines = arrayItems[2].split(','); var catIds = arrayItems[3].split(','); var metro2 = new Array(); var metro3 = new Array(); var isap = new Array(); var tram1 = new Array(); var tram2 = new Array(); for (var i = 0; i < xcos.length; i++) {
                if (xcos[i] != null && ycos[i] != null & lines[i] == 2 && catIds[i] == 5) { var x = parseFloat(xcos[i]); var y = parseFloat(ycos[i]); metro2.push(new telenavis.WorldPoint(x, y, telenavis.Projector.WGSSrid)); }
                if (xcos[i] != null && ycos[i] != null & lines[i] == 3 && catIds[i] == 5) { var x = parseFloat(xcos[i]); var y = parseFloat(ycos[i]); metro3.push(new telenavis.WorldPoint(x, y, telenavis.Projector.WGSSrid)); }
                if (xcos[i] != null && ycos[i] != null & lines[i] == 1 && catIds[i] == 14) { var x = parseFloat(xcos[i]); var y = parseFloat(ycos[i]); isap.push(new telenavis.WorldPoint(x, y, telenavis.Projector.WGSSrid)); }
                if (xcos[i] != null && ycos[i] != null & lines[i] == 1 && catIds[i] == 15) { var x = parseFloat(xcos[i]); var y = parseFloat(ycos[i]); tram1.push(new telenavis.WorldPoint(x, y, telenavis.Projector.WGSSrid)); }
                if (xcos[i] != null && ycos[i] != null & lines[i] == 2 && catIds[i] == 15) { var x = parseFloat(xcos[i]); var y = parseFloat(ycos[i]); tram2.push(new telenavis.WorldPoint(x, y, telenavis.Projector.WGSSrid)); } 
            }
            if (metro2.length > 0) { GeneratePolylines(5, 2, metro2); }
            if (metro3.length > 0) { GeneratePolylines(5, 3, metro3); }
            if (isap.length > 0) { GeneratePolylines(14, 1, isap); }
            if (tram1.length > 0) { GeneratePolylines(15, 1, tram1); }
            if (tram2.length > 0) { GeneratePolylines(15, 2, tram2); } 
        } 
    });
}
function MatchLayer(layerId) {
    var mapLayers = myMap.getLayersArray(); var layer; for (var index in mapLayers) { if (layerId == mapLayers[index].getId()) { layer = mapLayers[index]; } }
    return layer;
}
function GeneratePOIsLayers() {
    var values = new Array(); $("#ContentCheckbox").find("input").each
(function() { if ($(this).attr('checked')) { values.push($(this).attr("value")); } }); if (values.length > 0) {
        var Ids = values; for (var i = 0; i < Ids.length; i++)
        { var params = Ids[i].toString().split(':'); if (myMap.getLayerIndex(params[0] + '_layer') == -1) { var layer = new telenavis.Layer(params[0] + '_layer', 5 + i); layer.minZoom = parseInt(params[1]); layer.maxZoom = 18; myMap.addLayer(layer); } } 
    } 
}
function ClearPOIsLayers(values) {
    var layers = myMap.getLayersArray(); if (values.length > 0) {
        for (var c = layers.length - 1; c >= 0; c--) {
            var id = layers[c].getId(); for (var i = 0; i < values.length; i++)
            { var match = values[i].toString().split(':')[0]; if (id == match + '_layer') { myMap.removeLayer(id); } } 
        } 
    }
    return layers;
}
function ReInitPOIsLayers() {
    var layers = myMap.getLayersArray(); var values = new Array(); $("#ContentCheckbox").find("input").each(function() {
        if ($(this).attr('checked'))
        { values.push(parseInt($(this).attr('value'))); } 
    }); if (values.length > 0) { for (var c = 0; c < layers.length; c++) { var id = layers[c].getId(); for (var i = 0; i < values.length; i++) { var match = values[i].toString().split(':')[0]; if (layers[c].getId() == match + '_layer' && layers[c].getPinsArray().length > 0) { var layerId = match + '_layer'; var geopin = layers[c].getPinsArray(); for (var j = geopin.length - 1; j >= 0; j--) { layers[c].removePin(geopin[j].getId()); } } } } } 
}
function addPOIsPin(id, tip, tipBalloon, x, y, imgPin, layer) { var pin = new telenavis.Pin(id); var floatX = parseFloat(x); var floatY = parseFloat(y); pin.setWorldPos(new telenavis.WorldPoint(floatX, floatY, telenavis.Projector.WGSSrid)); pin.setImageSrc(imgPin); pin.setHotspot(new telenavis.Point(9, 9)); pin.setTip(tip); pin.address = tipBalloon; pin.onClick = POIsBalloon; layer.addPin(pin); }
function addClickEventToPOis() {
    $("#ContentCheckbox").find("input").click(function() {
        if ($(this).attr('checked')) { POIsHandling(); }
        else { var value = new Array(); value.push(parseInt($(this).attr('value'))); ClearPOIsLayers(value); } 
    });
}
function ClearPOIs() {
    var value = new Array(); $("#ContentCheckbox").find("input").each(function() {
        if ($(this).attr('checked'))
        { $(this).attr('checked', false); value.push(parseInt($(this).attr('value'))); } 
    }); ClearPOIsLayers(value);
}
function CheckZoom() {
    mapZoom = myMap.getZoom(); var values = new Array(); $("#ContentCheckbox").find("input").each
(function() {
    values.push($(this).attr("value")); var categories = values; for (var index in categories) {
        var zoom = categories[index].toString().split(':')[1]; if (mapZoom < parseInt(zoom)) { $(this).attr('disabled', true); }
        else { $(this).attr('disabled', false); }
        if (mapZoom < 6) { $(this).attr('disabled', true); ClearPOIs(); } 
    } 
});
}
function GeneratePolylines(cat_id, line, points) {
    var layer = null; if (cat_id == 14 && line == 1) { var IsapPline = new telenavis.Polyline('14_polyline'); IsapPline.setPoints(points); IsapPline.strokeColor = "green"; IsapPline.strokeWidth = "5px"; IsapPline.fillColor = 'none'; IsapPline.fillOpacity = 0; layer = SelectLayer('14_layer'); layer.addPolyline(IsapPline); }
    else if (cat_id == 5 && line == 2) { var Metro2Pline = new telenavis.Polyline('5.2_polyline'); Metro2Pline.setPoints(points); Metro2Pline.strokeColor = "red"; Metro2Pline.strokeWidth = "5px"; Metro2Pline.fillColor = 'none'; Metro2Pline.fillOpacity = 0; layer = SelectLayer('5_layer'); layer.addPolyline(Metro2Pline); }
    else if (cat_id == 5 && line == 3) { var Metro3Pline = new telenavis.Polyline('5.3_polyline'); Metro3Pline.setPoints(points); Metro3Pline.strokeColor = "blue"; Metro3Pline.strokeWidth = "5px"; Metro3Pline.fillColor = 'none'; Metro3Pline.fillOpacity = 0; layer = SelectLayer('5_layer'); layer.addPolyline(Metro3Pline); }
    else if (cat_id == 15 && line == 1) { var Tram1Pline = new telenavis.Polyline('15.1_polyline'); Tram1Pline.setPoints(points); Tram1Pline.strokeColor = "purple"; Tram1Pline.strokeWidth = "5px"; Tram1Pline.fillColor = 'none'; Tram1Pline.fillOpacity = 0; layer = SelectLayer('15_layer'); layer.addPolyline(Tram1Pline); }
    else if (cat_id == 15 && line == 2) { var Tram2Pline = new telenavis.Polyline('15.2_polyline'); Tram2Pline.setPoints(points); Tram2Pline.strokeColor = "purple"; Tram2Pline.strokeWidth = "5px"; Tram2Pline.fillColor = 'none'; Tram2Pline.fillOpacity = 0; layer = SelectLayer('15_layer'); layer.addPolyline(Tram2Pline); }
    else if (cat_id == 16 && line == 1) { var SuburbPline1 = new telenavis.Polyline('16.1_polyline'); SuburbPline1.setPoints(points); SuburbPline1.strokeColor = "black"; SuburbPline1.strokeWidth = "5px"; SuburbPline1.fillColor = 'none'; SuburbPline1.fillOpacity = 0; layer = SelectLayer('16_layer'); layer.addPolyline(SuburbPline1); }
    else if (cat_id == 16 && line == 2) { var SuburbPline2 = new telenavis.Polyline('16.2_polyline'); SuburbPline2.setPoints(points); SuburbPline2.strokeColor = "black"; SuburbPline2.strokeWidth = "5px"; SuburbPline2.fillColor = 'none'; SuburbPline2.fillOpacity = 0; layer = SelectLayer('16_layer'); layer.addPolyline(SuburbPline2); }
    else { return; } 
}
function SelectLayer(layerparam) {
    var mapLayers = myMap.getLayersArray(); var layer; for (var index in mapLayers)
    { if (mapLayers[index].getId() == layerparam) { layer = mapLayers[index]; } }
    return layer;
}
function POIsBalloon(pin) {
    flagBalloon = 1; GetTransportationInfo(pin.getId()); var layer = myMap.getLayersArray()[myMap.getLayerIndex("balloonLayer")]; var info = pin.getTip(); var addr = pin.address; var divBalloon = document.getElementById("divBalloon"); var worldPoint = pin.getWorldPos(); screenPos = myMap.screenPosAt(worldPoint); if (divBalloon != null) { divBalloon.parentNode.removeChild(divBalloon); }
    CreatePOIsBalloon(info, addr, worldPoint, layer);
}
function CreatePOIsBalloon(info, addr, worldPoint, layer) {
    divBalloon = document.createElement("div"); divBalloon.id = 'divBalloon'; divBalloon.className = 'divBalloon'; var Balloonanchor = document.createElement("div"); var img = document.createElement("IMG"); img.id = "imgStart"; img.className = "imgStart"; img.src = "Assets/Images/balloon/bt1.png"; var img2 = document.createElement("IMG"); img2.id = "imgMiddle"; img2.className = "imgMiddle"; img2.src = "Assets/Images/balloon/bb2.png"; img2.onclick = function() { divBalloon.parentNode.removeChild(divBalloon); flagBalloon = 0; }
    var img3 = document.createElement("IMG"); img3.id = "imgEnd"; img3.className = "imgEnd"; img3.src = "Assets/Images/balloon/bt3.png"; var img4 = document.createElement("IMG"); img4.id = "imgLeft"; img4.className = "imgLeft"; img4.src = "Assets/Images/balloon/bl.png"
    var img5 = document.createElement("IMG"); img5.id = "imgBottomStart"; img5.className = "imgBottomStartPois"; img5.src = "Assets/Images/balloon/bb1.png"; var img6 = document.createElement("IMG"); img6.id = "imgBottomMiddle"; img6.className = "imgBottomMiddlePois"; img6.src = "Assets/Images/balloon/bt2.png"; var img7 = document.createElement("IMG"); img7.id = "imgBottomEnd"; img7.className = "imgBottomEndPois"; img7.src = "Assets/Images/balloon/bb3.png"; var img8 = document.createElement("IMG"); img8.id = "imgRight"; img8.className = "imgRight"; img8.src = "Assets/Images/balloon/br.png"
    var img9 = document.createElement("IMG"); img9.id = "img"; img9.className = "imgPois"; img9.src = "Assets/Images/balloon/b1 e 1b.gif"; Balloonanchor.appendChild(img); Balloonanchor.appendChild(img2); Balloonanchor.appendChild(img3); Balloonanchor.appendChild(img4); Balloonanchor.appendChild(img5); Balloonanchor.appendChild(img6); Balloonanchor.appendChild(img7); Balloonanchor.appendChild(img8); Balloonanchor.appendChild(img9); var divAll = document.createElement("div"); divAll.id = 'divAll'; divAll.className = 'divAll'; Balloonanchor.appendChild(divAll); var divRoute = document.createElement("div"); divRoute.id = 'divRoute'; divRoute.className = 'divRoute'; divAll.appendChild(divRoute); var divTip = document.createElement("span"); divTip.id = 'divTip'; divTip.className = 'divTip'; divTip.innerHTML = "<strong>" + info; divTip.innerHTML += "<br>" + addr; divRoute.appendChild(divTip); var br = document.createElement("br"); var divMitsos = document.createElement("div"); divMitsos.id = 'divMitsos'; divMitsos.className = 'divMitsos'; var divDrive = document.createElement("div"); divDrive.id = 'divDrive'; divDrive.className = 'divDrive'; divDrive.appendChild(document.createTextNode(" ΔΡΟΜΟΛΟΓΗΣΗ")); var divFrom = document.createElement("a"); divFrom.id = 'divFrom'; divFrom.className = 'divFrom'; divFrom.appendChild(document.createTextNode(" ΑΠΟ")); divFrom.href = "#"; divFrom.onclick = function() { routestartclick(worldPoint.x, worldPoint.y); }
    var divTo = document.createElement("a"); divTo.id = 'divTo'; divTo.className = 'divTo'; divTo.appendChild(document.createTextNode(" ΠΡΟΣ")); divTo.href = "#"; divTo.onclick = function() { routeendclick(worldPoint.x, worldPoint.y); }
    divMitsos.appendChild(divDrive); divMitsos.appendChild(divFrom); divMitsos.appendChild(divTo); divRoute.appendChild(divMitsos); Balloonanchor.appendChild(divRoute); divBalloon.appendChild(Balloonanchor); divBalloon.appendChild(br); layer.getDiv().appendChild(divBalloon); var a = divBalloon.clientHeight; a = a + 31; divBalloon.style.left = screenPos.x - 25 + "px"; divBalloon.style.top = screenPos.y - a + "px";
}
function cleanPage() {
    ClearPins(); ClearPolylines(); ClearRouteSteps(); ClearPOIs(); ptStart = null; ptEnd = null; ptMiddle = null; actionFlag = 0; document.getElementById('Tip').style.display = 'block'; if (flagBalloon) { var divBalloon = document.getElementById('divBalloon'); divBalloon.parentNode.removeChild(divBalloon); flagBalloon = 0; }
    if (flagContext) { document.getElementById('divContextMenu').style.display = 'none'; flagContext = 0; }
    document.getElementById('StartTbx').value = ""; document.getElementById('MiddleTbx').value = ""; document.getElementById('EndTbx').value = ""; document.getElementById('RouteSummary').style.display = "none"; $("#RouteSummaryP").html("<div id='TimeDistanceP' style='padding-bottom:30px;'><table id='TimeDateP' width='100%' style='display:none;' ><tbody><tr class='totalTime'><td>Συνολικός Χρόνος:</td><td style='font-weight:bold;'><span id='spnTimeP' style='margin-right:620px;'></span></td></tr><tr class='totalDistance'><td>Συνολική Απόσταση:</td><td style='font-weight:bold;'><span id='spnDistanceP'></span></td></tr></tbody></table></div><div id='RouteStepsP' style='display:none;'><table id='InstructionsP'><tbody><tr class='instruction'><td>Οδηγίες Δρομολόγησης:</td></tr><tr class='routeDirections'><td><span id='spnDirectionsP' class='listDirections'><br /></span></td></tr></tbody></table></div>"); document.getElementById('RouteSummaryP').style.display = "none"; locations = ""; document.getElementById('SLOCTbx').value = ""; document.getElementById('SLOCTbx1').value = ""; document.getElementById('geocode').innerHTML = ""; document.getElementById('Candidates').innerHTML = ""; document.getElementById('lblGeocodePrint').style.display = "none"; document.getElementById('lblFromPrint').style.display = "none"; document.getElementById('lblViaPrint').style.display = "none"; document.getElementById('lblToPrint').style.display = "none"; document.getElementById('TimeDate').style.display = "none"; document.getElementById('Instructions').style.display = "none"; if (document.getElementById('lblGeocode') != null) { document.getElementById('lblGeocode').style.display = "none"; }
    if (document.getElementById('lblFrom') != null) { document.getElementById('lblFrom').value = ""; }
    if (document.getElementById('lblVia') != null) { document.getElementById('lblVia').value = ""; }
    if (document.getElementById('lblTo') != null) { document.getElementById('lblTo').value = ""; }
    document.getElementById('MessageTbx').value = ""; document.getElementById('EmailTbx').value = ""; document.getElementById('LocRoute').style.display = 'none'; via('none'); leftMenuHeight();
}
function reverseRoute() { if (document.getElementById("StartTbx").value != "" || document.getElementById("EndTbx").value != null) { var start = document.getElementById("StartTbx").value; var end = document.getElementById("EndTbx").value; document.getElementById("StartTbx").value = end; document.getElementById("EndTbx").value = start; if (start != "" && end != "") { performRouteButton(); } } }
function SetLocRoute(loc) {
    document.getElementById('StartTbx').value = ""; document.getElementById('MiddleTbx').value = ""; document.getElementById('EndTbx').value = ""; if (loc == "start") { document.getElementById('StartTbx').value = document.getElementById('SLOCTbx').value; }
    else if (loc == "middle") { document.getElementById('MiddleTbx').value = document.getElementById('SLOCTbx').value; via('block'); }
    else { document.getElementById('EndTbx').value = document.getElementById('SLOCTbx').value; }
    openRouting();
}
function roundTrip() { if (document.getElementById('EndTbx').value != document.getElementById('StartTbx').value) { document.getElementById('MiddleTbx').value = document.getElementById('EndTbx').value; via('block'); document.getElementById('EndTbx').value = document.getElementById('StartTbx').value; performRouteButton(); } }
function GetTransportationInfo(id) { $.ajax({ type: "POST", url: "Handler.ashx", data: ({ id: id, mode: "tnf" }), success: function(data) { } }); }