/**
* @author Gabriele
*/
function SendFriend()
{
this.script_page = "/ajax/sendToFriend.php";
this.checkForm = function()
{
var fromName = document.getElementById('from_name');
if (fromName.value.length <= 2)
{
alert("Nome non valido (min. 3 caratteri).");
fromName.focus();
return false;
}
var fromMail = document.getElementById('from_email');
if (!fromMail.value.match(/^([_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})){1}$/))
{
alert("E-Mail non valida.");
fromMail.focus();
return false;
}
var toName = document.getElementById('to_name');
if (toName.value.length <= 2)
{
alert("Nome non valido (min. 3 caratteri).");
toName.focus();
return false;
}
var toMail = document.getElementById('to_email');
if (!toMail.value.match(/^([_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})){1}$/))
{
alert("E-Mail non valida.");
toMail.focus();
return false;
}
this.params["from_name"] = new String(fromName.value);
this.params["from_email"] = new String(fromMail.value);
this.params["to_name"] = new String(toName.value);
this.params["to_email"] = new String(toMail.value);
return true;
}
this.send = function(url)
{
if (this.checkForm())
{
this.setLoadingSrc('/immagini/vote_loader.gif');
this.setLoadingTarget(document.getElementById('sf_target'));
this.setTarget(document.getElementById('sf_target'));
this.params["url"] = new String(url);
this.makeRequest(this.script_page);
}
}
}
SendFriend.prototype = new AjaxModule();
SendFriend.prototype.constructor = SendFriend;