﻿
function checkDy(strUrl,mid,lid,flid,filename,isfree) 
{
  checkClient(strUrl,mid,lid,flid,filename);
  if(typeof(listpagetracker)!='undefined'&& typeof listpagetracker == 'function'){
  	listpagetracker(mid);
  }
  recordClick(mid);
}
function recordClick(movid){
	var page=document.getElementById('pageproxy');
	if(page==null||page.contentWindow==null)	return;
	var proxy = page.contentWindow; 
	proxy.movieOnDemand(movid);
}

function checkClient(strUrl,mid,lid,flid,filename) {

 var sUrl = strUrl;
 var issetup = ShowCookie("ppfilmsetup");
 //setcookie("url_ppfilm",sUrl,1000*60*20);
 //SetCookie("url_ppfilm",sUrl,1000*60*10,"/","pipi.cn"); 
 var _loc=jse.playTips.getReffer(mid);
 sUrl = strUrl;
 var _temp=sUrl.split('|');
 var _t=[];
 _t.push(_temp[0]);
 _t.push("wnd=1");
 _t.push("for/chromebug");
 if(_loc.indexOf('http://pp/')==-1) _t.push("surl="+_loc);
 _t.push(_temp[1]);
 sUrl=_t.join('|');
 //alert(sUrl);

   if ( issetup != "")
     {
	   //alert("有cookie");
	   SetCookie("ppfilmsetup","1",60*60*24*365,"/",""+document.domain);
	   //jse.playTips.showInfo(_loc);
       document.location=sUrl;
     } 
   else
	 {
		if (!flag) 
		  {
          if (confirm("为了更流畅地观看高清电影，推荐您下载安装皮皮播放器。"))
			  //尊敬的用户，您需要安装皮皮播放器后才能正常的观看本网站的电影、电视剧，您是否确定下载并安装皮皮播放器？
             {
             SetCookie("url_ppfilm",sUrl,60*20,"/","pipi.cn");
             document.location="http://dl.pipi.cn/pipi.exe";
             } 
		  else 
			 {
			  if (!confirm('对不起，假如您没有安装皮皮播放器，就无法观看本网站提供的影片。\n\n如果您确认已经安装了皮皮播放器，请点击“取消”按钮。')) {
			      if (confirm("你确定本机已经安装了皮皮播放器了吗？点击“确认”将不再提示安装信息。")) {
			      		SetCookie("ppfilmsetup","1",60*60*24*365,"/",""+document.domain);
			  	        document.location=sUrl;
			      }
			  }              
             }
          }
		 else
		  {
			//alert("flag=true;没有cookie");
			//jse.playTips.showInfo(_loc);
		    document.location=sUrl;
		  }
       }
}

if (!pipiUtil) var pipiUtil={};

/*****************************************
广告对象格式
{
	res:"XXXXXXXXXXXXXXX",
	url:"XXXXXXXXXXXXXXX",
	showDiv:true //不要层就用false
}
*****************************************/
pipiUtil.randomShow=function(_targetDivId,_width,_height){	
	this.ads=[];	
	var _point=this;
	this._currentIndex=-1;
	this._lastIndex=-1;
	this.interval=null;
	this.time=10000;
	this._getHtmlForSwf=function(_index) {
		var _html='<div style="position:relative;width:'+_width+'px;height:'+_height+'px;display:none" id='+_targetDivId+'_randomDiv_'+_index+'>';
		_html+='<OBJECT codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0 width='+_width+' height='+_height+'  classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000>';
		_html+='<PARAM NAME="Movie" VALUE="'+this.ads[_index].res+'">';
		_html+='<PARAM NAME="SAlign" VALUE="TL">';
		_html+='<PARAM NAME="WMode" VALUE="Opaque">';
		_html+='<PARAM NAME="Quality" VALUE="High">';
		_html+='<embed src="'+this.ads[_index].res+'" quality="high" allowscriptaccess="always" wmode="Opaque" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" height="'+_height+'" width="'+_width+'">';
		_html+='</OBJECT>';
		if (this.ads[_index].showDiv)
			_html+='<a target="_blank" href="'+this.ads[_index].url+'"><img src="http://www.pipi.cn/images/spacer.gif" style="position:absolute;left:0px;top:0px;width:'+_width+'px;height:'+_height+'px;border:none;"/></a>';
		_html+='</div>';
		return _html;
	};
	this._getHtmlForPic=function(_index) {
		var _html='<div style="position:relative;width:'+_width+'px;height:'+_height+'px;display:none" id='+_targetDivId+'_randomDiv_'+_index+'>';
		_html+='<img src="'+this.ads[_index].res+'" border=0 width="'+_width+'" height="'+_height+'"/>';
		_html+='<a target="_blank" href="'+this.ads[_index].url+'"><img src="http://www.pipi.cn/images/spacer.gif" style="display:block; position:absolute; left:0px; top:0px; width:'+_width+'px; height:'+_height+'px; border:none;"/></a>';
		_html+='</div>';
		return _html;
	};
	this._getHtmlForString=function(_index) {
		var _html='<div style="position:relative;width:'+_width+'px;height:'+_height+'px;display:none" id='+_targetDivId+'_randomDiv_'+_index+'>';
		_html+=this.ads[_index].res;
		_html+='</div>';
		return _html;
	};
	this._getinnerHTML=function(){
		var _html="";
		for (var i=0;i<this.ads.length;i++) {
			var _temp="";
			if (this.ads[i].res.indexOf("swf")>=0) {
				_temp=this._getHtmlForSwf(i);
			} else if (this.ads[i].res.indexOf("iframe")>=0) {
				_temp=this._getHtmlForString(i);
			} else {
				_temp=this._getHtmlForPic(i);
			}
			_html+=_temp;
		}
		return _html;
	};	
	this._getRandomIndex=function() {
		return (parseInt(this._currentIndex)+1) % this.ads.length;
		//return Math.floor(Math.random()*this.ads.length);
	};
	this._show=function() {
		if (this.ads.length==1) return; //禁止只有一个广告
		var _index=this._getRandomIndex();
		while (_index==this._currentIndex) {
			_index=this._getRandomIndex();
		}
		this._currentIndex=_index;
		if (this._lastIndex!=-1) document.getElementById(_targetDivId+'_randomDiv_'+this._lastIndex).style.display="none";
		document.getElementById(_targetDivId+'_randomDiv_'+this._currentIndex).style.display="block";
		this._lastIndex=this._currentIndex;
	};	
	this.init=function() {
		var _container=document.getElementById(_targetDivId);
		if (!_container) {
			document.write('<div id="'+_targetDivId+'"></div>');
			_container=document.getElementById(_targetDivId);
		}
		_container.innerHTML=this._getinnerHTML();
		this._show();
		this.interval=window.setInterval(function(){_point._show()},this.time);
	};
}
