﻿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 ptLoc = null; var totaltime = null; var totaldistance = null; var routeInstructions = null; var routePoints = null; var centerX = null; var centerY = null; var routingType = null; var strategyType = 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 routing = null; var strategy = null; var daktilios = 0; var toll = 0; var middle = 0; var iframe = ""; var height = document.documentElement.clientHeight; var headerHeight = 75; var menuHeight = 0; var footerHeight = 0; 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' }); $('#costEstmation.scroll').css({ overflow: 'auto', maxHeight: '540px' }); 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]; address = decodeURIComponent(address); for (var i = 0; i <= 150; i++) { address = address.replace('+', ' '); } }
    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(); }
        initialize(); if (QueryString.split('&').length == 3) { var loc = QueryString.split('&')[2]; locY = parseFloat(loc.split(':')[0]); locX = parseFloat(loc.split(':')[1]); if (loc != "Dak") { 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 (loc.split('%20')[2] != undefined) { var c = loc.split('%20')[2].toString(); var d = loc.split('%20')[3].toString(); var e = loc.split('%20')[4].toString(); locTip = locTip + " " + c + " " + d + " " + e; } } }
        if (QueryString.split('&').length > 3) {
            var start = QueryString.split('&')[2]; startY = parseFloat(start.split(':')[0]); startX = parseFloat(start.split(':')[1]); startPt = startX + ":" + startY; addPin(0, "Αφετηρία", startX, startY, 'Assets/Images/routeStart.png', pinsLayer); var end = QueryString.split('&')[3]; endY = parseFloat(end.split(':')[0]); endX = parseFloat(end.split(':')[1]); endPt = endX + ":" + endY; addPin(1, "Προορισμός", endX, endY, 'Assets/Images/routeEnd.png', pinsLayer); if (QueryString.split('&').length > 4) {
                var i = 4; var element = QueryString.split('&')[i]; var startelem = element.substring(1, 0); if (startelem == 3) { var via = QueryString.split('&')[4]; viaY = parseFloat(via.split(':')[0]); viaX = parseFloat(via.split(':')[1]); ptMiddle = new telenavis.WorldPoint(viaX, viaY, telenavis.Projector.WGSSrid); viaPt = viaX + ":" + viaY; middle = 1; i += 1; addPin(2, "Ενδιάμεσος Προορισμός", viaX, viaY, 'Assets/Images/routeMiddle.png', pinsLayer); }
                if (QueryString.split('&')[i] == 'ped') { routing = 'pedestrian'; i = i + 1; }
                if (QueryString.split('&')[i] == 'dis') { strategy = 'distance'; i = i + 1; }
                if (QueryString.split('&')[i] == 'Dak') { daktilios = 1; getavoidedTypesLink(); i = i + 1; }
                if (QueryString.split('&')[i] == 'Toll') { toll = 1; getavoidedTypesLink(); i = i + 1; } 
            }
            GetRoute();
        }
        if (locTip != null) { locTip = urldecode(locTip); }
        if (QueryString.split('&').length == 3) { initialize(); route(); addPin('locPin', locTip, locX, locY, 'Assets/Images/pinFinal.gif', pinsLayer); }
        else if (address != null) { centerX = 23.72631435; centerY = 37.97507208; centerZoom = 6; initialize(); route(); LocationSearch(address); } 
    }
    else { centerX = 23.72631435; centerY = 37.97507208; centerZoom = 6; initialize(); } 
}
function urldecode(str) {
    var hash_map = {}, ret = str.toString(), unicodeStr = '', hexEscStr = ''; var replacer = function(search, replace, str) { var tmp_arr = []; tmp_arr = str.split(search); return tmp_arr.join(replace); }; hash_map["'"] = '%27'; hash_map['('] = '%28'; hash_map[')'] = '%29'; hash_map['*'] = '%2A'; hash_map['~'] = '%7E'; hash_map['!'] = '%21'; hash_map['%20'] = '+'; hash_map['\u0391'] = '%C1'; hash_map['\u0392'] = '%C2'; hash_map['\u0393'] = '%C3'; hash_map['\u0394'] = '%C4'; hash_map['\u0395'] = '%C5'; hash_map['\u0396'] = '%C6'; hash_map['\u0397'] = '%C7'; hash_map['\u0398'] = '%C8'; hash_map['\u0399'] = '%C9'; hash_map['\u039A'] = '%CA'; hash_map['\u039B'] = '%CB'; hash_map['\u039C'] = '%CC'; hash_map['\u039D'] = '%CD'; hash_map['\u039E'] = '%CE'; hash_map['\u039F'] = '%CF'; hash_map['\u03A0'] = '%D0'; hash_map['\u03A1'] = '%D1'; hash_map['\u03A2'] = '%D2'; hash_map['\u03A3'] = '%D3'; hash_map['\u03A4'] = '%D4'; hash_map['\u03A5'] = '%D5'; hash_map['\u03A6'] = '%D6'; hash_map['\u03A7'] = '%D7'; hash_map['\u03A8'] = '%D8'; hash_map['\u03A9'] = '%D9'; hash_map['\u03B1'] = '%E1'; hash_map['\u03B2'] = '%E2'; hash_map['\u03B3'] = '%E3'; hash_map['\u03B4'] = '%E4'; hash_map['\u03B5'] = '%E5'; hash_map['\u03B6'] = '%E6'; hash_map['\u03B7'] = '%E7'; hash_map['\u03B8'] = '%E8'; hash_map['\u03B9'] = '%E9'; hash_map['\u03BA'] = '%EA'; hash_map['\u03BB'] = '%EB'; hash_map['\u03BC'] = '%EC'; hash_map['\u03BD'] = '%ED'; hash_map['\u03BE'] = '%EE'; hash_map['\u03BF'] = '%EF'; hash_map['\u03C0'] = '%F0'; hash_map['\u03C1'] = '%F1'; hash_map['\u03C2'] = '%F2'; hash_map['\u03C3'] = '%F3'; hash_map['\u03C4'] = '%F4'; hash_map['\u03C5'] = '%F5'; hash_map['\u03C6'] = '%F6'; hash_map['\u03C7'] = '%F7'; hash_map['\u03C8'] = '%F8'; hash_map['\u03C9'] = '%F9'; hash_map['\u0384'] = '%B4'; hash_map['\u0385'] = '%B5'; hash_map['\u0386'] = '%B6'; hash_map['\u0387'] = '%B7'; hash_map['\u0388'] = '%B8'; hash_map['\u0389'] = '%B9'; hash_map['\u038A'] = '%BA'; hash_map['\u038C'] = '%BC'; hash_map['\u038E'] = '%BE'; hash_map['\u038F'] = '%BF'; hash_map['\u03AC'] = '%DC'; hash_map['\u03AD'] = '%DD'; hash_map['\u03AE'] = '%DE'; hash_map['\u03AF'] = '%DF'; hash_map['\u03CC'] = '%FC'; hash_map['\u03CD'] = '%FD'; hash_map['\u03CE'] = '%FE'; hash_map['<'] = '%3C'; hash_map['>'] = '%3E'; hash_map['/'] = '%2F'; hash_map['@'] = '%40'; hash_map['e'] = '%E9'; hash_map[' '] = '%20'; for (unicodeStr in hash_map) { hexEscStr = hash_map[unicodeStr]; ret = replacer(hexEscStr, unicodeStr, ret); }
    ret = decodeURIComponent(unescape(ret)); return ret;
}
function initialize() {
    telenavis.constants.showAllPins = true; 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(); document.getElementById('map_cross').style.display = 'none'; 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 {
        if (totaldistance.toString().split(".")[1] > 2) { distance = totaldistance.toString().split('.')[0] + ',' + totaldistance.toString().split('.')[1].substring(0, 2) + ' μέτρα'; }
        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 != '') { LocationSearch(this.value); return false; }
        else if (e.keyCode == 13) { return false; } 
    }
    else { e = e ? e : window.event; if (e.keyCode == 13 && this.value != '') { LocationSearch(this.value); } } 
}
function resizeMap() { myMap.resize(); }
function resizeMapDiv() {
    var height = document.documentElement.clientHeight; var width = document.documentElement.clientWidth; var menuWidth = 270; var headerHeight = 75; var menuHeight = 0; var footerHeight = 0; var height = document.documentElement.clientHeight; var width = document.documentElement.clientWidth; var height2 = (calculatedHeight - 105 - (6 * 26)) + 'px'; var calculatedHeight = height - (headerHeight + menuHeight + footerHeight) - 1; 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('Tip').style.display = 'block'; }
    if (calculatedHeight < 450) { document.getElementById('divMap').style.height = (calculatedHeight + 20) + 'px'; document.getElementById('menuTest').style.height = calculatedHeight + 'px'; document.getElementById('MenuPnl').style.height = calculatedHeight + 'px'; document.getElementById('Tip').style.display = 'none'; document.getElementById('footerLeft').style.display = 'none'; }
    else { document.getElementById('footerLeft').style.display = 'block'; document.getElementById('footerLeft').style.bottom = '0px'; document.getElementById('Tip').style.bottom = '20px'; }
    if (calculatedHeight < 620) { document.getElementById('divMap').style.height = calculatedHeight + 'px'; document.getElementById('menuTest').style.height = calculatedHeight + 'px'; document.getElementById('MenuPnl').style.height = calculatedHeight + 'px'; document.getElementById('Tip').style.display = 'none'; }
    if (calculatedHeight < 550) { document.getElementById('Tip').style.display = 'none'; }
    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(); positionPans();
}
function positionPans() { var height = document.documentElement.clientHeight; var width = document.documentElement.clientWidth; var menuWidth = 270; var headerHeight = 75; var menuHeight = 0; var footerHeight = 0; var calculatedHeight = height - (headerHeight + menuHeight + footerHeight) - 1; var calculatedWidth = $("#divMap").width(); document.getElementById('Up').style.width = calculatedWidth + "px"; document.getElementById('Down').style.width = calculatedWidth + "px"; document.getElementById('Right').style.height = calculatedHeight + "px"; document.getElementById('Left').style.height = calculatedHeight + "px"; document.getElementById('panUp').style.top = 7 + 'px'; document.getElementById('panUp').style.left = (calculatedWidth / 2) + 'px'; document.getElementById('panDown').style.bottom = 7 + 'px'; document.getElementById('panDown').style.left = (calculatedWidth / 2) + 'px'; document.getElementById('panRight').style.top = (calculatedHeight / 2) - 25 + 'px'; document.getElementById('panRight').style.left = 1 + 'px'; document.getElementById('panLeft').style.top = (calculatedHeight / 2) - 25 + 'px'; document.getElementById('panLeft').style.left = 7 + 'px'; }
function calculateMenuHeight() { return $('#menuTest').css('height'); }
function leftMenuHeight() {
    var height = document.documentElement.clientHeight; var width = document.documentElement.clientWidth; var menuWidth = 270; var headerHeight = 75; var menuHeight = 0; var footerHeight = 0; var height2 = (calculatedHeight - 90 - (4 * 26)) + 'px'; var calculatedHeight = height - (headerHeight + menuHeight + footerHeight) - 1; var ContentHeight = 0; var tipHeight = 105; 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 - 6 * 23 - tipHeight); }
                    ContentHeight = totalHeight;
                }
                else { $(this).css({ 'height': 'auto' }); ContentHeight = $(this).height(); } 
            }
            catch (e) { } 
        } 
    }); return ContentHeight + 6 * 23 + 105;
}
function adjustMenu() {
    var menuWidth = 270; var width = document.documentElement.clientWidth; if ($('#menuTest').height() < leftMenuHeight()) {
        var tipHeight = 105; if (!$('#Tip').is(':visible')) { tipHeight = 0; }
        var targetValue = $('#menuTest').height() - 6 * 23 - 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(); setTimeout(POIsHandling, 30); 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); var draggable = pin.draggable(); draggable = !draggable; pin.draggable(draggable); pin.setWorldPos(new telenavis.WorldPoint(floatX, floatY, telenavis.Projector.WGSSrid)); pin.setImageSrc(imgPin); pin.setHotspot(new telenavis.Point(18, 21)); pin.setTip(tip); if ((tip != 'Αφετηρία') && (tip != 'Προορισμός') && (tip != 'Μέσω')) { pin.setHotspot(new telenavis.Point(18, 29)); pin.onClick = Balloon; }
    pin.addEventListener(telenavis.Pin.events.DRAG_COMPLETE, Drag); 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) {
    var divBalloon = document.createElement('div'); divBalloon.id = 'divBalloon'; divBalloon.className = 'divBalloon'; divBalloon.style.left = screenPos.x - 145 + 'px'; divBalloon.style.top = screenPos.y - 108 + 'px'; var tableBalloon = document.createElement('table'); tableBalloon.id = 'top'; tableBalloon.setAttribute("cellSpacing", "0"); tableBalloon.setAttribute("cellPadding", "0"); var tbodyTable = document.createElement('tbody'); var firstTrTable = document.createElement('tr'); var divTipTd = document.createElement('td'); divTipTd.id = 'divTip'; var closeBalloonSpan = document.createElement('span'); closeBalloonSpan.id = 'closeBalloon'; closeBalloonSpan.onclick = function() { divBalloon.parentNode.removeChild(divBalloon); flagBalloon = 0; }
    var addressSpan = document.createElement('span'); addressSpan.id = 'address'; addressSpan.appendChild(document.createTextNode(addr)); var rightShadowRepeatTd = document.createElement('td'); rightShadowRepeatTd.id = 'rightShadowRepeat'; var secondTrTable = document.createElement('tr'); var divRouteTd = document.createElement('td'); divRouteTd.id = 'divRoute'; var divDriveSpan = document.createElement('span'); divDriveSpan.id = 'divDrive'; divDriveSpan.appendChild(document.createTextNode('Δρομολόγηση')); var divFrom = document.createElement('a'); divFrom.id = 'divFrom'; divFrom.appendChild(document.createTextNode('Από')); divFrom.href = '#'; divFrom.onclick = function() { openRouting(); routestartclick(worldPoint.x, worldPoint.y, addr); }
    var divMiddle = document.createElement('a'); divMiddle.id = 'divMiddle'; divMiddle.appendChild(document.createTextNode('Μέσω')); divMiddle.href = '#'; divMiddle.onclick = function() { openRouting(); routemiddleclick(worldPoint.x, worldPoint.y, addr); }
    var divTo = document.createElement('a'); divTo.id = 'divTo'; divTo.appendChild(document.createTextNode('Προς')); divTo.href = '#'; divTo.onclick = function() { openRouting(); routeendclick(worldPoint.x, worldPoint.y, addr); }
    var rightShadowTd = document.createElement('td'); rightShadowTd.id = 'rightShadow'; var thirdTrTable = document.createElement('tr'); var bottomTd = document.createElement('td'); bottomTd.id = 'bottom'; bottomTd.setAttribute("colSpan", "2"); var divbottomInner = document.createElement('div'); divbottomInner.id = 'bottomInner'; thirdTrTable.appendChild(bottomTd); divRouteTd.appendChild(divDriveSpan); divRouteTd.appendChild(divFrom); divRouteTd.appendChild(divMiddle); divRouteTd.appendChild(divTo); secondTrTable.appendChild(divRouteTd); secondTrTable.appendChild(rightShadowTd); divTipTd.appendChild(closeBalloonSpan); divTipTd.appendChild(addressSpan); firstTrTable.appendChild(divTipTd); firstTrTable.appendChild(rightShadowRepeatTd); tbodyTable.appendChild(firstTrTable); tbodyTable.appendChild(secondTrTable); tbodyTable.appendChild(thirdTrTable); tableBalloon.appendChild(tbodyTable); divBalloon.appendChild(tableBalloon); divBalloon.appendChild(divbottomInner); 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 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 ToggleRoot(bool) {
    if (typeof (bool) == 'undefined') { ToggleRoot(false); ; }
    document.getElementById('RouteBtn').disabled = bool;
}
function handleClick(x, y, addr) { ptLoc = new telenavis.WorldPoint(x, y, telenavis.Projector.WGSSrid); myMap.moveTo(ptLoc, 16); document.getElementById('SLOCTbx').value = addr; addPin('locPin', addr, x, y, 'Assets/Images/pinFinal.gif', pinsLayer); document.getElementById('LocRoute').style.display = 'block'; actionFlag = 1; }
function callbackGeoStart(resp, obj) { switch (resp.ResponseCode) { case 0: document.getElementById('StartTbx').value = 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) { switch (resp.ResponseCode) { case 0: document.getElementById('MiddleTbx').value = 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; 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"; CheckRoutingTYpe($('#Transportation').attr('value')); 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/routeStart.png', RouteLayer); if ((document.getElementById('middle').style.display == 'block') || ptMiddle != null) { points.push(ptMiddle); addPin("ViaPin", "Μέσω", ptMiddle.x, ptMiddle.y, 'Assets/Images/routeMiddle.png', RouteLayer); }
        points.push(ptEnd); addPin("EndPin", "Προορισμός", ptEnd.x, ptEnd.y, 'Assets/Images/routeEnd.png', RouteLayer); router.getRoute(points, strategyType, routingType, "el-GR", 8, avoidedTypes);
    } 
}
function callbackroute(resp) {
    var width = document.documentElement.clientWidth; var height = document.documentElement.clientHeight; var menuWidth = 270; var headerHeight = 75; var menuHeight = 0; var footerHeight = 0; var calculatedHeight = height - (headerHeight + menuHeight + footerHeight) - 1; if (resp.getRouteResults().ResponseCode == 1) {
        if (avoidedTypes == 1) { alert(' Η δρομολόγηση που ζητήσατε είναι αδύνατη! Επιλέξατε δρομολόγηση εντός Δακτυλίου, αλλά με ταυτόχρονη αποφυγή Δακτυλίου! Παρακαλώ προσπαθήστε ξανά αλλάζοντας τις επιλογές σας. '); }
        else if (avoidedTypes == 2) { alert(' Η δρομολόγηση που ζητήσατε δεν είναι εφικτή με αποφυγή των Διοδίων! Παρακαλώ προσπαθήστε ξανά αλλάζοντας τις επιλογές σας. '); }
        else if (avoidedTypes == 3) { alert(' Η δρομολόγηση που ζητήσατε δεν είναι εφικτή με ταυτόχρονη αποφυγή Δακτυλίου και Διοδίων! Παρακαλώ προσπαθήστε ξανά αλλάζοντας τις επιλογές σας. '); }
        else { 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" }); }
        var Time = resp.getRouteResults().TotalMinutes / 60; totaltime = convertMinutesToHours(resp.getRouteResults().TotalMinutes); document.getElementById('spnTime').innerHTML = totaltime; totaldistance = convertToKm(resp.getRouteResults().TotalDistance); document.getElementById('spnDistance').innerHTML = totaldistance; var polyline = resp.getPolyline('routePolyline'); polyline.strokeColor = "#0468ff"; polyline.strokeWidth = "5px"; polyline.fillColor = 'none'; polyline.fillOpacity = 0.1; RouteLayer.addPolyline(polyline); routeInstructions = resp.getRouteInstructions(); routePoints = resp.getRoutePoints(); GetTollStations(); var directions = ""; directions = "<ol>"; var length = routeInstructions.length; var doubleX = new Array(23.815543, 23.949885, 23.9801905, 23.849903, 23.874138, 23.8423, 23.744713, 23.530727, 23.509762, 23.496746, 23.490399); var doubleY = new Array(37.822632, 37.833809, 38.0182934, 38.114334, 38.136164, 38.137315, 38.136193, 38.075869, 38.072282, 38.043648, 38.030377); for (var j = 0; j < 11; j++) { for (var i = 0; i < routePoints.length; i++) { if ((routePoints.x == doubleX[j]) && (routePoints[i].y == doubleY[j])) { var dist = routePoints[i].distanceTo(routeInstructions[length - 1].point); convertToKm(dist); } } }
        for (var i = 0; i < length; i++) { var pt = routeInstructions[i].point; directions += "<li><a onclick='zoomTo(" + pt.x.toString() + "," + pt.y.toString() + ", 16);'>" + routeInstructions[i].directions.replace(routeInstructions[i].roadName, "<strong>" + routeInstructions[i].roadName + "</strong>") + "</a></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; 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 performRouteButton() {
    document.getElementById('ddlRadioTaxi').value = 0; document.getElementById('ddlLuggage').value = 0
    document.getElementById('Candidates').innerHTML = ""; document.getElementById('Tip').style.display = 'none'; ptStart = null; ptMiddle = null; ptEnd = null; ClearRouteSteps(); ClearPolylines(); ClearPins(); var a = findOpen(); if (a == 1) { PerformRoute(); }
    if (flagBalloon == 1) { document.getElementById('divBalloon').style.display = 'none'; }
    if (flagContext == 1) { document.getElementById('divOuterContextMenu').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 = 105; if (!$("#Tip").is(":visible")) { tipHeight = 0; }
        $("#routeTest").height(calculatedHeight - 6 * 23 - 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 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('divOuterContextMenu').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 divOuterContextMenu = document.getElementById('divOuterContextMenu'); if (divOuterContextMenu != null) { divOuterContextMenu.parentNode.removeChild(divOuterContextMenu); }
    divOuterContextMenu = document.createElement("div"); divOuterContextMenu.id = 'divOuterContextMenu'; divOuterContextMenu.className = 'divOuterContextMenu'; divOuterContextMenu.style.left = mapPosition[0] + screenPoint.x + "px"; divOuterContextMenu.style.top = mapPosition[1] + screenPoint.y + "px"; divContextMenu = document.createElement("div"); divContextMenu.id = 'divContextMenu'; divContextMenu.className = 'divContextMenu'; var Startanchor = document.createElement("a"); Startanchor.appendChild(document.createTextNode("Δρομολόγηση Από Εδώ")); Startanchor.href = "#"; Startanchor.onclick = function() { routestartclick(worldPoint.x, worldPoint.y, ""); }
    var br = document.createElement("br"); var br = document.createElement("br"); var Middleanchor = document.createElement("a"); Middleanchor.appendChild(document.createTextNode("Δρομολόγηση Μέσω Εδώ")); Middleanchor.href = "#"; Middleanchor.onclick = function() { routemiddleclick(worldPoint.x, worldPoint.y, ""); }
    var Endanchor = document.createElement("a"); 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 MiddleSpan = document.createElement("span"); MiddleSpan.id = 'middlecontainer'; MiddleSpan.className = 'middlecontainer'; var EndSpan = document.createElement("span"); EndSpan.id = 'endcontainer'; EndSpan.className = 'endcontainer'; divOuterContextMenu.appendChild(divContextMenu); divContextMenu.appendChild(StartSpan); StartSpan.appendChild(Startanchor); divContextMenu.appendChild(MiddleSpan); MiddleSpan.appendChild(Middleanchor); divContextMenu.appendChild(EndSpan); EndSpan.appendChild(Endanchor); document.body.appendChild(divOuterContextMenu);
}
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 via(display) {
    document.getElementById('middle').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() {
    var counters; if (mapZoom > 5) {
        var values = ""; ReInitPOIsLayers(); $("#ContentCheckbox").find("a").each(function() { if ($(this).attr('name') != '') { if ($(this).attr('name') == 'selected') { var id = $(this).attr("href").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, zoom: mapZoom, 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(','); var zoomLimits = arrayItems[12].split(','); var val = values.split(','); setTimeout(delay, 2000); mapZoom = myMap.getZoom(); var counterdata = ""; var c = 0; var incr = 0; for (var i = 0; i < val.length; i++) {
                    for (var j = 0; j < cat_ids.length; j++) { if (cat_ids[j] == val[i]) { incr++; } }
                    counterdata += val[i] + ":" + (incr) + ","; incr = 0;
                }
                counterdata = counterdata.substring(0, counterdata.length - 1); counters = counterdata.split(','); for (var index in counters) {
                    var catvalues = counters[index].split(':'); var num = parseInt(catvalues[1]); if (num > 0 && num < 100 && catvalues[0] != 'undefined') { $('#counter' + catvalues[0]).text('(' + num + ') '); }
                    else if (catvalues[0] == 'undefined' || num == 0) { $('#counter' + val[index]).text('(0) '); }
                    else { $('#counter' + catvalues[0]).text('(100+) '); } 
                }
                ShowPois(cat_ids, images, infos, streets, nos, regions, postcodes, xcos, ycos, mapZoom, line, order, rowIds, zoomLimits);
            });
        } 
    } 
}
function ShowPois(cat_ids, images, infos, streets, nos, regions, postcodes, xcos, ycos, mapzoom, line, order, rowId, zoomLimits) {
    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] == "18") { 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; if ((parseInt(zoomLimits[counter].split('-')[0]) - 1) < mapZoom) { addPOIsPin(rowId[counter], infos[counter], tipBalloon, p[counter].x, p[counter].y, "Assets/Images/POIs/" + images[counter], MatchLayer(cat_ids[counter] + '_layer')); }
            else { $('#counter' + cat_ids[counter]).text('(100+) '); } 
        }
        GetPolylinePoints();
    } 
}
function GetSelectedIds() {
    var values = new Array(); $("#ContentCheckbox").find("a").each(function() { if ($(this).attr('name') == 'selected') { values.push($(this).attr("href")); } }); 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] == 43) { 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] == 43) { 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] == 42) { 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] == 44) { 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] == 44) { 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(43, 2, metro2); }
            if (metro3.length > 0) { GeneratePolylines(43, 3, metro3); }
            if (isap.length > 0) { GeneratePolylines(42, 1, isap); }
            if (tram1.length > 0) { GeneratePolylines(44, 1, tram1); }
            if (tram2.length > 0) { GeneratePolylines(44, 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("a").each(function() { if ($(this).attr('name') == 'selected') { values.push($(this).attr("href")); } }); 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') { layers[c].clear(); } } } }
    return layers;
}
function ReInitPOIsLayers() { var layers = myMap.getLayersArray(); var values = new Array(); $("#ContentCheckbox").find("a").each(function() { if ($(this).attr('name') == 'selected') { values.push(parseInt($(this).attr('href'))); } }); 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("a").each(function() {
        if ($(this).attr('class') != 'category') {
            $(this).click(function() {
                if ($(this).attr('name') == 'empty') { $(this).attr('name', 'selected'); POIsHandling(); CheckImages(); }
                else if ($(this).attr('name') == 'selected') { $(this).attr('name', 'empty'); var value = new Array(); value.push(parseInt($(this).attr('href').toString().split(':')[0])); $(this).find('label').text(''); ClearPOIsLayers(value); CheckImages(); } 
            })
        } 
    });
}
function CheckImages() {
    $("#ContentCheckbox").find("a").each(function() {
        if ($(this).attr('class') != 'category') {
            if ($(this).attr("name") == 'empty') { var myid = $(this).attr("id"); $(this).css({ "background-position": shapesData[myid][0][0] + "px " + shapesData[myid][0][1] + "px" }); $(this).find("span.poisImg").css({ "background-position": shapesData[myid][0][0] + "px " + shapesData[myid][0][1] + "px" }); $(this).find(".poisText").css({ color: "#000000" }); $(this).find(".numPois").css({ color: "#000000" }); }
            else if ($(this).attr("name") == 'selected') { var myid = $(this).attr("id"); $(this).css({ "background-position": shapesData[myid][0][0] + "px " + shapesData[myid][0][1] + "px" }); $(this).find("span.poisImg").css({ "background-position": shapesData[myid][1][0] + "px " + shapesData[myid][1][1] + "px" }); $(this).find(".poisText").css({ color: "#f70004" }); $(this).find(".numPois").css({ color: "#f70004" }); } 
        } 
    });
}
function unsetPOIsHandlers() { $(".poisContent a.selectedPoisLink").each(function(i) { var myid = $(this).attr("id"); $(this).find("span.poisImg").css({ "background-position": shapesData[myid][0][0] + "px " + shapesData[myid][0][1] + "px" }); $(this).removeClass("selectedPoisLink"); $(this).find(".poisText").css({ color: "#000000" }); $(this).find(".numPois").css({ color: "#000000" }); }); $(".msg_body").hide(); $(".selectedPois").removeClass("selectedPois"); }
function ClearPOIs() { var value = new Array(); unsetPOIsHandlers(); $("#ContentCheckbox").find("a").each(function() { if ($(this).attr('class') != 'category') { var myid = $(this).attr("id"); $(this).attr('name', 'empty'); value.push(parseInt($(this).attr('href').toString().split(':')[0])); var cat_id = $(this).attr('href').toString().split(':')[0]; $("#ContentCheckbox").find("label").each(function() { if ($(this).attr('id') == 'counter' + cat_id) { $(this).text(''); } }); } }); ClearPOIsLayers(value); }
function CheckZoom() {
    mapZoom = myMap.getZoom(); var values = new Array(); $("#ContentCheckbox").find("a").each(function() {
        if ($(this).attr("name") == 'empty' || $(this).attr("name") == 'selected') { values.push($(this).attr("href")); }
        var categories = values; for (var index in categories) { if (mapZoom < 6) { $(this).attr('disabled', true); } } 
    }); if (mapZoom < 6) { ClearPOIs(); } 
}
function GeneratePolylines(cat_id, line, points) {
    var layer = null; if (cat_id == 42 && line == 1) { var IsapPline = new telenavis.Polyline('42_polyline'); IsapPline.setPoints(points); IsapPline.strokeColor = "green"; IsapPline.strokeWidth = "5px"; IsapPline.fillColor = 'none'; IsapPline.fillOpacity = 0; layer = SelectLayer('42_layer'); layer.addPolyline(IsapPline); }
    else if (cat_id == 43 && line == 2) { var Metro2Pline = new telenavis.Polyline('43.2_polyline'); Metro2Pline.setPoints(points); Metro2Pline.strokeColor = "red"; Metro2Pline.strokeWidth = "5px"; Metro2Pline.fillColor = 'none'; Metro2Pline.fillOpacity = 0; layer = SelectLayer('43_layer'); layer.addPolyline(Metro2Pline); }
    else if (cat_id == 43 && line == 3) { var Metro3Pline = new telenavis.Polyline('43.3_polyline'); Metro3Pline.setPoints(points); Metro3Pline.strokeColor = "blue"; Metro3Pline.strokeWidth = "5px"; Metro3Pline.fillColor = 'none'; Metro3Pline.fillOpacity = 0; layer = SelectLayer('43_layer'); layer.addPolyline(Metro3Pline); }
    else if (cat_id == 44 && line == 1) { var Tram1Pline = new telenavis.Polyline('44.1_polyline'); Tram1Pline.setPoints(points); Tram1Pline.strokeColor = "purple"; Tram1Pline.strokeWidth = "5px"; Tram1Pline.fillColor = 'none'; Tram1Pline.fillOpacity = 0; layer = SelectLayer('44_layer'); layer.addPolyline(Tram1Pline); }
    else if (cat_id == 44 && line == 2) { var Tram2Pline = new telenavis.Polyline('44.2_polyline'); Tram2Pline.setPoints(points); Tram2Pline.strokeColor = "purple"; Tram2Pline.strokeWidth = "5px"; Tram2Pline.fillColor = 'none'; Tram2Pline.fillOpacity = 0; layer = SelectLayer('44_layer'); layer.addPolyline(Tram2Pline); }
    else if (cat_id == 45 && line == 1) { var SuburbPline1 = new telenavis.Polyline('45.1_polyline'); SuburbPline1.setPoints(points); SuburbPline1.strokeColor = "black"; SuburbPline1.strokeWidth = "5px"; SuburbPline1.fillColor = 'none'; SuburbPline1.fillOpacity = 0; layer = SelectLayer('45_layer'); layer.addPolyline(SuburbPline1); }
    else if (cat_id == 45 && line == 2) { var SuburbPline2 = new telenavis.Polyline('45.2_polyline'); SuburbPline2.setPoints(points); SuburbPline2.strokeColor = "black"; SuburbPline2.strokeWidth = "5px"; SuburbPline2.fillColor = 'none'; SuburbPline2.fillOpacity = 0; layer = SelectLayer('45_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); }
    var subSection = info.substring(3, 0); var endSection = info.substring(info.length, 4); if (subSection == "  -") { info = endSection; }
    CreatePOIsBalloon(info, addr, worldPoint, layer);
}
function CreatePOIsBalloon(info, addr, worldPoint, layer) {
    var divBalloon = document.createElement('div'); divBalloon.id = 'divBalloon'; divBalloon.className = 'divBalloon'; divBalloon.style.left = screenPos.x - 145 + 'px'; divBalloon.style.top = screenPos.y - 108 + 'px'; var tableBalloon = document.createElement('table'); tableBalloon.id = 'top'; tableBalloon.setAttribute("cellSpacing", "0"); tableBalloon.setAttribute("cellPadding", "0"); var tbodyTable = document.createElement('tbody'); var firstTrTable = document.createElement('tr'); var divTipTd = document.createElement('td'); divTipTd.id = 'divTip'; var closeBalloonSpan = document.createElement('span'); closeBalloonSpan.id = 'closeBalloon'; closeBalloonSpan.onclick = function() { divBalloon.parentNode.removeChild(divBalloon); flagBalloon = 0; }
    var addressSpan = document.createElement('span'); addressSpan.id = 'address'; addressSpan.innerHTML = "<strong>" + info; addressSpan.innerHTML += "<br>" + addr; var rightShadowRepeatTd = document.createElement('td'); rightShadowRepeatTd.id = 'rightShadowRepeat'; var secondTrTable = document.createElement('tr'); var divRouteTd = document.createElement('td'); divRouteTd.id = 'divRoute'; var divDriveSpan = document.createElement('span'); divDriveSpan.id = 'divDrive'; divDriveSpan.appendChild(document.createTextNode('Δρομολόγηση')); var divFrom = document.createElement('a'); divFrom.id = 'divFrom'; divFrom.appendChild(document.createTextNode('Από')); divFrom.href = '#'; divFrom.onclick = function() { openRouting(); routestartclick(worldPoint.x, worldPoint.y, addr.replace(',', '').replace('<br/>', '').replace(',', '')); }
    var divMiddle = document.createElement('a'); divMiddle.id = 'divMiddle'; divMiddle.appendChild(document.createTextNode('Μέσω')); divMiddle.href = '#'; divMiddle.onclick = function() { openRouting(); routemiddleclick(worldPoint.x, worldPoint.y, addr.replace(',', '').replace('<br/>', '').replace(',', '')); }
    var divTo = document.createElement('a'); divTo.id = 'divTo'; divTo.appendChild(document.createTextNode('Προς')); divTo.href = '#'; divTo.onclick = function() { openRouting(); routeendclick(worldPoint.x, worldPoint.y, addr.replace(',', '').replace('<br/>', '').replace(',', '')); }
    var rightShadowTd = document.createElement('td'); rightShadowTd.id = 'rightShadow'; var thirdTrTable = document.createElement('tr'); var bottomTd = document.createElement('td'); bottomTd.id = 'bottom'; bottomTd.setAttribute("colSpan", "2"); var divbottomInner = document.createElement('div'); divbottomInner.id = 'bottomInner'; thirdTrTable.appendChild(bottomTd); divRouteTd.appendChild(divDriveSpan); divRouteTd.appendChild(divFrom); divRouteTd.appendChild(divMiddle); divRouteTd.appendChild(divTo); secondTrTable.appendChild(divRouteTd); secondTrTable.appendChild(rightShadowTd); divTipTd.appendChild(closeBalloonSpan); divTipTd.appendChild(addressSpan); firstTrTable.appendChild(divTipTd); firstTrTable.appendChild(rightShadowRepeatTd); tbodyTable.appendChild(firstTrTable); tbodyTable.appendChild(secondTrTable); tbodyTable.appendChild(thirdTrTable); tableBalloon.appendChild(tbodyTable); divBalloon.appendChild(tableBalloon); divBalloon.appendChild(divbottomInner); layer.getDiv().appendChild(divBalloon); var a = divBalloon.clientHeight; a = a + 31; divBalloon.style.left = screenPos.x - 145 + "px"; divBalloon.style.top = screenPos.y - a + "px";
}
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) { } }); }
function Links() { prepareLink('send'); document.getElementById('LinkForm').style.display = "block"; document.getElementById('linkTxt').value = emailLink; Frames(emailLink); document.getElementById('frameTxt').value = iframe; }
function Frames(defaultLink) {
    var loc = ""; var st = ""; var v = ""; var en = ""; domain = 'http://www.letsgo.gr/Frame.aspx'; var primarylink = domain + "?" + myMap.getCenter().y + ":" + myMap.getCenter().x + "&" + myMap.getZoom(); var loclink = GetLocParameters(); loclink = loclink.replace(' ', '%20'); var routelink = GetRoutingParameters(); GetLocationTexts(); if (routelink != "") { link = "<a href='" + primarylink + routelink + "'>" + primarylink + routelink + "</a>"; }
    else { link = "<a href='" + primarylink + loclink + "'>" + primarylink + loclink + "</a>"; }
    if (locationM != "" && actionFlag == 1) { locations += locationM; }
    if (startM != "" && actionFlag == 2) { locations += startM; }
    if (viaM != "" && actionFlag == 2) { locations += viaM; }
    if (endM != "" && actionFlag == 2) { locations += endM; }
    if (actionFlag == 1) { emailLink = primarylink + loclink; }
    else if (actionFlag == 2) { emailLink = primarylink + routelink; }
    else { emailLink = primarylink; }
    if (document.getElementById('Transportation').value == 'PEDESTRIAN') { emailLink += '&ped'; }
    if (document.getElementById('Strategy').value == 'DISTANCE') { emailLink += '&dis'; }
    if (document.getElementById('chkDaktilios').checked) { emailLink += '&Dak'; }
    if (document.getElementById('chkToll').checked) { emailLink += '&Toll'; }
    iframe = "<iframe width='425' height='350' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='" + emailLink + "'></iframe><br /><small><a href='" + defaultLink + "' style='color:#0000FF;text-align:left'>Δες το σε Μεγάλο χάρτη</a></small>";
}
function TaxiForm() { var id = document.getElementById('Kmtbx').value; if (id != "") { document.getElementById('TaxiForm').style.display = "block"; document.getElementById('validateLbl').style.display = "none"; } }
function CloseTaxi() { document.getElementById('TaxiForm').style.display = "none"; }
function Taxi() {
    var km = document.getElementById('Kmtbx').value; var airport = document.getElementById("AirportDdl").value; var night = document.getElementById("NightDdl").value; var station = document.getElementById("StationChk").checked; var luggage = document.getElementById('LuggageTbx').value; var radio = document.getElementById('radioDdl').value; var start = document.getElementById('StartTbx').value; var end = document.getElementById('EndTbx').value; var middle = document.getElementById('MiddleTbx').value; var doubletar = document.getElementById('TarifaTbx').value; var time = document.getElementById('TimeTxt').value; if ((start.split(',')[2]) != " Αττική" && (start.split(',')[3]) != " Αττική") { document.getElementById('validateLbl').style.display = "block"; return; }
    if (km != "") { document.getElementById('TaxiForm').style.display = "block"; $.ajax({ type: "POST", url: "Default.aspx", data: ({ id: km, air: airport, night: night, station: station, lug: luggage, rad: radio, time: time, doubletar: doubletar, mode: "taxi" }), success: function(data) { document.getElementById("ResultsTbx").value = data; } }); } 
}
function clearTaxi() { document.getElementById("AirportDdl").value = 0; document.getElementById("NightDdl").value = 0; document.getElementById("StationChk").checked = false; document.getElementById('LuggageTbx').value = ""; document.getElementById('radioDdl').value = 0; document.getElementById('ResultsTbx').value = ""; }
function CloseLink() { document.getElementById('LinkForm').style.display = 'none'; }