	//-------------------------------网站根路径-------------------------
	var varSite='http://v.ifeng.com';

	//-------------------------定义评论对象---------------------------
	var ph = new Object();
	ph.videoInfo = function(vid,ptitle,url,categoryid)
	{
		this.videoID =vid ;
		this.title = ptitle;
		this.url=url;
		this.chid="-8994";//默认全部频道
		switch(categoryid)
		{
			case "0019-0050": //-3600		大中华0019-0050
				this.chid="-3600";
							break;
			case "0019-0051"://	-3601		环球0019-0051
					this.chid="-3601";
							break;
			case "0019-0052"://	-3602		军事0019-0052
				this.chid="-3602";
							break;
			case  "0019-0053"://-3603		历史文化0019-0053
				this.chid="-3603";
							break;
			case   "0019-0054"://-3604		社会0019-0054
				this.chid="-3604";
							break;
			case   "0019-0055"://-3605		娱乐0019-0055
				this.chid="-3605";
							break;
			case   "0019-0056"://-3606		体育0019-0056
				this.chid="-3606";
							break;
			case   "0019-0057"://-3607		财经0019-0057
				this.chid="-3607";
							break;
			case   "0019-0051-0000"://-3608		评论大陆
			this.chid="-3608";
							break;
			case   "0019-0051-0002"://-3609		评论国际	
				this.chid="-3609";
							break;
			case   "0019-0051-0001"://-3610		评论台港澳					       
				this.chid="-3610";
							break;
			case   "0019-0050-0000"://-3611		资讯大陆
				this.chid="-3611";
							break;
			case   "0019-0050-0002"://-3612		资讯国际
				this.chid="-3612";
							break;
			case   "0019-0050-0001"://-3613		资讯台港澳
				this.chid="-3613";
							break;
			case   "0019-0057"://-3614		佛教
				this.chid="-3614";
							break;
			case   "0019-0057"://-3615		探索
				this.chid="-3615";
							break;
			default:
				this.chid="-8994";
				break;		
		}
	}

//-------------------------------通用判断-------------------------------


function niMingSelect(item)
{
	if(item.checked)
	{
		document.getElementById("name").value="凤凰网友";
	}
	else
	{
		document.getElementById("name").value="";
	}
}
function getLen(str) {
  var  len  =  0;  
  for(i=0;i<str.length;i++)  
  { 
          if(str.charCodeAt(i)>128)
          { len += 2;  }
          else { len++; } 
  } return len;
}
    //-------------------------发布评论-------------------------

	function ifrcheck()
	{
		var uname = document.getElementById('name').value;
		var ufrom = document.getElementById('userFrom').value;
		var cont = document.getElementById('content').value;

		if(uname == "")
			{
				alert("昵称不能为空!");
				document.getElementById('name').focus();
				return false;
			}
		
			if(ufrom == "")
			{			
				if(!document.getElementById('niming').checked)
				{
					alert("来自何方不能为空!");
					document.getElementById('userFrom').focus();
					return false;
				}
			}
			if (cont == "")
			{
				alert('请输入评论内容！');
				document.getElementById('content').focus();
				return false;
			}
			if (getLen(cont) > 1000)//
			{
				alert("评论内容请控制在500个中文字符以内！");
				document.getElementById('content').focus();
				return false;
			}

		var today = new Date();		
		var tempPingLun= '';
		tempPingLun += '<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">';
		tempPingLun += '<tr>';
		tempPingLun += ' <td height=\"22\" bgcolor=\"#ececec\" class=\"name\">'+ufrom+"网友:"+uname+' 发表于'+today.getYear()+"-"+(today.getMonth()+1)+"-"+today.getDate()+'</td>';
		tempPingLun += '</tr>';
		tempPingLun += '<tr>';
		tempPingLun += ' <td class="text">'+changeIMG(cont)+'</td>';
		tempPingLun += '</tr>';
		tempPingLun += '</table>'+document.getElementById('divComment').innerHTML;
		document.getElementById('divComment').innerHTML=tempPingLun;		
		
		alert("回复成功!!");
		frames["ifr_pl"].document.getElementById('userName').value=ufrom+"网友:"+uname;		//网友名称(来自的地方也加里边)
		frames["ifr_pl"].document.getElementById('docName').value=ph.VideoInfo.title;//文章标题（必填项，需要进行encode）
		frames["ifr_pl"].document.getElementById('docUrl').value=ph.VideoInfo.url;//文章URL（必填项，需要进行encode）
		frames["ifr_pl"].document.getElementById('content').value=cont;
		frames["ifr_pl"].document.getElementById('chid').value=ph.VideoInfo.chid;		
		frames["ifr_pl"].document.getElementById('form1').submit();
		
		document.getElementById('content').value="";
		document.getElementById("ifr_pl").src="/include/ifr_pinglun.html";

	}

	function changeIMG(str){
	for(var i = 0 ; i < imgToken.length ; i++){
		if(str.indexOf("["+imgToken[i]+"]")>=0){
			raRegExp = new RegExp("\\["+imgToken[i]+"\\]","g");
			str = str.replace(raRegExp,img_s+imgpath+imgHTML[i]);
		}
	}
	return str;
}

