
// ---------------------------------------------------------------------------------------------------------------------- //
// Funzione per l'aggiunta dei bookmark

    function add_bookmark() {

        var url = document.location;
        if (url == '')
        	url = 'http://www.albergodiffusosmerillo.com/';
        	
        var title = document.title;
        if (title == '')
        	title = 'albergodiffuso marche in Italy';
        
        if (window.sidebar && window.sidebar.addPanel) { 
            window.sidebar.addPanel(title, url,""); 
        } else if( document.all ) {
            window.external.AddFavorite(url, title);
        } else if( window.opera && window.print ) {
            return true;
        }
    }
    
    
// ---------------------------------------------------------------------------------------------------------------------- //
// Funzione per il riempimento delle select delle date
    
    function riempi_select_giorni_prenotazione(id_select_annomese_in, id_select_giorno_out){
    
    
        // Recupero l'oggetto della select dell'annomese e ne ricavo i valori
        var select_annomese_in = document.getElementById(id_select_annomese_in);
        var anno = intval(select_annomese_in.value.substr(0, 4));
        var mese = intval(select_annomese_in.value.substr(4, 2))-1;
        
        // Recupero l'oggetto della select del giorno
        var select_giorno_out = document.getElementById(id_select_giorno_out);

        var num_giorni = new Date(anno, mese+1, 0).getDate();
        
        var giorno_selezionato = Math.max(select_giorno_out.selectedIndex, 0);

        //alert(select_annomese_in.value+' -> '+select_giorno_out.options.length+' '+num_giorni);
        
        if(select_giorno_out.options.length >= num_giorni){
            while(select_giorno_out.options.length > num_giorni)
                select_giorno_out.options[select_giorno_out.options.length-1] = null;
            
        }else{
            for(i=select_giorno_out.options.length; i<num_giorni; i++){
                opt_label = i+1;
                if(opt_label < 10)
                    opt_label = "0"+opt_label;
                select_giorno_out.options[i] = new Option(opt_label, i+1);
            }
        }
        
        giorno_selezionato = Math.min(giorno_selezionato, select_giorno_out.options.length-1);
        
        select_giorno_out.selectedIndex = giorno_selezionato;
        
    }
    
    
    
    

// ---------------------------------------------------------------------------------------------------------------------- //
// Funzione per la creazione del daystamp
    
    function daystamp(timestamp){
    
    
        if((timestamp == null) || isNaN(timestamp))
            timestamp = new Date();
    
        var anno = timestamp.getFullYear();
        var mese = timestamp.getMonth();
        var giorno = timestamp.getDate();
        
        if(mese < 10)
            mese = '0'+mese;
        
        if(giorno < 10)
            giorno = '0'+giorno;
        
        return parseInt(anno+''+mese+''+giorno);
    }
    
    
    
    

// ---------------------------------------------------------------------------------------------------------------------- //
// Funzione per la creazione del daystamp
    
    function datestamp(timestamp){
    
    
        if((timestamp == null) || isNaN(timestamp))
            timestamp = new Date();
    
        var anno = timestamp.getFullYear();
        var mese = timestamp.getMonth()+1;
        var giorno = timestamp.getDate();
        
        if(mese < 10)
            mese = '0'+mese;
        
        if(giorno < 10)
            giorno = '0'+giorno;
        
        return giorno+'-'+mese+'-'+anno;
    }
    
    
    
    

// ---------------------------------------------------------------------------------------------------------------------- //
// Funzione per la creazione del monthstamp
    
    function monthstamp(timestamp, select_value){
    
        if(timestamp == null)
            timestamp = new Date();
    
        var anno = timestamp.getFullYear();
        var mese = timestamp.getMonth()+(select_value ? 1 : 0);
        
        if(mese < 10)
            mese = '0'+mese;
        
        return parseInt(anno+''+mese);
    }
    
    
    

// ---------------------------------------------------------------------------------------------------------------------- //
// Funzione per la gestione degli errori javascript
    
    window.onerror = function(err, filename, line){
        log_error("["+filename+" @ linea: "+line+"] - ERRORE JS: "+err, true);
    }
    
    
    
    

// ---------------------------------------------------------------------------------------------------------------------- //
// Funzione per la selezione dei giorni della prenotazione
    
    function seleziona_giorno_arrivo_prenotazione(timestamp){
        seleziona_giorno_prenotazione('prenotazione_annomese_arrivo', 'prenotazione_giorno_arrivo', monthstamp(timestamp, true), timestamp.getDate());
    }
    
    function seleziona_giorno_partenza_prenotazione(timestamp){
        seleziona_giorno_prenotazione('prenotazione_annomese_partenza', 'prenotazione_giorno_partenza', monthstamp(timestamp, true), timestamp.getDate());
    }
    
    function seleziona_giorno_prenotazione(id_select_annomese, id_select_giorno, annomese, giorno){
    
        
        var select_annomese = document.getElementById(id_select_annomese);
        var select_giorno = document.getElementById(id_select_giorno);
        
        var i;
        for(i=0; i<select_annomese.options.length; i++)
            if(select_annomese.options[i].value == annomese){
                select_annomese.selectedIndex = i;
                break;
            }
        
        riempi_select_giorni_prenotazione(id_select_annomese, id_select_giorno);
        
        for(i=0; i<select_giorno.options.length; i++)
            if(parseInt(select_giorno.options[i].value) == giorno){
                select_giorno.selectedIndex = i;
                break;
            }
        
    }
    
    
    
    

// ---------------------------------------------------------------------------------------------------------------------- //
// Funzione per l'aggiornamento dei giorni nel mese

    function aggiorna_giorni_prenotazione(){
    
        // Riempio le select dei giorni con il numero di giorni corretto
        riempi_select_giorni_prenotazione('prenotazione_annomese_arrivo', 'prenotazione_giorno_arrivo');
        riempi_select_giorni_prenotazione('prenotazione_annomese_partenza', 'prenotazione_giorno_partenza');

    }
    
    
    
    
    

// ---------------------------------------------------------------------------------------------------------------------- //
// Funzione per l'aggiornamento dei giorni nel mese

    function aggiorna_giorni_prenotazione_struttura(){
    
        // Riempio le select dei giorni con il numero di giorni corretto
        riempi_select_giorni_prenotazione('prenotazione_annomese_arrivo_struttura', 'prenotazione_giorno_arrivo_struttura');
        riempi_select_giorni_prenotazione('prenotazione_annomese_partenza_struttura', 'prenotazione_giorno_partenza_struttura');

    }
    
    
    
    
function intval(stringa){

    var reg_exp = /^[0]*/;
    return parseInt(stringa.replace(reg_exp, ''));
}

