function validate_form2(){
    vediCodice('editArea1','desc');

var posti=document.getElementById("posti").value;
var id_cam=document.getElementById("id_cam").value;
var num=document.getElementById("num").value;
var subm=true;
//document.getElementById('sub').disabled=true;

if (id_cam=="") {
document.getElementById("id_cam_notify").innerHTML="Campo assente!";
subm=false;
}

if (!IsNumeric(document.getElementById("num"),'num_notify')) {
subm=false;
}

if (!IsNumeric(document.getElementById("posti"),'posti_notify')) {
subm=false;
}
if (subm){
id_div_errore="ajax_alert";
loadXMLDoc(concat_value());

}

}

function visual_dim_form()
{
	document.getElementById("pwd_dim").style.display="block";
}

function invia_password(tipo,email)
{
	id_div_errore="msg_pwd";
	loadXMLDoc("ajax_pwd_dim.php?tipo="+tipo+"&email="+email.value)
}

function ricaricaProv2(valore)
{
id_div_errore="seleziona_loc";
loadXMLDoc('comuni_sel.php?prov='+valore);
}

function dettagli_abb(id){
  var  mywindow = window.open ('dettagli_abbonamento.php?id_abb='+id,"mywindow","location=1,status=1,scrollbars=1,resizable=yes, width=450,height=300");
  mywindow.moveTo(100,200);
}

function salva_abb(id){
	
	var tipo="";
	if (document.getElementById('tipo1_'+id).checked)
		tipo="1"
	else 
		if (document.getElementById('tipo2_'+id).checked)
			tipo="2";
		else 
			if (document.getElementById('tipo4_'+id).checked)
				tipo="4";
			else
				tipo="3";

	var op="";
	if (document.getElementById('op1_'+id).checked){
		op="nuovo";
	} else
		op="aggiornamento";

	var querystring="?operazione="+op+"&tipo="+tipo+"&da="+document.getElementById("da_"+id).value+"&a="+document.getElementById("a_"+id).value+"&id_abb="+id+"&id_strut="+document.getElementById("id_strut_"+id).value;
	id_div_errore="ris_"+id;
	loadXMLDoc('salva_abb.php'+querystring);

}

function elimina_abb(id){
  var querystring="?operazione=elimina&id_abb="+id;
  id_div_errore="ris_"+id;

  loadXMLDoc('salva_abb.php'+querystring);

}

function salva_rec(id,id_st){
	
	var operazione="";
	if (document.getElementById('visibile_'+id).checked)
		operazione="vis";
	else
		operazione="novis";

	var staff="";
	if (document.getElementById('visitato_'+id).checked)
	{
		staff="si";
	} else {
		staff='no';
	}
	
	var querystring="?op="+operazione+"&id_rec="+id+"&st="+staff+"&ids="+id_st;
	id_div_errore="ris_"+id;
	loadXMLDoc('salva_rec.php'+querystring);

}

function elimina_rec(id){
  var querystring="?op=elimina&id_rec="+id;
  id_div_errore="ris_"+id;

  loadXMLDoc('salva_rec.php'+querystring);

}

function togli(obj){
obj1=document.getElementById(obj);
if (obj1.cheked){
obj1.checked=false;
}
}

function convalida_mail(){
var flag=true;
if (!checkEmailAddress(document.getElementById('mittente'),'mit')){
  flag=false;
}

if (!Is_void(document.getElementById('oggetto'),'ogg') || !Is_void(document.getElementById('testo'),'corpo'))
  flag=false;
  if (!Is_void(document.getElementById('codice'),'codice_err') )
  flag=false;

if (flag)
document.getElementById('contatto').submit();

}

function convalida_invia_amico()
{
	var flag=true;
	
	if (!checkEmailAddress(document.getElementById('mittente'),'mit')){
		flag=false;
	}

	if (!checkEmailAddress(document.getElementById('ricevente'),'ric')){
		flag=false;
	}

/*
	if (!Is_void(document.getElementById('oggetto'),'ogg') || !Is_void(document.getElementById('testo'),'corpo'))
		flag=false;
	if (!Is_void(document.getElementById('codice'),'codice_err') )
		flag=false;
	*/

	if (flag)
		document.getElementById('contatto').submit();
}

function cambia_mark_itin(obj){
id_div_errore="div_"+obj.value;
if (obj.checked){
if (parseInt(document.getElementById("numero_itin").innerHTML)>0){
document.getElementById("numero_itin").innerHTML=parseInt(document.getElementById("numero_itin").innerHTML)-1;
loadXMLDoc('agg_mark_itin.php?op=i&itin='+obj.value);
}
else{
obj.checked=!obj.checked;

}
}
else {
document.getElementById("numero_itin").innerHTML=parseInt(document.getElementById("numero_itin").innerHTML)+1;
loadXMLDoc('agg_mark_itin.php?op=c&itin='+obj.value);
}
}

function salva_num_itin(id_s){
id_div_errore="numero_itinter";
loadXMLDoc("salva_agg_it.php?id_s="+id_s+"&num="+document.getElementById('itin').value)
}

function salva_num_last(id_s){
	id_div_errore="numero_last";
	loadXMLDoc("salva_agg_last.php?id_s="+id_s+"&num="+document.getElementById('last').value);
}

function salva_num_off(id_s){
	id_div_errore="numero_off";
	loadXMLDoc("salva_agg_off.php?id_s="+id_s+"&num="+document.getElementById('off').value);
}

