/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------- */
/* SETTA I DATI PER L' EVENTO E IL NUMERO DI POSTI MAX E MIN PER L' EVENTO  TRASPORTO E PERNOTTAMENTO
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------- */
	
function checkPostiCamera(idStruttura){
    	
    var datiCamera	 	= document.getElementById('idCamera-'+idStruttura).options[document.getElementById('idCamera-'+idStruttura).selectedIndex].value;
    var arrayDatiCamera	= datiCamera.split("-");
    var postiScelti     = Number(document.getElementById('posti-'+idStruttura).value);
    var postiMin       	= Number(arrayDatiCamera[2]);
    var postiMax       	= Number(arrayDatiCamera[3]);
				
		


    if(datiCamera=='xxx' || datiCamera=='0-0-1-1' ){
        alert('Specificare la tipologia camera desiderata!');
        document.getElementById('idCamera-'+idStruttura).focus();
        return false;
    }
    else if(isNaN(postiScelti) || postiScelti==0){
        alert('Nel campo \u00E9 possibile immettere solo numeri!');
        document.getElementById('posti-'+idStruttura).focus();
        return false;
    }
    else if(postiScelti > postiMax){
        alert('Il numero massimo di posti in questa stanza  \u00E9 '+postiMax+' \n Scegliere un altra stanza o modificare il numero di partecipanti');
        document.getElementById('posti-'+idStruttura).focus();
        return false;
    }
		
    else if(postiScelti < postiMin){
        alert('Il numero minimo di posti in questa stanza  \u00E9 '+postiMin+' \n Scegliere un altra stanza o modificare il numero di partecipanti');
        document.getElementById('posti-'+idStruttura).focus();
        return false;
    }
    else
        return true;
}


function updatePosti(idStruttura,posti){
    
    var datiCamera	 	= document.getElementById('idCamera-'+idStruttura).options[document.getElementById('idCamera-'+idStruttura).selectedIndex].value;
    var arrayDatiCamera	= datiCamera.split("-");
    var postiScelti     = Number(document.getElementById('posti-'+idStruttura).value);
    var postiMin       	= Number(arrayDatiCamera[2]);
    var postiMax       	= Number(arrayDatiCamera[3]);
        
    if(posti=="0" || isNaN(postiScelti) || postiScelti==0 )
        var  postiScelti = postiMin;
        
        
           
    document.getElementById('posti-'+idStruttura).value = postiScelti;
        
       
    var assicurazione  = Number(document.getElementById('assicurazione-'+idStruttura).value);
    var quota          = Number(document.getElementById('quota-'+idStruttura).value );
        
    if(assicurazione){
        var totaleAssicurazione = assicurazione * postiScelti;
        var totaleQuota         = quota * postiScelti;
        var totaleDovuto        = totaleAssicurazione + totaleQuota; 
    }
    else
        var totaleDovuto         = quota * postiScelti;
        
    document.getElementById('totale-'+idStruttura).innerHTML = totaleDovuto ;
}  
      
function mostraOpzioni(totaleStrutture, idTipologia){
    
    var idStruttura	 	= document.getElementById('select-'+idTipologia).options[document.getElementById('select-'+idTipologia).selectedIndex].value;
    var dati			= idStruttura.split("-");
    var datiTipologia   = Number(dati[0]);
    var datiStruttura    = Number(dati[1]);
        
    for(x=0; x<totaleStrutture;x++){
        if(x==datiStruttura)
            document.getElementById('box-'+datiTipologia+'-'+x).style.display = 'block';
        else
            document.getElementById('box-'+datiTipologia+'-'+x).style.display = 'none';
    }
} 
      
      
      


/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------- */
/* SETTA I DATI PER L' EVENTO E IL NUMERO DI POSTI MAX E MIN PER L' EVENTO SOLO TRASPORTO
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------- */

