<!--
function Invia(url)
{
	var cognome = document.contact.cognome.value;
	var nome = document.contact.nome.value;
	var mail = document.contact.mail.value;
	var messaggio = document.contact.messaggio.value;
	 // Espressione regolare dell'email
    var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;

    // Effettua il controllo sul campo NOME
    if ((nome == "") || (nome == "undefined")) {
       alert("Il campo Nome è obbligatorio.");
       document.contact.nome.focus();
       return false;
    }else if((cognome == "") || (cognome == "undefined")) {//Effettua il controllo sul campo COGNOME
        alert("Il campo Cognome è obbligatorio.");
        document.contact.cognome.focus();
        return false;
    }else if (!email_reg_exp.test(mail) || (mail == "") || (mail == "undefined")) {
          alert("Inserire un indirizzo email corretto.");
          document.contact.mail.select();
          return false;
    }else if((messaggio == "") || (messaggio == "undefined")) {//Effettua il controllo sul campo MESSAGGIO
        alert("Il campo Messaggio è obbligatorio.");
        document.contact.messaggio.focus();
        return false;
    }else{  
		document.contact.action = url;
		document.contact.submit();
		/*alert("Informazioni richieste correttamente"); */
    }
}

function cambia_foto(foto, titolo, id_div, larghezza, altezza)
{
	var new_foto = new Image();
	new_foto.src = foto;

	document.getElementById(id_div).src = foto;
	document.getElementById(id_div).alt = titolo;
	document.getElementById(id_div).title = titolo;
	document.getElementById(id_div).width = larghezza;
	document.getElementById(id_div).height = altezza;
	

}
function MM_preloadImages() { //v3.0
	  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	}
function UB_showHideObject() { //v2.0
	var i,p,v,obj,args=UB_showHideObject.arguments;
	for (i=0; i<(args.length-1); i+=2) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+1];
	if (obj.style) { obj=obj.style; v=(v=='off')?'none':(v=='on')?'block':v; }
	obj.display=v; }
	}
function DB_showHideObject(obj)
	{
		document.getElementById(obj).style.display = document.getElementById(obj).style.display != 'block'?'block':'none';
	}
function MM_findObj(n, d) { //v4.0
	  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	  if(!x && document.getElementById) x=document.getElementById(n); return x;
	}

/**
 * @author <fra.casula@gmail.com> Francesco Casula
 * @author <cristiano.casciotti@gmail.com> Cristiano Casciotti
 */
var setOpacity = function(id, alpha)
{
	var myDiv = document.getElementById(id);
	myDiv.style.mozOpacity = alpha / 100;
	myDiv.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + alpha + ")";
	myDiv.style.opacity = alpha / 100;
}

/**
 * @class Wall
 */
function Wall(instance)
{
	this.instance = instance;
	this.box = document.createElement("div");
	this.box.alreadyAdded = false;
}

Wall.prototype.createForm = function(link)
{
	var dimX = screen.width; //larghezza pagina
	var dimY = screen.height; //lunghezza pagina
	
	this.box = document.createElement("div");
	this.box.id = "box_segnala";
	this.box.style.position = "absolute";
	this.box.style.top = parseInt(dimY / 2)+250 + "px";
	this.box.style.left = parseInt(dimX / 3) + "px";
	this.box.style.width = "300px";
	this.box.style.height = "250px";
	this.box.style.borderColor = "#cccccc";
	this.box.style.borderWidth = "1px";
	this.box.style.borderStyle = "solid";
	this.box.style.backgroundColor = "#f1f3e9";

	// Nick
	var nick_text = document.createElement("label");
	nick_text.style.position = "absolute";
	nick_text.style.top = "70px";
	nick_text.style.left = "20px";
	nick_text.innerHTML = "Il tuo nome:";
	
	
	var nick = document.createElement("input");
	nick.style.position = "absolute";
	nick.id = "form_nick";
	nick.name = "form_nick";
	nick.style.fontSize = "12px";
	nick.style.top = "65px";
	nick.style.left = "95px";
	nick.style.width = "170px";
	nick.style.border = "0px";
	nick.style.height = "20px";
	
	//E-Mail
	var email_text = document.createElement("label");
	email_text.style.position = "absolute";
	email_text.style.top = "95px";
	email_text.style.left = "21px";
	email_text.innerHTML = "E-mail:";
	
	
	var email = document.createElement("input");
	email.id = "email";
	email.name = "email";
	email.style.position = "absolute";
	email.style.fontSize = "12px";
	email.style.top = "90px";
	email.style.left = "95px";
	email.style.width = "170px";
	email.style.border = "0px";
	email.style.height = "20px";
	
	
	
	// Note
	var note_text = document.createElement("label");
	note_text.style.position = "absolute";
	note_text.style.top = "114px";
	note_text.style.left = "20px";
	note_text.innerHTML = "Commento:";
	
	
	var note = document.createElement("textarea");
	note.id = "commento";
	note.name = "commento";
	note.style.position = "absolute";
	note.style.top = "114px";
	note.style.left = "95px";
	note.style.fontSize = "12px";
	note.style.width = "170px";
	note.style.height = "100px";
	note.style.border = "0px";
	note.rows = 5;
		
	// Send link
	var send_link = document.createElement("a");
	send_link.style.position = "absolute";
	send_link.style.top = "225px";
	send_link.style.left = "105px";
	send_link.style.textDecoration = "none";
	send_link.href = "javascript:;";
	send_link.innerHTML = "Invia e-mail";
	send_link.onclick = function() { segnala.invia_segnalazione(link, document.getElementById("email").value, document.getElementById("form_nick").value, document.getElementById("commento").value); }

	var main_text = document.createElement("label");
	main_text.style.position = "absolute";
	main_text.style.top = "20px";
	main_text.style.left = "20px";
	main_text.style.fontWeight = "bold";
	main_text.style.fontSize = "16px";
	main_text.style.color = "#798E29";
	main_text.style.textTransform = "uppercase";
	main_text.style.textDecoration = "underline";
	main_text.innerHTML = "Segnala ad un amico";
	
	var close_link = document.createElement("a");
	close_link.style.position = "absolute";
	close_link.style.top = "4px";
	close_link.style.left = "260px";
	close_link.style.textDecoration = "none";
	close_link.innerHTML = "Chiudi";
	close_link.href = "javascript:;";
	close_link.onclick = function() { wall.destroyForm(); }
	
	this.box.appendChild(nick_text);
	this.box.appendChild(nick);
	this.box.appendChild(email_text);
	this.box.appendChild(email);
	this.box.appendChild(note_text);
	this.box.appendChild(note);
	this.box.appendChild(send_link);
	this.box.appendChild(close_link);
	this.box.appendChild(main_text);
	document.body.appendChild(this.box);
}

