//Funzione per l'adeguamento del left

var myreg_name=new RegExp("^[a-zA-Z ']+$");
var myreg_num=new RegExp("^[0-9]+$");
var myreg_email=new RegExp("^([a-zA-Z0-9\._-])+@([a-zA-Z0-9-])+\.([a-zA-Z0-9])+$");

function adegua_left() {
	if(document.getElementById) {
		alt_destra = document.getElementById('content').offsetHeight;
		alt_sinistra = document.getElementById('left').offsetHeight;
    if(alt_sinistra < alt_destra) {
		       document.getElementById('left').style.height = alt_destra + 'px';
	   }
	}

}

function ric_lingua(lingua) {
	mio_link = document.location.pathname;
	 passa = document.location.search;
	 parametri="";
	 if(passa.indexOf("lang=ita")==true) {
	 
		a = passa.split("lang=ita");
		parametri = a[0]+a[1];
	 }
	 if(passa.indexOf("lang=eng")==true) {
	 
		a = passa.split("lang=eng");
		parametri = a[0]+a[1];
	 }
	 if(passa.indexOf("lang")!=true) {
		parametri=passa;
	 }
	 
	 if(parametri!="") {
		 lun = parametri.length;
		 stringa="&";
		 for(i=0; i<lun; i++){
			 
			 if(i>0) {
				 stringa=stringa+parametri.charAt(i);
			 }
		 }
	 } else {
		 stringa=""; 
	 }
	mio_link = mio_link+"?lang="+lingua+stringa;
	document.location.replace(mio_link);
}

function apri_opera(id) {

     pag="/opera.php?opera="+id;
     window.open(pag, 'fin_opera', 'width=720, height=530, top=10, left=10, resizable=no, menubar=no, toolbar=no, location=no, scrollbars=no, status=no');

}

function ctl_annuncio(lingua) {
     a=document.invio_annuncio;
     obblighi=0;
     errori=0;
     
     if(a.consenso.checked==false) {
          if(lingua=="ita") {
               alert("Attenzione. Prestare consenso al trattamento dei dati personali.");
          }
          
          if(lingua=="eng") {
               alert("You must give your consent to the treatment of the personal data");
          }
     } else {
          if(a.annuncio.value=="" || a.email.value=="") {
               if(lingua=="ita") {
                    alert("I campi email e annuncio sono obbligatori");
               }
               
               if(lingua=="eng") {
                    alert("The fields email and announcement are obligatory");
               }
          } else {
               if(a.nome.value!="") {
                    res=myreg_name.test(a.nome.value);
                    if(!res) {
                         errori++;
                         if(lingua=="ita") {
                              alert("Ci sono errori nel campo nome");
                         } else {
                              alert("Some error in the field name");
                         }
                         
                         return ko;
                    }
               }
               
               if(a.cognome.value!="") {
                    res=myreg_name.test(a.cognome.value);
                    if(!res) {
                         errori++;
                         if(lingua=="ita") {
                              alert("Ci sono errori nel campo cognome");
                         } else {
                              alert("Some error in the field second name");
                         }

                         return ko;
                    }
               }
               
               if(a.email.value!="") {
                    res=myreg_email.test(a.email.value);
                    if(!res) {
                         errori++;
                         if(lingua=="ita") {
                              alert("Ci sono errori nel campo email");
                         } else {
                              alert("Some error in the field second email");
                         }

                         return ko;
                    }
               }
               
               if(errori==0) {
                    a.submit();
               }
          }
     }
     
}

