<?php
function PrintComment($pars)
 {
?>
<style type="text/css">
#tab_container1{width:100%;text-align:left;}
.cls_tab_nav{height:26px;overflow:hidden;font-size:12px;text-align:left;background:url(images/line_bg.jpg) repeat-x bottom;}
.cls_tab_nav ul{font-size:9pt;margin:0;padding:0;}
.cls_tab_nav_li{background:url(images/tab_bg.jpg) no-repeat -157px 0;width:157px;height:26px;line-height:26px;float:left;display:inline;overflow:hidden;text-align:center;cursor:pointer;}
.cls_tab_nav_li_first{background-position:0px 0px;}
.cls_tab_nav_li a{text-decoration:none;color:#555;font-size:12px;}
.cls_tab_body{border:1px solid #999999;border-top:none;min-height:260px;padding:20px;}
.cls_div{display:none;font-size:12px; text-align:left;}
</style>


<div id="tab_container1">
 <div class="cls_tab_nav">
  <ul>
   <li class="cls_tab_nav_li cls_tab_nav_li_first"><a href="#">最新评论</a></li>
   <li class="cls_tab_nav_li"><a href="#">我来说两句</a></li>
  </ul>
 </div>
 <div class="cls_tab_body">
  <div class="cls_div" style="display:block;">
    <?php
     $pl_result = mysql_query("select * from `web_comment` where bid=".$pars["bid"]." and sid=".$pars["sid"]." and tid=".$pars["tid"]." and fid=".$pars["fid"]." and getid=".$pars["id"]." limit 5");
	 if (mysql_num_rows($pl_result) > 0)
	 {
	 while ($pl_rs = mysql_fetch_object($pl_result))
	  {
	?>
    <table width="100%" border="0" cellspacing="0" cellpadding="0" style="border-bottom: dotted 1px #ccc;">
      <tr>
        <td width="20%" height="30" align="left" bgcolor="#FFFFFF" style="color:#666">姓名：<?php echo $pl_rs->username;?></td>
        <td width="60%" align="right">&nbsp;</td>
        <td width="20%" align="left" style="color:#666">日期：<?php echo date_fromats($pl_rs->addtime);?></td>
      </tr>
      <tr>
        <td height="30" colspan="3" style="padding-left:30px;color:#666"><?php echo nl2br($pl_rs->comment);?></td>
      </tr>
    </table>
    <?php
	  }
	 }
	 else 
	 {
		 echo "暂无评论！";
	 }
	?>
  </div>
  <div class="cls_div">
    <script language="javascript">
	
	//去左空格; 
function ltrim(s){ 
    return s.replace( /^\s*/,""); 
} 
//去右空格; 
function rtrim(s){ 
    return s.replace( /\s*$/,""); 
} 
//去左右空格; 
function trim(s){ 
    return ltrim(rtrim(s)); 
}

	
      function plcheck()
	  {
		  var notnull;
	notnull=true;
    if (document.com.username.value == ""){
		window.alert("提示：请输入姓名！");
		document.com.username.focus();
		notnull=false;
		}
	else if (document.com.comment.value =="" ){
		window.alert("提示：请输入内容！");
		document.com.comment.focus();
		notnull=false;
		}
	else if (document.getElementById("codes").value == "") 	
	{
		   alert('提示:请输入验证码');
		   document.getElementById("codes").focus();
		  notnull=false;
		}
	else if (document.getElementById("codes").value != document.com.checkcode.value)	
	 {
		   alert('提示:请核实验证码');
		   notnull=false;
		 }		
	return notnull;
		 }
    </script>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
     <form action="SendComment.php?<?php echo Getpars();?>" method="post" name="com" id="com" onsubmit="return plcheck();" >
      <tr>
        <td width="12%" height="30" align="right" style="padding-right:10px;">姓名:</td>
        <td width="88%"><input type="text" name="username" id="username"  style="border: 1px solid #ccc; font-size:12px;" /> <span style="color:#F00;">* 姓名不可为空</span></td>
      </tr>
      <tr>
        <td height="30" align="right" style="padding-right:10px;">内容:</td>
        <td><textarea name="comment" cols="50" rows="10" id="comment" style="border: 1px solid #ccc; font-size:12px;" ></textarea></td>
      </tr>
      <tr>
        <td height="30" align="right" style="padding-right:10px;">验证码:</td>
        <td><input name="codes" type="text" id="codes" style="border: 1px solid #ccc; font-size:12px;" maxlength="4"  /> <input type="hidden" name="checkcode" /><script language="javascript">
var num1=Math.round(Math.random()*10000000);
var num=num1.toString().substr(0,4);
document.write("<img name=codeimg4 style='cursor:pointer;' src='admin/code.php?num="+num+"' onClick=\"this.src='admin/code.php?num='+Math.round(Math.random()*10000000).toString().substr(0,4);\"   >");
document.com.checkcode.value = num;
</script>       <span style="color:#F00;">* 验证码不可为空</span>	</td>
      </tr>
      <tr>
        <td height="30" align="right" style="padding-right:10px;">&nbsp;</td>
        <td><input type="submit" name="button" id="button" value="发表评论" style="border: 1px solid #ccc; font-size:12px; background-color:#FFF"  /></td>
      </tr>
     </form> 
    </table>

  </div>
 </div>
</div>
<script type="text/javascript">
try{
 document.execCommand("BackgroundImageCache", false, true);
}catch(e){}
function $(element){
 if(arguments.length>1){
  for(var i=0,elements=[],length=arguments.length;i<length;i++)
   elements.push($(arguments[i]));
  return elements;
 }
 if(typeof element=="string")
  return document.getElementById(element);
 else
  return element;
}
var Class={
 create:function(){
  return function(){
   this.initialize.apply(this,arguments);
  } 
 }
}
Object.extend=function(destination,source){
 for(var property in source){
  destination[property]=source[property];
 }
 return destination;
}
var tabMenu=Class.create();
tabMenu.prototype={
 initialize:function(container,selfOpt,otherOpt){
  this.container=$(container);
    var selfOptions=Object.extend({fontWeight:"bold",fontSize:"12px",color:"#FFBC44"},selfOpt||{});
  var otherOptions=Object.extend({fontWeight:"normal",fontSize:"12px",color:"#666"},otherOpt||{});
  //用for循环得到objs数组,主要是为了兼容非IE浏览器把空白也当作子对象
  for(var i=0,length=this.container.childNodes.length,objs=[];i<length;i++){
   if(this.container.childNodes[i].nodeType==1)
    objs.push(this.container.childNodes[i]);
  }
  var tabArray=objs[0].getElementsByTagName("li");
  //用for循环得到divArray数组,主要是为了兼容非IE浏览器把空白也当作子对象
  var divArray=new Array();
  for(i=0,length=objs[1].childNodes.length;i<length;i++){
   if(objs[1].childNodes[i].nodeType==1)
    divArray.push(objs[1].childNodes[i]);
  }
  
  for(i=0,length=tabArray.length;i<length;i++){
   tabArray[i].length=length;
   tabArray[i].index=i;
   tabArray[i].onmouseover=function(){
    //其它选项卡样式设置
    for(var j=0;j<this.length;j++){
     tabArray[j].style.backgroundPosition="-"+tabArray[j].offsetWidth+"px 0";
     for(var property in selfOptions){
      tabArray[j].firstChild.style[property]=otherOptions[property];
     }
    }
    //当前选项卡样式
    this.style.backgroundPosition="0 0";
    for(var property in selfOptions){
     this.firstChild.style[property]=selfOptions[property];
     /*
      注意this.style.property和selfOptions.property的用法错误
      style.fontWeight正确
      style["fontWeight"]正确
      style["font-weight"]错误
     */
    }
    //隐藏其它选项卡
    for(j=0;j<this.length;j++){
     divArray[j].style.display="none";
    }
    //显示当前选项卡
    divArray[this.index].style["display"]="block";
   }
  }
 }
}
var tab1=new tabMenu("tab_container1",{fontSize:"14px",color:"#FFBC44",fontWeight:"bold"},{fontWeight:"normal",color:"#666"});
</script>
<?php
 }
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0" >
  <tr>
    <td colspan="2"><?php PrintComment($pars);?></td>
  </tr>
</table>

