﻿//Setta la cultura in italiano
function ChangeLanguageIta()
{
    var culture = document.getElementById(PortalId + "HFCulture");
    culture.value = "it-IT";
    __doPostBack(culture.id,"");
}

//Setta la cultura in inglese
function ChangeLanguageEng()
{
    var culture = document.getElementById(PortalId + "HFCulture");
    culture.value = "en-US";
    __doPostBack(culture.id,"");
}

//Setta la cultura in spagnolo
function ChangeLanguageEsp()
{
    var culture = document.getElementById(PortalId + "HFCulture");
    culture.value = "es-ES";
    __doPostBack(culture.id,"");
}

//Setta la cultura in tedesco
function ChangeLanguageDe()
{
    var culture = document.getElementById(PortalId + "HFCulture");
    culture.value = "de-DE";
    __doPostBack(culture.id,"");
}

//Setta la cultura in francese
function ChangeLanguageFr()
{
    var culture = document.getElementById(PortalId + "HFCulture");
    culture.value = "fr-FR";
    __doPostBack(culture.id,"");
}


function SelectAndata(row)
{
    var viaggio = document.getElementById(PortalId + 'ContentPlaceHolder1_HFAndata');
    viaggio.value = row;
    __doPostBack(viaggio.id,'');
}


function SelectRitorno(row)
{
    var viaggio = document.getElementById(PortalId + 'ContentPlaceHolder1_HFRitorno');
    viaggio.value = row;
    __doPostBack(viaggio.id,'');
}

function ConfermaAcquisto()
{
    var acq = document.getElementById(PortalId + 'ContentPlaceHolder1_HFAcq');
    acq.value=1;
    __doPostBack(acq.id,'');
}

function noBack()
{
    window.history.forward(); 
}

function Print()
{
    var headstr = "<html><head><title>Print</title><link rel='stylesheet' type='text/css' href='../App_Themes/Theme/Theme.css' media='print'></head><body>";
    var footstr = "</body></html>"
    var WinPrint = window.open('','Print','width=950,height=600,location=no,scrollbars=no,toolbar=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,dependent=yes');
    WinPrint.document.write(headstr + document.getElementById(PortalId + 'ContentPlaceHolder1_divStampa').innerHTML + footstr);
    WinPrint.document.close();
    WinPrint.focus();
    WinPrint.print();
}

function copyName()
{
    var cognome = document.getElementById(PortalId + 'ContentPlaceHolder1_txtCogPax');
    var nome = document.getElementById(PortalId + 'ContentPlaceHolder1_txtNomePax'); 
    var lbltit = document.getElementById(PortalId + 'ContentPlaceHolder1_lblTit');
    var cctit = document.getElementById(PortalId + 'ContentPlaceHolder1_TxtTitCarta');
    
    if (lbltit != null) 
    {
        lbltit.innerHTML = cognome.value + ' ' +nome.value;
        lbltit.value = cognome.value + ' ' +nome.value;
    }
    if (cctit != null) cctit.value = cognome.value + ' ' + nome.value;
    
    return true;
}

function onOkSist(titolo, num)
{
    //textbox da cui prendere i valori
    var adIns = document.getElementById(PortalId + 'ContentPlaceHolder1_UC' + titolo + '_txtNumAd');
    var bamIns = document.getElementById(PortalId + 'ContentPlaceHolder1_UC' + titolo + '_txtNumBam');
    var infIns = document.getElementById(PortalId + 'ContentPlaceHolder1_UC' + titolo + '_txtNumInf');
    var chk = document.getElementById(PortalId + 'ContentPlaceHolder1_UC' + titolo + '_chkCopySist'); 

    //hidden field x captare change sist
    var hfSist = document.getElementById(PortalId + 'ContentPlaceHolder1_UC' + titolo + '_HFInsSist' + num);
    hfSist.value = adIns.value + "-" + bamIns.value + "-" + infIns.value;
    
    if (chk != null)
        hfSist.value += ';' + chk.checked;

    //svuoto textbox
    adIns.value = "";
    bamIns.value = "";
    infIns.value = "";

    __doPostBack(hfSist.id,'');
}

function onCancelSist(titolo, num)
{
    var hfCanc = document.getElementById(PortalId + 'ContentPlaceHolder1_UC' + titolo + '_HFCancelSist');
    hfCanc.value = num;
    
    __doPostBack(hfCanc.id,'');
}

