this.imagePreview = function(){	
	/* CONFIG */
		
		xOffset = 10;
		yOffset = 30;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.preview").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='preview'><img src='"+ this.name +"' alt='Image preview' />"+ c +"</p>");								 
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#preview").remove();
    });	
	$("a.preview").mousemove(function(e){
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};

// starting the script on page load
$(document).ready(function(){
	imagePreview();
	
	$("a[rel=zoom_foto]").fancybox({
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		//'titlePosition' 	: 'over',
		'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
		    return '';
		}
	});
});


function Modulo() {
   var nome = document.modulo.nome.value;
	 var cognome = document.modulo.cognome.value;
	 var citta = document.modulo.citta.value;
   var telefono = document.modulo.telefono.value;
   var messaggio = document.modulo.messaggio.value;
		if ((nome == "") || (nome == "undefined")) {
      alert("Il campo Nome è obbligatorio.");
    	document.modulo.nome.focus();
    return false;
    }
   	else if ((cognome == "") || (cognome == "undefined")) {
      alert("Il campo Cognome è obbligatorio.");
    	document.modulo.cognome.focus();
    return false;
    }
    else if ((citta == "") || (citta == "undefined")) {
      alert("Il campo Città è obbligatorio.");
    	document.modulo.citta.focus();
    return false;
    }
    else if ((telefono == "") || (telefono == "undefined")) {
      alert("Il campo telefono è obbligatorio.");
    	document.modulo.telefono.focus();
    return false;
    }
		else if ((messaggio == "") || (messaggio == "undefined")) {
			alert("Scrivi un messaggio!");
			document.modulo.messaggio.focus();
			return false;
		}
		else if(document.modulo.accetto.checked == false){
			alert("Bisogna accettare la legge sul trattamento dei dati");
		return false;
		}
        else {
           document.modulo.action = "include/invio.php";
           document.modulo.submit();
        }
  }
	
function Numeri(){ if (event.keyCode < 48 || event.keyCode > 57){ event.returnValue = false } }
