function controlla_registrazione ()
{
	var msg="Sono stati riscontrati i seguenti errori:";
	var msgdef=msg;
	var i=0;
	var a=0;
	//var email_pattern=/^[\w]+([\w.-]*)+@([\w.])+\w+$/;
	var email_pattern=/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/;
	var cf_pattern = /^[a-zA-Z]{6}[0-9]{2}[a-zA-Z][0-9]{2}[a-zA-Z][0-9]{3}[a-zA-Z]$/;
	var username_pattern=/\W/i;
	var f=document.registrati;
	
	//controllo email
	if (!email_pattern.test(f.mail.value)){
		f.mail.style.backgroundColor="#FF8888"; 
		i++;
	} else f.mail.style.backgroundColor="";
	
	/*
	//controllo mail
	if (f.mail.value=="") {
		f.mail.style.backgroundColor="#FF8888"; 
		i++;
	} else f.mail.style.backgroundColor="#E2FFC6";
	*/
	
	//controllo password
	if (f.password.value=="") {
		f.password.style.backgroundColor="#FF8888";
		i++; 
	} else f.password.style.backgroundColor="";
	
	//controllo ripeti_password
	if (f.ripeti_password.value=="") {
		f.ripeti_password.style.backgroundColor="#FF8888";
		i++; 
	} else f.ripeti_password.style.backgroundColor="";
	
	/*
	//controllo ripeti_password=password
	if ((f.ripeti_password.value!="")&&(f.password.value!="")&&(f.ripeti_password.value!=f.password.value)) {
		f.ripeti_password.style.backgroundColor="#FF8888"; 
		f.password.style.backgroundColor="#FF8888";
	} else {f.ripeti_password.style.backgroundColor="#E2FFC6";f.password.style.backgroundColor="#E2FFC6";}
	*/
	
	//controllo nome
	if (f.nome.value=="") {
		f.nome.style.backgroundColor="#FF8888";
		i++; 
	} else f.nome.style.backgroundColor="";
	
	//controllo cognome
	if (f.cognome.value=="") {
		f.cognome.style.backgroundColor="#FF8888";
		i++; 
	} else f.cognome.style.backgroundColor="";
	
	//controllo username
	if ((username_pattern.test(f.username.value))||(f.username.value=="")){
		f.username.style.backgroundColor="#FF8888";
		i++; 
	} else f.username.style.backgroundColor="";
	
	//controllo citta
	if (f.citta.value=="") {
		f.citta.style.backgroundColor="#FF8888";
		i++; 
	} else f.citta.style.backgroundColor="";
	
	//controllo provincia
	if (f.provincia.value=="") {
		f.provincia.style.backgroundColor="#FF8888";
		i++; 
	} else f.provincia.style.backgroundColor="";
	
	//controllo cap
	if (f.cap.value=="") {
		f.cap.style.backgroundColor="#FF8888";
		i++; 
	} else f.cap.style.backgroundColor="";
	
	//controllo cf
	if (!cf_pattern.test(f.cf.value)) {
		f.cf.style.backgroundColor="#FF8888";
		i++; 
	} else f.cf.style.backgroundColor="";
	
	
	//controllo Sesso
	if (f.sesso.selectedIndex==0) {
		f.sesso.style.backgroundColor="#FF8888";
		i++; 
	} else f.sesso.style.backgroundColor="";
	
	//controllo giorno
	if (f.birthday_day.selectedIndex==0) {
		f.birthday_day.style.backgroundColor="#FF8888";
		i++; 
	} else f.birthday_day.style.backgroundColor="";
	
	//controllo mese
	if (f.birthday_month.selectedIndex==0) {
		f.birthday_month.style.backgroundColor="#FF8888";
		i++; 
	} else f.birthday_month.style.backgroundColor="";
	
	//controllo mese
	if (f.birthday_year.selectedIndex==0) {
		f.birthday_year.style.backgroundColor="#FF8888";
		i++; 
	} else f.birthday_year.style.backgroundColor="";
	
	
	
	
	//controllo condizioni_di_utilizzo
	if (f.condizioni_di_utilizzo[0].checked) {} 
	else a++;
	
	//controllo informativa_privacy
	if (f.informativa_privacy[0].checked) {} 
	else a++;
	
	
	if ((i==0)&&(a==0))
		f.submit();
	else
		if (a!=0)
			alert ("Per poter procedere devi accettare le condizioni e leggere l'informativa sulla privacy");
		return false;
	

}