var img_s = "<img src=\"";
var imgpath = "http://img.ifeng.com/tres/appres/images/motion/";
var imgHTML = ["0.gif" + "\" alt=\"惊讶\"/>","1.gif" + "\" alt=\"撇嘴\"/>",
"2.gif" + "\" alt=\"色\"/>","3.gif" + "\" alt=\"发呆\"/>",
"4.gif" + "\" alt=\"得意\"/>","5.gif" + "\" alt=\"流泪\"/>",
"6.gif" + "\" alt=\"害羞\"/>","7.gif" + "\" alt=\"闭嘴\"/>",
"8.gif" + "\" alt=\"睡\"/>","9.gif" + "\" alt=\"大哭\"/>",
"10.gif" + "\" alt=\"尴尬\"/>","11.gif" + "\" alt=\"发怒\"/>",
"12.gif" + "\" alt=\"调皮\"/>","13.gif" + "\" alt=\"呲牙\"/>",
"14.gif" + "\" alt=\"微笑\"/>","15.gif" + "\" alt=\"难过\"/>",
"16.gif" + "\" alt=\"酷\"/>","17.gif" + "\" alt=\"非典\"/>",
"18.gif" + "\" alt=\"抓狂\"/>","19.gif" + "\" alt=\"吐\"/>",
"20.gif" + "\" alt=\"偷笑\"/>"];
var imgToken = ["ex0","ex1","ex2","ex3","ex4","ex5","ex6",
				"ex7","ex8","ex9","ex10","ex11","ex12","ex13",
				"ex14","ex15","ex16","ex17","ex18","ex19","ex20"]


