<div id="mes-nouveau">
    <div id="text"></div>
    <form action="<?php echo php_self(); ?>" method="post" accept-charset="utf-8" id="mes-form">
        <h2 align="left"><?php echo __('mess.ecrire.dest'); ?></h2>
        <select id="JOU_DEST" name="JOU_DEST"></select>
        <br/>

        <h2 align="left"><?php echo __('mess.ecrire.message'); ?></h2>
        <textarea name="MES_CONTENU" id="MES_CONTENU"></textarea>
        <br/>

        <div align="right">
            <input type="submit" name="submit" value="<?php echo __('mess.ecrire.envoyer'); ?>">
            <input type="button" value="<?php echo __('com.action.retour'); ?>" onclick="$.unblockUI();">
        </div>
    </form>
</div>

<script type="text/javascript">
    <!--
    $(document).ready(function () {
        $("#mes-form").submit(function () {
            if ($("#JOU_DEST option:selected").size() == 0) {
                $(".holder").css('border', '2px solid red');
                return false;
            } else {
                $(".holder").css('border', '1px solid black');
            }
            if ($("#MES_CONTENU").val() == "") {
                $("#MES_CONTENU").css('border', '2px solid red');
                return false;
            }

            $.ajax({
                url:$(this).attr('action'),
                cache:false,
                type:'POST',
                data:$(this).serialize(),
                success:function (html) {
                    alert("Message envoyé !");
                    $.unblockUI();
                    return false;
                },
                error:function (request, status, error) {
                    alert("Erreur : " + request.responseText);
                }
            });
            return false;
        });

        $("#JOU_DEST").fcbkcomplete({
            json_url:"<?php echo href('', '/tabjoueurs/listerjson', false, true); ?>",
            cache:false,
            filter_case:false,
            filter_hide:true,
            firstselected:true,
            filter_selected:true,
            maxitems:10,
            delay:300
        });

    });

    //-->
</script>

