﻿// JScript 文件

// JScript 文件
/*******************************************/
            //调用说明：date_obj为时间对象，date_templet为返回的日期格式模版（如：date_obj为“2006-9-23 12:34:10”；date_templet为“yy年mm月”，返回：“06年9月”）
            /*******************************************/
            function getFormatDate(date_obj,date_templet){
              var year,month,day,hour,minutes,seconds,short_year,full_month,full_day,full_day,full_hour,full_minutes,full_seconds;
              if(!date_templet)date_templet = "yyyy-mm-dd hh:ii:ss";
              year = date_obj.getFullYear().toString();
              short_year = year.substring(2,4);
              month = (date_obj.getMonth()+1).toString();
              month.length == 1 ? full_month = "0"+month : full_month = month;
              day = date_obj.getDate().toString();
              day.length == 1 ? full_day = "0"+day : full_day = day;
              hour = date_obj.getHours().toString();
              hour.length == 1 ? full_hour = "0"+hour : full_hour = hour;
              minutes = date_obj.getMinutes().toString();
              minutes.length == 1 ? full_minutes = "0"+minutes : full_minutes = minutes;
              seconds = date_obj.getSeconds().toString();
              seconds.length == 1 ? full_seconds = "0"+seconds : full_seconds = seconds;
              return date_templet.replace("yyyy",year).replace("mm",full_month).replace("dd",full_day).replace("yy",short_year).replace("m",month).replace("d",day).replace("hh",full_hour).replace("ii",full_minutes).replace("ss",full_seconds).replace("h",hour).replace("i",minutes).replace("s",seconds);
            }

            
            
            //去掉左右空格
	        function Trim(value)
	        {

		        var res = String(value).replace(/^[\s]+|[\s]+$/g,'');
		        return res;

	        }
                        
            //提交评论 
			function Insert() 
            { 
			    
                
                var content=document.getElementById("content");
                var Hid=document.getElementById("Hid");
                var Uid=document.getElementById("Uid");  
                if (Trim(content.value)!="" && Trim(Uid.value)!="")               
                {
                    Video_Detail.InsertComment(Hid.value,Uid.value,content.value,InsertCallBack);               
                    document.getElementById("div_comment").innerHTML="<img src='../images/loadding.gif'>加载中。。。";
                    alert("发表评论成功！");
                }
                else
                {
                    alert("留言者与留言内容不能为空！");
                }
            }
            
            function InsertCallBack(response)
            {
            
                        
　　　　            var ds = response.value;
                    if(ds != null && typeof(ds) == "object" && ds.Tables != null && ds.Tables[0].Rows.length!=0)
                    {   
                       var divContent="";
                       //var CommentCount=ds.Tables[1].Rows[0].Ccount;
                       for(var i=0; i<ds.Tables[0].Rows.length; i++)
　　　　               {
//　　　　                    var img="vide0_manye.gif";
//　　　　                    if (ds.Tables[0].Rows[i].remark_name!="游客")
//　　　　                    {
　　　　                        img="vide0_man.gif";
//　　　　                    }　　　　                    
　　　　               
　　　　                    divContent +="<table width='100%' border='0' cellspacing='0' cellpadding='0' style='margin:10px auto'><tr><td height='1' colspan='2' background='../Images/Video/video_line.gif'></td></tr>"
　　　　                                  +"<tr><td colspan='2' style='padding:10px;color:#000000; line-height:130%'>"+ds.Tables[0].Rows[i].content+"</td></tr>"
　　　　                                  +"<tr><td width='5%'align='center'><img src='../Images/Video/"+img+"' width='16' height='16'></td>"
　　　　                                  +"<td width='95%' ><span class='date12'>"+ds.Tables[0].Rows[i].name+"</span>&nbsp; <span class='word_12'>"+getFormatDate(ds.Tables[0].Rows[i].publish_time,'yyyy-mm-dd hh:ii:ss')+"</span> </td></tr></table>";　　　　                                 
　　　　                                 
　　　　                    
　　　　               }
                       document.getElementById("div_comment").innerHTML=divContent;                       
                       document.getElementById("content").value="";
                       document.getElementById("Uid").value="";
                       
            
                    }
                    else
                    {
                        document.getElementById("div_comment").innerHTML="暂无评论";
                    }  
                    
                          
                
            }


 