<form action="<?php echo php_self(); ?>" method="post" accept-charset="utf-8" id="mes-form">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h3><?php echo __('mess.ecrire.message'); ?></h3>
    </div>
    <div class="modal-body">
        <div class="control-group">
            <textarea rows="3" name="MES_CONTENU" placeholder="Votre message" id="MES_CONTENU" class="mes-contenu"></textarea>
        </div>
    </div>
    <div class="modal-footer">
        <div class="pull-left hide text-info" id="status">
            <?php echo zk_loading(); ?>
        </div>
        <a href="#" class="btn btn-primary" id="mes-envoyer"><?php echo __('mess.ecrire.envoyer'); ?></a>
        <a href="#" class="btn btn-close"><?php echo __('com.action.retour'); ?></a>
    </div>
</form>

<script type="text/javascript">
    $(function () {
        $(".btn-close").click(function() {
           closeModal();
        });

        $("#mes-envoyer").click(function () {
            var statusDiv = $("#status");
            statusDiv.hide();
            statusDiv.removeClass('text-error');

            var contenu = $.trim($("#MES_CONTENU").val());
            if (contenu.length == 0) {
                statusDiv.html('Merci de saisir un message');
                statusDiv.addClass('text-error');
                statusDiv.show();
                $("#MES_CONTENU").parent().addClass('error');
                return false;
            }
            $(this).attr('disabled','disabled');
            statusDiv.html('Chargement en cours…');
            statusDiv.show();
            $.ajax({
                url:'<?php echo php_self(); ?>',
                cache:false,
                type:'POST',
                data:{'MES_CONTENU':contenu},
                success:function (html) {
                    $("#status").hide();
                    alert("Message envoyé !");
                    closeModal();
                },
            error:function (request, status, error) {
                alert("Erreur : " + request.responseText);
                statusDiv.addClass('text-error');
                statusDiv.html('Erreur : '+request.responseText);
            }
            });
            return false;
        });
    });
</script>