function validate_last(){
    var flag=true;
    vediCodice('editArea1','testo');

    if (!Is_void(document.getElementById('testo'),'descrizione'))
    flag=false;

	/*
    if (!IsDouble(document.getElementById('prezzo'),'errorePrezzo'))
    flag=false;
	*/

    if (!Is_void(document.getElementById('da'),'errore_da'))
    flag=false;

    if (!Is_void(document.getElementById('a'),'errore_a')){
        flag=false;
    }
    else{
      var data1=document.getElementById("da");
      var data2=document.getElementById("a");
      if ((compareDates(data1.value,"dd/MM/y",data2.value,"dd/MM/y")==1)){
      document.getElementById('errore_a').innerHTML="la data di fine deve essere successiva alla data di inizio";
      flag=false;
      }
      }
    if (!Is_void(document.getElementById('data_inizio'),'errore_data_inizio')){
        flag=false;
    }
    else
    {
    if (flag){
        var data2
        var d = new Date()
        d.setTime(getDateFromFormat(document.getElementById("data_inizio").value,"dd/MM/y")+7*86400*1000)

        var m=parseInt(d.getMonth())+1;
        var g=parseInt(d.getDate());
        if (m<10)
        {
        m='0'+m;
        }

        if (g<10)
        {
        g='0'+g;
        }
        data2=g+'/'+m+'/'+d.getFullYear();
        data1=document.getElementById("da");
        if ((compareDates(data2,"dd/MM/y",data1.value,"dd/MM/y")==1)){
          document.getElementById('errore_da').innerHTML="Affinchè il last minute sia valido è necessario che sia pubblicato almeno una settimana prima dell'inizio dell'offerta";
          flag=false;
        }
    }
    }
    if (flag&&!(document.getElementById("data_inizio").type=="hidden")){
      var d = new Date()
      d.setTime(d.getTime())
      var m=parseInt(d.getMonth())+1;
      var g=parseInt(d.getDate());
      if (m<10)
      {
      m='0'+m;
      }

      if (g<10)
      {
      g='0'+g;
      }
      var data2;
      data2=g+'/'+m+'/'+d.getFullYear();

      data1=document.getElementById("data_inizio");

      if ((compareDates(data2,"dd/MM/y",data1.value,"dd/MM/y")==1)){
        document.getElementById('errore_data_inizio').innerHTML="la data di pubblicazione deve essere successiva alla data odierna";
        flag=false;
      }


    }
 if (flag){
 document.getElementById('last_minute').submit();
 }

}

function conta_click_ban(num)
{
	id_div_errore="click_ban";
	loadXMLDoc("conta_ban.php?id_b="+num);
}


function validate_off()
{
	var flag=true;
	vediCodice('editArea1','descrizione_2');

	if (!Is_void(document.getElementById('descrizione_2'),'descrizione'))
		flag=false;

	/*
	if (!IsDouble(document.getElementById('prezzo'),'errorePrezzo'))
		flag=false;
	*/

	if (!Is_void(document.getElementById('testo'),'erroreTesto'))
		flag=false;

	if (!Is_void(document.getElementById('da'),'errore_da'))
		flag=false;

	if (!Is_void(document.getElementById('a'),'errore_a')){
		flag=false;
	} else {
		var data1=document.getElementById("da");
		var data2=document.getElementById("a");
		if ((compareDates(data1.value,"dd/MM/y",data2.value,"dd/MM/y")==1)){
			document.getElementById('errore_a').innerHTML="la data di fine deve essere successiva alla data di inizio";
			flag=false;
		}
	}

	if (!Is_void(document.getElementById('data_inizio'),'errore_data_inizio')){
		flag=false;
	} else {
		if (flag){
			var data2
			var d = new Date()
			d.setTime(getDateFromFormat(document.getElementById("data_inizio").value,"dd/MM/y")+7*86400*1000)

			var m=parseInt(d.getMonth())+1;
			var g=parseInt(d.getDate());
			if (m<10){
				m='0'+m;
			}

			if (g<10){
				g='0'+g;
			}
			data2=g+'/'+m+'/'+d.getFullYear();
			data1=document.getElementById("da");
			if ((compareDates(data2,"dd/MM/y",data1.value,"dd/MM/y")==1)){
				document.getElementById('errore_da').innerHTML="Affinchè l'offerta sia valido è necessario che sia pubblicato almeno una settimana prima dell'inizio dell'offerta";
				flag=false;
			}
		}
	}

	if (flag&&!(document.getElementById("data_inizio").type=="hidden")){
		var d = new Date()
		d.setTime(d.getTime())
		var m=parseInt(d.getMonth())+1;
		var g=parseInt(d.getDate());
		if (m<10){
			m='0'+m;
		}

		if (g<10){
			g='0'+g;
		}
		var data2;
		data2=g+'/'+m+'/'+d.getFullYear();

		data1=document.getElementById("data_inizio");

		if ((compareDates(data2,"dd/MM/y",data1.value,"dd/MM/y")==1)){
			document.getElementById('errore_data_inizio').innerHTML="la data di pubblicazione deve essere successiva alla data odierna";
			flag=false;
		}
	}

	if (flag){
		document.getElementById('offerte').submit();
	}

}

function mypopup_img(url_img,larghezza,altezza,itin) {
estensione =   500;
	meno_estensione = url_img.substr(0,url_img.length-4);
	larghezza = 500;
	var mywindow = window.open ('player_img_new.php?nome='+meno_estensione+'&est='+estensione+'&itin='+itin,"mywindow","location=1,status=1,scrollbars=0,resizable=yes, width="+larghezza+",height="+altezza);
}