$(function() {
$('#formulaireContact').validate({
    submitHandler: function(form) {
        $("#randContact").val( Math.random());
        $(form).ajaxSubmit(function(responseText, statusText) {
            jQuery.facebox(function() {
                jQuery.get('resultat.php', function(data) {
                    jQuery.facebox( data )
                })
            })
            document.getElementById('image').src = '../securimage/securimage_show.php?sid=' + Math.random();
            $(form).resetForm();
        })
    },
    rules: {
        nom: {
            required: true
        },
        adresse: {
            required: true
        },
        ville: {
            required: true
        },
        email: {
            required: true,
            email:true
        },
        message: {
            required: true
        },
        captcha: {
            required: true,
            remote: {
                url: "../php/verifiecaptcha1.php",
                type: "get"
            }
        }
    },
    messages:	 {
    captcha: 		{
            required: "Entrer les caractères comme sur l'image au-dessus:",
            remote: jQuery.format("le code actuel est incorrect.")
        }
    },
    // the errorPlacement has to take the table layout into account
    errorPlacement: function(error, element) {
        if ( element.is(":radio") ) {
            error.appendTo( element.parent());
        }
        else if ( element.is(":checkbox") )
            error.appendTo ( element.next() );
        else
            error.appendTo( element.parent() );
    }
});



});
