<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<div class="module" id="user_comment">  
  <p class="top"><span></span></p>
  <div class="content">
    <h1><span>({$lang.total}<font class="f5">{$pager.record_count}</font>{$lang.user_comment_num})</span>{$lang.user_comment}</h1>
    <ul>
      <!-- {if $comments} -->
      <!-- {foreach from=$comments item=comment} -->
      <li>
        <img src="../images/stars{$comment.rank}.gif" alt="{$comment.comment_rank}" /><font class="f2"><!-- {if $comment.username} -->{$comment.username|escape:html}<!-- {else} -->{$lang.anonymous}<!-- {/if} --></font> <font class="f4">( {$comment.add_time} )</font>        
        <p>{$comment.content}</p>
        <!-- {if $comment.re_content} -->
        <p><font class="f1">{$lang.admin_username}</font>{$comment.re_content}</p>
        <!-- {/if} -->
      </li>
      <!-- {/foreach} -->
      <!--{else}-->
      <li>{$lang.no_comments}</li>
      <!--{/if}-->      
    </ul>
    <div class="comment_list">
      <form action="javascript:;" onsubmit="submitComment(this)" method="post" name="commentForm" id="commentForm">
       <table width="710" border="0" align="left" cellpadding="0" cellspacing="5">
        <tr>
          <td width="188" align="right"><strong>{$lang.username}：</strong></td>
          <td><!--{if $smarty.session.user_name}-->{$smarty.session.user_name}<!--{else}-->{$lang.anonymous}<!--{/if}--></td>
        </tr>
        <tr>
          <td align="right"><strong>E-mail：</strong></td>
          <td>
          <input type="text" name="email" id="email"  maxlength="100" value="{$smarty.session.email|escape}" class="inputBorder"/>          </td>
        </tr>
        <tr>
          <td align="right"><strong>{$lang.comment_rank}：</strong></td>
          <td>
          <input name="comment_rank" type="radio" value="1" id="comment_rank1" /> <img src="../images/stars1.gif" />
          <input name="comment_rank" type="radio" value="2" id="comment_rank2" /> <img src="../images/stars2.gif" />
          <input name="comment_rank" type="radio" value="3" id="comment_rank3" /> <img src="../images/stars3.gif" />
          <input name="comment_rank" type="radio" value="4" id="comment_rank4" /> <img src="../images/stars4.gif" />
          <input name="comment_rank" type="radio" value="5" checked="checked" id="comment_rank5" /> <img src="../images/stars5.gif" />          </td>
        </tr>
        <tr>
          <td align="right" valign="top"><strong>{$lang.comment_content}：</strong></td>
          <td><textarea name="content" class="inputBorder" style="height:50px; width:610px;"></textarea>
            <input type="hidden" name="cmt_type" value="{$comment_type}" />
          <input type="hidden" name="id" value="{$id}" />          </td>
        </tr>
        <tr>          
          <td colspan="7" align="right">          
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="79%">
              <!-- 判断是否启用验证码{if $enabled_captcha} -->
              <table width="100%" border="0" cellspacing="5" cellpadding="0">
                <tr>
                  <td width="77" align="right"><strong>{$lang.comment_captcha}：</strong></td>
                  <td width="8%"><input type="text" name="captcha"  class="inputBorder" style="width:50px;"/></td>
                  <td><span style="text-align:left; float:left; cursor:pointer; padding-left:10px;"><img src="captcha.php?{$rand}" alt="captcha" onClick="this.src='captcha.php?'+Math.random()" class="captcha"></span></td>
                </tr>
             </table>
             <!-- {/if} --> 
              </td>
              <td width="21%" align="right"><input name="input" type="submit"  value="" style=" position:relative; right:0px; border:none; margin:0px; padding:0px; background:url(../images/submit.jpg); width:75px; height:25px; cursor:pointer;"></td>
            </tr>
          </table>
            </td>
          </tr>
      </table>
      </form>
    </div>		
  </div>
  <p class="bottom"><span></span></p>
</div>
<script type="text/javascript">
//<![CDATA[
{foreach from=$lang.cmt_lang item=item key=key}
var {$key} = "{$item}";
{/foreach}
{literal}
/**
 * 提交评论信息
*/
function submitComment(frm)
{
  var cmt = new Object;

  //cmt.username        = frm.elements['username'].value;
  cmt.email           = frm.elements['email'].value;
  cmt.content         = frm.elements['content'].value;
  cmt.type            = frm.elements['cmt_type'].value;
  cmt.id              = frm.elements['id'].value;
  cmt.enabled_captcha = frm.elements['enabled_captcha'] ? frm.elements['enabled_captcha'].value : '0';
  cmt.captcha         = frm.elements['captcha'] ? frm.elements['captcha'].value : '';
  cmt.rank            = 0;

  for (i = 0; i < frm.elements['comment_rank'].length; i++)
  {
    if (frm.elements['comment_rank'][i].checked)
    {
       cmt.rank = frm.elements['comment_rank'][i].value;
     }
  }

//  if (cmt.username.length == 0)
//  {
//     alert(cmt_empty_username);
//     return false;
//  }

  if (cmt.email.length > 0)
  {
     if (!(Utils.isEmail(cmt.email)))
     {
        alert(cmt_error_email);
        return false;
      }
   }
   else
   {
        alert(cmt_empty_email);
        return false;
   }

   if (cmt.content.length == 0)
   {
      alert(cmt_empty_content);
      return false;
   }

   if (cmt.enabled_captcha > 0 && cmt.captcha.length == 0 )
   {
      alert(captcha_not_null);
      return false;
   }

   Ajax.call('comment.php', 'cmt=' + cmt.toJSONString(), commentResponse, 'POST', 'JSON');
   return false;
}

/**
 * 处理提交评论的反馈信息
*/
  function commentResponse(result)
  {
    if (result.message)
    {
      alert(result.message);
    }

    if (result.error == 0)
    {
      var layer = document.getElementById('ECS_COMMENT');

      if (layer)
      {
        layer.innerHTML = result.content;
      }
    }
  }
{/literal}
//]]>
</script>