﻿function FailedCallback(error) {
    alert(error.get_message());
    alert(error.get_stackTrace());
}

function TranslateTo(lang) {
    $("#translating").show();
    $(document).ready(function() {
        $("#DivContainer").translate(lang, {
            data: true,
            not: ".language",
            start: function() { $("#translating").show(); },
            each: function(i, e, transl, src, from, to) {
                /*if ((to == "en") && (transl.toLowerCase().match("boat") || transl.toLowerCase().match("board") || transl.toLowerCase().match("sunday") || transl.toLowerCase().match("institutions"))) {
                var newTransl = transl.replace(/Boat/i, "Skafos").replace(/ Board/i, " Skafos").replace(/ Sunday/i, " Kyriaki").replace(/ institutions/i, " musical instruments");
                $(e).context.innerHTML = newTransl;
                }*/
            },
            complete: function() { $("#translating").hide(); },
            error: function() { $("#translating").hide(); }
        })
    });
    // set a cookie to remember the selected language
    $.cookie('destLang', lang);
}

function CheckTranslate() {
    var destLang = $.cookie('destLang'); //get previously translated language
    if (destLang)  //if it was set then
        TranslateTo(destLang);
}

function ApplyColorBox(rel, type) {
    $(document).ready(function() {
        if (type == 0)//Photo
            $("a[rel='" + rel + "']").colorbox({ scalePhotos: true, transition: "fade", height: "450px", width: "550px", opacity: 0.70, current: "{current} / {total}" });

        if (type == 1)//Video
        {
            $("a[rel='" + rel + "']").colorbox({ scalePhotos: true, transition: "fade", height: "90%", opacity: 0.70, current: "{current} / {total}" });
            $("." + rel + "").colorbox({ iframe: true, height: "80%", width: "50%" });
        }

        if (type == 2)
        {
            $("a[rel='" + rel + "']").colorbox({ transition: "fade", width: "80%", height: "95%", iframe: true, opacity: 0.70, title: "Χάρτης της Google" });
            $("." + rel + "").colorbox({ width: "80%", height: "95%", iframe: true });
        }

        if (type == 3)
        {
            $("a[rel='" + rel + "']").colorbox({ transition: "fade", width: "565px", height: "450px", iframe: true, opacity: 0.70, title: "Περισσότερες πληροφορίες σχετικά με την καταχώριση" });
        }

        if (type == 4)
        {
            $("a[rel='" + rel + "']").colorbox({ transition: "fade", width: "562px", height: "450px", iframe: true, opacity: 0.70, current: "{current} / {total}", title: "Αγγελίες που έχουν συσχετισθεί με αυτό το επάγγελμα" });
        }

        if (type == 5)
        {
            $("a[rel='" + rel + "']").colorbox({ transition: "fade", width: "795px", height: "690px", iframe: true, opacity: 0.70, title: "Επικοινωνία με τον κάτοχο - Εγγραφή στη λίστα για αποστολή ενημέρωσης και πληροφοριών" });
        }

        if (type == 6)
        {
            $("a[rel='" + rel + "']").colorbox({ transition: "fade", width: "565px", height: "350px", iframe: true, opacity: 0.70, title: "Ο επαγγελματίας στον οποίο ανήκει η αγγελία αυτή" });
        }

        if (type == 7)//Tell to friend
        {
            $("a[rel='" + rel + "']").colorbox({ transition: "fade", width: "795px", height: "530px", iframe: true, opacity: 0.70, title: "Αποστολή σε φίλο" });
        }

        if (type == 8)
        {
            $("a[rel='" + rel + "']").colorbox({ transition: "fade", width: "795px", height: "300px", iframe: true, opacity: 0.70, current: "{current} / {total}", title: "Προσφορές που ανήκουν στον επαγγελματία" });
        }
    });
}

$(document).ready(function() {
    $(".TreeviewMenuTree").find('*[src]').each(function(index, value) {
        if (this.src.indexOf("WebResource.axd") >= 0) {
            $(this).hide();
        }
    });
});