function checkPostiTrasporto(postiMax){
    
    var postiScelti     = Number(document.getElementById('postiScelti').value);
    var postiMin       	= 1;
	    
    if(isNaN(postiScelti) || postiScelti==0){
        alert('Nel campo \u00E9 possibile immettere solo numeri!');
        document.getElementById('postiScelti').focus();
        return false;
    }
    else if(postiScelti > postiMax){
        alert('Il numero massimo di posti prenotabili \u00E9 '+postiMax+' \n Modificare il numero di partecipanti');
        document.getElementById('postiScelti').focus();
        return false;
    }
		
    else if(postiScelti < postiMin){
        alert('Il numero minimo di posti prenotabili \u00E9 '+postiMin+' \n Modificare il numero di partecipanti');
        document.getElementById('postiScelti').focus();
        return false;
    }
    else
        return true;
}

	
function updatePostiTrasporto(){ 
    
    var postiScelti     = Number(document.getElementById('postiScelti').value);
       
    var assicurazione  = Number(document.getElementById('assicurazione').value);
    var quota          = Number(document.getElementById('quota').value );
          
    if(assicurazione){
        var totaleAssicurazione = assicurazione * postiScelti;
        var totaleQuota         = quota * postiScelti;
        var totaleDovuto        = totaleAssicurazione + totaleQuota; 
    }
    else
        var totaleDovuto         = quota * postiScelti;
        
    document.getElementById('totaleDovuto').innerHTML = totaleDovuto;
}  


/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------- */
/* SETTA I DATI PER L' EVENTO E IL NUMERO DI POSTI MAX E MIN PER L' EVENTO SOLO TRASPORTO
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------- */

function updateOpzioni(opzione,prezzo){


    document.getElementById(opzione).disabled = true;
    var segno ='';
    var prezzoTemp  		= Number(prezzo);
    var totaleTemp  		= Number(document.getElementById('totaleTemp').value);
    var totaleOpzioni 	 	= Number(document.getElementById('totaleTempOpzioni').value);
    	
    if(document.getElementById(opzione).checked == true)
        segno           = 'aggiungi';
    else
        segno           = 'sottrai';	
    
    jQuery.post('../librerie/libreria_php/funzioni_opzioni.php', {
        'prezzoOpzione': prezzoTemp, 
        'totaleTemp': totaleTemp, 
        'totaleOpzioni': totaleOpzioni, 
        'segno': segno
    }, function(data){ 
            
        document.getElementById('totaleOpzioni').innerHTML	 = data.tmpOpzioni;
        document.getElementById('totaleDovuto').innerHTML	 = data.tmpTotale;
        document.getElementById('totaleRiassunto').innerHTML = data.tmpTotale;
        document.getElementById('totaleTemp').value			 = data.tmpTotale;
        document.getElementById('totaleTempOpzioni').value	 = data.tmpOpzioni;
        
        
    }, "json");
        
        
    document.getElementById(opzione).disabled = false;
        
        
        
}
    	
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------- */
/* SETTA I DATI PER L' EVENTO E IL NUMERO DI POSTI MAX E MIN PER L' EVENTO SOLO TRASPORTO
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------- */