Wall.prototype.destroyForm = function()
{
	document.body.removeChild(this.box);
}

Wall.prototype.show = function(content)
{
	if (this.box.alreadyAdded === true)
	{
		document.body.appendChild(this.box);
		return;
	}

	var ie = (navigator.appName.indexOf("Internet Explorer") != -1) ? true : false;
	var marginTop = (ie) ? document.documentElement.scrollTop : window.pageYOffset;

	this.box.id = "box_" + parseInt(Math.random() * 100);
	this.box.style.position = "absolute";
	this.box.style.top = "0px";
	this.box.style.left = "0px";
	this.box.style.width = "100%";
	this.box.style.height = "100%";

	var wall = document.createElement("div");
	wall.id = "wall_" + parseInt(Math.random() * 100);
	wall.style.position = "absolute";
	wall.style.top = "0px";
	wall.style.left = "0px";
	wall.style.width = "100%";
	wall.style.height = document.body.clientHeight + "px";	
	wall.style.backgroundColor = "white";

	var pop = document.createElement("div");
	pop.id = "popup_" + parseInt(Math.random() * 100);
	pop.style.position = "absolute";
	pop.style.top = parseInt(marginTop + 10) + "px";
	pop.style.left = "10px";
	pop.style.backgroundColor = "white";
	pop.style.borderColor = "green";
	pop.style.borderWidth = "1px";
	pop.style.borderStyle = "solid";
	pop.style.padding = "10px 10px 10px 10px";

	var contentHTML = content;
	contentHTML += '<br /><div style="width:100%;" align="center">';
	contentHTML += '<a href="javascript:void(0);" onclick="' + this.instance + '.hide();">';
	contentHTML += 'Chiudi</a></div>';
	pop.innerHTML = contentHTML;

	this.box.appendChild(wall);
	this.box.appendChild(pop);
	document.body.appendChild(this.box);
	this.box.alreadyAdded = true;

	setOpacity(wall.id, 70);
	setOpacity(pop.id, 80);
}

Wall.prototype.hide = function()
{
	document.body.removeChild(this.box);
}

function EMail()
{
	this.script_page = "/ajax/segnala.php";

	this.invia_segnalazione = function(link, email, nick, commento)
	{
		if (nick.length <= 0)
		{
			alert("Nome non valido!");
			document.getElementById("form_nick").style.borderColor = "red";
			document.getElementById("form_nick").focus();
			return;
		}
		else if (email.length <= 0)
		{
			document.getElementById("form_nick").style.borderColor = "";
			alert("Indirizzo E-Mail non valido!");
			document.getElementById("email").style.borderColor = "red";
			document.getElementById("email").focus();
			return;
		}
		else
		{
			this.setTarget(this.gestisciRisposta);
			this.setLoadingTarget(document.getElementById("box_segnala"));
			this.params["link"] = link;
			this.params["email"] = email;
			this.params["nick"] = nick;
			this.params["commento"] = commento;
			this.makeRequest(this.script_page);
		}
	}
	
	this.gestisciRisposta = function(risposta)
	{
		document.getElementById("box_segnala").style.height = "150px";
		document.getElementById("box_segnala").innerHTML = '<div style="position: absolute; top: 50px; left: 65px; width: 170px; height: auto;">' +
		'<h1>' + risposta + '</h1>' + 
		'</div>' + 
		'<a style="position: absolute; top: 130px; left: 125px;" href="javascript:;" onclick="wall.hide();">chiudi</a>';
	}
}

EMail.prototype = new AjaxModule();
EMail.prototype.constructor = EMail;


//-->
