var adsPage="/templets/js/player/loading.html";//视频播放前广告页路径
var adsTime=10;//视频播放前广告时间，单位秒
var w='660';//播放器宽度
var h='480';//播放器高度
var NextWebPage="";//百度影音专用下集WEB
var NextCacheUrl="";//百度影音专用下集播放地址
function getHtmlParas(suffix){
	var WebUrl=window.location.href;
	var urlsea=window.location.search;
	var urls;
	if (WebUrl.indexOf("?")>0){
		urls=urlsea.substring(1,urlsea.length).split('-');
	}else{
		urls=WebUrl.substring(WebUrl.lastIndexOf("/")+1,WebUrl.indexOf(".html")).split('-');	
	}
	return urls;
}
function getPlayerId()
{
	return getHtmlParas(".html")[1];
}
function stringReplaceAll(str,findstr,replacestr){var raRegExp = new RegExp(findstr,"g");return str.replace(raRegExp,replacestr);}

function handleParas(para1,para2){
	var i,fromArray,len1,len2,urlArray,j,dataStr,dataArray
	if (isNaN(para1) || isNaN(para2)){return false;}
	fromArray=VideoInfoList.split('::::::');
	len1=fromArray.length;
	if(para2>len1-1){
		para2=len1-1;
		}
	for (i=0;i<len1;i++)
	{
		if (para2==i){
		urlArray=fromArray[i].split('|||')[1].split('#');
		len2=urlArray.length;
			if(para1>len2-1){para1=len2-1};
			for (j=0;j<len2;j++)
			{
				if (para1==j)
				{
				dataStr=urlArray[j];
				dataArray=dataStr.split('$');
				dataArray[2]=fromArray[i].split('|||')[0];
				//alert(dataArray);
				return dataArray;
				}
			}
		}
	}
}
function viewplay(para1,para2){
	var urlAndFrom,url,wd
	urlAndFrom=handleParas(para1,para2)
	url=urlAndFrom[1];
	wd=urlAndFrom[2];
	wdpm=urlAndFrom[0];
	document.writeln("<div id=\"loadimg\"><iframe src=\""+adsPage+"\" frameborder=\"0\" scrolling=\"no\"  width=\""+w+"\" height=\""+h+"\"><\/iframe><\/div>");
	document.writeln("<div id=\"OpenPlay\" style=\"display: none;\"><iframe marginWidth=\"0\" marginHeight=\"0\" src=\"/templets/js/player/PlayerTips.html\" frameBorder=\"0\" width=\""+w+"\" scrolling=\"no\" height=\""+h+"\"></iframe><\/div>");
	var PlayerName=wd.replace("hd_","").replace("baidu","bdhd").replace("hd_tudou","tudou").replace("hd_56","56").replace("baibu","bdhd").replace("baiduhd","bdhd");
	var ToUrl="/templets/js/player/" + PlayerName + ".html?p=p&a=" + escape(url) + "&w="+w+"&h="+h+"";
	if(PlayerName!='flash'){
	setTimeout(function(){$("#loadimg").hide();$("#OpenPlay").show();$("#OpenPlay iframe").attr("src",ToUrl);}, adsTime*1000);
	}
	else{
	setTimeout(function(){$("#loadimg").hide();$("#OpenPlay").show();  
			$("#loadimg").html('');
			;$("#OpenPlay").html('<embed name="Player" id="Player" src="http://yiyi.92game.net/templets/js/player/ckplayer.swf" flashvars="a='+encodeURIComponent(url)+'&my_url='+encodeURIComponent(window.location.href)+'&e=1&c=1" quality="high" width="660" height="480" align="middle" allowScriptAccess="always" allowFullscreen="true" type="application/x-shockwave-flash"></embed>');													   
																   
																   
																   
																   
																   }, adsTime*1000);
	
	
	}
	if(PlayerName=="bdhd")//baidu
	{
		if(wdjs(wd_i,wd_zu)>1){
			NextWebPage=daoxuxia2();
			NextCacheUrl=handleParas(para1,para2+1)[1];
		}
	}
}

