var contact =
{
    dynamise: function()
    {
        $("form.contact").ajaxForm({
            dataType:  'json',      /** pour que le json soit évalué automatiquement */
            beforeSubmit: function() {
                $.blockUI({message: '<div class="blockUI-chargement">Chargement...</div>'});
            },
            error: $.unblockUI,
            success: function(json) {
                $.unblockUI();
                if(json.formErrors != undefined){
                    var message = '';
                    for(name in json.formErrors){
                        $("form.contact [@name='" + name + "']")
                            .css({
                                backgroundColor: '#F29400',
                                border: '1px solid red' })
                            .focus(function(){
                                $(this).css({
                                    backgroundColor: 'white',
                                    border: '1px solid #F29400' });
                            });
                        message += json.formErrors[name] + "\n"
                    }
                    $.blockUI_alert(message);
                }
                else if (json.mailError != undefined) {
                    $.blockUI_alert(json.mailError);
                }
                else if (json.message != undefined) {
                    $.blockUI_confirm(json.message, function(){
                        window.location.replace('./');
                    });
                }
            }
        });
    }
}