// ---------------------------------------------------------------------------------------------------------------------- //
// Funzione per la gestione degli errori javascript

    function allinea_giorni_prenotazione(){
        allinea_giorni_prenotazione_base('prenotazione_giorno_arrivo', 'prenotazione_annomese_arrivo', 'prenotazione_giorno_partenza', 'prenotazione_annomese_partenza', 'prenotazione_checkin', 'prenotazione_checkout')
    }
    
    function allinea_giorni_prenotazione_struttura(){
        allinea_giorni_prenotazione_base('prenotazione_giorno_arrivo_struttura', 'prenotazione_annomese_arrivo_struttura', 'prenotazione_giorno_partenza_struttura', 'prenotazione_annomese_partenza_struttura', 'prenotazione_checkin_struttura', 'prenotazione_checkout_struttura')
    }
    
    function allinea_giorni_prenotazione_base(id_giorno_arrivo, id_annomese_arrivo, id_giorno_partenza, id_annomese_partenza, id_data_arrivo_hidden, id_data_partenza_hidden){

        
        // Recupero la data di arrivo
        var select_annomese_arrivo = document.getElementById(id_annomese_arrivo);
        var select_giorno_arrivo = document.getElementById(id_giorno_arrivo);
        var anno_arrivo = intval(select_annomese_arrivo.value.substr(0, 4));
        var mese_arrivo = intval(select_annomese_arrivo.value.substr(4, 2))-1;
        var giorno_arrivo = intval(select_giorno_arrivo.value);
        var data_arrivo = new Date(anno_arrivo, mese_arrivo, giorno_arrivo);
        
        
        // Recupero la data di partenza
        var select_annomese_partenza = document.getElementById(id_annomese_partenza);
        var select_giorno_partenza = document.getElementById(id_giorno_partenza);
        var anno_partenza = intval(select_annomese_partenza.value.substr(0, 4));
        var mese_partenza = intval(select_annomese_partenza.value.substr(4, 2))-1;
        var giorno_partenza = intval(select_giorno_partenza.value);
        
        var data_partenza = new Date(anno_partenza, mese_partenza, giorno_partenza);
        
/*        
        // Controllo che la data di arrivo sia successiva o uguale ad oggi
        if(daystamp(data_arrivo) < daystamp()){
            data_arrivo = new Date();
            seleziona_giorno_prenotazione(id_annomese_arrivo, id_giorno_arrivo, monthstamp(data_arrivo, true), data_arrivo.getDate());
        }
*/        
        
        // Controllo che la data di partenza sia a quella di arrivo
        if(daystamp(data_partenza) <= daystamp(data_arrivo)){
            data_partenza = new Date(data_arrivo.getFullYear(), data_arrivo.getMonth(), data_arrivo.getDate()+1);
            seleziona_giorno_prenotazione(id_annomese_partenza, id_giorno_partenza, monthstamp(data_partenza, true), data_partenza.getDate());
        }
        
        document.getElementById(id_data_arrivo_hidden).value = datestamp(data_arrivo);
        document.getElementById(id_data_partenza_hidden).value = datestamp(data_partenza);
    }    
    
    
    
    

// ---------------------------------------------------------------------------------------------------------------------- //
// Funzione per la segnalazione di foto mancante

    var foto_mancante = new Image();

    function missing_photo(id_foto, obj_foto){
        if(!foto_mancante.src)
            foto_mancante.src = '/immagini/foto_mancante.gif';
        
        log_warning('Manca la foto id: '+id_foto);
        if(obj_foto){
            obj_foto.style.borderWidth = '0px';
            obj_foto.src = foto_mancante.src;
        }
    }
    
    
    
    

// ---------------------------------------------------------------------------------------------------------------------- //
// Funzione per la segnalazione di mappa mancante

    var mappa_mancante = new Image();

    function missing_map(localita, obj_foto){
        if(!mappa_mancante.src)
            mappa_mancante.src = '/immagini/foto_mancante.gif';
        
        log_warning('Manca la mappa della localita '+localita);
        if(obj_foto){
            obj_foto.style.borderWidth = '0px';
            obj_foto.src = mappa_mancante.src;
            obj_foto.style.width = 'auto';
            obj_foto.style.height = 'auto';
        }
    }
    
    
    
    

// ---------------------------------------------------------------------------------------------------------------------- //
// Rollover dei link dei paragrafi nella scheda struttura

    var freccia_link = new Image();
    var freccia_link_hover = new Image();

    function freccia_link_over(obj_link){
        if(!freccia_link_hover.src)
            freccia_link_hover.src = '/immagini/freccia_link_over.gif';
            
        obj_link.getElementsByTagName('img')[0].src =  freccia_link_hover.src;
    }

    function freccia_link_out(obj_link){
        if(!freccia_link.src)
            freccia_link.src = '/immagini/freccia_link_out.gif';
            
        obj_link.getElementsByTagName('img')[0].src =  freccia_link.src;
    }
    
    
    
    

// ---------------------------------------------------------------------------------------------------------------------- //
// Imposta l'opacitÃ  di un oggetto

function set_opacity(obj, opacity){

    obj.style.opacity = (opacity / 100);
    obj.style.MozOpacity = (opacity / 100);
    obj.style.KhtmlOpacity = (opacity / 100);
    obj.style.filter = "alpha(opacity=" + opacity + ")";
    
}
    
   

// ---------------------------------------------------------------------------------------------------------------------- //
// Prende un parametro dalla url

function get_url_param(strParamName){
    var strReturn = "";
    var strHref = window.location.href;
    if ( strHref.indexOf("?") > -1 ){
        var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
        var aQueryString = strQueryString.split("&");
        
        for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
            if ( aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
                var aParam = aQueryString[iParam].split("=");
                strReturn = aParam[1];
                break;
            }
        }
    }
    return strReturn;
}
    
    
    
    

// ---------------------------------------------------------------------------------------------------------------------- //
// Funzioni per il rollover dei pulsanti del layer dell'assistenza telefonica

    function btn_layer_over(obj){
        with(obj.style){
            border = 'solid 1px #d2dbe3';
            backgroundColor = '#f0f5fb';
        }
        
        obj.rows[0].cells[1].style.color = '#ff8000';
    }

    function btn_layer_out(obj){
        with(obj.style){
            border = 'solid 1px #f0f0f0';
            backgroundColor = '#ffffff';
        }
        
        obj.rows[0].cells[1].style.color = '#000000';
    }
    
    
    
    

// ---------------------------------------------------------------------------------------------------------------------- //
// Trim php-like

    function trim(stringa){
      return String(stringa).replace(/^\s*|\s*$/g,"");
    }
    
    
    
    

