<?php use_helper('tvtl'); ?>
<?php echo form_tag() ?>
<?php echo input_hidden_tag('entry_id', $sf_request->getParameter('entry_id')) ?>
<?php echo textarea_tag('cm_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: "",
    		  height:150,width:548')); ?>

<?php echo submit_to_remote('send', __('Send your comment'), array(
  'update' => 'comments',
  'url' => '/'.$sf_context->getModuleName().'/insertcomment',
  'method' => 'POST',
  'before' => '$("send").disabled=true; tinyMCE.triggerSave()',
  'complete' => '$("send").disabled=false; if ($("insertOk")!=undefined) tinyMCE.get("cm_content").setContent("");'
), array(
  'id' => 'send',
  'style' => $sf_user->isAuthenticated()? '': 'display:none'
)) ?>

<?php if (!$sf_user->isAuthenticated()): ?>
  <?php use_helper('ModalBox'); ?>
  <?php echo javascript_tag('
  $("send").disabled = true;
  function summitRemote() {
    Modalbox.hide();
    sendButton = $("send");
    sendButton.disabled = false;
    sendButton.onclick(sendButton);
    sendButton.style.display = "block";
    $("send2").style.display = "none";
  }') ?>
  <span id='send2'><?php echo mm_link_need_login(__('Send your comment'), 'javascript:summitRemote()') ?></span>
<?php endif ?>
</form>