function is_email(value) 
{
	return /^[\w\-]+(\.[\w\-]+)*@[\w\-]+\.([\w\-]+\.)*[a-z]{2,}$/i.test(value);
}

$(document).ready(function () {
							
	$('.slideshow').cycle({
		fx: 'fade'
	});

    $("#newsletter_email").focus(function () {
		if($("#newsletter_email").val() == "E-mail")
		{
        	this.value = '';
		}
    });
	
	$("#btn_newsletter").click(function () {
		if ($('#acconsento').attr('checked'))
		{
			var emailval = $("#newsletter_email").val();
			if(is_email(emailval))
			{
				$.post("ajax.php", { azione: 'newsletter', email: emailval }, 
					function(data) {
						if(data == "1")
						{
							alert("E-mail registrata correttamente!\nE-mail address successfully subscribed!");
						}
						else
						{
							alert("L'indirizzo immesso e' gia' presente!\nThis email address is already subscribed!");
						}
				});
			}
			else
			{
				alert("L'indirizzo inserito non e' valido!\nThe e-mail you entered is not valid!");
			}
		}
		else
		{
			alert("Devi accettare il trattamento dei dati personali!\nYou must accept the privacy rules!");
		}
	});
});