// ---------------------------------------------------------------------------------------------------------------------- //
// Corrispettivo javascript della funzione php number_format

    function number_format(numero, cifre_decimali, separatore_decimale, separatore_centinaia){
        if(separatore_decimale == undefined)
            separatore_decimale = '.';
            
        if(separatore_centinaia == undefined)
            separatore_centinaia = '';
        
        if(isNaN(numero))
            numero = 0;
        
        var regexp_numero = /^[0-9\.]+$/;
        if(!regexp_numero.test(numero.toString()) || (cifre_decimali < 0))
            return false;
        
        numero = parseFloat(numero);
        
        var decimali = '', i, j;
        
        if(cifre_decimali > 0){
            decimali = (parseInt(numero*Math.pow(10, cifre_decimali))%Math.pow(10, cifre_decimali)).toString();
            while(decimali.length < cifre_decimali)
                decimali = '0'+decimali;
            decimali = separatore_decimale+decimali;
        }
            
        numero = parseInt(numero).toString();
        if((numero.length > 3) && (separatore_centinaia != '')){
            var temp_numero = '';
            j = 0;
            for(i=numero.length-1; i>=0; i--){
                if((j%3 == 0) && (j > 0))
                    temp_numero = separatore_centinaia+temp_numero;
                    
                temp_numero = numero.substr(i, 1)+temp_numero;
                j++;
            }
            numero = temp_numero;
        }
            
        
        
        return numero+decimali;
    }
    
    
    

// ---------------------------------------------------------------------------------------------------------------------- //
// strlen php-like

    function strlen(stringa){
      return stringa.length;
    }
    
    
    
    

// ---------------------------------------------------------------------------------------------------------------------- //
// strlen php-like

    function create_get_array(obj_document){

        if(obj_document == null)
            obj_document = document;

        var str=new String(obj_document.location.href);
        
        pstart=str.search(/\?/)
        if(pstart==-1)
          return new Array();
          
        var params_array = str.substr(pstart+1).split('&');
        var ritornato = new Array();
        var i;
        
        for(i=0; i<params_array.length; i++){
        
            pstart=params_array[i].search(/\=/)
            if(pstart==-1)
                continue;
          
            var temp = params_array[i].split('=');
            ritornato[temp[0]] = temp[1];
        }

        return ritornato;
    }




// ---------------------------------------------------------------------------------------------------------------------- //


    function ajax_struct2array(string_struct){
    
        if((string_struct.substr(0,1) != '[') || (string_struct.substr(string_struct.length-1) != ']'))
            return false;
    
        string_struct = string_struct.substr(1,string_struct.length-2);
    
        var coppie = string_struct.split('|');
        var ritornato = new Array(), i, j;
        
        for(i in coppie){
            if(trim(coppie[i]) == '')
                continue;
            
            var valori = coppie[i].split('=');
            if(valori.length < 2)
                continue;
                
            var temp_valori = new Array();
            for(j=1; j<valori.length; j++)
                temp_valori[temp_valori.length] = valori[j];
                
            ritornato[valori[0]] = trim(temp_valori.join('='));
        }
        
        return ritornato;
    }


// ---------------------------------------------------------------------------------------------------------------------- //
// Da associare all'onMouseKeyDown

    function is_numeric_key(evt){
        if(evt.which)
            var code = evt.which;
        else
            var code = evt.keyCode;
    
        if(evt.shiftKey)
            return false;
            
        var caratteri_accettati = new String('0123456789');
    
        if( (caratteri_accettati.indexOf(String.fromCharCode(code)) > -1) ||
            (code == 8) || // backspace
            (code == 9) || // tab
            (code == 13) || // enter
            (code == 33) || // page up
            (code == 34) || // page down
            (code == 35) || // end
            (code == 36) || // home
            (code == 37) || // left arrow
            (code == 38) || // up arrow
            (code == 39) || // right arrow
            (code == 40) || // down arrow
            (code == 45) || // insert
            (code == 46) || // delete
            ((code >= 96) && (code <= 105)) || // numpad
            ((code >= 112) && (code <= 123)) // fXX
        ){
            return true;
        }
        
        return false;
    }


// ---------------------------------------------------------------------------------------------------------------------- //


    function is_email(email){
    /*
        var regExpEmail = new RegExp(/^[a-zA-Z0-9_\-\.\+]+@[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,}$/);
        return regExpEmail.test(email);
    */

        // Recupero la posizione della @
        chicciola = email.indexOf('@');
        // non trovato
        if(chicciola == -1)
            return false;
        // primo carattere
        if(chicciola == 0)
            return false;
            
            
        // Recupero la posizione del . dopo @
        punto = email.substr(chicciola).indexOf('.');
        // non trovato
        if(punto == -1)
            return false;
        // primo carattere dopo @
        if(punto == 0)
            return false;
        // ultimo carattere
        if(punto > (email.substr(chicciola).length-3))
            return false;

        return true;
    }


// ---------------------------------------------------------------------------------------------------------------------- //


    function is_telefono(telefono){
    /*
        var regExpEmail = new RegExp(/^[a-zA-Z0-9_\-\.\+]+@[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,}$/);
        return regExpEmail.test(email);
    */

        if(telefono.length == 0)
            return false;
    
        var caratteri_accettati = "0123456789 /-\\+.", i;
        for(i=0; i<telefono.length; i++)
            if(caratteri_accettati.indexOf(telefono.substr(i,1)) == -1)
                return false;
        
        
        return true;
    }


// ---------------------------------------------------------------------------------------------------------------------- //


    function is_numeric(stringa){

        if(stringa.length == 0)
            return false;
    
        var caratteri_accettati = "0123456789 ", i;
        for(i=0; i<stringa.length; i++)
            if(caratteri_accettati.indexOf(stringa.substr(i,1)) == -1)
                return false;
        
        return true;
    }


// ---------------------------------------------------------------------------------------------------------------------- //


    function get_position(obj){
        var l=0; var t=0;
        
        aTag = obj;
        do {
            aTag = aTag.offsetParent;
            l += aTag.offsetLeft;
            t += aTag.offsetTop;
        } while (aTag.offsetParent && aTag.tagName != 'BODY');
        
        var left = obj.offsetLeft + l;
        var top = obj.offsetTop + t;

        return new Array(left, top);
    }

    
// ---------------------------------------------------------------------------------------------------------------------- //


    IE4 = (document.all);

    function myConfirm(messaggio){
        return newConfirm("InItalia.it", messaggio, 3, 1, 0)
    }
    
    function newConfirm(title,mess,icon,defbut,mods) {
       if (IE4) {
          icon = (icon==0) ? 0 : 2;
          defbut = (defbut==0) ? 0 : 1;
          retVal = makeMsgBox(title,mess,icon,4,defbut,mods);
          retVal = (retVal==6);
       }
       else {
          retVal = confirm(mess);
       }
       return retVal;
    }
    
    
    
// ---------------------------------------------------------------------------------------------------------------------- //


function is_function(obj){
    return typeof obj == 'function';
}

    
// ---------------------------------------------------------------------------------------------------------------------- //