function invia_messaggio()
{
	document.getElementById("notifiche").innerHTML="Invio messaggio in corso...";
	var f=document.new_mex;
	var i=0;
	
	/*
	//controllo destinatario
	if (f.destinatario.selectedIndex==0) {
		f.destinatario.style.backgroundColor="#FF8888";
		i++; 
	} else f.destinatario.style.backgroundColor="#E2FFC6";
	
	//controllo oggetto
	if (f.oggetto.value=="") {
		f.oggetto.style.backgroundColor="#FF8888";
		i++; 
	} else f.oggetto.style.backgroundColor="#E2FFC6";
*/

	if (i==0)
		f.submit();
	
}

function inviaRichiestaSupporto()
{
	document.getElementById("notifiche").innerHTML="Invio richiesta in corso...";
	document.invio_richiesta.submit();
}

function inviaRichiestaDocenza()
{
	document.getElementById("notifiche").innerHTML="Invio richiesta in corso...";
	document.richiedi_docenza.submit();
	
}


function cancella_messaggio()
{
	var f;
	if (f=document.del_mex)
	{
		document.getElementById("notifiche").innerHTML="Eliminazione messaggio in corso...";
		f.submit();	
	}	
}



function apri(pagina) {
   var w = 720;
   var h = 360;
   var l = Math.floor((screen.width-w)/2);
   var t = Math.floor((screen.height-h)/2);
   var scrollbar = 0;
   if (pagina == "privacy_registrazione.php" || pagina == "condizioni_di_utilizzo.php")
   		scrollbar = 1;
   window.open(pagina,"","width=" + w + ",height=" + h + ",top=" + t + ",left=" + l + ",scrollbars=" + scrollbar);
 }
 
 


function apri_calendario(calendario,utente,corso) {

   var w = 1280;
   var h = 800;
   var l = Math.floor((screen.width-w)/2);
   var t = Math.floor((screen.height-h)/2);
   var get="";
   
   if ((utente!=null)&&(corso!=null))
   		get="?user="+utente+"&corso="+corso;
   		
	else if ((utente==null)&&(corso!=null))
   		get="?corso="+corso;
   	
   	else if ((utente!=null)&&(corso==null))
   		get="?utente="+utente;
   	
   		
    window.open(calendario+get,"","width=" + w + ",height=" + h + ",top=" + t + ",left=" + l);
 }


/*
function apri_agenda(id) {
   var w = 1280;
   var h = 800;
   var l = Math.floor((screen.width-w)/2);
   var t = Math.floor((screen.height-h)/2);
      window.open("sistema/jquery-weekcalendar-1.2.2/weekcalendar2.php?id="+id,"","width=" + w + ",height=" + h + ",top=" + t + ",left=" + l);
 }
*/
function visualizza(id)
{
	if (id=='societa')
	{
		for (var i=0;i<2;i++)
		{
			if (document.getElementById('societa'+i).style.display == "block")
				document.getElementById('societa'+i).style.display = "none";
			else
				document.getElementById('societa'+i).style.display = "block";	
		}
	}	
	else
	{
		if (document.getElementById(id).style.display == "block")
			document.getElementById(id).style.display = "none"
		else
			document.getElementById(id).style.display = "block"
	}		
}


function avanzato()
{
	if (document.getElementById('avanzato').style.display == "none")
	{
		document.getElementById('base').style.display = "none";
		document.getElementById('avanzato').style.display = "block";
	}
	else
	{
		document.getElementById('base').style.display = "block";
		document.getElementById('avanzato').style.display = "none";
	}

}


function tutoraggio(x,y)
{
	var w = 650;
   var h = 325;
   var l = Math.floor((screen.width-w)/2);
   var t = Math.floor((screen.height-h)/2);
      window.open("decidi.php?dec="+x+"&id="+y,"","width=" + w + ",height=" + h + ",top=" + t + ",left=" + l);
}


function nascondi(id)
{
	document.getElementById(id).style.display = "none";
}
/*
function visualizza(id)
{
	document.getElementById(id).style.display = "block";
}
*/


function ricerca_cambio_testo(){
	if (document.getElementById('input_ricerca').value=="Ricerca...")  document.getElementById('input_ricerca').value="";
	
}
function pulsante_home(url){
	var newImage = "url("+url+")";
    document.getElementById('pulsante_entra').style.backgroundImage = newImage;
}

function invia_invito()
{
	if (document.invito.trattamento_dati.checked) 
		 document.invito.submit();
	else 
		alert ("Devi acconsentire al trattamento dei tuoi dati personali per continuare!");
}

function pulisci(id)
{
	document.getElementById(id).value="";
}

function submitForm()
{
	document.contentForm.submit();
}

/*AGGIUNTO*/
function showById (id) {
	$(id).toggle("slow");
}




