<?php echo form_tag('message/send') ?>
  <div class="mailbox">
    <table class="outer" cellspacing='0'>
      <tr>
        <th colspan="2">
          <?php if ($mail): ?>
            Trả lời cho:<br />
            <?php echo input_tag('ms_address', $address, array('style'=>'width:515px', 'disabled'=>true)) ?>
            <?php echo input_hidden_tag('ms_id', $mail->getMsId()) ?>
          <?php else: ?>
            Gửi đến:<br />
            <?php echo form_error('ms_address') ?>
            <?php echo input_tag('ms_address', $address? $address: $sf_request->getParameter('ms_address'), array('style'=>'width:450px')) ?>
            <?php echo submit_to_remote('search', 'Tìm kiếm', array('update'=>'result', 'url'=>'/message/search', 'before'=>'search.disabled=true;', 'complete'=>'search.disabled=false;'), array('size'=>'20')) ?>
            <div id="result"></div>
          <?php endif ?>
        </th>
      </tr>
      <tr>
        <th colspan="2">
          Tiêu đề thư:<br />
          <?php echo form_error('ms_subject') ?>
          <?php echo input_tag('ms_subject', $title? $title: $sf_request->getParameter('ms_subject'), array('style'=>'width:515px')) ?>
        </th>
      </tr>
      <tr>
        <td colspan="2">
        <?php echo form_error('ms_content') ?>
        <?php echo textarea_tag('ms_content', $content? $content: $sf_request->getParameter('ms_content'), array(
          'rich' => true,
          'tinymce_options' => '
            entity_encoding: "raw",
            plugins:"emotions,equation",
            theme_advanced_buttons1: "fontsizeselect,|,justifyleft,justifycenter,justifyright,justifyfull,|,bold,italic,|,emotions,link,unlink,|,equation",
            theme_advanced_buttons2: "",
            theme_advanced_buttons3: "",
            width:515, height:250')); ?>
        </td>
      </tr>     
      <tr><th>
        <?php echo submit_tag('Gửi thư', array('onclick'=>'$("ms_address").disabled = false')) ?>
      </th></tr>
    </table>
  </div>
</form>

<?php $sf_context->getResponse()->addJavascriptCommand('
  function select_user(name) {
    $("ms_address").value = name;
    $("result").innerHTML = "";
  }
  if ($("ms_address").value == "") $("ms_address").focus();
  else if ($("ms_subject").value == "") $("ms_subject").focus();
  else $("ms_content").focus();
'); ?>
