﻿var mouse_x = null; var mouse_y = null; var show_tooltip = false; var mouse_out = null; function getWindowWidth() {
    var windowWidth = 0; if (typeof (window.innerWidth) == 'number') { windowWidth = window.innerWidth; }
    else {
        if (document.documentElement && document.documentElement.clientWidth) { windowWidth = document.documentElement.clientWidth; }
        else { if (document.body && document.body.clientWidth) { windowWidth = document.body.clientWidth; } }
    }
    return windowWidth;
}
function on_MouseMove(e, tipo) {
    var objTooltip = document.getElementById('tooltip'); var tipo_browser = navigator.appName; var pos_x = 0; var pos_y = 0; if (tipo_browser == 'Netscape') {
        pos_x = parseInt(self.pageXOffset) + e.clientX + document.body.scrollLeft; pos_y = parseInt(self.pageYOffset) + e.clientY + document.body.scrollTop; pos_x = pos_x + 10; pos_y = pos_y + 20; if (objTooltip.offsetWidth + pos_x >= getWindowWidth())
        { pos_x = getWindowWidth() - objTooltip.offsetWidth - 20; }
        pos_x = pos_x + "px"; pos_y = pos_y + "px";
    }
    else {
        if (e.pageX) return e.pageX; else if (e.clientX)
            pos_x = e.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft); else return null; if (e.pageY) return e.pageY; else if (e.clientY)
            pos_y = e.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); else return null; pos_x = pos_x + 10; pos_y = pos_y + 20; if (objTooltip.offsetWidth + pos_x >= getWindowWidth())
        { pos_x = getWindowWidth() - objTooltip.offsetWidth - 20; }
    }
    var posizione_y; var element_tooltip = document.getElementById("tooltip")
    mouse_x = pos_x; mouse_y = pos_y; if (tipo == 'partenza') { posizione_y = mouse_y; }
    else { posizione_y = (parseInt(mouse_y) - 200); }
    if (element_tooltip) {
        if (show_tooltip)
        { $('tooltip').setStyles({ top: posizione_y, left: mouse_x, visibility: 'visible' }); document.getElementById('tooltip').style.display = ''; }
        else
        { document.getElementById('tooltip').style.display = 'none'; }
    }
    return false;
}
function toolTip(var_display, ajax_url, set_className) {
    if (var_display == 'show')
    { mouse_out = true; show_tooltip = true; document.getElementById('tooltip').className = set_className; var myHTMLRequest = new Request.HTML({ url: ajax_url, update: "tooltip", onComplete: function() { show_tooltip = true; } }).send(); }
    else
    { mouse_out = false; show_tooltip = false; document.getElementById('tooltip').style.display = 'none'; }
}
function IsNumeric(sText) {
    var ValidChars = "0123456789."; var IsNumber = true; var Char; for (i = 0; i < sText.length && IsNumber == true; i++) {
        Char = sText.charAt(i); if (ValidChars.indexOf(Char) == -1)
        { IsNumber = false; }
    }
    return IsNumber;
}
function F_engine_control() {
    var dal_value; var al_value; var book_period; dal_value = document.getElementById('ctl00_body_data_dal').value; al_value = document.getElementById('ctl00_body_data_al').value; book_period = parseInt(document.getElementById('ctl00_body_book_period').value); var dal_gg = dal_value.substr(0, 2); var dal_mm = dal_value.substr(3, 2) - 1; var dal_aaaa = dal_value.substr(6, 4); var dal = new Date(dal_aaaa, dal_mm, dal_gg); var al_gg = al_value.substr(0, 2); var al_mm = al_value.substr(3, 2) - 1; var al_aaaa = al_value.substr(6, 4); var al = new Date(al_aaaa, al_mm, al_gg); var current_date = new Date(); if (isDate(dal) == false) {
        var current_gg = current_date.getDate(); if (('' + current_gg).length == 1)
        { current_gg = '0' + current_gg; }
        var current_mm = current_date.getMonth(); var current_mm_input = current_mm + 1; if (('' + current_mm).length == 1)
        { current_mm = '0' + current_mm; }
        if (('' + current_mm_input).length == 1)
        { current_mm_input = '0' + current_mm_input; }
        var current_aaaa = current_date.getFullYear(); dal = new Date(current_aaaa, current_mm, current_gg); document.getElementById('ctl00_body_data_dal').value = current_gg + '/' + current_mm_input + '/' + current_aaaa;
    }
    if (isDate(al) == false) {
        var next_date = new Date(); next_date = dateAdd("d", 1, dal); var next_gg = next_date.getDate(); if (('' + next_gg).length == 1)
        { next_gg = '0' + next_gg; }
        var next_mm = next_date.getMonth(); var next_mm_input = next_mm + 1; if (('' + next_mm).length == 1)
        { next_mm = '0' + next_mm; }
        if (('' + next_mm_input).length == 1)
        { next_mm_input = '0' + next_mm_input; }
        var next_aaaa = next_date.getFullYear(); al = new Date(next_aaaa, next_mm, next_gg); document.getElementById('ctl00_body_data_al').value = next_gg + '/' + next_mm_input + '/' + next_aaaa;
    }
    var i_weekday; var al_dopo = dal; var cambia_data = false; var conta_sabati = 0; var conta_domeniche = 0; while (conta_sabati < 1 + book_period / 7 && conta_domeniche < 1 + book_period / 7) {
        i_weekday = al_dopo.getUTCDay(); if (i_weekday == 5)
        { conta_sabati = conta_sabati + 1; }
        if (i_weekday == 6)
        { conta_domeniche = conta_domeniche + 1; }
        if (conta_sabati < 1 + book_period / 7 && conta_domeniche < 1 + book_period / 7)
        { al_dopo = dateAdd("d", 1, al_dopo); }
    }
    if (dateDiff("d", al, al_dopo) > 0)
    { cambia_data = true; }
    if (cambia_data == true) {
        var al_dopo_gg = al_dopo.getDate(); if (('' + al_dopo_gg).length == 1)
        { al_dopo_gg = '0' + al_dopo_gg; }
        var al_dopo_mm = al_dopo.getMonth() + 1; if (('' + al_dopo_mm).length == 1)
        { al_dopo_mm = '0' + al_dopo_mm; }
        var al_dopo_aaaa = al_dopo.getFullYear(); document.getElementById('ctl00_body_data_al').value = al_dopo_gg + '/' + al_dopo_mm + '/' + al_dopo_aaaa;
    }
    return true;
}
function isDate(p_Expression) { return !isNaN(new Date(p_Expression)); }
function dateAdd(p_Interval, p_Number, p_Date) {
    if (!isDate(p_Date)) { return "invalid date: '" + p_Date + "'"; }
    if (isNaN(p_Number)) { return "invalid number: '" + p_Number + "'"; }
    p_Number = new Number(p_Number); var dt = new Date(p_Date); switch (p_Interval.toLowerCase()) {
        case "yyyy": { dt.setFullYear(dt.getFullYear() + p_Number); break; }
        case "q": { dt.setMonth(dt.getMonth() + (p_Number * 3)); break; }
        case "m": { dt.setMonth(dt.getMonth() + p_Number); break; }
        case "y": case "d": case "w": { dt.setDate(dt.getDate() + p_Number); break; }
        case "ww": { dt.setDate(dt.getDate() + (p_Number * 7)); break; }
        case "h": { dt.setHours(dt.getHours() + p_Number); break; }
        case "n": { dt.setMinutes(dt.getMinutes() + p_Number); break; }
        case "s": { dt.setSeconds(dt.getSeconds() + p_Number); break; }
        case "ms": { dt.setMilliseconds(dt.getMilliseconds() + p_Number); break; }
        default: { return "invalid interval: '" + p_Interval + "'"; }
    }
    return dt;
}
function dateDiff(p_Interval, p_Date1, p_Date2, p_firstdayofweek, p_firstweekofyear) {
    if (!isDate(p_Date1)) { return "invalid date: '" + p_Date1 + "'"; }
    if (!isDate(p_Date2)) { return "invalid date: '" + p_Date2 + "'"; }
    var dt1 = new Date(p_Date1); var dt2 = new Date(p_Date2); var iDiffMS = dt2.valueOf() - dt1.valueOf(); var dtDiff = new Date(iDiffMS); var nYears = dt2.getUTCFullYear() - dt1.getUTCFullYear(); var nMonths = dt2.getUTCMonth() - dt1.getUTCMonth() + (nYears != 0 ? nYears * 12 : 0); var nQuarters = parseInt(nMonths / 3); var nMilliseconds = iDiffMS; var nSeconds = parseInt(iDiffMS / 1000); var nMinutes = parseInt(nSeconds / 60); var nHours = parseInt(nMinutes / 60); var nDays = parseInt(nHours / 24); var nWeeks = parseInt(nDays / 7); var iDiff = 0; switch (p_Interval.toLowerCase()) { case "yyyy": return nYears; case "q": return nQuarters; case "m": return nMonths; case "y": case "d": return nDays; case "w": return nDays; case "ww": return nWeeks; case "h": return nHours; case "n": return nMinutes; case "s": return nSeconds; case "ms": return nMilliseconds; default: return "invalid interval: '" + p_Interval + "'"; }
}
function contaCaratteri(id, span, numero) {
    var str = document.getElementById(id).value; var spanGenerale = document.getElementById(span); if (numero - str.length == -1) { document.getElementById(id).value = str.substring(0, str.length - 1); }
    spanGenerale.innerHTML = numero - str.length + " caratteri mancanti"; if (numero - str.length < 0) { document.getElementById(id).value = str.substring(0, numero); spanGenerale.innerHTML = 0 + " caratteri mancanti"; }
}
function returnFalse() { alert("Selezionare almeno 2 crociere per fare un confronto"); return false; }
function returnTrue() { return true; }
function enableLinkButton(clientID) { document.getElementById(clientID).style.color = '#FFCC00'; document.getElementById(clientID).onclick = returnTrue; }
function disableLinkButton(clientID) { document.getElementById(clientID).style.color = '#FFFFFF'; document.getElementById(clientID).onclick = returnFalse; }
function ajax_risultato_crociera(partenza_id, tipologia, azione, id_check) {
    $.ajax({ type: "GET", cache: false, url: http_path + "ajax/F_ajax_risultato_crociera.aspx", data: "partenza_id=" + partenza_id + "&tipologia=" + tipologia + "&azione=" + azione + "&dummy=" + new Date().getTime(), async: false, error: function() { alert('Error loading XML document'); }, success: function(msg) {
        if (tipologia == 1) {
            if (azione == 1) { if (parseInt(msg) > 3) { alert("Puoi inserire al massimo 3 crociere per il confronto."); document.getElementById(id_check).checked = false; msg = parseInt(msg) - 1; } }
            if (msg == 0) { document.getElementById('ctl00_centre_N_crociere').innerHTML = ""; $('#ctl00_centre_content_risultato').css('display', 'none'); if (document.getElementById('ctl00_centre_N_crociere_bottom') != null) { document.getElementById('ctl00_centre_N_crociere_bottom').innerHTML = ""; } }
            else { document.getElementById('ctl00_centre_N_crociere').innerHTML = "(<b>" + (parseInt(msg)) + "</b>)"; if (document.getElementById('ctl00_centre_N_crociere_bottom') != null) { document.getElementById('ctl00_centre_N_crociere_bottom').innerHTML = "(<b>" + (parseInt(msg)) + "</b>)"; } }
            if (parseInt(msg) <= 1) { disableLinkButton('ctl00_centre_btn_confronta'); if (document.getElementById('ctl00_centre_N_crociere_bottom') != null) { disableLinkButton('ctl00_centre_btn_confronta_bottom'); } }
            else { enableLinkButton('ctl00_centre_btn_confronta'); if (document.getElementById('ctl00_centre_N_crociere_bottom') != null) { enableLinkButton('ctl00_centre_btn_confronta_bottom'); } }
        }
    }
    });
}
function confronta(e, partenza_id) {
    $('#ctl00_centre_content_risultato').css('display', 'block'); $('#elimina').css('display', 'inline'); $('#elimina_bottom').css('display', 'inline'); if ($.browser.msie) {
        if (document.getElementById(e.srcElement.id).checked) { ajax_risultato_crociera(partenza_id, 1, 1, e.srcElement.id); }
        else { ajax_risultato_crociera(partenza_id, 1, 0); }
    }
    else {
        if (document.getElementById(e.target.id).checked) { ajax_risultato_crociera(partenza_id, 1, 1, e.target.id); }
        else { ajax_risultato_crociera(partenza_id, 1, 0); }
    }
}
function uncheckAll() { var checkbox = $('input[@type=checkbox]'); $('#ctl00_centre_content_risultato').css('display', 'none'); $('#elimina').css('display', 'none'); $('#elimina_bottom').css('display', 'none'); ajax_risultato_crociera(0, 1, 2); for (i = 0; i < checkbox.length; i++) { checkbox[i].checked = false; } }

