
	//-------------------------------网站根路径-------------------------
	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;
			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;
			}

		if(document.getElementById('niming').clicked)//是否匿名:（0：否  1：是）
		{
			frames["ifr_pl"].document.getElementById('ifAnony').value=0;
		}
		else
		{
			frames["ifr_pl"].document.getElementById('ifAnony').value=1;
		}
		
		var today = new Date();		
		var tempPingLun= '<div class="list"><h3>'+ufrom+"网友:"+uname+' 发表于'+today.getYear()+"-"+(today.getMonth()+1)+"-"+today.getDate()+'</h3><h4>'+changeIMG(cont)+'</h4><div class="clear"></div></div>'+document.getElementById('divComment').innerHTML;
		document.getElementById('divComment').innerHTML=tempPingLun;		
		
		alert("回复成功!!");
		frames["ifr_pl"].document.getElementById('userName').value=ufrom+"网友:"+uname;		//网友名称(来自的地方也加里边)
		frames["ifr_pl"].document.getElementById('docId').value=ph.VideoInfo.videoID; //文章ID（必填项）
		frames["ifr_pl"].document.getElementById('docName').value=encodeURIComponent(ph.VideoInfo.title);//文章标题（必填项，需要进行encode）
		frames["ifr_pl"].document.getElementById('docUrl').value=encodeURIComponent(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 DBClient(id,url,timeout){
        this.id=id;
        this.url=url;
        this.timeout=(timeout==null?5000:timeout);
        this.node=document.createElement('script');
        this.isStop=false;
        this.onComplete=null;
        this.onError=null;
        this.onStop=null;
    }

    DBClient.prototype={
        open:function(){
            this.node['type']='text/javascript';
            this.node['src']=this.url;
            document.body.insertBefore(this.node,null);
            this.isStop=false;
            this.getData();
        },
        getData:function(){
            var t=0;
            var timeout=this.timeout;
            var id=this.id;
            var _=this;
            var eh=setInterval(function(){
                if(t>timeout){
                    clearInterval(eh);
                    if(_.onError!=null){
                        _.onError(_,1);
                }
            }
            if(_.isStop){
                clearInterval(eh);
                if(_.onStop!=null){
                _.onStop(_,2);
                }
            }
            t+=10;
            if(DBClient.pool.contain(id)){
                clearInterval(eh);
                if(_.onComplete!=null){
                    _.onComplete(_,DBClient.pool.get(id));
                }
            }
            },10);
        },
        stop:function(){
            this.isStop=true;
        },
        close:function(){
            try{
                document.body.removeChild(this.node);
                DBClient.pool.remove(this.id)
            }catch(e){}
        }
    }


	DBClient.pool=new Dictionary();
	DBClient.add=function(key,value)
	{
			 DBClient.pool.add(key,value);
	}


	function LoadMsg(vid,ptitle,url,categoryid)
	{
		 if(navigator.userAgent.indexOf("MSIE")<=0)//非IE浏览器直接执行
		 {
    		LoadMsg_fun(vid,ptitle,url,categoryid);
		 } 
		 else
		 {
			//IE下,防止浏览器提示“internet explore 无法打开internet站点 已终止操作”
			if (document.readyState=="complete")
			{
			  LoadMsg_fun(vid,ptitle,url,categoryid);
			} 
			else 
			{
			  document.onreadystatechange=function()
			  {
				if(document.readyState=="complete") LoadMsg_fun(vid,ptitle,url,categoryid);
			  }
			}
		 }
	}
	
	var urlflag=false;
	function LoadMsg_fun(vid,ptitle,url,categoryid)
	{				
			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://wwww.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://wwww.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;			
			
			//复制html地址
			var ssflashpath='http://v.ifeng.com/include/exterior.swf?guid='+vid;
			document.getElementById("flashpath").value=ssflashpath;

			ph.VideoInfo = new ph.videoInfo(vid,ptitle,url,categoryid);		
			 document.getElementById("divComment").innerHTML = "<span  style='color:#BFC1C0;'>评论加载中,请稍后......</span>";	
			var varIViewUrl='http://cmt.ifeng.com/iviewcmts.do?chId=-9999&docId='+ph.VideoInfo.videoID+'&docName='+encodeURIComponent(ph.VideoInfo.title)+'&docUrl='+encodeURIComponent(url);
			var varViewUrl='http://cmt.ifeng.com/viewcmts.do?chId=-9999&docId='+ph.VideoInfo.videoID+'&docName='+encodeURIComponent(ph.VideoInfo.title)+'&docUrl='+encodeURIComponent(url);
			var varKey=url;		
			
			var db=new DBClient(varKey,varIViewUrl,10000);
			db.onComplete=function(o,d)
			{
					var value = "";
					document.getElementById("PingLunCount").innerHTML="<h2>网友评论（"+d.count+"）</h2>";
					    
					for (var i=0; i < d.records ; i++)
					{
						value += '<div class="list"><h3>'+d.cmts[i].name+' 发表于'+d.cmts[i].createTime+'</h3><h4>'+d.cmts[i].content+'</h4><div class="clear"></div></div>';
					}
					//显示评论数据
					 document.getElementById("divComment").innerHTML = value;					
					//更多链接				
					var moreCmts='<a href="'+varViewUrl+'" target="_blank" style="color:#BFC1C0;">->查看更多</a></div>';
					document.getElementById("bottomMore").innerHTML=moreCmts;      
					document.getElementById("topMore").innerHTML=moreCmts;
			}
			db.onError=function(o)
			{
				//alert("服务器忙(CMTs),请稍后重试！");
				return;
			}
			db.open();
			//更改标题
			document.title=ptitle+"--视频--凤凰宽频--凤凰网 ";
	}

  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("复制成功！") ;   
      }
	
	//--------------------------------------
