function SimpleSwap(el,which){
  el.src=el.getAttribute(which || "origsrc");
}

function SimpleSwapSetup(){
  var x = document.getElementsByTagName("img");
  for (var i=0;i<x.length;i++){
    var oversrc = x[i].getAttribute("oversrc");
    if (!oversrc) continue;
      
    // preload image
    // comment the next two lines to disable image pre-loading
    x[i].oversrc_img = new Image();
    x[i].oversrc_img.src=oversrc;
    // set event handlers
    x[i].onmouseover = new Function("SimpleSwap(this,'oversrc');");
    x[i].onmouseout = new Function("SimpleSwap(this);");
    // save original src
    x[i].setAttribute("origsrc",x[i].src);
  }
}

var PreSimpleSwapOnload =(window.onload)? window.onload : function(){};
window.onload = function(){PreSimpleSwapOnload(); SimpleSwapSetup();}


function controlla(modulo)
	{
		var strErr="";
		if(modulo.nome.value=='')
		{
			strErr+="Il campo nome è obbligatorio\n\n";
		}
		if(modulo.cognome.value=='')
		{
			strErr+="Il campo cognome è obbligatorio\n\n";
		}	
		if(modulo.email.value=='')
		{
			strErr+="Il campo email è obbligatorio\n\n";
		}
		else
		{
			var email = modulo.email.value;	
			if ((tmpint = email.indexOf ('@',0)) == -1)
				{strErr+="La chiocciola @ non è stata inserita nell'indirizzo.\n";}
			if (tmpint==0)
				{strErr+="L'indirizzo e-mail non può iniziare con il simbolo '@'.\n";}
			if ((tmpint2 = email.indexOf ('.',tmpint)) == -1) 
				{strErr+="Nel campo è necessario inserire un punto dopo la chiocciola @.\n";}
			if (tmpint2-tmpint==1)
				{strErr+="La sequenza di simboli '@.' non può appartenere all'indirizzo e-mail.\n";}
			if (tmpint2 == email.length-1)
				{strErr+="L'indirizzo e-mail non può finire con il simbolo '.'\n";}
		}
		if(modulo.commento.value=='-- inserisci il tuo commento --')
		{
			strErr+="Il campo commento è obbligatorio\n\n";
		}
		if(strErr!="")
		{
			alert("ATTENZIONE!\n\n" + strErr + "\nControllare il contenuto del form!");
			return false;
		}
		else 
		{
			return true;
		}
	}
	