function ajax_navi(nave_id, object_id, zone, type) { var elementID = document.getElementById(object_id); if (elementID) { $.ajax({ type: "GET", url: http_path + "ajax/F_ajax_caricamento_dati_nave.aspx", data: "nave_id=" + nave_id + "&zone=" + zone + "&type=" + type + "&dummy=" + new Date().getTime(), beforeSend: function() { elementID.innerHTML = '<img src="' + http_path + 'img/loading_circle.gif" /> caricamento in corso..'; }, success: function(msg) { elementID.innerHTML = msg; }, complete: function() { $('#' + object_id + ' img.fancyzoom').fancyzoom(); $('#' + object_id + ' a.fancyzoom').fancyzoom(); } }); } }
function loading_web() { document.getElementById('aspnetForm').style.display = 'none'; document.getElementById('html').style.backgroundColor = 'white'; }
function loading_web_mini() { if (document.getElementById('splashScreen')) { document.getElementById('splashScreen').style.width = '400px'; document.getElementById('splashScreen').style.height = '200px'; var left = parseInt((($(window).width() - 400) / 2) + $(window).scrollLeft()); var top = parseInt((($(window).height() - 200) / 2) + $(window).scrollTop()); document.getElementById('splashScreen').style.left = left + 'px'; document.getElementById('splashScreen').style.top = top + 'px'; document.getElementById('splashScreen').style.paddingTop = '0px'; } }
function visualizza_ponte(compagnia_id, nave_id, ponte_id, sistemazione) { var left_px = parseInt((($(window).width() - 900) / 2) + $(window).scrollLeft()); var top_px = parseInt((($(window).height() - 400) / 2) + $(window).scrollTop()); var radio_button = $('input[@name$="wizard_prenotazione$scelta_sistemazione"]:checked'); var radio_offset = radio_button.offset(); $('span[@id$="Label_tooltip_planimetria"]').unbind("onclick"); $.get('ajax/tooltip_ponte.aspx', { ponte_id: ponte_id, nave_id: nave_id, compagnia_id: compagnia_id, sistemazione_cat: sistemazione }, function(data) { $(data).css({ position: 'absolute', top: top_px, left: left_px }).appendTo('body'); var div_finto = $('<div id="progressBackgroundFilter" style="position:absolute; top:0px;left:0px; width:' + $(document).width() + 'px; height:' + $(document).height() + 'px;filter:alpha(opacity=30);opacity:0.3; background-color:#000; z-index:100;"></div>'); div_finto.appendTo('body'); var nuovo_top = top_px - 15; var nuovo_left = left_px - 15; $("#close_tooltip_ponte").css({ position: 'absolute', top: top_px - 10, left: nuovo_left, cursor: 'pointer' }); $('#div_out').css('top', top_px); $("#close_tooltip_ponte").bind("click", function() { $("#close_tooltip_ponte").fadeOut("slow"); $("#div_out").fadeOut("slow"); $("#close_tooltip_ponte").remove(); $("#div_out").remove(); div_finto.remove(); }); $("body").bind("click", function() { $("#close_tooltip_ponte").fadeOut("slow"); $("#div_out").fadeOut("slow"); $("#close_tooltip_ponte").remove(); $("#div_out").remove(); div_finto.remove(); }); }); }
function F_visualizza_partenze(obj, itinerario_programma_giorni_id, mese, anno, offerta_id, seleziona_partenza) {
    if ($(obj).attr("class") == "itinerario_mese") { $(".mesi > a ").css("background-color", "#E3E3E3"); $(".mesi > a ").css("border", "1px solid #FFF"); $(".mesi > a ").css("font-weight", "normal"); $(".mesi > .altri_mesi ").css("background-color", "#FFFFFF"); for (i = 0; i < document.getElementsByTagName("div").length - 1; i++) { if (document.getElementsByTagName("div")[i].id.substring(0, 16) == "partenze_giorni_") { document.getElementsByTagName("div")[i].innerHTML = ""; } } }
    $.ajax({ type: "GET", cache: false, url: http_path + "ajax/F_visualizza_partenze.aspx", data: "itinerario_programma_giorni_id=" + itinerario_programma_giorni_id + "&tipologia_itinerario=" + $('#ctl00_centre_HiddenField_sel_tipologia_itinerari').attr('value') + "&tema=" + $('#ctl00_centre_HiddenField_sel_temi').attr('value') + "&periodo=" + $('#ctl00_centre_HiddenField_sel_periodi').attr('value') + "&destinazione=" + $('#ctl00_centre_HiddenField_sel_destinazioni').attr('value') + "&compagnia=" + $('#ctl00_centre_HiddenField_sel_compagnie').attr('value') + "&nave=" + $('#ctl00_centre_HiddenField_sel_navi').attr('value') + "&durata=" + $('#ctl00_centre_HiddenField_sel_durata').attr('value') + "&mese=" + mese + "&anno=" + anno + "&offerta=" + offerta_id + "&seleziona_partenza=" + seleziona_partenza, async: false, error: function() { }, beforeSend: function() { $('#partenze_giorni_' + itinerario_programma_giorni_id).html('caricamento...'); }, success: function(msg) { $('#partenze_giorni_' + itinerario_programma_giorni_id).html(msg); } }); if ($(obj).attr("class") == "itinerario_mese") { obj.style.backgroundColor = "#FFE26F"; obj.style.border = "1px solid #B8CBD9"; obj.style.fontWeight = "normal"; }
    return false;
}
function F_visualizza_calendario_partenze_mesi(obj, page_index, seleziona_data, offerta_id, tipologia_itinerario_id, itinerario_programma_giorni_id, tema_id, destinazione_id, compagnia_id, nave_id, durata_id, porto_partenza_id, azione_nome_pagina, partenza_id, provenienza, pagina_dinamica_id) { $.ajax({ type: "GET", cache: false, url: http_path + "ajax/F_visualizza_calendario_partenze_mesi.aspx", data: "&page_index=" + page_index + "&seleziona_data=" + seleziona_data + "&tipologia_itinerario_id=" + tipologia_itinerario_id + "&itinerario_programma_giorni_id=" + itinerario_programma_giorni_id + "&tema_id=" + tema_id + "&destinazione_id=" + destinazione_id + "&compagnia_id=" + compagnia_id + "&nave_id=" + nave_id + "&durata_id=" + durata_id + "&porto_partenza_id=" + porto_partenza_id + "&offerta_id=" + offerta_id + "&azione_nome_pagina=" + azione_nome_pagina + "&partenza_id=" + partenza_id + "&provenienza=" + provenienza + "&pagina_dinamica_id=" + pagina_dinamica_id, async: false, error: function() { }, beforeSend: function() { }, success: function(msg) { $('#JT_copy').html(msg); } }); return false; }
function F_visualizza_calendario_partenze_mesi5(obj, mese, anno, pag_ultimo_mese, pag_ultimo_anno, direction, offerta_id, mesi_saltati, mesi_saltati_tra_pagine, seleziona_data, tipologia_itinerario, itinerario_programma_giorni_id, tema, destinazione, compagnia, nave, durata, porto_partenza, azione_nome_pagina, partenza) {
    if (!mesi_saltati) { mesi_saltati = ''; }
    if (!mesi_saltati_tra_pagine) { mesi_saltati_tra_pagine = ''; }
    $.ajax({ type: "GET", cache: false, url: http_path + "ajax/F_visualizza_calendario_partenze_mesi5.aspx", data: "tipologia_itinerario=" + tipologia_itinerario + "&itinerario_programma_giorni_id=" + itinerario_programma_giorni_id + "&tema=" + tema + "&destinazione=" + destinazione + "&compagnia=" + compagnia + "&nave=" + nave + "&durata=" + durata + "&porto_partenza=" + porto_partenza + "&mese=" + mese + "&anno=" + anno + "&pag_ultimo_mese=" + pag_ultimo_mese + "&pag_ultimo_anno=" + pag_ultimo_anno + "&direction=" + direction + "&offerta=" + offerta_id + "&mesi_saltati=" + mesi_saltati + "&mesi_saltati_tra_pagine=" + mesi_saltati_tra_pagine + "&seleziona_data=" + seleziona_data + "&azione_nome_pagina=" + azione_nome_pagina + "&partenza=" + partenza, async: false, error: function() { }, beforeSend: function() { }, success: function(msg) { $('#JT_copy').html(msg); } }); return false;
}
function F_visualizza_partenze_mesi(obj, itinerario_programma_giorni_id, mese, anno, pag_ultimo_mese, pag_ultimo_anno, direction, offerta_id, mesi_saltati, seleziona_mese) {
    if (!mesi_saltati) { mesi_saltati = ''; }
    $.ajax({ type: "GET", cache: false, url: http_path + "ajax/F_visualizza_partenze_mesi.aspx", data: "itinerario_programma_giorni_id=" + itinerario_programma_giorni_id + "&tipologia_itinerario=" + $('#ctl00_centre_HiddenField_sel_tipologia_itinerari').attr('value') + "&tema=" + $('#ctl00_centre_HiddenField_sel_temi').attr('value') + "&periodo=" + $('#ctl00_centre_HiddenField_sel_periodi').attr('value') + "&destinazione=" + $('#ctl00_centre_HiddenField_sel_destinazioni').attr('value') + "&compagnia=" + $('#ctl00_centre_HiddenField_sel_compagnie').attr('value') + "&nave=" + $('#ctl00_centre_HiddenField_sel_navi').attr('value') + "&durata=" + $('#ctl00_centre_HiddenField_sel_durata').attr('value') + "&mese=" + mese + "&anno=" + anno + "&pag_ultimo_mese=" + pag_ultimo_mese + "&pag_ultimo_anno=" + pag_ultimo_anno + "&direction=" + direction + "&offerta=" + offerta_id + "&mesi_saltati=" + mesi_saltati + "&seleziona_mese=" + seleziona_mese, async: false, error: function() { }, beforeSend: function() { $('#partenze_mesi_' + itinerario_programma_giorni_id).html('caricamento...'); }, success: function(msg) { $('#partenze_mesi_' + itinerario_programma_giorni_id).html(msg); } }); $('#partenze_giorni_' + itinerario_programma_giorni_id).html(''); return false;
}
function F_cambia_partenza(obj, itinerario_programma_giorni_id, mese, anno, offerta) { var sel_partenza = obj.options[obj.selectedIndex].getAttribute('value'); if (sel_partenza != '') { var sel_mese = obj.options[obj.selectedIndex].getAttribute('ajax_mese_partenza'); var sel_anno = obj.options[obj.selectedIndex].getAttribute('ajax_anno_partenza'); var sel_pag_ultimo_mese = obj.options[obj.selectedIndex].getAttribute('ajax_pag_ultimo_mese'); var sel_pag_ultimo_anno = obj.options[obj.selectedIndex].getAttribute('ajax_pag_ultimo_anno'); var sel_pag_direction = obj.options[obj.selectedIndex].getAttribute('ajax_pag_direction'); var sel_mesi_saltati = obj.options[obj.selectedIndex].getAttribute('ajax_mesi_saltati'); var sel_seleziona_mese = obj.options[obj.selectedIndex].getAttribute('ajax_seleziona_mese'); var sel_seleziona_anno = obj.options[obj.selectedIndex].getAttribute('ajax_seleziona_anno'); } }
function F_lista_partenze_una_data(id_programma, mese, anno, offerta, prefisso_control_id) {
    var conta_opzioni_select = 0
    for (i = 0; i < document.getElementsByTagName("select").length - 1; i++) {
        var select_id = $(document.getElementsByTagName("select")[i]).attr("id"); if (select_id.indexOf("lista_partenze") > -1) {
            for (index = 0; index < document.getElementsByTagName("select")[i].length; index++) { conta_opzioni_select = conta_opzioni_select + 1; }
            if (conta_opzioni_select == 2) { 
				$('#ctl00_centre_UCBoxItinerario_div_CalPartenzeMesi').attr("style", "display:none"); 
				$('#ctl00_centre_UCBoxItinerario_div_accontoDinamicoPartenzeMesi').attr("style", "width:100%"); 
				$('#ctl00_centre_UCBoxItinerario_div_CalPartenzeGiorni').attr("style", "display:none"); 
				$('#ctl00_centre_UCBoxItinerario_div_accontoDinamico').attr("style", "width:100%"); 
				document.getElementsByTagName("select")[i].selectedIndex = 1; 
				F_cambia_partenza(document.getElementsByTagName("select")[i], id_programma, mese, anno, ''); 
				setTimeout('__doPostBack(\'' + $(document.getElementsByTagName("select")[i]).attr("id") + '\',\'\')', 0); }
        }
    }

    if (prefisso_control_id != '') {

        if (document.getElementById(prefisso_control_id + "_wizard_prenotazione_data_partenza_lbl")) { if (
		$("#" + prefisso_control_id + "_wizard_prenotazione_data_partenza_lbl").css("display") == 'none') { 
			$("#ctl00_centre_UCBoxItinerario_div_CalPartenzeMesi").css("display", '');
			$('#ctl00_centre_UCBoxItinerario_div_accontoDinamico').attr("style", "width:25%");		
		} else { 
			$("#ctl00_centre_UCBoxItinerario_div_CalPartenzeMesi").css("display", 'none');
			$('#ctl00_centre_UCBoxItinerario_div_accontoDinamico').attr("style", "width:100%");		
		} };
        /*
        if (document.getElementById("ctl00_centre_Wizard_louis_wizard_prenotazione_data_partenza_lbl")) { if ($("#ctl00_centre_Wizard_louis_wizard_prenotazione_data_partenza_lbl").css("display") == 'none') { $("#ctl00_centre_UCBoxItinerario_TableRowCalPartenzeMesi").css("display", ''); } else { $("#ctl00_centre_UCBoxItinerario_TableRowCalPartenzeMesi").css("display", 'none'); } }
        if (document.getElementById("ctl00_centre_Wizard_costa_wizard_prenotazione_data_partenza_lbl")) { if ($("#ctl00_centre_Wizard_costa_wizard_prenotazione_data_partenza_lbl").css("display") == 'none') { $("#ctl00_centre_UCBoxItinerario_TableRowCalPartenzeMesi").css("display", ''); } else { $("#ctl00_centre_UCBoxItinerario_TableRowCalPartenzeMesi").css("display", 'none'); } }
        if (document.getElementById("ctl00_centre_Wizard_viking_wizard_prenotazione_data_partenza_lbl")) { if ($("#ctl00_centre_Wizard_viking_wizard_prenotazione_data_partenza_lbl").css("display") == 'none') { $("#ctl00_centre_UCBoxItinerario_TableRowCalPartenzeMesi").css("display", ''); } else { $("#ctl00_centre_UCBoxItinerario_TableRowCalPartenzeMesi").css("display", 'none'); } }
        */
    }

}
function F_cambia_data_partenza(obj, partenza_id, itinerario_id) {
    var tendina_trovata = false; for (i = 0; i < document.getElementsByTagName("select").length - 1; i++) {
        var select_id = $(document.getElementsByTagName("select")[i]).attr("id"); if (select_id.indexOf("lista_partenze") > -1) {
            $(obj).attr("href", "#"); $("#" + $(document.getElementsByTagName("select")[i]).attr("id") + " option[value=" + parseInt(partenza_id) + "]").attr("selected", true); setTimeout('__doPostBack(\'' + $(document.getElementsByTagName("select")[i]).attr("id") + '\',\'\')', 0)
            tendina_trovata = true;
        }
    }
    $(".partenze_giorni").addClass("link_azzurro_no_bold").removeClass("link_azzurro_bold"); $(obj).addClass("link_azzurro_bold").removeClass("link_azzurro_no_bold"); if (tendina_trovata == false) { return true; }
    else { return true; }
}
function F_pref_over(objTable, state) {
    if (state == 'over') { $(objTable).addClass("tbl_pref_sel").removeClass("tbl_pref"); }
    if (state == 'out') { $(objTable).addClass("tbl_pref").removeClass("tbl_pref_sel"); }
}
function F_last_minute_over(objTable, state) {
    if (state == 'over') { $(objTable).addClass("tbl_last_minute_sel"); }
    if (state == 'out') { $(objTable).removeClass("tbl_last_minute_sel"); }
}
function F_promo_over(objBox, state) {
    if (state == 'over') { $(objBox).addClass("box_promozione_sel").removeClass("box_promozione"); }
    if (state == 'out') { $(ot_minutbjBox).addClass("box_promozione").removeClass("box_promozione_sel"); }
}
function F_calendar_day_over(objTr, state) {
    if (state == 'over') { $(objTr).addClass("tr_giorno_partenza_sel").removeClass("tr_giorno_partenza"); }
    if (state == 'out') { $(objTr).addClass("tr_giorno_partenza").removeClass("tr_giorno_partenza_sel"); }
}
function F_cerca_codice(event) { if (event.keyCode == 13) { $("#ctl00_lkb_cerca").focus(); $("#ctl00_lkb_cerca").click(); __doPostBack('ctl00$lkb_cerca', ''); } }
function F_cerca_porto(event) { if (event.keyCode == 13) { $("#ctl00_centre_cerca_btn").focus(); $("#ctl00_centre_cerca_btn").click(); __doPostBack('ctl00$centre$cerca_btn', ''); } }


