// powered by ebug.it

// www.ebug.it :)


$(document).ready(function(){
$("#button").click(function(){

var nome = $("#nome").val();
var oggetto = $("#oggetto").val();
var mail = $("#mail").val();
var testo = $("#testo").val();
var dove = $("#dove").val();
var cell = $("#cell").val();
var esito = '';

var doverisp = 'Da dove scrivi';

if (dove.length<1 || dove == doverisp ) {

var esito = "Dove errato <br>";

} 

if (cell.length<1 || cell == 'Il tuo numero telefonico' ) {

var esito = "cellullare errato <br>";

} 

if (nome.length<1 || nome == 'Inserisci il tuo Nome' ) {

var esito = "Nome errato <br>";

} 

if (oggetto.length<1 || oggetto == 'Oggetto' ) {

var esito = "Oggetto errato <br>";

} 

if (!mail.match(/^([a-z0-9._-]+@[a-z0-9._-]+\.[a-z]{2,4}$)/i)) {

var esito = "Mail errata <br>";

} 

if (testo.length<1 || testo == 'Parlaci' ) {

var esito = "Testo errato <br>";

}

if (esito == "" ) {

// inviamo la mail 

var dati_mail ='nome=' + nome + '&oggetto=' + oggetto + '&mail=' + mail + '&testo=' + testo + '&cell=' + cell + '&dove=' + dove;

$.ajax({
	
type: "POST",
url: "http://www.sicilpiscine.it/wp-content/themes/sicilpiscine/js/mail.php",
data: dati_mail,
cache: false,
success: function(html){

var esito = "Ok, sto inviando l'mail";

$("#risposta_form").fadeIn("slow");
$("#risposta_form").html(esito);
$("#risposta_form").css("background-color","#389b28");


setTimeout('$("#risposta_form").fadeOut("slow")',2000);

}})
	


} else {


$("#risposta_form").fadeIn("slow");
$("#risposta_form").html(esito);
$("#risposta_form").css("background-color","#e3141a");

// setTimeout('$("#risposta_form").fadeOut("slow")',2000);


}

return false;

});

});





