﻿var domainSend = "http://www.letsgo.gr/"; var domainPrint = "http://www.letsgo.gr/print.aspx"; var emailLink = ""; var emailText = ""; var actionFlag = 0; var locationM = ""; var startM = ""; var viaM = ""; var endM = ""; var locations = ""; function terms() { window.open(domain + "terms.aspx", "mywindow", "scrollbars=1, width=1070, height=800 left=100 top=50"); }
function Greeting() { document.getElementById('Greeting').style.display = 'block'; setTimeout(CloseG, 5000); }
function CloseG() { document.getElementById('Greeting').style.display = 'none'; }
function mailpage() { window.open(domain + "Email_form.aspx", "mywindow", "scrollbars=1, width=900, height=450, resizable=1, dependent=1"); }
function ClearInput(x) { inputstring = document.getElementById(x).value; if ((inputstring == 'π.χ. Newsphone Hellas') || (inputstring == 'π.χ. Φαλήρου 10 Πειραιάς')) { document.getElementById(x).value = ' '; } }
function prepareLink(value) {
    var loc = ""; var st = ""; var v = ""; var en = ""; domain = domainSend; var link = ""; if (value == 'print') { domain = domainPrint; }
    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'; }
    if (value == "print") {
        if (locationM != "" && actionFlag == 1) { loc = $("#SLOCTbx").attr("value"); }
        if (startM != "" && actionFlag == 2) { st = $("#StartTbx").attr("value"); }
        if (viaM != "" && actionFlag == 2) { v = $("#MiddleTbx").attr("value"); }
        if (endM != "" && actionFlag == 2) { en = $("#EndTbx").attr("value"); }
        var pois = checkPois(); $.ajax({ type: "POST", url: "Print.aspx?q=locations", data: ({ loc: loc, st: st, v: v, en: en, pois: pois[1], parameters: pois[0], email: emailLink }), success: function(data) { } });
    }
    if (value == 'print') {
        if (navigator.appName == 'Microsoft Internet Explorer') { setTimeout("opens(emailLink)", 1); }
        else { open(emailLink); } 
    } 
}
function opens(link) { var win = window.open(link, "", "status = 0, width=900px, height=800px, resizable=1, scrollbars=1"); if (!win) { alert("Είναι ενεργοποιημένος ο Popup Blocker. Ενεργοποιήστε το από το Toolbar και επιλέξτε ξανά Εκτύπωση"); } }
function checkPois() {
    var Kati = new Array(); var values = new Array(); var pois = new Array(); $("#ContentCheckbox").find("a").each
(function() { if ($(this).attr("name") == 'selected') { pois.push($(this).attr("href")); values.push($(this).attr("href").split(':')[0]); } }); Kati[0] = pois; Kati[1] = values; return Kati;
}
function GetMapParameters() { center = myMap.getCenter(); zoom = myMap.getZoom(); }
function GetLocationTexts() {
    if ($("#SLOCTbx").attr("value") != "") { locationM = "<label id='lblGeocode'>Διεύθυνση Αναζήτησης: " + $("#SLOCTbx").attr("value") + "</label><br/><br/>"; }
    if ($("#StartTbx").attr("value") != "") { startM = "<label id='lblFrom'>Διεύθυνση Αφετηρίας: " + $("#StartTbx").attr("value") + "</label><br/><br/>"; }
    if ($("#MiddleTbx").attr("value") != "") { viaM = "<label id='lblVia'>Διεύθυνση Ενδιάμεσου Προορισμού: " + $("#MiddleTbx").attr("value") + "</label><br/><br/>"; }
    if ($("#EndTbx").attr("value") != "") { endM = "<label id='lblTo'>Διεύθυνση Τερματισμού: " + $("#EndTbx").attr("value") + "</label><br/><br/>"; } 
}
function GetRoutingParameters() {
    var routingLink = ""; var startPin = null; var startCos = ""; var viaPin = null; var viaCos = ""; var endPin = null; var endCos = ""; if (pinsLayer.getPinIndex('StartPin') != -1 || pinsLayer.getPinIndex(0) != -1) {
        if (pinsLayer.getPinIndex('StartPin') == 0) { startPin = pinsLayer.getPinsArray()[pinsLayer.getPinIndex('StartPin')]; }
        else { startPin = pinsLayer.getPinsArray()[pinsLayer.getPinIndex(0)]; }
        startCos = "&" + startPin.getWorldPos().y + ":" + startPin.getWorldPos().x; routingLink = startCos;
    }
    if (pinsLayer.getPinIndex('EndPin') != -1 || pinsLayer.getPinIndex(1) != -1) {
        if (pinsLayer.getPinIndex('EndPin') == 1) { endPin = pinsLayer.getPinsArray()[pinsLayer.getPinIndex('EndPin')]; }
        else { endPin = pinsLayer.getPinsArray()[pinsLayer.getPinIndex(1)]; }
        endCos = "&" + endPin.getWorldPos().y + ":" + endPin.getWorldPos().x; routingLink += endCos;
    }
    if (pinsLayer.getPinIndex('ViaPin') != -1 || pinsLayer.getPinIndex(2) != -1) {
        if (pinsLayer.getPinIndex('ViaPin') == 2) { viaPin = pinsLayer.getPinsArray()[pinsLayer.getPinIndex('ViaPin')]; }
        else { viaPin = pinsLayer.getPinsArray()[pinsLayer.getPinIndex(2)]; }
        viaCos = "&" + viaPin.getWorldPos().y + ":" + viaPin.getWorldPos().x; routingLink += viaCos;
    }
    return routingLink;
}
function GetLocParameters() {
    var pinLayer = myMap.getLayersArray()[myMap.getLayerIndex('pinsLayer')]; var pinLink = ""; var locPin = null; var locCos = ""; if (pinLayer.getPinIndex('locPin') != -1) { locPin = pinLayer.getPinsArray()[pinLayer.getPinIndex('locPin')]; locCos = "&" + locPin.getWorldPos().y + ":" + locPin.getWorldPos().x + ":" + locPin.getTip(); pinLink = locCos; }
    return pinLink;
}
function delay() { return; }
function IsNullOrEmpty(str) {
    if (str == null || str == "") { return true; }
    else { return false; } 
}
function MessageFeedback() {
    var msg = document.getElementById("MessageTbx").value; var email = document.getElementById("EmailTbx").value; if (IsNullOrEmpty(msg)) { document.getElementById("textMessage").style.display = 'block'; return; }
    else if (!IsNullOrEmpty(msg) && IsNullOrEmpty(email)) { SendFeedBack(); }
    else if (!IsNullOrEmpty(msg) && !IsNullOrEmpty(email) && IsEmail(email)) { SendFeedBack(); }
    else if (!IsNullOrEmpty(msg) && !IsNullOrEmpty(email) && !IsEmail(email)) { document.getElementById("textEmail").style.display = 'block'; return; } 
}
function SendFeedBack() { document.getElementById("textMessage").style.display = 'none'; document.getElementById("textEmail").style.display = 'none'; $.ajax({ type: "POST", url: "Handler.ashx", data: ({ text: document.getElementById("MessageTbx").value, email: document.getElementById("EmailTbx").value, mode: "FeedBackMessage" }), success: function(data) { document.getElementById("MessageTbx").value = ""; document.getElementById("EmailTbx").value = ""; Greeting(); resizeMapDiv(); } }); }
N = (document.all) ? 0 : 1; var ob; var name; function MD(e) {
    if (N) {
        name = e.target.id; if (name == "ImgTool") { ob = e.target.parentNode.style; }
        Y = e.layerY; return;
    }
    else {
        name = event.srcElement.id; if (name == "ImgTool") { ob = event.srcElement.parentElement.style; }
        Y = event.offsetY;
    } 
}
function MM(e) {
    if (ob) {
        if (N) { var top = e.clientY - (93 + Y) + document.body.scrollTop; }
        else { var top = event.clientY - (93 + Y) + document.body.scrollTop; }
        if (top > 220) { top = 225; toolbar(1, 225); }
        else if (top < 219 && top > 210) { top = 214; toolbar(2, 214); }
        else if (top < 209 && top > 198) { top = 203; toolbar(3, 203); }
        else if (top < 197 && top > 186) { top = 192; toolbar(4, 192); }
        else if (top < 187 && top > 176) { top = 181; toolbar(5, 181); }
        else if (top < 177 && top > 165) { top = 170; toolbar(6, 170); }
        else if (top < 166 && top > 154) { top = 159; toolbar(7, 159); }
        else if (top < 145 && top > 142) { top = 148; toolbar(8, 148); }
        else if (top < 133 && top > 131) { top = 137; toolbar(9, 137); }
        else if (top < 132 && top > 121) { top = 126; toolbar(10, 126); }
        else if (top < 122 && top > 109) { top = 115; toolbar(11, 115); }
        else if (top < 110 && top > 99) { top = 104; toolbar(12, 104); }
        else if (top < 100 && top > 89) { top = 93; toolbar(13, 93); }
        else if (top < 94 && top > 77) { top = 82; toolbar(14, 82); }
        else if (top < 78 && top > 65) { top = 71; toolbar(15, 71); }
        else if (top < 66 && top > 53) { top = 60; toolbar(16, 60); }
        else if (top < 54 && top > 43) { top = 49; toolbar(17, 49); }
        if (top < 44) { top = 38; toolbar(18, 38); }
        ob.pixeltop = top;
    }
    return false;
}
function MU() { ob = null; }
if (N) { document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP); }
document.onmousedown = MD; document.onmousemove = MM; document.onmouseup = MU; function IsEmail(str) {
    var expr = /^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/i
    return expr.test(str);
}
function SendMapByMail() {
    if (IsEmail($("#ToTbx").attr("value")) && IsEmail($("#FromTbx").attr("value"))) {
        document.getElementById('toVld').style.display = 'none'; document.getElementById('fromVld').style.display = 'none'; document.getElementById('MsgTo').style.display = 'none'; document.getElementById('MsgFrom').style.display = 'none'; var toEmail = $("#ToTbx").attr("value"); var fromEmail = $("#FromTbx").attr("value"); var instructions = routeInstructions; var loc = ""; var st = ""; var v = ""; var en = ""; var routestr = ""; var time = ""; var distance = ""; if (locationM != "" && actionFlag == 1) { loc = $("#SLOCTbx").attr("value"); }
        if (startM != "" && actionFlag == 2) { st = $("#StartTbx").attr("value"); }
        if (viaM != "" && actionFlag == 2) { v = $("#MiddleTbx").attr("value"); }
        if (endM != "" && actionFlag == 2) { en = $("#EndTbx").attr("value"); }
        if (instructions != null) {
            routestr = ""; var points = ""; time = totaltime; distance = totaldistance; for (var i = 0; i < instructions.length; i++) { routestr += instructions[i].directions + ":"; points += instructions[i].point.x + "," + instructions[i].point.y + ":" }
            routestr = routestr.substring(0, routestr.length - 1); points = points.substring(0, points.length - 1);
        }
        if (toEmail == "") { document.getElementById('MsgTo').style.display = 'block'; }
        if (fromEmail == "") { document.getElementById('MsgFrom').style.display = 'block'; }
        if (toEmail != "" && fromEmail != "") { $.ajax({ type: "POST", url: "Handler.ashx", data: ({ to: toEmail, from: fromEmail, time: time, distance: distance, steps: routestr, link: emailLink, loc: loc, st: st, v: v, en: en, mode: "MapByMail" }), success: function(data) { document.getElementById('emailform1').style.display = 'none'; document.getElementById('emailform').style.display = 'none'; document.getElementById('ToTbx').value = ""; document.getElementById('FromTbx').value = ""; document.getElementById('MailTbx').innerHTML = ""; } }); } 
    }
    else {
        if (!IsEmail($("#ToTbx").attr("value"))) { document.getElementById('toVld').style.display = 'block'; }
        if (!IsEmail($("#FromTbx").attr("value"))) { document.getElementById('fromVld').style.display = 'block'; } 
    } 
}
function NewMapPanelShow() { document.getElementById('NewMapSpan').style.display = 'block'; document.getElementById('MapsGvw').style.display = 'none'; }