function F_campi_obbligatori_richiesta(tipo_pagamento) {
    if (tipo_pagamento == 0 || tipo_pagamento == 1 || tipo_pagamento == 2 || tipo_pagamento == 3) {

        $('#obbligatorio_richiedente_cognome').html('*');
        $('#obbligatorio_richiedente_nome').html('*');
        $('#obbligatorio_richiedente_indirizzo').html('*');
        $('#obbligatorio_richiedente_citta').html('*');
        $('#obbligatorio_richiedente_provincia').html('*');
        $('#obbligatorio_richiedente_cap').html('*');
        $('#obbligatorio_richiedente_nazionalita').html('*');
        $('#obbligatorio_richiedente_email').html('*');
        $('#obbligatorio_richiedente_telefono').html('*');
        $('#obbligatorio_richiedente_cellulare').html('');
        $('#info_passeggeri').html('i campi contrassegnati da * sono obbligatori');
        $('#info_dati_richiedente').html('');

    }
    else if (tipo_pagamento == 4) {

        $('#obbligatorio_richiedente_cognome').html('*');
        $('#obbligatorio_richiedente_nome').html('*');
        $('#obbligatorio_richiedente_indirizzo').html('');
        $('#obbligatorio_richiedente_citta').html('');
        $('#obbligatorio_richiedente_provincia').html('');
        $('#obbligatorio_richiedente_cap').html('');
        $('#obbligatorio_richiedente_nazionalita').html('');
        $('#obbligatorio_richiedente_email').html('*');
        $('#obbligatorio_richiedente_telefono').html('*');
        $('#obbligatorio_richiedente_cellulare').html('');
        $('#info_passeggeri').html('i campi contrassegnati da * sono obbligatori');
        $('#info_dati_richiedente').html('i campi contrassegnati da * sono obbligatori');

    } 
}