var player = player || {};
player.lighter = {
    closed: false,
    speed: 200,
    opacity: "0.95",
    height: 0,
    timer: null,
    show: true,
    Close: function() {
        if (this.height === 0) {
            this.heigth = 1;
            $("#light").height($(document).height())
        }
        var a = this;
        $("#lighter").addClass("close").text("开灯");
        $("#light").fadeTo(this.speed, a.opacity,
        function(b) {
            a.closed = true;
            $(document).bind("keydown", "esc",
            function() {
                a.Open()
            });
            $(this).dblclick(function() {
                a.Open()
            });
            $(this).mousemove(function() {
                if (a.show === false) {
                    $("#lighter").show();
                    a.show = true
                }
                a.timer && clearTimeout(a.timer);
                a.timer = setTimeout(function() {
                    $("#lighter").hide();
                    a.show = false
                },
                3000)
            })
        })
    },
    Open: function() {
        var a = this;
        $("#light").fadeOut(this.speed,
        function() {
            a.timer && clearTimeout(a.timer);
            a.closed = false;
            $(this).unbind("dblclick mousemove");
            $("#lighter").removeClass("close").text("关灯").show();
        })
    },
    bind: function() {
        var a = this;
        $("#lighter").bind("click",
        function() {
            a.closed == false ? a.Close() : a.Open()
        })
    }
};

function wdjs(para1,para2){
	var wdi,wdfromArray,wdlen1,wdlen2,wdurlArray,wdj,wddataStr,wddataArray
	wdfromArray=VideoInfoList.split('::::::')
	wdlen1=wdfromArray.length;if(para2>wdlen1-1){para2=wdlen1-1}
	for (wdi=0;wdi<wdlen1;wdi++){if (para2==wdi){wdurlArray=wdfromArray[wdi].split('|||')[1].split('#');wdlen2=wdurlArray.length;if(wdfromArray[wdi].split('|||')[1].substring(wdfromArray[wdi].split('|||')[1].length-1)=='#'){wdlen2=wdlen2-1};return wdlen2;}}}
function dyj(para1,para2){
	var wdi,wdfromArray,wdlen1,wdlen2,wdurlArray,wdj,wddataStr,wddataArray
	wdfromArray=VideoInfoList.split('::::::')
	wdlen1=wdfromArray.length;if(para2>wdlen1-1){para2=wdlen1-1}
	for (wdi=0;wdi<wdlen1;wdi++){if (para2==wdi){wdurlArray=wdfromArray[wdi].split('|||')[1].split('#');return wdurlArray[0].split('$')[0];}}}

function dej(para1,para2){
	var wdi,wdfromArray,wdlen1,wdlen2,wdurlArray,wdj,wddataStr,wddataArray
	wdfromArray=VideoInfoList.split('::::::')
	wdlen1=wdfromArray.length;if(para2>wdlen1-1){para2=wdlen1-1}
	for (wdi=0;wdi<wdlen1;wdi++){if (para2==wdi){wdurlArray=wdfromArray[wdi].split('|||')[1].split('#');return wdurlArray[1].split('$')[0];}}}

function shang()
{
if(wdjs(wd_i,wd_zu)>1){
if(dyj(wd_i,wd_zu).match(/\d+/ig)>dej(wd_i,wd_zu).match(/\d+/ig))
{
daoxuxia("没有上一集了");
}
else
{ 
daoxushang("没有上一集了");
}
}
else
{ 
daoxushang("没有上一集了");
}
}

function xia()
{
if(wdjs(wd_i,wd_zu)>1){
	if(dyj(wd_i,wd_zu).match(/\d+/ig)>dej(wd_i,wd_zu).match(/\d+/ig))
	{
	daoxushang("目前没有下一集了");
	}
	else
	{ 
	daoxuxia("目前没有下一集了");
	}
}
else
{ 
daoxuxia("目前没有下一集了");
}
}

function daoxushang(wdts)
{
	var d = wd_id;
	var z = parseInt(wd_zu)+1;
	var n = parseInt(wd_i)+1;

    if(n==1){
	alert(wdts);
	}
	else
	{ 
	var n=n-1
	 window.location.href=""+d+"-"+z+"-"+n+".html";
	}
}


function daoxuxia2(wdts)
{
	var WebUrl=window.location.href;
	var urls=WebUrl.substring(0,WebUrl.lastIndexOf("/"));	

	var d = wd_id;
	var z = parseInt(wd_zu)+1;
	var n = parseInt(wd_i)+1;
	var m = wdjs(wd_i,wd_zu);
	if(n!=m){
		n=parseInt(n)+1;
	 return urls+"/"+d+"-"+z+"-"+n+".html";
	}
}

function daoxuxia(wdts)
{
	var d = wd_id;
	var z = parseInt(wd_zu)+1;
	var n = parseInt(wd_i)+1;
var m = wdjs(wd_i,wd_zu);
	if(n==m){alert(wdts);
	}
	else
	{
n=parseInt(n)+1;
	 window.location.href=""+d+"-"+z+"-"+n+".html";
		}
		}
function reportErr(id){
	window.open ('/plus/error.php?id='+id+'','newwindow','height=220,width=400,top=350,left=250,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no');
}