function onOkVei(titolo, num)
{
    var numVeiIns = document.getElementById(PortalId + 'ContentPlaceHolder1_UC' + titolo + '_txtNumVei');
    var lungVeiIns = document.getElementById(PortalId + 'ContentPlaceHolder1_UC' + titolo + '_listLungVei');
    var chk = document.getElementById(PortalId + 'ContentPlaceHolder1_UC' + titolo + '_chkCopyVeicolo'); 
    
    var hfVei = document.getElementById(PortalId + 'ContentPlaceHolder1_UC' + titolo + '_HFInsVei' + num);
    hfVei.value = numVeiIns.value + "-";
    if (lungVeiIns != null) hfVei.value += lungVeiIns.value;
    
    if (chk != null)
        hfVei.value += ';' + chk.checked;
    
    __doPostBack(hfVei.id,'');
}

function onCancelVei(titolo, num)
{
    var hfCanc = document.getElementById(PortalId + 'ContentPlaceHolder1_UC' + titolo + '_HFCancelVei');
    hfCanc.value = num;
    
    __doPostBack(hfCanc.id,'');
}

function onOkAnim(titolo)
{
    var numAnimIns = document.getElementById(PortalId + 'ContentPlaceHolder1_UC' + titolo + '_txtNumAnim');
    var hfAnim = document.getElementById(PortalId + 'ContentPlaceHolder1_UC' + titolo + '_HFInsAnim');
    var chk = document.getElementById(PortalId + 'ContentPlaceHolder1_UC' + titolo + '_chkCopyAnimale'); 
    
    if (numAnimIns.value == "") hfAnim.value = "-";
    else hfAnim.value = numAnimIns.value;
    
    if (chk != null)
        hfAnim.value += ';' + chk.checked;
    
    __doPostBack(hfAnim.id,'');
}

function onCancelAnim(titolo)
{
    var hfCanc = document.getElementById(PortalId + 'ContentPlaceHolder1_UC' + titolo + '_HFCancelAnim');
    hfCanc.value = '1';
    
    __doPostBack(hfCanc.id,'');
}

function onOkVia()
{    
    var hfNuovoVia = document.getElementById(PortalId + 'ContentPlaceHolder1_HFNuovoViaggio');
    hfNuovoVia.value = '1';
    
    __doPostBack(hfNuovoVia.id,'');
}

function onCancelVia()
{
    var hfCanc = document.getElementById(PortalId + 'ContentPlaceHolder1_HFCancelVia');
    hfCanc.value = '1';
    
    __doPostBack(hfCanc.id,'');
}

//select viaggi nelle grid della popup
function SelectViaggioPopup(row)
{
    var viaggio = document.getElementById(PortalId + 'ContentPlaceHolder1_HFViaggi');
    viaggio.value = row;
    __doPostBack(viaggio.id,'');
}
function SelectViaggioRPopup(row)
{
    var viaggio = document.getElementById(PortalId + 'ContentPlaceHolder1_HFRitorno');
    viaggio.value = row;
    __doPostBack(viaggio.id,'');
}

function chkShowRitornoOnClick(strMex)
{
    var chkBox = document.getElementById(PortalId + 'ContentPlaceHolder1_UCRitorno_chkShowRitorno');
    
    if (chkBox.checked)
    {
        var chkSel = document.getElementById(PortalId + 'ContentPlaceHolder1_UCRitorno_HFchkRitorno');
        chkSel.value = '1';
        __doPostBack(chkSel.id,'');
    }
    else
    {
        if (window.confirm(strMex) == true)
        {
            var chkDeSel = document.getElementById(PortalId + 'ContentPlaceHolder1_UCRitorno_HFunchkRitorno');
            chkDeSel.value = '1';
            __doPostBack(chkDeSel.id,'');
        }
        else chkBox.checked = true;
    } 
}

function CambiaViaggioByCalendario(newVia)
{
    index = 0;
    if ((navigator.appName == 'Netscape') || (navigator.appName == 'Opera')) index = 1;
    
    for (i=0; i<window.opener.document.body.childNodes[index].length; i=i+1)
    {
	    if (window.opener.document.body.childNodes[index][i].id.match("HFNuovoViaggio"))
	    {
	        var via = window.opener.document.getElementById(window.opener.document.body.childNodes[index][i].id);
            via.value = newVia;
            window.close();
            window.opener.focus();
            window.opener.__doPostBack(via.id,'');
	    }
    }
}

function PrintTck()
{
    document.getElementById('divStampaTck').style.visibility = 'hidden'; 
    var headstr = "<html><head><link rel='stylesheet' type='text/css' href='../App_Themes/Theme/Theme.css' media='print'></head><body style=\"background-color:White; color:Black;\">";
    var footstr = "</body></html>"
    var WinPrint = window.open('','PrintTicket','left=130,top=130,width=750,height=500,location=no,toolbar=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,dependent=yes');
    WinPrint.document.write(headstr + document.getElementById('divBiglietto').innerHTML + footstr);
    WinPrint.document.close();
    WinPrint.focus();
    WinPrint.print();
}