function imposta_visibilita_elemento(id_elemento_da_gestire, id_elemento_che_apre, id_elemento_che_chiude, id_hidden_nascondi) {

    /* inizio - controllo se l'id_elemento_da_gestire ha come stile display:none */
    /* - se l'id_elemento_da_gestire display:none allora non visualizzo il box che nasconde l'id_elemento_da_gestire*/
    /* - altrimenti visualizzo il box che nasconde l'id_elemento_da_gestire*/
    if ($("#" + id_hidden_nascondi).val() == "1") {
        $("#" + id_elemento_che_apre).css("display", "");
        $("#" + id_elemento_che_chiude).css("display", "none");
        $("#" + id_elemento_da_gestire).css("display", "none");
    }
    else {
        $("#" + id_elemento_che_apre).css("display", "none");
        $("#" + id_elemento_che_chiude).css("display", "");
        $("#" + id_elemento_da_gestire).css("display", "");
    }
    /* fine - controllo se l'id_elemento_da_gestire ha come stile display:none */

    /* inizio - associo ai 2 box(apri, chiudi) le funzioni per nascondere o rendere visibile l'id_elemento_da_gestire*/
    $("#" + id_elemento_che_chiude).click(function() {
        $(this).css("display", "none");
        $("#" + id_elemento_da_gestire).css("display", "none");
        $("#" + id_elemento_che_apre).css("display", "");
        $("#" + id_hidden_nascondi).val("1");
    });
    $("#" + id_elemento_che_apre).click(function() {
        $(this).css("display", "none");
        $("#" + id_elemento_da_gestire).css("display", "");
        $("#" + id_elemento_che_chiude).css("display", "");
        $("#" + id_hidden_nascondi).val("0");
    });
    /* fine - associo ai 2 box(apri, chiudi) le funzioni per nascondere o rendere visibile l'id_elemento_da_gestire*/

}