//-----------------评论------------------------------------

    function selectMood(_mood) {
        var _con = document.getElementById("content");
        _con.focus();
        _con.value = _con.value + "[" + _mood + "]";
        _con.focus();
    }

	function LoadMsg(vid,ptitle,url,categoryid,progname,progurl)
	{
		
		//----------------end------------------------

		 if(navigator.userAgent.indexOf("MSIE")<=0)//非IE浏览器直接执行
		 {
    		LoadMsg_fun(vid,ptitle,url,categoryid,progname,progurl);
		 } 
		 else
		 {
			//IE下,防止浏览器提示“internet explore 无法打开internet站点 已终止操作”
			if (document.readyState=="complete")
			{
				LoadMsg_fun(vid,ptitle,url,categoryid,progname,progurl);
			} 
			else 
			{
			  document.onreadystatechange=function()
			  {
				if(document.readyState=="complete") LoadMsg_fun(vid,ptitle,url,categoryid,progname,progurl);
			  }
			}
		 }
	}
	
	var urlflag=false;
	function LoadMsg_fun(vid,ptitle,url,categoryid,progname,progurl)
	{	

			if(urlflag==true)
			{			
				var reurl=location.href;
				var rindex=reurl.indexOf("#");		
				if(rindex!=-1)
				{
					reurl=reurl.substring(0, rindex);					
				}
				location.href=reurl+"#"+vid;
			}

			urlflag=true;	

				
			//复制flash地址
				var sflashpath="";
			sflashpath+='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="400" height="325">'
			sflashpath+='<param name="movie" value="http://v.ifeng.com/include/exterior.swf?guid='+vid+'&pageurl=http://www.ifeng.com&fromweb=other" />';
			sflashpath+='<param name="quality" value="high" />';
			sflashpath+='<param name="AutoPlay" value="false" />';
			sflashpath+='<embed src="http://v.ifeng.com/include/exterior.swf?guid='+vid+'&pageurl=http://www.ifeng.com&fromweb=other"  AutoPlay="false" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="400" height="325"></embed>';
			sflashpath+='</object>';
			document.getElementById("htmPath").value=sflashpath;		
			document.getElementById("pagepath").value=url;
			
			//复制html地址
			var ssflashpath='http://v.ifeng.com/include/exterior.swf?guid='+vid;
			document.getElementById("flashpath").value=ssflashpath;
	
                        //---同一节目评论处理
		if(ph.VideoInfo!=null)
		{			
			if(ph.VideoInfo.title==progname)
			{	
				return;//同一节目评论不变
			}
		}

			if(progname!=null && progurl!=null)
			{			
				ph.VideoInfo = new ph.videoInfo("",progname,progurl,categoryid);	
			}
			else
			{						
				ph.VideoInfo = new ph.videoInfo(vid,ptitle,url,categoryid);	
			}
			paging(1);
			//更改标题
			document.title=ph.VideoInfo.title+"--视频--凤凰宽频--凤凰网 ";
	}
	//---------------------js paging-----------------
	JQ(document).ready(function(){});
	function paging(num)
	{
			var p=new  OpinionPaging();
			p.Goto(num);
	}
	function OpinionPaging()
	{
		this.PageCount=1;//总页数
		this.CurrectPageIndex=1;//当前页数
		this.RecordCount=0;//总记录数
		this.PageSize=30;//每页记录数(现有评论系统只支持30条)
		this.PageNum=9;//显示9个页码(奇数最好)
	}

	//跳到第几页
	var currectpage=0;//记录当前页数(异步传输公共变量)
	OpinionPaging.prototype.Goto=function(num)
	{
		this.CurrectPageIndex=num;
		currectpage=this.CurrectPageIndex;
		this.ShowData();		

	}

		//显示页码
	OpinionPaging.prototype.ShowNum = function()
	{
		var strpag="";
		var index=this.CurrectPageIndex;
		var ptot=this.PageCount;
	
		if(index>=1 && index<=ptot)
		{
			strpagfir='<a href="javascript:paging(1)">首页</a>&nbsp;<a href="javascript:paging('+(this.CurrectPageIndex-1)+')">上页</a>';			
			if(index==1)
			{
					strpagfir='首页&nbsp;上页';
			}
			strpagend='&nbsp;<a href="javascript:paging('+(this.CurrectPageIndex+1)+')">下页</a>&nbsp;<a href="javascript:paging('+ptot+')">末页</a>';
			if(index==ptot)
			{
					strpagend='&nbsp;下页&nbsp;末页';
			}

			if(index<(this.PageNum/2+1) || ptot<this.PageNum)//前3条
			{		
				var pc=this.PageCount;
				if(pc>this.PageNum)
				{
					pc=this.PageNum;
				}
				for(i=1;i<pc+1;i++)
				{					
					if(i==index)
					{
						strpag+='&nbsp;<font color="red">'+i+'</font>';						
					}
					else
					{
						strpag+='&nbsp;<a href="javascript:paging('+i+')">'+i+'</a>';
					}					
				}				
			}
			else if(index>parseInt(ptot-(this.PageNum/2)))
			{
				//当前页=尾页	alert(index);
				for(i=0;i<this.PageNum;i++)
				{
					if((ptot-i)==index)
					{
						strpag='&nbsp;<font color="red">'+(ptot-i)+'</font>'+strpag;			
					}
					else
					{
						strpag='&nbsp;<a href="javascript:paging('+(ptot-i)+')">'+(ptot-i)+'</a>'+strpag;
					}					
				}
			}
			else
			{
				for(i=index-parseInt(this.PageNum/2);i<index+parseInt(this.PageNum/2+1);i++)
				{
					if(i==index)
					{
						strpag+='&nbsp;<font color="red">'+i+'</font>';						
					}
					else
					{
						strpag+='&nbsp;<a href="javascript:paging('+i+')">'+i+'</a>';
					}					
				}
			}
			document.getElementById("spPingLunPaging2").innerHTML=document.getElementById("spPingLunPaging1").innerHTML=strpagfir+strpag+strpagend;		
		}
	}
	//获取数据
	
	OpinionPaging.prototype.ShowData = function()
	{		
	  JQ.getScript('http://comment.ifeng.com/viewcmtsjson.php?dcount='+this.PageSize+'&docUrl='+encodeURIComponent(ph.VideoInfo.url)+'&pagenumber='+this.CurrectPageIndex);	
	  	//更多链接
		var 	MoreUrl='http://comment.ifeng.com/view.php?docName='+encodeURIComponent(ph.VideoInfo.title)+'&docUrl='+encodeURIComponent(ph.VideoInfo.url);		
		document.getElementById("url_more").innerHTML='<a href="'+MoreUrl+'" target="_blank"><img src="http://vimg.ifeng.com/v/images200808/icon_42.gif" width="75" height="30" border="0" /></a>';
	}
	function templateData(obj,a,c)
	{		
		var list=obj.commentList;
		
		if(typeof(list)=="undefined")
		{
			document.getElementById("divComment").innerHTML ="";		
			document.getElementById("PingLunCount").innerHTML='共1页&nbsp;0条';
			return ;	
		}
			
	
		var p=new  OpinionPaging();
		p.RecordCount=obj.normal_count;//总记录数
		p.CurrectPageIndex=currectpage;
		//总页数
		var pagecount=parseInt(p.RecordCount/p.PageSize);
		if(pagecount<p.RecordCount/p.PageSize)
		{
			p.PageCount=pagecount+1;
		}
		else
		{			
			p.PageCount=pagecount;
		}

		var value = "";		
		var len=list.length;

		for(i=0;i<len;i++)
		{
			 value += '<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style="table-layout:fixed;">';
			  value += '<tr>';
			   value += ' <td height=\"22\" bgcolor=\"#ececec\" class=\"name\">'+list[i].COMNAME+'&nbsp; 发表于'+list[i].COMDATE+'</td>';
			  value += '</tr>';
			  value += '<tr>';
			   value += ' <td class="text" style="word-wrap:break-word;">'+list[i].COMDETAIL+'</td>';
			  value += '</tr>';
			value += '</table>';
		
		}
		document.getElementById("divComment").innerHTML =value;		
		document.getElementById("PingLunCount").innerHTML='共'+p.PageCount+'页&nbsp;'+p.RecordCount+'条';

		p.ShowNum();//显示页码
	}


//copy地址
  function copyAddress(obj)
      {
     // var elm = document.getElementById(obj).value;
      //window.clipboardData.setData("Text",elm);
      //alert("已复制页面地址到剪贴板。");
      //return;
	  var txt=document.getElementById(obj).value;
	  if(window.clipboardData) {    
             window.clipboardData.clearData();    
             window.clipboardData.setData("Text", txt);    
     } else if(navigator.userAgent.indexOf("Opera") != -1) {    
          window.location = txt;    
     } else if (window.netscape) {    
          try {    
               netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");    
          } catch (e) {    
               alert("您的firefox安全限制 限制您进行剪贴板操作！\n请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true'");    
          }    
          var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);    
          if (!clip)    
               return;    
          var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);    
          if (!trans)    
               return;    
          trans.addDataFlavor('text/unicode');    
          var str = new Object();    
          var len = new Object();    
          var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);    
          var copytext = txt;    
          str.data = copytext;    
          trans.setTransferData("text/unicode",str,copytext.length*2);    
          var clipid = Components.interfaces.nsIClipboard;    
          if (!clip)    
               return false;    
          clip.setData(trans,null,clipid.kGlobalClipboard);    
         
     }    
 alert("复制成功！") ;   
      }