$(function() {
    $('.error').hide();
    $('input.text-input').css({ backgroundColor: "#FFFFFF" });
    $('input.text-input').focus(function() {
        $(this).css({ backgroundColor: "#27a8e1" });
    });
    $('input.text-input').blur(function() {
        $(this).css({ backgroundColor: "#FFFFFF" });
    });

    $(".button").click(function() {
        // validate and process form
        // first hide any error messages
        $('.error').hide();

        /*  var name = $("input#name").val();
        if (name == "") {
        $("label#name_error").show();
        $("input#name").focus();
        return false;
        }*/
        var email = $("input#email").val();
        if (email == "") {
            //$("label#email_error").show();
            //$("label#for-email").hide();
            $("input#email").focus();
            return false;
        }
        /*	var phone = $("input#phone").val();
        if (phone == "") {
        $("label#phone_error").show();
        $("input#phone").focus();
        return false;
        }*/

        var dataString = "{'email': '" + email + "'}"; //'name='+ name + '&email=' + email + '&phone=' + phone;
        //alert (dataString);return false;

        $.ajax({
            url: "service/sendMail.asmx/sendMessage",
            data: dataString,
            dataType: "json",
            type: "POST",
            contentType: "application/json; charset=utf-8",            
            success: function() {
                $('#contact_form').html("<div id='message' style='color:#666666';></div>");
                $('#message').html("Iscrizione avvenuta correttamente")
                //.append("<p>We will be in touch soon.</p>")
        .hide()
        .fadeIn(1500, function() {
            $('#message').append("&nbsp;<img id='checkmark' src='images/email.png' align='absmiddle' />");
        });
            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {
                alert(textStatus);
            }
        });
        return false;
    });
});
//runOnLoad(function() {
//    $("input#email").select().focus();
//});