function preventivo_selezionato(id, nome_gridView, hiddenField, id_biglietto, linkConferma) {

    if (document.getElementById(id).checked == true) {
        document.getElementById(hiddenField).value = id_biglietto;
        document.getElementById(linkConferma).style.display = '';
    } else {
        document.getElementById(hiddenField).value = "";
        document.getElementById(linkConferma).style.display = 'none';
    }

    var righe = document.getElementById(nome_gridView).getElementsByTagName("tr");
    for (i = 1; i < righe.length; i++) {
        var input = righe[i].getElementsByTagName("td")[0].getElementsByTagName("input")[0];
        if (input.id != id) {
            input.checked = false;
        }
    }
}

function preventivo_selezionato_creazione(id) {

    if (id == 'CheckBox_lastminute') {
        document.getElementById('CheckBox_offerta').checked = false;
    }

    if (id == 'CheckBox_offerta') {
        document.getElementById('CheckBox_lastminute').checked = false;
    }

}

function modificaLabel(id) {

    if (document.getElementById(id).value == 0) {
        document.getElementById('LabelSconto').innerHTML = '- € ';
    }

    if (document.getElementById(id).value == 1) {
        document.getElementById('LabelSconto').innerHTML = '- % ';
    }

    if (document.getElementById(id).value == '') {
        document.getElementById('LabelSconto').innerHTML = '';
    }
}