function checkForm(posti){
    for(x=1; x<=posti; x++){
        if(document.getElementById('nome_'+x+'').value==''){
            alert('Il campo nome per il partecipante '+x+'  \u00E9 obligatorio');
            document.getElementById('nome_'+x+'').focus();
            return false;
        }
        if(document.getElementById('cognome_'+x+'').value==''){
            alert('Il campo cognome per il partecipante '+x+'  \u00E9 obligatorio');
            document.getElementById('cognome_'+x+'').focus();
            return false;
        }
        if(document.getElementById('data_'+x+'').value==''){
            alert('Il campo data di nascita per il partecipante '+x+' \u00E9 obligatorio');
            document.getElementById('data_'+x+'').focus();
            return false;
        }
        if(document.getElementById('cellulare_'+x+'').value==''){
            alert('Il campo cellulare per il partecipante '+x+'  \u00E9 obligatorio');
            document.getElementById('cellulare_'+x+'').focus();
            return false;
        }
        else{
            var espressione = /^([0-9])+$/;
            var tmpCellulare    = document.getElementById('cellulare_'+x+'').value;
            if (!espressione.test(tmpCellulare)){
                alert("Il numero di cellulare inserito non \u00E9 valido! \n Inserire solo valori numerici ( no / no - no spazzi) ");
                document.getElementById('cellulare_'+x+'').focus();
                return false
            }

        }
        if(document.getElementById('email_'+x+'').value==''){
            alert('Il campo email per il partecipante '+x+'  \u00E9 obligatorio');
            document.getElementById('email_'+x+'').focus();
            return false;
        }
        else{
            var espressione = /^[_a-z0-9+-]+(\.[_a-z0-9+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/;
            var tmpEmail    = document.getElementById('email_'+x+'').value;
            if (!espressione.test(tmpEmail)){
                alert("La mail inserita non \u00E9 valida!");
                document.getElementById('email_'+x+'').focus();
                return false
            }
        }
    }
    if(document.getElementById('privacy').checked == false){
        alert('Devi aver letto l\'informativa sulla privacy D.lgs 196/2003 deve esere selezionato');
        document.getElementById('privacy').focus();
        return false;
    }
    if(document.getElementById('contratto').checked == false){
        alert('Devi avere letto e accettato le condizioni contrattuali relative ai pacchetti turistici deve essere selezionato');
        document.getElementById('contratto').focus();
        return false;
    }
    if(document.getElementById('tipo_pagamento').options[document.getElementById('tipo_pagamento').selectedIndex].value == '0'){
        alert('Devi specificare la modalita di pagamento');
        document.getElementById('tipo_pagamento').focus();
        return false;
    }
}
    
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------- */
/* FUNZIONI VARIE
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------- */
 
function switchEventi(tipo){
    if(tipo =='mostra'){
        document.getElementById('switchMostra').style.display = 'none';
        document.getElementById('eventiPassati').style.display = 'block';
        document.getElementById('switchNascondi').style.display = 'block';
    }
    else if (tipo=='nascondi'){
        document.getElementById('switchMostra').style.display = 'block';
        document.getElementById('switchNascondi').style.display = 'none';
        document.getElementById('eventiPassati').style.display = 'none';
    }
}
    
function switchImmagine(immagine){
    document.getElementById('img-big').innerHTML = '<img src=\'https://www.mobitour.it/librerie/libreria_img/public/publicStrutture/big/'+immagine+'\'>';
}
    
    
function mostraDettaglio(tipo){
    if(tipo =='mostra'){
        document.getElementById('switchMostra').style.display = 'none';
        document.getElementById('eventoTesto').style.display = 'block';
        document.getElementById('switchNascondi').style.display = 'block';
    }
    else if (tipo=='nascondi'){
        document.getElementById('switchMostra').style.display = 'block';
        document.getElementById('switchNascondi').style.display = 'none';
        document.getElementById('eventoTesto').style.display = 'none';
    }
}
        
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------- */
/* FUNZIONI NOLLEGIO AUTO 
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------- */


function fillDate(){
    Ddate= new Date();
    datum=new Date(Ddate.getFullYear(),Ddate.getMonth(),Ddate.getDate());


    var month31Days = new Array();
    month31Days[1] = 1;
    month31Days[3] = 3;
    month31Days[5] = 5;
    month31Days[7] = 7;
    month31Days[8] = 8;
    month31Days[10] = 10;
    month31Days[12] = 12;
			
    var month30Days = new Array();
    month30Days[4] = 4;
    month30Days[6] = 6;
    month30Days[9] = 9;
    month30Days[11] = 11;

			
    var day = datum.getDate()+1;
    var month = datum.getMonth()+1;  
    var year = datum.getFullYear();
			
    switch (day) {
        case 31:
            if (month == month31Days[month]) {
                if (month == month31Days[12]) {
                    document.forms['SearchResultsForm'].doDay.selectedIndex = 2;
                    document.forms['SearchResultsForm'].doMonth.selectedIndex = 0;
                    document.forms['SearchResultsForm'].doYear.selectedIndex = +1;
                } else {
                    document.forms['SearchResultsForm'].doDay.selectedIndex = 2;
                    document.forms['SearchResultsForm'].doMonth.selectedIndex = month;
                //alert('31 Days true')
                }
				
            } else {
                document.forms['SearchResultsForm'].doDay.selectedIndex = day+2;
                document.forms['SearchResultsForm'].doMonth.selectedIndex = datum.getMonth();
            //alert('31 Days NOTtrue');
            }	

            break;
        case 30:
            if (month == month30Days[month]) {
                document.forms['SearchResultsForm'].doDay.selectedIndex = 2;
                document.forms['SearchResultsForm'].doMonth.selectedIndex = month+1;
            //alert('30 Days true')

            } else {
                document.forms['SearchResultsForm'].doDay.selectedIndex = day+2;
                document.forms['SearchResultsForm'].doMonth.selectedIndex = datum.getMonth();
            //alert('30 Days NOTtrue');
            }
				
            break;
        case 28:
			
            if (month == 2) {
                document.forms['SearchResultsForm'].doDay.selectedIndex = 2;
                document.forms['SearchResultsForm'].doMonth.selectedIndex = month+1;
            //alert('28 Days true')
            } else {
                document.forms['SearchResultsForm'].doDay.selectedIndex = day+2;
                document.forms['SearchResultsForm'].doMonth.selectedIndex = datum.getMonth();
            //alert('28 Days NOTtrue')
            }
				
            break;
        case 29:
			
            if (month == 2) {
                document.forms['SearchResultsForm'].doDay.selectedIndex = 2;
                document.forms['SearchResultsForm'].doMonth.selectedIndex = month+1;
            //alert('28 Days true')
            } else {
                document.forms['SearchResultsForm'].doDay.selectedIndex = day+2;
                document.forms['SearchResultsForm'].doMonth.selectedIndex = datum.getMonth();
            //alert('28 Days NOTtrue')
            }
				
            break;
        default :
            document.forms['SearchResultsForm'].doDay.selectedIndex = datum.getDate()+2;
            document.forms['SearchResultsForm'].doMonth.selectedIndex = datum.getMonth();
            break;
    }
		

    document.forms['SearchResultsForm'].puDay.selectedIndex = datum.getDate();
    document.forms['SearchResultsForm'].puMonth.selectedIndex = datum.getMonth();
	
/*
  if (day == 31 && month == 12) {
		document.forms['SearchResultsForm'].puYear.selectedIndex = setFullYear();
		document.forms['SearchResultsForm'].doYear.selectedIndex = setFullYear() + 1;
	} else {
		document.forms['SearchResultsForm'].puYear.selectedIndex = setFullYear();
		document.forms['SearchResultsForm'].doYear.selectedIndex = setFullYear(); 
	}
  */
  
}

/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------- */
/* FUNZIONI PRENOTAZIONI ALBREGHI
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------- */

function azzeraTesto(num) {
    var destText=document.b_frm.ss;
 
 
    if (num==1) {
        if (destText.value=="" || destText.value=="Città , Regione, Nazione, Luoghi di interesse, Hotel"){
            destText.value="";
            document.getElementById("b_inputDest").style.color="#000000";	
        }
    }
	
    if (num==2) {
        if (destText.value==""){
            destText.value="Città , Regione, Nazione, Luoghi di interesse, Hotel";
            document.getElementById("b_inputDest").style.color="#CCCCCC";
 
        }
    }
	
 
	
} 

function tickCheckBox(el)
{
    if (document.getElementById)
    {
        if (document.getElementById(el))
        {
            document.getElementById(el).checked = true;
        }
    }
    return true;
}
 
 
var filaMonth;
 
function showCalendar (img, cal, dt, frm,m,y,d) {
    if (document.getElementById) {
        var c = document.getElementById(cal);
        var i = document.getElementById(img);
        var f = document.getElementById(frm);
        calendar.calfrm = frm;
        calendar.cal = c;
        calendar.caldt = dt;
        calendar.calf = f;
        var my = f[dt + '_month'].value.split("-");
        y=my[0];
        m=my[1];
        d=f[ dt + '_day'].value;
        buildCal(y,m,d);
        var l=5;
        var t=0;
        aTag = i;
        document.getElementById("b_calendarInner").style.display="block";
        do {
            aTag = aTag.offsetParent;
            l += aTag.offsetLeft;
            t += aTag.offsetTop;
        } while (aTag.offsetParent && aTag.tagName != 'body');
        var left =  i.offsetLeft + l;
        var top = i.offsetTop + t + i.offsetHeight + 2;
        c.style.position = "absolute";
        c.style.left = (left-120)+'px';
        c.style.top = (top-120)+'px';
        c.style.display="block";    
    }
}
 
function closeCal() {
    calendar.cal.style.display='none';
}
 
function buildCal(y,m,d){
    var daysInMonth=[31,0,31,30,31,30,31,31,30,31,30,31];
    td=new Date();
    if (!y) y = td.getFullYear();
    if (!m) m = td.getMonth()+1;
    if (!d) d = td.getDate;
    var frm = calendar.calfrm;
    var dt = calendar.caldt;
 
    var mDate = new Date(y, m-1, 1);
    var firstMonthDay = mDate.getDay();
    daysInMonth[1]=(((mDate.getFullYear()%100!=0) && (mDate.getFullYear()%4==0)) || (mDate.getFullYear()%400==0))?29:28;
 
    var today = (y==td.getFullYear() && m==td.getMonth()+1)? td.getDate() : 0;
    var t='<table class="b_caltable" cellspacing="0"><tr class="b_calHeader">';
    var flm=td.getMonth()+1;
    var flyr=td.getFullYear();
    for(p=0;p<=10;p++){
        if (flm == m) {
            filaMonth = p;
        }
        flm++;
        if (flm>12) {
            flm=1;
            flyr++
        }
    }
    t+='<td colspan="7">';
    if (filaMonth == 0) {
        t+='&nbsp;&lt;&nbsp;';
    }
    else {
        t+='<a href="javascript:prevMonth('+y+','+m+');" title="'+tr.prevMonth+'">&nbsp;&lt;&nbsp;</a>';
    }
    t+='&nbsp;<select name="ym" onchange="goMonth(this.options[this.selectedIndex].value)">';
    var mn=td.getMonth()+1;
    var yr=td.getFullYear();
    for(n=0;n<=10;n++){
        t+='<option value="' + mn + '"';
        if (mn == m) {
            t+=' selected="selected"';
        }
        t+='>' + months[mn-1] + ' ' + yr +'</option>';
        mn++;
        if (mn>12) {
            mn=1;
            yr++
        }
    }
    t+= ' </select>&nbsp;';
    if (filaMonth == 10) {
        t+='&nbsp;&gt;&nbsp;';
    }
    else {
        t+='<a href="javascript:nextMonth('+y+','+m+');" title="' + tr.nextMonth +'">&nbsp;&gt;&nbsp;</a>';
    }
    t+='</td></tr>';
    t+='<tr class="b_calDayNames">';
    for(dn=0;dn<7;dn++){
        var cl = '';
        if ((dn%7==5) || (dn%7 == 6)) cl += ' b_calWeekend';
        t+='<th class="'+cl+'">'+days[dn]+'</th>';
    }
    t+='</tr><tr class="b_calDays">';
    for(i=1;i<=42;i++){
        var x = i - (firstMonthDay+6)%7;
        if (x > daysInMonth[m-1] || x <1) x = '&nbsp;';
        var cl = '';
        var href = 0;
        if ((i%7==0) || (i%7 == 6)) cl += ' b_calWeekend';
        if (x>0){
            var xDay = new Date(y, m-1, x);
            if ((xDay.getFullYear() == y) && (xDay.getMonth()+1 == m)
                && (xDay.getDate() == d))
                {
                cl += ' b_calSelected' ;
                href=1
            }
            if ((xDay.getFullYear() == td.getFullYear())
                && (xDay.getMonth() == td.getMonth())
                && (xDay.getDate() == td.getDate()))
                {
                cl += ' b_calToday';
                href=1;
            }
            else {
                if (xDay > td){
                    cl += ' b_calFuture';
                    href=1;
                }
                else {
                    if (xDay < td) {
                        cl += ' b_calPast'
                    }
                }
            }
        };
        t+='<td class="'+cl+'">';
        if (href){
            t+='<a href="javascript:pickDate('+y+','+m+','+x+',\''+dt+'\',\''+frm+'\');">'+x+'</a>';
        } else {
            t+=x;
        }
        t+='</td>';
        if(((i)%7==0)&&(i<36)) {
            t+='</tr><tr class="b_calDays">';
        }
    }
    t+='</tr><tr class="b_calClose"><td colspan="7"><a href="javascript:closeCal();">' + tr.closeCalendar + '</a></td></tr></table>';
    document.getElementById("b_calendarInner").innerHTML= t;
}
 
function prevMonth(y,m) {
    if (new Date(y,m-1,1) < td) return;
    if (m > 1) {
        m--
    } else {
        m = 12;
        y--
    };
    buildCal(y,m);
}
 
function nextMonth(y,m) {
    //    if ((new Date(y,m-1,1) - td) > 1000*3600*24*300) return;
    if (m<12){
        m++;
    } else {
        m=1;
        y++;
    }
    if (y > td.getFullYear() && m >= td.getMonth() ) return;
    buildCal(y,m);
}
 
function goMonth(m){
    var y = td.getFullYear();
    if (m < td.getMonth()+1) y++;
    buildCal(y,m);
}
 
function pickDate(y,m,d,dt,frm){
    // set form values
    var f = calendar.calf;
    var dt = calendar.caldt;
    f[dt + '_month'].value = y + "-"  + m;
    f[dt + '_day'].value = d;
    tickCheckBox('b_availcheck');
    if (dt == "b_checkin"){
        checkDateOrder(calendar.calfrm, 'b_checkin_day', 'b_checkin_month', 'b_checkout_day', 'b_checkout_month');
    }
    closeCal();
}
 
 
function addzero( value )
{
    while( value.length<2 ) value = String("0") + value;
    return value;
}
 
 
function checkDateOrder(frm, ci_day, ci_month_year, co_day, co_month_year) {
    if (document.getElementById) {
        var frm = document.getElementById(frm);
        // create date object from checkin values
        // set date to 12:00 to avoid problems with one
        // date being wintertime and the other summertime
        var my = frm[ci_month_year].value.split("-");
        var ci = new Date (my[0], my[1]-1, frm[ci_day].value, 12, 0, 0, 0);
 
        // create date object from checkout values
        my = frm[co_month_year].value.split("-");
        var co = new Date (my[0], my[1]-1, frm[co_day].value, 12, 0, 0, 0);
 
        // if checkin date is at or after checkout date,
        // add a day full of milliseconds, and set the
        // selectbox values for checkout date to new value
        if (ci >= co){
            co.setTime(ci.getTime() + 1000 * 60 * 60 * 24);
            frm[co_day].value =  co.getDate();
            var com = co.getMonth()+1;
            frm[co_month_year].value = co.getFullYear() + "-" + com;
        }
    }
}
 
 
// <![CDATA[
calendar = new Object();
tr = new Object();
tr.nextMonth = "Mese successivo";
tr.prevMonth = "Mese precedente";
tr.closeCalendar = "Chiudi calendario";
tr.pressCtlD = "Premete control-d o chiudete aggiungi/segnalibri o aggiungi/favoriti del vostro browser";
tr.pressCtlP = "Premete  control-p or chiudete file/stampa del vostro browser";
tr.url = "http://www.booking.com/general.html?aid=329521;sid=6b2078e0002a7de7db69c5cd2ba6c8fc;tmpl=sbSezioneHotel";
tr.title = "Booking.com: Benvenuti";
tr.icons = "/static/affiliate_base/img/";
var months=["Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre"];
var days=['Lu','Ma','Me','Gi','Ve','Sa','Do'];
// ]]>
 
 
 
   

if (document.getElementById) {
    document.write("<style type='text/css'>");
    document.write(".b_blocktoggle {display: none}");
    document.write("</style>");
    var shown = new Array();
}
 
function blocktoggle(i) {
    if (document.getElementById) {
        shown[i] = (shown[i]) ? false : true;
        currentdisplay = (shown[i]) ? 'block' : 'none';
        document.getElementById('b_blocktoggle'+i).style.display = currentdisplay;
    }
}
 
function blockdisplay(i) {
    if (document.getElementById){
        if (document.getElementById("b_blockdisplay"+i)) {
            for ( j = 1; j < 1000; j++ ) {
                if (document.getElementById('b_blockdisplay' + j)) {
                    document.getElementById('b_blockdisplay' + j).style.display = 'none';
                }
                else {
                    j = 1000;
                }
            }
            if (i) {
                document.getElementById("b_blockdisplay"+i).style.display = 'block';
            }
        }
    }
}   


/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------- */
/* FORM NEWSLETTER
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------- */
function ckekEmail(){
    var mess ='';
    if(document.getElementById('email_form').value!=""){
        var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
        if(!email_reg_exp.test(document.getElementById('email_form').value)){
            document.getElementById('email_form').focus();
            mess= "Indirizzo e-mail non valido!";
          
        }
    }
    if(mess!=''){
        document.getElementById('response_mail').style.display='block';
        document.getElementById('response_mess').innerHTML= mess;
    }
    else
        document.getElementById('response_mail').style.display='none';
    
}





function CkFormMailing(element){
    
    var mess ='';
    
    if(element.VAR_cellulare.value!=""){
        var ctrl_cell = /^([\+]{0,1})([0-9]+)$/;
        if(!ctrl_cell.test(element.VAR_cellulare.value) || element.VAR_cellulare.length > 16 || element.VAR_cellulare.length < 8 ){
            mess ="Cellulare non corretto!";
            element.VAR_cellulare.focus();
        }
    }
    
    
    
    
    if(element.VAR_email.value=="" || element.VAR_email.value == "undefined"){
        mess = 'Indirizzo e-mail non valido!';
        element.VAR_email.focus();
      
    }
    else if(element.VAR_email.value!=""){
        
        var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
        if(!email_reg_exp.test(element.VAR_email.value) || element.VAR_email.value.length > 50 ){
            element.VAR_email.focus();
            mess= "Indirizzo e-mail non valido!";
          
        }
    }
    
    if(document.getElementById('mailing_privacy').checked != true ){
        element.VAR_campo_3.focus();
        mess += 'Dare consenso privacy';
     
    }
    
    if(mess!=''){
        document.getElementById('response_mail').style.display='block';
        document.getElementById('response_mess').innerHTML= mess;
        return false;
    }
    else
        return true ;
         
}
function ceckCell(){
    if(document.getElementById('ceckcell').checked == true){
        document.getElementById('cellFake').style.display='none';
        document.getElementById('cellGood').style.display='block';
        document.getElementById('txtMobile').style.color='#474554';
    }
    else{
        document.getElementById('cellGood').style.display='none';
        document.getElementById('cellFake').style.display='block';
        document.getElementById('txtMobile').style.color='#cccccc';
    }
}


function showPrivacy(){
    $('#dialogPrivacy').dialog('open');
}