function switch_display_object(id_object){
    if(document.getElementById(id_object).style.display != 'none')
        document.getElementById(id_object).style.display = 'none';
    else
        document.getElementById(id_object).style.display = 'block';
}

    
// ---------------------------------------------------------------------------------------------------------------------- //


    function next_page(){
    
        if(!document.getElementById('type_1'))
            return false;
    
        if(document.getElementById('type_1').checked)
            selected_type = 1;
        else if(document.getElementById('type_2').checked)
            selected_type = 2;
        else if(document.getElementById('type_3').checked)
            selected_type = 3;
        else
            return false;
        
        assistenza_telefonica.call('/ajax/assistenza_telefonica.php?type='+selected_type+'&lang=<%LANG%>');
    }
    
    
    
    function make_mail_link(label){
        return "<a class=\"bars\" href=\"#\"  onClick=\"document.location='mailto:?subject="+escape(document.title)+"&body="+escape(document.location)+"'; return false;\">"+label+" <img src=\"immagini/icona_invia.gif\" width=\"19\" height=\"11\" border=\"0\" alt=\"\" style=\"vertical-align: middle; margin-left: 5px;\"><"+"/a>";
    }


    
// ---------------------------------------------------------------------------------------------------------------------- //

// funzione per assegnare l'oggetto XMLHttpRequest
// compatibile con i browsers piÃ¹ recenti e diffusi
function mkXMLHttpRequest() {

    // lista delle variabili locali
    var
    // variabile di ritorno, nulla di default
    XHR = null,

    // informazioni sul nome del browser
    browserUtente = navigator.userAgent.toUpperCase();

    // browser standard con supporto nativo
    // non importa il tipo di browser
    if(typeof(XMLHttpRequest) === "function" || typeof(XMLHttpRequest) === "object")
        XHR = new XMLHttpRequest();

    // browser Internet Explorer
    // Ã¨ necessario filtrare la versione 4
    else if(
        window.ActiveXObject &&
        browserUtente.indexOf("MSIE 4") < 0
        ) {

            // la versione 6 di IE ha un nome differente
            // per il tipo di oggetto ActiveX
            if(browserUtente.indexOf("MSIE 5") < 0)
            XHR = new ActiveXObject("Msxml2.XMLHTTP");

            // le versioni 5 e 5.5 invece sfruttano lo stesso nome
        else
            XHR = new ActiveXObject("Microsoft.XMLHTTP");
    }

    return XHR;
}
    
    
    
    

// ---------------------------------------------------------------------------------------------------------------------- //
// Funzione per loggare gli errori javascript
    
    function log_error(errore, no_prefix){
        var request = mkXMLHttpRequest();
        
        if(request == null)
            return;
        
        if(no_prefix != true)
            errore = "ERRORE JS 1: "+errore;
        
        request.open("post", "/ajax/ajax.php", true);
        request.setRequestHeader("content-type", "application/x-www-form-urlencoded");
        request.setRequestHeader("connection", "close");
        request.send("type=error&errstr="+encodeURI(errore));
    }
    
    
    
    

// ---------------------------------------------------------------------------------------------------------------------- //
// Funzione per loggare gli errori javascript
    
    function log_warning(errore, no_prefix){
        var request = mkXMLHttpRequest();
        
        if(request == null)
            return;
        
        if(no_prefix != true)
            errore = "WARNING JS 2: "+errore;
        
        request.open("post", "/ajax/ajax.php", true);
        request.setRequestHeader("content-type", "application/x-www-form-urlencoded");
        request.setRequestHeader("connection", "close");
        request.send("type=warning&errstr="+encodeURI(errore));
    }

    
    
    
    

// ---------------------------------------------------------------------------------------------------------------------- //
// Funzione per loggare gli errori javascript
    
    function assistenza_telefonica_over(){
        var assistenza_sidebar = document.getElementById('assistenza_sidebar');
        if(!assistenza_sidebar)
            return void(0);
            
        assistenza_sidebar.className = 'assistenza_telefonica_sidebar_over';
    }
    
    function assistenza_telefonica_out(){
        var assistenza_sidebar = document.getElementById('assistenza_sidebar');
        if(!assistenza_sidebar)
            return void(0);
            
        assistenza_sidebar.className = 'assistenza_telefonica_sidebar';
    }

    
    
    
    

// ---------------------------------------------------------------------------------------------------------------------- //
// Funzione per l'highlight dei campi text dei form
    
    function get_row_parent(obj){
    
        var temp_obj = obj;
    
        do{
            temp_obj = temp_obj.parentNode;
        }while(temp_obj.parentNode && temp_obj.tagName.toLowerCase() != 'tr');
        
        return temp_obj;
    }

    function dati_utenti_focus(obj_input){
        obj_input.className = 'focus';
    
        var riga = get_row_parent(obj_input);
        //riga.className = 'focus';
        
        riga.cells[0].className = 'focus';
    }
    
    function dati_utenti_blur(obj_input){
        obj_input.className = null;
        
        var riga = get_row_parent(obj_input);
        //riga.className = null;
        
        riga.cells[0].className = null;
    }

    
    
    
    

// ---------------------------------------------------------------------------------------------------------------------- //
// Funzione per l'invio dei form in ajax


    function send_form_ajax(obj_form){
    
        /*
        if(obj_form.type != 'form'){
            alert('ERRORE: L\'oggetto \'obj_form\' non Ã¨ un form ma '+obj_form.type);
            return false;
        }
        */
    
        var campi = obj_form.getElementsByTagName('input'), i;
        
        if(campi.length == 0){
            alert('ERRORE: Il form non ha campi');
            return false;
        }
    
        var parametri = new Array();
        for(i=0; i<campi.length; i++)
            if(campi[i].type == 'checkbox'){
                if((campi[i].name != '') && campi[i].checked)
                    parametri[parametri.length] = campi[i].name+'='+encodeURIComponent(campi[i].value);
            }else{
                if(campi[i].name != '')
                    parametri[parametri.length] = campi[i].name+'='+encodeURIComponent(campi[i].value);
            }
        
        campi = obj_form.getElementsByTagName('textarea');
        for(i=0; i<campi.length; i++)
            parametri[parametri.length] = campi[i].name+'='+encodeURIComponent(campi[i].value);        
        
        campi = obj_form.getElementsByTagName('select');
        for(i=0; i<campi.length; i++)
            parametri[parametri.length] = campi[i].name+'='+encodeURIComponent(campi[i].value);        
        
        
        var request = mkXMLHttpRequest();
        
        request.open("post", "/ajax/static_form.php", true);
        request.setRequestHeader("content-type", "application/x-www-form-urlencoded");
        request.setRequestHeader("charset", "utf-8");
        request.setRequestHeader("connection", "close");
        
        request.onreadystatechange = function() {
            if(request.readyState === 4) {
                if(request.status === 200){
                    if(!/^[a-z_]+\|/.test(request.responseText)){
                        var type = 'error';
                        var mess = request.responseText;
                    }else{
                        var type = request.responseText.substr(0, request.responseText.indexOf('|'));
                        var mess = request.responseText.substr(request.responseText.indexOf('|')+1);
                    }
                    if(typeof return_handler == 'function')
                        return_handler(type, mess);
                }else{
                    alert('error');
                }
            } 
        }
        
        request.send(parametri.join('&'));
        
        return void(0);
        
    }
 

    
    
    
    