function evidenzia_riga_selezionata(biglietto_id, nome_gridview, id_oggetto) {

    var nomeGridView = nome_gridview;
    var oggettoUtilizzato = id_oggetto;
    var span_riga;
    var span_biglietto;
    var riga_splittata;
    var biglietto_selezionato = biglietto_id;
    var righe = document.getElementById(nomeGridView).getElementsByTagName("tr");

    var biglietto_riga;
    var data_opzione;
    var stato_pratica;
    var stato_scadenza_opzione;
    var tipologia_richiesta;

    var now = new Date()
    var data_opzione_vera;
    for (i = 1; i < righe.length; i++) {
        span_riga = righe[i].getElementsByTagName("span")
        for (j = 1; j < span_riga.length; j++) {
            if (span_riga[j].id == "span_biglietto_id") {

                biglietto_riga = span_riga[j].innerHTML.split("_")[0]
                data_opzione = span_riga[j].innerHTML.split("_")[1].split(" ")[0]
                stato_pratica = span_riga[j].innerHTML.split("_")[2]
                stato_scadenza_opzione = span_riga[j].innerHTML.split("_")[3]
                tipologia_richiesta = span_riga[j].innerHTML.split("_")[4]

                data_opzione_vera = new Date(data_opzione.split("/")[2], data_opzione.split("/")[1] - 1, data_opzione.split("/")[0])

                if (biglietto_riga == biglietto_selezionato) {
                    righe[i].style.backgroundColor = '#87BBFF';
                } else {

                    if (i % 2) {
                        righe[i].style.backgroundColor = '#F8F8F8';
                    }
                    else {
                        righe[i].style.backgroundColor = '#E0E0E0';
                    }

                    //                    if (stato_scadenza_opzione == 1 && stato_pratica != 3 && stato_pratica != 4 && stato_pratica != 6) {
                    //                        if (dateDiff("d", now, data_opzione_vera) <= 0) {
                    //                            righe[i].style.backgroundColor = '#99CC99';
                    //                        }                
                    //                    }

                }
            }
        }
    }
}

/*
function F_nome_pagina() {
var sPath = window.location.pathname;
//var sPage = sPath.substring(sPath.lastIndexOf('\\') + 1);
var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
alert(sPage);
}
*/