﻿// dipende da jquery

//OGGETTO TIPO oltrematica...
var oltrematica = new function fnOltrematica() {

    //converte gli elementi div con classe headerBox in elementi complessi come da descrizione
    this.makeHeaderBoxes = function fnMakeHeaderBoxes() {
        $(".headerBox").each(function(index) {
            var b = this;
            var w = $(b).width(); $(b).width("")
            var t = $(b).text(); $(b).text("");
            $(b).append("<div class ='headerBoxL'>");
            $(b).append("<div class='headerBoxC'>").children(":last").text(t).width(w - 10);
            $(b).append("<div class='headerBoxR'>").append("<div class='clear'>");
        });
    }

    this.makeRoundBorders = function() {
        $(".toRoundCorners").each(function() {
            $(this).corner("4px").css("margin-top", "1px");
        });
    }

    this.pageTopRotate = function() {
        var rndid = 1 + Math.floor(Math.random() * 12);
        $("#page").css("background", "transparent url(images/css/page-bg"+ rndid +".jpg) no-repeat center top");
    }
}


//funzioni e funzionalità statiche

//adattamento di stile per i vecchi internet explorer
function updateOlderIE() {
    if ($.browser.msie && (($.browser.version == "6.0") || ($.browser.version == "5.5"))) {
        $("#info_header_text").css("position", "absolute");

        $("#ventur_viaggi_logo").css("position", "absolute");
        $("#ventur_viaggi_logo > img").css("left", "-550px");
        $("#ventur_viaggi_logo > img").css("top", "15px");

        $("#hswitcher").css("top", "-50px");
        $("#hswitcher").css("left", "20px");

        $("#menu").css("margin-top", "-12px");
        
        ie6pngFix();
    }
}

function ie6pngFix() {
    var ie6FixarVersion = navigator.appVersion.split("MSIE")
    var ie6Fixversion = parseFloat(ie6FixarVersion[1])
    if ((ie6Fixversion >= 5.5) && (document.body.filters)) {
        for (var i = 0; i < document.images.length; i++) {
            var img = document.images[i]
            var imgName = img.src.toUpperCase()
            if (imgName.substring(imgName.length - 3, imgName.length) == "PNG") {
                var imgID = (img.id) ? "id='" + img.id + "' " : ""
                var imgClass = (img.className) ? "class='" + img.className + "' " : ""
                var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
                var imgStyle = "display:inline-block;" + img.style.cssText
                if (img.align == "left") imgStyle = "float:left;" + imgStyle
                if (img.align == "right") imgStyle = "float:right;" + imgStyle
                if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
                var strNewHTML = "<span " + imgID + imgClass + imgTitle
         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
                img.outerHTML = strNewHTML
                i = i - 1
            }
        }
    }
}

function checkUserErrorNotify() {
   
    var lberr = $("span[id*='lbError']").html();
    if ((lberr != "") && (lberr != null)) {
        var tpos = $("span[id*='lbError']:first").position();
        if ((tpos != null) && (tpos.top < 600)) {return; };
        
        $("#cntDialogGeneric").html("<div style='background:#f00; color:#fff;'>Attenzione! Operazione non eseguita a causa dei seguenti errori:<br><br>" + lberr + "</div>")
            .dialog({ modal: true, title: "Errore", minWidth: 500, buttons: { "Chiudi": function() { $(this).dialog("close"); } } });
    }
}

//str omDecrypt(str)
eval(function(p, a, c, k, e, r) { e = function(c) { return c.toString(a) }; if (!''.replace(/^/, String)) { while (c--) r[e(c)] = k[c] || e(c); k = [function(e) { return r[e] } ]; e = function() { return '\\w+' }; c = 1 }; while (c--) if (k[c]) p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]); return p } ('7 n(a){2 b="6%@#$^&*()-3=+.:/?";2 c="4 +=3-)(*&^$#@:.<[";2 d;2 e;2 f;2 g="";2 h=a.5;2 i=0;2 j=1;8(i!=h){d=a.9(i,j);e=c.k(d);f=b.l(e);i++;j++;g+=f}m g}', 24, 24, '||var|_|zyxwvutsrqponmlkjihgf0e1d2c3b4a5Z6Y7X8W9VUTSRQPONMLKJIHGFEDCBA|length|abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890|function|while|substring|||||||||||indexOf|charAt|return|omDecrypt'.split('|'), 0, {}))