// ---------------------------------------------------------------------------------------------------------------------- //
// Funzione che controlla il formato delle date gg/mm/aaaa

    function is_ddmmyyyy_date(stringa){
        return /^[0-9]{1,2}[^0-9][0-9]{1,2}[^0-9][0-9]{4}$/.test(stringa);
    }


////////////////// PRECENDETE script_ttt.js



var main_ttt = document.createElement('div');
var ttt_text = document.createElement('div');
var ttt_bg_01 = document.createElement('div');
var ttt_bg_02 = document.createElement('div');
var ttt_bg_03 = document.createElement('div');
var ttt_bg_04 = document.createElement('div');
var ttt_bg_05 = document.createElement('div');
var ttt_bg_06 = document.createElement('div');
var ttt_bg_07 = document.createElement('div');
var ttt_bg_08 = document.createElement('div');
var ttt_bg_09 = document.createElement('div');
    
main_ttt.display = 'none';

function _ttt_obj_position(obj){
	var l=0; var t=0;
	
	aTag = obj;
	do {
		aTag = aTag.offsetParent;
		l += aTag.offsetLeft;
		t += aTag.offsetTop;
	} while (aTag.offsetParent && aTag.tagName != 'BODY');
	
	var left = obj.offsetLeft + l;
	var top = obj.offsetTop + t;

    return new Array(left, top, obj.offsetWidth);
}




function _ttt_make_txt(text, ttt_width, ttt_height){
    ttt_text.innerHTML = text;
    with(ttt_text.style){
        position = 'absolute';
        top = '7px';
        left = '7px';
        width = (ttt_width-14)+'px';
        height = (ttt_height-14)+'px';
        overflow = 'hidden';
        zIndex = 502;
        fontSize = '11px';
        color = '#000000';
    }
    main_ttt.appendChild(ttt_text);
}

function _ttt_make_bg(ttt_width, ttt_height){
    with(ttt_bg_01.style){
        position = 'absolute';
        top = '0px';
        left = '0px';
        width = '10px';
        height = '10px';
        backgroundImage = 'url(immagini/ttt_01.gif)';
        overflow = 'hidden';
        zIndex = 501;
    }
    main_ttt.appendChild(ttt_bg_01);
    
    with(ttt_bg_02.style){
        position = 'absolute';
        top = '0px';
        left = '10px';
        width = (ttt_width-20)+'px';
        height = '10px';
        backgroundImage = 'url(immagini/ttt_02.gif)';
        overflow = 'hidden';
        zIndex = 501;
    }
    main_ttt.appendChild(ttt_bg_02);
    
    with(ttt_bg_03.style){
        position = 'absolute';
        top = '0px';
        right = '0px';
        width = '10px';
        height = '10px';
        backgroundImage = 'url(immagini/ttt_03.gif)';
        overflow = 'hidden';
        zIndex = 501;
    }
    main_ttt.appendChild(ttt_bg_03);
    
    with(ttt_bg_04.style){
        position = 'absolute';
        top = '10px';
        left = '0px';
        width = '10px';
        height = (ttt_height-20)+'px';
        backgroundImage = 'url(immagini/ttt_04.gif)';
        overflow = 'hidden';
        zIndex = 501;
    }
    main_ttt.appendChild(ttt_bg_04);
    
    with(ttt_bg_05.style){
        position = 'absolute';
        top = '10px';
        left = '10px';
        width = (ttt_width-20)+'px';
        height = (ttt_height-20)+'px';
        backgroundImage = 'url(immagini/ttt_05.gif)';
        overflow = 'hidden';
        zIndex = 501;
    }
    main_ttt.appendChild(ttt_bg_05);
    
    with(ttt_bg_06.style){
        position = 'absolute';
        top = '10px';
        right = '0px';
        width = '10px';
        height = (ttt_height-20)+'px';
        backgroundImage = 'url(immagini/ttt_06.gif)';
        overflow = 'hidden';
        zIndex = 501;
    }
    main_ttt.appendChild(ttt_bg_06);
    
    with(ttt_bg_07.style){
        position = 'absolute';
        bottom = '0px';
        left = '0px';
        width = '10px';
        height = '10px';
        backgroundImage = 'url(immagini/ttt_07.gif)';
        overflow = 'hidden';
        zIndex = 501;
    }
    main_ttt.appendChild(ttt_bg_07);
    
    with(ttt_bg_08.style){
        position = 'absolute';
        bottom = '0px';
        left = '10px';
        width = (ttt_width-20)+'px';
        height = '10px';
        backgroundImage = 'url(immagini/ttt_08.gif)';
        overflow = 'hidden';
        zIndex = 501;
    }
    main_ttt.appendChild(ttt_bg_08);
    
    with(ttt_bg_09.style){
        position = 'absolute';
        bottom = '0px';
        right = '0px';
        width = '10px';
        height = '10px';
        backgroundImage = 'url(immagini/ttt_09.gif)';
        overflow = 'hidden';
        zIndex = 501;
    }
    main_ttt.appendChild(ttt_bg_09);
}

function show_ttt(obj, text, ttt_width, ttt_height, side){

    _ttt_make_bg(ttt_width, ttt_height);
    
    _ttt_make_txt(text, ttt_width, ttt_height);
    
    var posizione = _ttt_obj_position(obj);
    
    if((side == null) || (side == 'sx')){
        var ttt_corner = document.createElement('div');
        with(ttt_corner.style){
            position = 'absolute';
            bottom = '-30px';
            left = '-10px';
            width = '30px';
            height = '50px';
            backgroundImage = 'url(immagini/ttt_sx.gif)';
            overflow = 'hidden';
            zIndex = 501;
        }
        main_ttt.appendChild(ttt_corner);
        posizione[0] += ttt_width+10+posizione[2];
    }else{
        var ttt_corner = document.createElement('div');
        with(ttt_corner.style){
            position = 'absolute';
            bottom = '-30px';
            right = '-10px';
            width = '30px';
            height = '50px';
            backgroundImage = 'url(immagini/ttt_dx.gif)';
            overflow = 'hidden';
            zIndex = 501;
        }
        main_ttt.appendChild(ttt_corner);
        posizione[0] -= 10;
    }
    
    posizione[1] -= 30;
        
    
    with(main_ttt.style){
        position = 'absolute';
        left = (posizione[0]-ttt_width)+'px';
        top = (posizione[1]-ttt_height)+'px';
        width = ttt_width;
        height = ttt_height;
        zIndex = 500;
        display = 'block';
    }

}

function hide_ttt(){
    main_ttt.style.display = 'none';
}

function create_ttt(){
    document.body.appendChild(main_ttt);
}

function controlla_testo_search_box(text_field) {
	if (text_field.value.substr(0,6)=="hotel ") {
	
		if(typeof show_baloon_generic == 'function') 
			show_baloon_generic(text_field, cerca_hotel_help, 400);
	}
	
	return true;
		
}

////////////////// PRECENDETE script_layer.js



// valori show_type
//   0 -> centrato schermo
//   1 -> personalizzato
//   2 -> centrato oggetto
//   3 -> clipping angolo

