var list; 
var tickerObj; 
var hex = 255;
var currentNews = 3;

function fadeText(divId) {
	//alert(hex);
	//alert(document.getElementById("news_"+divId).style.color);
    if(hex>0) {		
      hex-=10; // increase color darkness
      document.getElementById("news_"+divId).style.color="rgb("+hex+","+hex+","+hex+")";
      setTimeout("fadeText('" + divId + "')", fadeSpeed); 
    } else
      hex=255; //reset hex value
}

function news() 
	{
		//alert(currentNews);
		if(currentNews == 3)
			nuovaNews = 1;
		else
			nuovaNews = currentNews+1;

		//visualizzo la nuova news
		document.getElementById("news_"+nuovaNews).style.display = "block";
		fadeText(nuovaNews);
		
		//oscuro la vecchia news		
		document.getElementById("news_"+currentNews).style.display = "none";
		//aggiorno currentNews
		currentNews = nuovaNews;
		//richiamo la funzione tra n secondi
		window.setTimeout("news()", interval*1000);
	}

var interval = 10; // interval in seconds
var fadeSpeed = 40; // fade speed, the lower the speed the faster the fade.  40 is normal.

function MM_openBrWindow(theURL,winName,features) 
	{ //v2.0
	features = 'status=yes,scrollbars=yes,resizable=no,'+features;
	window.open(theURL,winName,features);
	}
	
function veriFormRegistrazione()
	{
	var form = document.getElementById('registrazione');
	var controllo=true;
	//alert('ok');
	//alert(form.privacy.checked);
	
	if (form.nominativo.value == "" )
	{
		controllo=false;
		alert("Prego, inserire il proprio nome e cognome");
		form.nominativo.focus();
	}
	else 
	if (form.mail.value == "")
	{
		controllo=false;
		alert("Verificare di aver inserito un'indirizzo e-mail valido");
		form.mail.focus();
	}
	else
		{
			controllo=validate_mail(form.mail.value);
			if(controllo == false) 
				form.mail.focus();
			else 
			if (form.username.value == "" )
			{
				controllo=false;
				alert("Prego, inserire la propria username");
				form.username.focus();
			}
			else 
			if (form.password.value == "" )
			{
				controllo=false;
				alert("Prego, inserire la propria password");
				form.password.focus();
			}
			else 
			if (form.confermapassword.value == "")
			{
				controllo=false;
				alert("Prego, inserire la conferma della propria password");
				form.confermapassword.focus();
			}
			else 
			if (form.confermapassword.value != form.password.value)
			{
				controllo=false;
				alert("Prego, verificare di aver inserito correttamente\nla conferma della propria password");
				form.confermapassword.focus();
			}			
			else 
			if (!form.privacy.checked)
			{
				controllo=false;
				alert("Per procedere e' necessaria l'accettazione dell'informativa sulla privacy");
			}
		}

	return controllo;
	}

function veriFormRecupera()
	{
	var form = document.getElementById('recupera');
	var controllo=true;
	//alert('ok');
	//alert(form.privacy.checked);
	
	if (form.mail.value == "")
	{
		controllo=false;
		alert("Verificare di aver inserito un'indirizzo e-mail valido");
		form.mail.focus();
	}
	else
		{
			controllo=validate_mail(form.mail.value);
			if(controllo == false) 
				form.mail.focus();
		}

	return controllo;
	}


function validate_mail(mail)
		{
		EmailAddr = mail;
		Filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
		if (Filtro.test(EmailAddr)) return true;
			else
				{
				 alert("Verificare di aver inserito un'indirizzo e-mail valido");
				 //document.registrazione.mail.focus();
				 return false;
				}
		}