function openWelcomeTravel() {
    document.title = "Ventur.it - Trova la tua vacanza";
    
    $("#cntContattaci").css("display", "none");    
    $("#cntAttesa").css("display", "block");
    var u = omDecrypt("sggk.<<z2rvmwv:evoxlnvlmormv:rg<nlwfovh<luuvigv<luuvigv:ksk[rwxzg#GD)fhvirw#0vmgfi)kzhhew#giz0voGH");
    $("#cntFrame").attr("src", u);
    $("#cntDialog").dialog({ modal: true, position: "top", minWidth: 880, title: 'Trova la tua vacanza', close: cntDialogClose, closeOnEscape: false, buttons: { "Chiudi": function() { $(this).dialog("close"); } } }).show("blind");
    $("#cntFrame").css("height", "800px");
    return false;
}

function openAlbaTravel() {
    document.title = "Ventur.it - Prenota la tua vacanza";
    
    $("#cntAttesa").css("display", "block");
    var u = "http://b2c.towers.it/?cstz=VENTUR";
    $("#cntFrame").attr("src", u);
    $("#cntDialog").dialog({ modal: true, position: "top", minWidth: 850, title: 'Prenota la tua vacanza', close: cntDialogClose, closeOnEscape: false, buttons: { "Chiudi": function() { $(this).dialog("close"); } } }).show("blind");
    $("#cntContattaci").css("display", "block");
    $("#cntFrame").css("height", "550px");
    return false;
}

function openCostaClick() {
    document.title = "Ventur.it - Prenota la tua crociera";
    
    $("#cntAttesa").css("display", "block");
    var u = "http://www.CruisEngine.com/BookingEngine/partners/it-IT/Step1a?Key=boKYTTZkT1vu%2b9bFLHwkrg%3d%3d";
    $("#cntFrame").attr("src", u);
    $("#cntDialog").dialog({ modal: true, position: "top", minWidth: 850, title: 'Prenota la tua crociera', close: cntDialogClose, closeOnEscape: false, buttons: { "Chiudi": function() { $(this).dialog("close"); } } }).show("blind");
    $("#cntContattaci").css("display", "block");
    $("#cntFrame").css("height", "550px");
    return false;
}


function cntDialogClose(event, ui) {
    //$("#wrapper").css("opacity", "1");
}

function cntFrameLoaded() {
    if ($("#cntFrame").attr("src") != "") $("#cntAttesa").css("display", "none");
}

//show: 'blind', 'bounce', 'clip', 'drop', 'explode', 'fold', 'highlight', 'puff', 'pulsate', 'scale', 'shake', 'size', 'slide', 'transfer'
//hide: 'blind', 'clip', 'drop', 'explode', 'fold', 'puff', 'slide', 'scale', 'size', 'pulsate'


//GESTIONE DEI BANNER DI TESTA//
var cntLastSecond = -1
var tmrIssimaChiudo = 0;
var elemLastSecond =new Array() ;

function startUpLastSecond() {
    $.get("ajaxHelper.aspx?getLastSeconds=" + new Date(), function(data) { readyLastSecond(data); });    
}

function readyLastSecond(data) {
    elemLastSecond = eval(data);
    if (elemLastSecond.length > 0) {$("#cntLastSecond:first").show();  startLastSecond(); }
}

function startLastSecond() {
    cntLastSecond = ((cntLastSecond + 1) >= elemLastSecond.length) ? 0 : (cntLastSecond + 1);
    $("#dvLastSecond2").html(elemLastSecond[cntLastSecond]);   
    setTimeout(function() { $("#dvLastSecond").show("drop", null, "swing", function() { chiudo(); }) }, 1500);
}

function chiudo() {tmrIssimaChiudo = setTimeout(function() { $("#dvLastSecond").hide("drop", null, "swing", function() { tmrIssimaChiudo = 0; startLastSecond(); }) }, 6000); }

function pauseVenturissima() {window.clearTimeout(tmrIssimaChiudo);}
function restartVenturissima() {chiudo();}

//FINE GESTIONE DEI BANNER DI TESTA//