function kLayer(layer_width, layer_height){
	
    var base_url = '';
    if(document.location.href.indexOf('https') == 0){
        var base_url = document.location.href.substr(document.location.href.indexOf('/')+2);
        if(base_url.indexOf('/') != -1)
            base_url = base_url.substr(0, base_url.indexOf('/'));
        base_url = 'https://'+base_url;
    }
    
    var ver_kLayer = 0.8;
    
	if(layer_width == null){
		layer_width = 320;
		layer_height = 240;
	}
	
    var _show_overlay = true;
    var _layer_move = false;
    
    var _clicked = false;
    var _start_x = 0;
    var _start_y = 0;
	
    var _script_ajax = '';
    
    var layer_left = 0;
    var layer_top = 0;
    
    var layer_mouseover = false;
    
    var _go_out_page = false;
    
    var zIndex_base = 150000;
    
    var show_type = 0;
    
    var custom_left = null;
    var custom_top = null;

    var obj_center_left = null;
    var obj_center_top = null;
    
    var clipping_left = null;
    var clipping_top = null;
    var clipping_width = null;
    var clipping_height = null;
    
    // ---------------------------------------------------------------------------------------------------------------------
    
    
    function errstr(error){
        return 'kLayer v'+ver_kLayer+"\nErrore:\n"+error;
    }
    
    
    // ---------------------------------------------------------------------------------------------------------------------
    
    
    var is_ie6 = false;
    if(navigator.appName.toLowerCase() == 'microsoft internet explorer'){
        var infos = navigator.appVersion.split(";");
        var i = 0;
        for(i=0; i<infos.length; i++)
            if(infos[i].toLowerCase().indexOf('msie') != -1)
                if(parseFloat(infos[i].substr(5)) <= 6){
                    is_ie6 = true;
                    break;
                }
    }

    
    // ---------------------------------------------------------------------------------------------------------------------
    
    
	function set_opacity(obj, opacity){
	    // IE filter opacity:
	    obj.style.filter = "alpha(opacity:" + opacity + ")";
	    // Safari and Konqueror:
	    obj.style.KHTMLOpacity = opacity / 100;
	    // Old Mozilla and Firefox:
	    obj.style.MozOpacity = opacity / 100;
	    // CSS3 opacity for browsers that support it:
	    obj.style.opacity = opacity / 100;
	}
	
	
	// ----------------------------------------------------------------------
	// Creo i layer per il catch dell'onclick sul body
	
    var layer_overlay = document.createElement('div');
    var layer_suboverlay = document.createElement('iframe');
 	
	with(layer_overlay.style){
		position = 'absolute';
        top = '0px';
        left = '0px';
        width = '100%';
        backgroundColor = '#2d4e59';
        display = 'none';
        zIndex = zIndex_base+1;
    }
	layer_overlay.inneHTML = '&nbsp;';
	set_opacity(layer_overlay, 75);
	
    layer_suboverlay.setAttribute('frameborder', '0', 0);
    with(layer_suboverlay.style){
        position = 'absolute';
        top = '0px';
        left = '0px';
        width = '100%';
        display = 'none';
        zIndex = zIndex_base;
        filter = 'mask()';
    }
	set_opacity(layer_suboverlay, 0);
   
	// ----------------------------------------------------------------------
	// Creo la tabella principale
	
	
	
    var main_sublayer = document.createElement('iframe');
    main_sublayer.setAttribute('frameborder', '0', 0);
    with(main_sublayer.style){
        position = 'absolute';
        display = 'none';
        zIndex = zIndex_base+2;
        width = layer_width+'px';
        height = layer_height+'px';
        filter = 'mask()';
    }
    var main_layer = document.createElement('div');
    with(main_layer.style){
        position = 'absolute';
        display = 'none';
        zIndex = zIndex_base+3;
    }
    
    var main_layer_table = document.createElement('table');
    main_layer_table.setAttribute('border', '0', 0);
    main_layer_table.setAttribute('cellspacing', '0', 0);
    main_layer_table.setAttribute('cellpadding', '0', 0);
    with(main_layer_table.style){
        position = 'absolute';
        width = layer_width+'px';
        height = layer_height+'px';
    }
    
    var main_layer_body = document.createElement('tBody');
    
    main_layer.appendChild(main_layer_table);
    
    main_layer_table.appendChild(main_layer_body);
	
    
    
	// ----------------------------------------------------------------------
	// Creo le righe
    
    var row_01 = document.createElement('tr');
    var row_03 = document.createElement('tr');
    var row_02 = document.createElement('tr');
	
    
    
	// ----------------------------------------------------------------------
	// Creo le celle
    
    var cell_01 = document.createElement('td');
    var cell_02 = document.createElement('td');
    var cell_03 = document.createElement('td');
    var cell_04 = document.createElement('td');
    var cell_05 = document.createElement('td');
    var cell_06 = document.createElement('td');
    var cell_07 = document.createElement('td');
    var cell_08 = document.createElement('td');
    var cell_09 = document.createElement('td');
    
    row_01.appendChild(cell_01);
    row_01.appendChild(cell_02);
    row_01.appendChild(cell_03);
    row_02.appendChild(cell_04);
    row_02.appendChild(cell_05);
    row_02.appendChild(cell_06);
    row_03.appendChild(cell_07);
    row_03.appendChild(cell_08);
    row_03.appendChild(cell_09);
    
    main_layer_body.appendChild(row_01);
    main_layer_body.appendChild(row_02);
    main_layer_body.appendChild(row_03);
	
    
    
	// ----------------------------------------------------------------------
	// Creo la barra di attesa
    
    var waiting_bar = document.createElement('img');
    waiting_bar.src = base_url+'immagini/working_wheel.gif';
    
    cell_05.appendChild(waiting_bar);
    
   

   
    // ---------------------------------------------------------------------------------------------------------------------

    set_png_bg(cell_01, base_url+'immagini/layer_01.png');
    with(cell_01.style){
        width = '8px';
        height = '8px';
    }
    
    set_png_bg(cell_02, base_url+'immagini/layer_02.png');
    with(cell_02.style){
        height = '8px';
    }
    
    set_png_bg(cell_03, base_url+'immagini/layer_03.png');
    with(cell_03.style){
        width = '8px';
        height = '8px';
    }
    
    set_png_bg(cell_04, base_url+'immagini/layer_04.png');
    with(cell_04.style){
        width = '8px';
    }

     
    //cell_05.innerHTML = '&nbsp;';
	cell_05.setAttribute('align', 'center', 0);
	cell_05.setAttribute('valign', 'middle', 0);
	with(cell_05.style){
		backgroundImageUrl = base_url+'immagini/layer_05.gif';
		backgroundImage = "url('"+backgroundImageUrl+"')";
	}



    
    
    set_png_bg(cell_06, base_url+'immagini/layer_06.png');
    with(cell_06.style){
        width = '8px';
    }
    
    set_png_bg(cell_07, base_url+'immagini/layer_07.png');
    with(cell_07.style){
        width = '8px';
        height = '10px';
    }
    
    set_png_bg(cell_08, base_url+'immagini/layer_08.png');
    with(cell_08.style){
        height = '10px';
    }
    
    set_png_bg(cell_09, base_url+'immagini/layer_09.png');
    with(cell_09.style){
        width = '8px';
        height = '10px';
    }

    
    // ---------------------------------------------------------------------------------------------------------------------
    
        
    function get_mouse_pos(e){
    
	    var posx = 0;
	    var posy = 0;
        
	    if (!e) var e = window.event;
	    if (e.pageX || e.pageY) 	{
		    posx = e.pageX;
		    posy = e.pageY;
	    }
        
	    else if (e.clientX || e.clientY) 	{
		    posx = e.clientX + document.body.scrollLeft
			    + document.documentElement.scrollLeft;
		    posy = e.clientY + document.body.scrollTop
			    + document.documentElement.scrollTop;
	    }

        
        return new Array(posx, posy);
    }

    
    // ---------------------------------------------------------------------------------------------------------------------
    
        
    function get_act_pos(){
	    var l=0; var t=0;
	    
	    aTag = main_layer;
	    do {
		    aTag = aTag.offsetParent;
		    l += aTag.offsetLeft;
		    t += aTag.offsetTop;
	    } while (aTag.offsetParent && aTag.tagName != 'BODY');
	    
	    var left = main_layer.offsetLeft + l;
	    var top = main_layer.offsetTop + t;
        
        return new Array(left, top);
    }
        
    
    // ---------------------------------------------------------------------------------------------------------------------
	
		
	function get_page_scroll(){
	
		var yScroll;
		
		if (self.pageYOffset) {
			yScroll = self.pageYOffset;
		} else if (document.documentElement && document.documentElement.scrollTop){ // Explorer 6 Strict
			yScroll = document.documentElement.scrollTop;
		} else if (document.body) {// all other Explorers
			yScroll = document.body.scrollTop;
		}
		
		// arrayPageScroll = new Array('',yScroll)
		return yScroll;
	}

	
    // ---------------------------------------------------------------------------------------------------------------------
	
	
	function get_page_size(){
	
		var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		var windowWidth, windowHeight;
		if (self.innerHeight) { // all except Explorer
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}
		
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else {
			pageHeight = yScroll;
		}
		
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){
			pageWidth = windowWidth;
		} else {
			pageWidth = xScroll;
		}
		
		
		arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
		return arrayPageSize;
	}


    // ---------------------------------------------------------------------------------------------------------------------
	
	
    function show_overlay(){
        
        if (base_url!='' && layer_suboverlay.src=='' && is_ie6)
            layer_suboverlay.src=base_url+"immagini/transparent.gif";

        if (base_url!='' && main_sublayer.src=='' && is_ie6)
            main_sublayer.src=base_url+"immagini/transparent.gif";
  	
        document.body.appendChild(layer_overlay);
        document.body.appendChild(layer_suboverlay);
        document.body.appendChild(main_layer);
        document.body.appendChild(main_sublayer);
    
    
   		var page_size = get_page_size();
   
        // Visualizzo l'overlay
        layer_overlay.style.height = page_size[1]+'px';
        layer_suboverlay.style.height = page_size[1]+'px';
        
        layer_overlay.onclick = function(){
            hide();
        }
        
	    layer_suboverlay.onclick = function(){
		    hide();
	    }
	    
        if(_show_overlay){
	        layer_overlay.style.display = 'block';
	        layer_suboverlay.style.display = 'block';
        }
	    
    }
    
    
    // ---------------------------------------------------------------------------------------------------------------------
    

	function set_png_bg(obj, img){
		
        if(is_ie6)
	        obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+img+"', sizingMethod='scale')";
	    else
	        obj.style.backgroundImage = "url('"+img+"')";
		
	}

	
    // ---------------------------------------------------------------------------------------------------------------------
    
    
    function show_layer(){

   		var page_size = get_page_size();

        if(_layer_move){
            main_layer.onmousedown = function(e){
            
                var mouse_pos = get_mouse_pos(e);
                var layer_pos = get_act_pos(e);
            
                _start_x = mouse_pos[0]-layer_pos[0];
                _start_y = mouse_pos[1]-layer_pos[1];
            
                _clicked = true;
                
                document.body.onmousemove = function(e){ main_layer.onmousemove(e); }
            }
            
            main_layer.onmouseup = function(){
                _clicked = false;
            }
        
        }
        
	    main_layer.onmousemove = function(e){
        
            var pos = get_mouse_pos(e);
            
            if(_clicked){
                layer_left = pos[0]-_start_x;
                layer_top = pos[1]-_start_y;
    
                main_layer.style.left = layer_left+'px';
                main_layer.style.top = layer_top+'px';
                
                main_sublayer.style.left = (pos[0]-_start_x)+'px';
                main_sublayer.style.top = (pos[1]-_start_y)+'px';
            }
            
            layer_mouseover = ((pos[0] > layer_left) && (pos[0] < layer_left+layer_width)) && ((pos[1] > layer_top) && (pos[1] < layer_top+layer_height));
            
        }
         
        switch(show_type){
            case 0:     // Centrato schermo
                local_left = parseInt((page_size[2]-layer_width)/2);
                local_top = (parseInt((page_size[3]-layer_height)/2)+get_page_scroll());
                break;
                
            case 1:     // Personalizzato
                local_left = custom_left;
                local_top = custom_top;
                break;
                
            case 2:     // Centrato oggetto
                local_left = obj_center_left - parseInt(layer_width/2);
                local_top = obj_center_top - parseInt(layer_height/2);
                break;
                
            case 3:     // Clipping
                if((clipping_top - parseInt(clipping_height/2) + layer_height ) > page_size[3])
                    local_top = clipping_top + parseInt(clipping_height/2) - layer_height;
                else
                    local_top = clipping_top - parseInt(clipping_height/2);
                
                if((clipping_left - parseInt(clipping_width/2) + layer_width ) > page_size[2])
                    local_left = clipping_left + parseInt(clipping_width/2) - layer_width;
                else
                    local_left = clipping_left - parseInt(clipping_width/2);
                
                break;
        }
            
        
        if(!_go_out_page){
            local_left = Math.max(0, local_left);
            local_top = Math.max(0, local_top);
            
            local_left = Math.min(page_size[2]-layer_width, local_left);
            local_top = Math.min(page_size[3]-layer_height+get_page_scroll(), local_top);
        }
        
        layer_left = local_left;
        layer_top = local_top;

        with(main_layer.style){
            left = local_left+'px';
            top = local_top+'px';
            display = 'block';
        }
        
	    with(main_sublayer.style){
	        left = main_layer.style.left;
	        top = main_layer.style.top;
	        display = 'block';
	    }
        
    }
    
    
    // ---------------------------------------------------------------------------------------------------------------------
    
    
    function call_remote_script(script_name){
        
        var request = mkXMLHttpRequest();
        
        if(request == null)
            return;
        
        request.open("get", script_name, true);
        
        request.onreadystatechange = function() {
            if(request.readyState === 4) {
                if(request.status === 200){
                    cell_05.innerHTML = request.responseText;
                }else {
                    cell_05.innerHTML = 'Si &egrave; verificato un errore<br>(status: '+request.status+')';                    
                }
            } 
        }
        
        request.send(null);
        
    }
    
    
    // ---------------------------------------------------------------------------------------------------------------------
    
    
    function hide(){
    
        main_layer.style.display = 'none';
		main_sublayer.style.display = 'none';
		layer_overlay.style.display = 'none';
		layer_suboverlay.style.display = 'none';
        
    }
    
    
    // ---------------------------------------------------------------------------------------------------------------------
    
    
    this.overlay = function(value){
        _show_overlay = value;
    }
    
    
    // ---------------------------------------------------------------------------------------------------------------------
    
    
    this.floating = function(value){
        _show_overlay = !value;
        _layer_move = value;
    }
    
    
    // ---------------------------------------------------------------------------------------------------------------------
    
    
    this.onshow = function(script_name){
    	
        _script_ajax = base_url+script_name;
        
    }
    
    
    // ---------------------------------------------------------------------------------------------------------------------
    
    
    this.is_over = function(e){
    
        if(main_layer.style.display == 'none')
            return false;
    
    
        var mouse_pos = get_mouse_pos(e);
        
        if( (mouse_pos[0] > layer_left) && (mouse_pos[0] < (layer_left+layer_width)) &&
            (mouse_pos[1] > layer_top) && (mouse_pos[1] < (layer_top+layer_height))
        )
        return true;
            
        return false;
            
    }
    
    
    // ---------------------------------------------------------------------------------------------------------------------
    
    
    this.hide_onmouseout = function(){
        main_layer.onmouseout = function(e){
            var mouse_pos = get_mouse_pos(e);
            
            if( (mouse_pos[0] > layer_left) && (mouse_pos[0] < (layer_left+layer_width)) &&
                (mouse_pos[1] > layer_top) && (mouse_pos[1] < (layer_top+layer_height))
            )
            return false;
                
            hide();
        };
    }
    
    
    // ---------------------------------------------------------------------------------------------------------------------
    
    
    this.show = function(custom_show_type, left, top, obj_width, obj_height){
        
        switch(custom_show_type){
            case null:
            case undefined:
            case 0:
                show_type = 0;
                break;
        
            case 1:     // Custom
                show_type = 1;
                custom_left = left;
                custom_top = top;
                break;
        
            case 2:     // Object center
                show_type = 2;
                obj_center_left = left;
                obj_center_top = top;
                break;
        
            case 3:     // Object corner clipping
                // Se uso il clipping mi serve il centro dell'oggetto e le dimensioni
                show_type = 3;
                clipping_left = left;
                clipping_top = top;
                clipping_width = obj_width;
                clipping_height = obj_height;
                break;
                
            default:
                alert(errstr('show_type "'+custom_show_type+'" sconosciuto'));
                return;
                break;
        }
       
        
        show_overlay();
        show_layer();
        
        if(_script_ajax)
            call_remote_script(_script_ajax);
    }
    
    
    // ---------------------------------------------------------------------------------------------------------------------
    
    
    this.call = function(script_name){
        cell_05.innerHTML = '';
        cell_05.appendChild(waiting_bar);

        call_remote_script(script_name);
    }
    
    
    // ---------------------------------------------------------------------------------------------------------------------
    
    
    this.hide = function(clear){
		hide();
        
        if(clear == null)
            clear = true;
            
        if(clear){
            cell_05.innerHTML = '';
            cell_05.appendChild(waiting_bar);
        }
    }

    
}




function submitForm() {
document.search_box_hp.submit(); } 


function validate(string, regexp, err, fieldName) {
    if (string.match(regexp) == null) {
        alert(err);
        warnField(fieldName);
        return false;
    }
    return true;
}

function validateForm(string, regexp, err, fieldName,formName) {
    if (string.match(regexp) == null) {
//        alert(err);

        xwarnField(fieldName,formName);
        return false;
    }
    return true;
}

function warnField(fieldName)
{
    eval("document.search_box_hp."+fieldName+".style.border='1px solid #E74815';");
    eval("document.search_box_hp."+fieldName+".focus();");
}
 
function xwarnField(fieldName,formname)
{
    eval("document."+formname+"."+fieldName+".style.border='1px solid #E74815';");
    eval("document."+formname+"."+fieldName+".focus();");
}

function isValidEmail(a)
{
        var at = a.indexOf("@");
        var name = a.substring(0, at);
        var isp = a.substring(at + 1, a.length);
        var dot = a.lastIndexOf(".");
        if (at == -1 || at == 0 || name == "" || isp == "" || dot == -1 ||
dot== (a.length - 1))
        {
                return false;
        }
        return true;
}

function check_form_step1_box() {
disableButton();
	var xnumadulti = 0;
	var i = 0;
	xnumadulti = document.search_box_hp.dodicesimo.value;

	if ( isNaN(xnumadulti) || (xnumadulti < 1) ) {
	ableButton();
	document.getElementById("errorbox").innerHTML='<br/><div style="border:1px solid #FF0000;"><p><b>Per proseguire occore selezionare un numero di adulti almeno pari a 1</b></p></div>'; 
	warnField("dodicesimo")
	return false;
	}

    
	submitForm();

	
}

function disableButton(){
document.getElementById("prenotaButtonx").disabled=true;
document.getElementById("prenotaButtonx").innerHTML="Attendere..."; 
}
function ableButton(){
document.getElementById("prenotaButtonx").disabled=false;
//document.getElementById("prenotaButtonx").innerHTML='<input id="prenotaButtonx" name="prenotaButton" type="image" style="border:0px;" src="immagini/send.png" alt="INVIA" title="invia il modulo" width="100" height="30" value="Invia" onClick="prenota();return false;"> '; }
document.getElementById("prenotaButtonx").innerHTML='<input  type="button" onClick="return check_form_step1_box();return false;" value="Prosegui" />'; 
}

	     
function stampa_flash(percorso, width, height, id)
{
document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" id=\""+id+"\" width=\""+width+"\" height=\""+height+"\">");
document.write("<param name=\"movie\" value=\""+percorso+"\">");
document.write("<param name=\"menu\" value=\"false\">");
document.write("<param name=\"quality\" value=\"high\">");
document.write("<PARAM NAME=\"wmode\" VALUE=\"transparent\">");
document.write("<param name=\"scale\">");
document.write("<param name=\"bgcolor\" value=\"#ffffff\">");
document.write("<embed src=\""+percorso+"\" wmode=\"transparent\" menu=\"false\" quality=\"high\" scale=\"noborder\" bgcolor=\"#ffffff\" width="+width+" height="+height+" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\">");
document.write("</embed>");
document.write("</object>");
} 



		