//joybase.js
var JoySpaceUrl = "http://www.joy.cn/space/";
function killErrors() {
    return true;
}
window.onerror = killErrors;

jQuery.fn.extend({
    Opacity : function(value){
        return this.each(function(){
            if(value!=null)
            {
                if ( $.browser.msie ){
                    this.style.filter = "alpha(opacity = "+value+")";
                }
                else{
                    this.style.MozOpacity = parseInt(value)/100;
                }
            }
        })
    }
})

jQuery.fn.offset = function() {
    var ua = navigator.userAgent.toLowerCase();
    var isOpera = (ua.indexOf('opera') != -1);
    var isIE = (ua.indexOf('msie') != -1 && !isOpera); // not opera spoof
    var el = this[0];
    if(el.parentNode === null || el.style.display == 'none')
    {
        return false;
    }
    var parent = null;
    var pos = [];
    var box;
    
    if(el.getBoundingClientRect) //IE
    {
        box = el.getBoundingClientRect();
        var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);
        var scrollLeft = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft);
        return {left:box.left + scrollLeft, top:box.top + scrollTop};
    }
    else if(document.getBoxObjectFor) // gecko
    {
        box = document.getBoxObjectFor(el);
        var borderLeft = (el.style.borderLeftWidth)?parseInt(el.style.borderLeftWidth):0;
        var borderTop = (el.style.borderTopWidth)?parseInt(el.style.borderTopWidth):0;
        pos = [box.x - borderLeft, box.y - borderTop];
    }
    else // safari & opera
    {
        pos = [el.offsetLeft, el.offsetTop];
        parent = el.offsetParent;
        if (parent != el)
        {
            while (parent) {
                pos[0] += parent.offsetLeft;
                pos[1] += parent.offsetTop;
                parent = parent.offsetParent;
            }
        
        }
        if (ua.indexOf('opera') != -1
        || ( ua.indexOf('safari') != -1 && el.style.position == 'absolute' ))
        {
            pos[0] -= document.body.offsetLeft;
            pos[1] -= document.body.offsetTop;
        }
    }
    if (el.parentNode) { parent = el.parentNode; }
    else { parent = null; }
    while (parent && parent.tagName != 'BODY' && parent.tagName != 'HTML')
    { // account for any scrolled ancestors
        pos[0] -= parent.scrollLeft;
        pos[1] -= parent.scrollTop;
        if (parent.parentNode) { parent = parent.parentNode; }
        else { parent = null; }
    }
    return {left:pos[0], top:pos[1]}; 
};

jQuery.ByteLen=function(str)
{
    return str.replace(/[^\x00-\xff]/g,"**").length;
};

jQuery.FixTitle=function(str,len)
{
    if($.ByteLen(str)>=(len*2-6))
    {
        if($.ByteLen(str)>str.length)
        {
            return str.substring(0,len);
        }
        return str.substring(0,(len*2-6));
    }
    return str;
};


//playerbag.js
function ShowPlayer(vId,fileName,type)
{
    	if(type=="media")
	    {
	       writeMegadiaPlaer(fileName);
	    }
	    else if(type=="flv")
	    { 
	       writeFLV();
	    }
	    else if(type=="interact")
	    { 
	       interactFLV();
	    }
	    else if(type=="photoplay")
	    {
	        writePhotoPlayer(vId);
	    }
	    else if(type=="real")
	    {
            writeRealPlayer(fileName)
	    }
	    else
	    {
           writeFLV();
	    }
}


function writeRealPlayer(filePath)
{
	var obj = document.getElementById('dplayer');
	if (obj){
		 var htm ='<object classid=clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA height="520" id=RAOCX name=rmplay width="640"> ' 
		    +'<param name="SRC" value="'+filePath+'">' 
		    +'<param name="CONSOLE" value="Clip1">' 
		    +'<param name="CONTROLS" value="imagewindow">' 
		    +'<param name="AUTOSTART" value="true">' 
		    +'<embed src="'+filePath+'" autostart="true" controls="ImageWindow" console="Clip1" pluginspage="http://www.real.com" width="640" height="520"></embed>' 
		 	+'<object classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" height="54" id="video1" width="460">' 
			+'<param name="_ExtentX" value="7276">' 
			+'<param name="_ExtentY" value="1058">' 
			+'<param name="AUTOSTART" value="0">' 
			+'<param name="SHUFFLE" value="0">' 
			+'<param name="PREFETCH" value="0">' 
			+'<param name="NOLABELS" value="0">' 
			+'<param name="CONTROLS" value="ControlPanel,StatusBar">' 
			+'<param name="CONSOLE" value="Clip1">' 
			+'<param name="LOOP" value="0">' 
			+'<param name="NUMLOOP" value="0">' 
			+'<param name="CENTER" value="0">' 
			+'<param name="MAINTAINASPECT" value="0">' 
			+'<param name="BACKGROUNDCOLOR" value="#ffffff">' 
			+'<param name="wmode" value="opaque">' 
			+'<embed type="audio/x-pn-realaudio-plugin" wmode="opaque" console="Clip1" controls="ControlPanel,StatusBar" height="520" width="640" autostart="0" _extentx="7276" _extenty="1058" shuffle="0" prefetch="0" nolabels="0" loop="0" numloop="0" center="0" maintainaspect="0" backgroundcolor="#ffffff"></embed>' 
			+'</object>';
			
		obj.innerHTML = htm;
	}
   
}


function writeMegadiaPlaer(filepath)
{
	var obj = document.getElementById('dplayer');
	if (obj){
		var htm ='<object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" width="640" height="520" id="MediaPlayer1" VIEWASTEXT>'
				+'<param name="AudioStream" value="-1">'
				+'<param name="AutoSize" value="0">'
				+'<param name="AutoStart" value="-1">'
				+'<param name="AnimationAtStart" value="-1">'
				+'<param name="AllowScan" value="-1">'
				+'<param name="AllowChangeDisplaySize" value="-1">'
				+'<param name="AutoRewind" value="0">' 
				+'<param name="Balance" value="0">' 
				+'<param name="BaseURL" value>' 
				+'<param name="BufferingTime" value="15">' 
				+'<param name="CaptioningID" value>' 
				+'<param name="ClickToPlay" value="-1">' 
				+'<param name="CursorType" value="0">' 
				+'<param name="CurrentPosition" value="0">' 
				+'<param name="CurrentMarker" value="0">' 
				+'<param name="DefaultFrame" value>' 
				+'<param name="DisplayBackColor" value="#000000">' 
				+'<param name="DisplayForeColor" value="16777215">' 
				+'<param name="DisplayMode" value="0">' 
				+'<param name="DisplaySize" value="0">' 
				+'<param name="Enabled" value="-1">' 
				+'<param name="EnableContextMenu" value="0">' 
				+'<param name="EnablePositionControls" value="-1">' 
				+'<param name="EnableFullScreenControls" value="-1">' 
				+'<param name="EnableTracker" value="-1">' 
				+'<param name="Filename" value="' + filepath+ '" valuetype="ref">' 
				+'<param name="InvokeURLs" value="-1">' 
				+'<param name="Language" value="-1">' 
				+'<param name="Mute" value="0">' 
				+'<param name="PlayCount" value="1">' 
				+'<param name="PreviewMode" value="-1">' 
				+'<param name="Rate" value="1">' 
				+'<param name="SAMIStyle" value>' 
				+'<param name="SAMILang" value>' 
				+'<param name="SAMIFilename" value>' 
				+'<param name="SelectionStart" value="-1">' 
				+'<param name="SelectionEnd" value="-1">' 
				+'<param name="SendOpenStateChangeEvents" value="-1">' 
				+'<param name="SendWarningEvents" value="-1">' 
				+'<param name="SendErrorEvents" value="-1">' 
				+'<param name="SendKeyboardEvents" value="0">' 
				+'<param name="SendMouseClickEvents" value="0">' 
				+'<param name="SendMouseMoveEvents" value="0">' 
				+'<param name="SendPlayStateChangeEvents" value="-1">' 
				+'<param name="ShowCaptioning" value="0">' 
				+'<param name="ShowControls" value="-1">' 
				+'<param name="ShowAudioControls" value="-1">' 
				+'<param name="ShowDisplay" value="0">' 
				+'<param name="ShowGotoBar" value="0">' 
				+'<param name="ShowPositionControls" value="-1">' 
				+'<param name="ShowStatusBar" value="-1">' 
				+'<param name="ShowTracker" value="-1">' 
				+'<param name="TransparentAtStart" value="-1">' 
				+'<param name="VideoBorderWidth" value="0">' 
				+'<param name="VideoBorderColor" value="0">' 
				+'<param name="VideoBorder3D" value="0">' 
				+'<param name="Volume" value="0">' 
				+'<param name="WindowlessVideo" value="0">' 
				+'<param name="wmode" value="opaque">' 
				+'<embed width="640" height="520" type="application/x-mplayer2" wmode="opaque" src="' + filepath+ '"></embed>'
				+'</object>';
		obj.innerHTML = htm;
	}
	
}

function getKanBaParam()
{
	try
	{
		var url = location.href;
		var m = url.match(/video\/(\d+_[^_]+(?:_\d+)+)\.htm/i);
		if (m != null)
		{
			if (m.length > 1)
			{
				var pm = '';
				var p = m[1].split('_');
				return p;
			}
		}
	}
	catch (e)
	{
	}
	return '[]';
}


/*老播放器
function setVideoIdToPlayer(videoId)
{
    var flvObj = window.document.myplayer;
    if(flvObj.GetVideoIdFromJs)
    {
        flvObj.GetVideoIdFromJs(videoId);
    }
    else
    {
       setTimeout("setVideoIdToPlayer("+videoId+")",100);
    }
}

function writeFLV()
{
	var flash = new SWFObject("http://client.joy.cn/flvplayer/v20081022.swf", "myplayer", _player_obj.width, _player_obj.height, "9", "#00000");
	flash.addParam("allowFullScreen", "true");
	flash.addParam("allowScriptAccess", "always");
	flash.addParam("quality", "high");
	flash.addParam("wmode", "Transparent");
	flash.addVariable("jname", "setPlayerFront");
	//flash.addVariable('strvid', _player_obj.videoId);
	
	flash.addVariable("playermode", _player_obj.playerMode);
	flash.addVariable("listmode", "0");
	var channelId = _player_obj.channelId;
	if (channelId==57||channelId==58||channelId==51){
		if (channelId==58){
			channelId=3;
		}
		flash.addVariable("programid", _player_obj.programId);
		flash.addVariable("type", "vod");
		flash.addVariable("channelid", channelId);
	}
	flash.write("dplayer");
}
*/
function addStream(videoId){

		var channelId = _player_obj.channelId;
		if (channelId==58){
				channelId=3;
		}
	  var flvObj = window.document.myplayer;
	  if (flvObj){
	  
	  	  var obj=getVideos(videoId);
		  var videoIdArray=obj.video;
		  var programIdArray=obj.program;
		  
		  var addVideoId=0;
		  var addProgramId=0
		  var addCodeLevel=1;
		  
		  //alert("hid="+videoIdArray[0]+",lid="+videoIdArray[1]+",phid="+programIdArray[0]+",plid="+programIdArray[1]+",isHigh="+_player_obj.isHigh);
		  if (_player_obj.isHigh==1){
			  	addVideoId = videoIdArray[1];
			  	addProgramId = programIdArray[1];
			  	addCodeLevel=1;
		  }else{
			  	addVideoId = videoIdArray[0];
			  	addProgramId = programIdArray[0];
			  	addCodeLevel=2;
		  }
	
		  if (addVideoId > 0 && addProgramId>0 && addProgramId!=_player_obj.programId && addVideoId!=videoId){
		  	  	flvObj.AddVideo(_player_obj.videoType,channelId,addProgramId,addVideoId,0,-1,addCodeLevel);
		  	  	//alert("AddVideo:addVideoId="+addVideoId+",addProgramId="+addProgramId+",codeLevel="+addCodeLevel);
		  }
	  }else{
	     setTimeout("addStream("+videoId+")",100);
	  }
	 
	
}

function recommend(){

	var flvObj = window.document.myplayer;

    if (flvObj){
    	//alert("flvObj.EnableRecommend:"+flvObj.EnableRecommend);	
    	if (flvObj.EnableRecommend){
    		flvObj.EnableRecommend(false);
    	}else{
    		setTimeout("recommend()",1000);
    	}
    }else{
    		setTimeout("recommend()",1000);
    }
    
   // alert("flvObj.EnableRecommend:"+flvObj.EnableRecommend);	
   // flvObj.EnableRecommend(true);
}


/*新播放器*/
function setVideoIdToPlayer(videoId)
{
	var channelId = _player_obj.channelId;
	if (channelId==58){
			channelId=3;
	}
    var flvObj = window.document.myplayer;
    if (flvObj){
    		if(flvObj.PlayVideo){
    			if (videoId>0){
			    	var codeLevel=1;
			    	if (_player_obj.isHigh==1){
			    		codeLevel=2;
			    	}
			    	var time = 0;
			    	if (typeof(_video_obj.cId) != 'undefined' && typeof(_video_obj.pId) != 'undefined' && typeof(_video_obj.vId) != 'undefined'){
			    		var time = getlist('playinglist',_video_obj.cId,_video_obj.pId,_video_obj.vId);
			    	}
			    	//alert("time="+time);
			    	if (typeof(_player_obj.adId) != 'undefined'){
			    		flvObj.PlayVideo(_player_obj.videoType,channelId,_player_obj.programId,videoId,time,-1,codeLevel,_player_obj.adId);
			    	}else{
			    		flvObj.PlayVideo(_player_obj.videoType,channelId,_player_obj.programId,videoId,time,-1,codeLevel);
			    	}
			        
			        if (_player_obj.videoType==2){
			        	 	addStream(videoId);
			        }
			        
			        //最后一集，启用后推荐
		    		if (_video_obj.isLast==-1){
		    			recommend();
		    		}
		    		
			    }
			}
			else{
			        setTimeout("setVideoIdToPlayer("+videoId+")",100);
			}
    		
    }else{
	     setTimeout("setVideoIdToPlayer("+videoId+")",100);
	}
   
}

function writeFLV()
{
	var myDate = new Date();
	//var timestamp = myDate.getFullYear()+""+myDate.getMonth()+""+myDate.getDate()+""+Math.ceil(myDate.getHours()/4);
	var timestamp = 20100910;
	var channelId = _player_obj.channelId;
	if (channelId==58){
			channelId=3;
	}
	var flash = new SWFObject("http://client.joy.cn/flvplayer/joyplayer.swf?"+timestamp, "myplayer", _player_obj.width, _player_obj.height, "9", "#00000");

	flash.addParam("allowFullScreen", "true");
	flash.addParam("allowScriptAccess", "always");
	flash.addParam("quality", "high");
	flash.addParam("wmode", "opaque");
	flash.addVariable("EnableInter", _player_obj.enableInter);
	
	flash.addVariable("PlayerMode", _player_obj.playerMode);
	flash.addVariable("ShowMode", _player_obj.showMode);
	flash.addVariable("SkinType", _player_obj.skinType);
	flash.addVariable("VideoType", _player_obj.videoType);
	flash.addVariable("ChannelID", channelId);
	flash.addVariable("ProgramID", _player_obj.programId);
	
	if (_player_obj.playerMode==2){
		flash.addVariable("ControlFlag",'11');
	}
	/*
	if (_player_obj.playerMode==1 && _player_obj.videoId>0){
		flash.addVariable("VideoID", _player_obj.videoId);
		if (_player_obj.videoType==2){
		   addStream(_player_obj.videoId);
		}
	}
	*/
	if (typeof(_player_obj.enableAD) != 'undefined'){
		flash.addVariable("EnableAD", _player_obj.enableAD);
	}
	
	if (typeof(_player_obj.adFlag) != 'undefined'){
		flash.addVariable("AdFlag", _player_obj.adFlag);
	}
	
	if (typeof(_player_obj.enableSound) != 'undefined'){
		flash.addVariable("EnableSound", _player_obj.enableSound);
	}
	
	if (typeof(_player_obj.enableScale) != 'undefined'){
		flash.addVariable("EnableScale", _player_obj.enableScale);
		//flash.addVariable("EnableScale", true);
	}
	
	//广告位代码
	if (typeof(_player_obj.frontPid) != 'undefined'){
		flash.addVariable("FrontPid", _player_obj.frontPid);
	}
	
	if (typeof(_player_obj.otherPids) != 'undefined'){
		flash.addVariable("OtherPids", _player_obj.otherPids);
	}
	//插播广告
	if (typeof(_player_obj.insert) != 'undefined'){
		flash.addVariable("Insert", _player_obj.insert);
	}

	flash.write("dplayer");
	
}

function interactFLV()
{
	var myDate = new Date();
	//var timestamp = myDate.getFullYear()+""+myDate.getMonth()+""+myDate.getDate()+""+Math.ceil(myDate.getHours()/4);
	var timestamp = 20101118;
	var channelId = _player_obj.channelId;
	if (channelId==58){
			channelId=3;
	}
	var flash = new SWFObject("http://client.joy.cn/flvplayer/joyplayer.swf?"+timestamp, "myplayer", _player_obj.width, _player_obj.height, "9", "#00000");

	flash.addParam("allowFullScreen",true);
	flash.addParam("allowScriptAccess","always");
	flash.addParam("quality", "high");
	flash.addParam("wmode", "opaque");
	flash.addVariable("EnableInter", _player_obj.enableInter);
	flash.addVariable("EnableAD",true);
	flash.addVariable("AdFlag", "3,4");
	
	flash.addVariable("extend",1);
	flash.addVariable("PlayerMode",_player_obj.playerMode);
	flash.addVariable("ShowMode",_player_obj.showMode);
	flash.addVariable("SkinType",_player_obj.skinType);
	flash.addVariable("VideoType", _player_obj.videoType);
	flash.addVariable("ChannelID",channelId);
	flash.addVariable("ProgramID",_player_obj.programId);
	
	if (_player_obj.playerMode==1 && _player_obj.videoId>0){
		flash.addVariable("VideoID", _player_obj.videoId);
	}
	if (typeof(_player_obj.adFlag) != 'undefined'){
		flash.addVariable("AdFlag", _player_obj.adFlag);
	}
	
	if (typeof(_player_obj.enableSound) != 'undefined'){
		flash.addVariable("EnableSound", _player_obj.enableSound);
	}
	

	flash.write("dplayer");
}

	//加载用于显示背景板和拉幕广告的FLASH
	function showDBAdPlayer()
	{
		var width=960;
		var height=460;
		if (_player_obj.showMode==1){
			height=580;
		}
		var obj = document.getElementById('video1');
		if (obj)
		{
			var swf = 'http://client.joy.cn/flvplayer/dbadplayer.swf';
			var htm = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+width+'" height="'+height+'" id="dbAdPlayer" align="middle" style="position:absolute;z-index:1;">'
				    + '<param name="allowScriptAccess" value="always" />'
					+ '<param name="allowFullScreen" value="false" />'
					+ '<param name="movie" value="' + swf + '" />'
					+ '<param name="quality" value="high" />'
					+ '<param name="bgcolor" value="#000000" />'
					+ '<param name="wmode" value="opaque" />'
					+ '<embed src="' + swf + '" quality="high" bgcolor="#000000" width="'+width+'" height="'+height+'" id="dbAdPlayer" name="dbAdPlayer" align="middle" allowScriptAccess="always" allowFullScreen="false" wmode="opaque" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'
					+ '</object>';
			obj.innerHTML = htm;
		}
	}
	
	//播放器调用此函数,此函数调用广告(adstr为广告字符串,adtype:0-背景板;1-拉幕)
	function startLoadAd(adstr, adtype)
	{
		//16:9广告位ID
		var adId = 'joke_1000_10022';
		if (typeof(_player_obj.backboardId) != 'undefined'){
			adId = _player_obj.backboardId;
		}
		//4:3广告位ID
		if (_player_obj.showMode==1){
			adId = 'joke_1000_10216';
			if (typeof(_player_obj.backboardId) != 'undefined'){
				adId = _player_obj.backboardId;
			}
		}

		if (typeof(adtype) == 'undefined') adtype = 0;
		if (!document.getElementById('video1')) return;
		var obj = document.dbAdPlayer;
		if (obj)
		{
			if (obj.startLoadAd)
			{
				if (adtype == 1)
				{
					//播放拉幕广告时,将video1前置
					document.getElementById('video1').style.zIndex = 100;
				}
				obj.startLoadAd(adstr,adId);
			}
			else
			{
				setTimeout('startLoadAd("' + adstr.replace(/\"/g, '\\"') + '",' + adtype + ')', 100);
			}
		}
		else
		{
			showDBAdPlayer();
			setTimeout('startLoadAd("' + adstr.replace(/\"/g, '\\"') + '",' + adtype + ')', 100);
		}
	}
	//拉幕广告结束后调用此函数
	function endLoadAd()
	{
		//还原video1,开始播放视频
		document.getElementById('video1').style.zIndex = 1;
		DoPlay();
	}
	//播放视频
	function DoPlay()
	{
		var obj = document.myplayer;
		if (obj)
		{
			if (obj.DoPlay)
			{
				obj.DoPlay();
			}
			else
			{
				setTimeout('DoPlay()', 100);
			}
		}
		else
		{
			setTimeout('DoPlay()', 100);
		}
	}


//前置播放器避免覆盖右侧栏
function setPlayerFront(playerfront)
{
	var rc = document.getElementById("rightcolumn");
	if (rc) {
		if (playerfront == 'true')
		{
			rc.style.position =  'static';
		}
		else
		{
			rc.style.position =  'relative';
		}
	}
}
function writePhotoPlayer(vId)
{
		var url = "http://client.joy.cn/flvplayer/AlbumPlayer.swf";
		if (vId>=boundary){
			url = "http://client.joy.cn/flvplayer/photoalbumplayer.swf";
		}
		var flash = new SWFObject(url, "myplayer", _player_obj.width, _player_obj.height, "9", "#00000");

		flash.addParam("allowFullScreen", "true");
		flash.addParam("allowScriptAccess", "always");
		flash.addParam("quality", "high");
		flash.addParam("wmode", "opaque");
		flash.addVariable("strvid", vId);
		flash.addVariable("autoplay", "true");
		flash.write("dplayer");

}

//megajoyplay.js

/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept == "undefined") var deconcept = new Object();
if(typeof deconcept.util == "undefined") deconcept.util = new Object();
if(typeof deconcept.SWFObjectUtil == "undefined") deconcept.SWFObjectUtil = new Object();
deconcept.SWFObject = function(swf, id, w, h, ver, c, quality, xiRedirectUrl, redirectUrl, detectKey) {
	if (!document.getElementById) { return; }
	this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
	this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY);
	this.params = new Object();
	this.variables = new Object();
	this.attributes = new Array();
	if(swf) { this.setAttribute('swf', swf); }
	if(id) { this.setAttribute('id', id); }
	if(w) { this.setAttribute('width', w); }
	if(h) { this.setAttribute('height', h); }
	if(ver) { this.setAttribute('version', new deconcept.PlayerVersion(ver.toString().split("."))); }
	this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion();
	if (!window.opera && document.all && this.installedVer.major > 7) {
		// only add the onunload cleanup if the Flash Player version supports External Interface and we are in IE
		deconcept.SWFObject.doPrepUnload = true;
	}
	if(c) { this.addParam('bgcolor', c); }
	var q = quality ? quality : 'high';
	this.addParam('quality', q);
	this.setAttribute('useExpressInstall', false);
	this.setAttribute('doExpressInstall', false);
	var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location;
	this.setAttribute('xiRedirectUrl', xir);
	this.setAttribute('redirectUrl', '');
	if(redirectUrl) { this.setAttribute('redirectUrl', redirectUrl); }
}
deconcept.SWFObject.prototype = {
	useExpressInstall: function(path) {
		this.xiSWFPath = !path ? "expressinstall.swf" : path;
		this.setAttribute('useExpressInstall', true);
	},
	setAttribute: function(name, value){
		this.attributes[name] = value;
	},
	getAttribute: function(name){
		return this.attributes[name];
	},
	addParam: function(name, value){
		this.params[name] = value;
	},
	getParams: function(){
		return this.params;
	},
	addVariable: function(name, value){
		this.variables[name] = value;
	},
	getVariable: function(name){
		return this.variables[name];
	},
	getVariables: function(){
		return this.variables;
	},
	getVariablePairs: function(){
		var variablePairs = new Array();
		var key;
		var variables = this.getVariables();
		for(key in variables){
			variablePairs[variablePairs.length] = key +"="+ variables[key];
		}
		return variablePairs;
	},
	getSWFHTML: function() {
		var swfNode = "";
		if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
			if (this.getAttribute("doExpressInstall")) {
				this.addVariable("MMplayerType", "PlugIn");
				this.setAttribute('swf', this.xiSWFPath);
			}
			swfNode = '<embed pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" style="'+ this.getAttribute('style') +'"';
			swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
			var params = this.getParams();
			 for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; }
			var pairs = this.getVariablePairs().join("&");
			 if (pairs.length > 0){ swfNode += 'flashvars='+ pairs +'&realfull=1&moz=1"'; }
			swfNode += '/>';
		} else { // PC IE
			if (this.getAttribute("doExpressInstall")) {
				this.addVariable("MMplayerType", "ActiveX");
				this.setAttribute('swf', this.xiSWFPath);
			}
			//data="'+this.getAttribute('swf')+'"
			swfNode = '<object type="application/x-shockwave-flash"  id="'+ this.getAttribute('id') +'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" style="'+ this.getAttribute('style') +'">';
			swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
			var params = this.getParams();
			for(var key in params) {
			 swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
			}
			var pairs = this.getVariablePairs().join("&");
			if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';}
			swfNode += "</object>";
		}
		return swfNode;
	},
	write: function(elementId){
		if(this.getAttribute('useExpressInstall')) {
			// check to see if we need to do an express install
			var expressInstallReqVer = new deconcept.PlayerVersion([6,0,65]);
			if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) {
				this.setAttribute('doExpressInstall', true);
				this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl')));
				document.title = document.title.slice(0, 47) + " - Flash Player Installation";
				this.addVariable("MMdoctitle", document.title);
			}
		}
		if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){
			
		}else{
			if(this.getAttribute('redirectUrl') != "") {
				document.location.replace(this.getAttribute('redirectUrl'));
			}
			
		}
		var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
		n.innerHTML = this.getSWFHTML();
		return true;
	}
}

/* ---- detection functions ---- */
deconcept.SWFObjectUtil.getPlayerVersion = function(){
	var PlayerVersion = new deconcept.PlayerVersion([0,0,0]);
	if(navigator.plugins && navigator.mimeTypes.length){
		var x = navigator.plugins["Shockwave Flash"];
		if(x && x.description) {
			PlayerVersion = new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
		}
	}else if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0){ // if Windows CE
		var axo = 1;
		var counter = 3;
		while(axo) {
			try {
				counter++;
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+ counter);
//				document.write("player v: "+ counter);
				PlayerVersion = new deconcept.PlayerVersion([counter,0,0]);
			} catch (e) {
				axo = null;
			}
		}
	} else { // Win IE (non mobile)
		// do minor version lookup in IE, but avoid fp6 crashing issues
		// see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
		try{
			var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		}catch(e){
			try {
				var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
				PlayerVersion = new deconcept.PlayerVersion([6,0,21]);
				axo.AllowScriptAccess = "always"; // error if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code)
			} catch(e) {
				if (PlayerVersion.major == 6) {
					return PlayerVersion;
				}
			}
			try {
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			} catch(e) {}
		}
		if (axo != null) {
			PlayerVersion = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
		}
	}
	return PlayerVersion;
}
deconcept.PlayerVersion = function(arrVersion){
	this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0;
	this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0;
	this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0;
}
deconcept.PlayerVersion.prototype.versionIsValid = function(fv){
	if(this.major < fv.major) return false;
	if(this.major > fv.major) return true;
	if(this.minor < fv.minor) return false;
	if(this.minor > fv.minor) return true;
	if(this.rev < fv.rev) return false;
	return true;
}
/* ---- get value of query string param ---- */
deconcept.util = {
	getRequestParameter: function(param) {
		var q = document.location.search || document.location.hash;
		if (param == null) { return q; }
		if(q) {
			var pairs = q.substring(1).split("&");
			for (var i=0; i < pairs.length; i++) {
				if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
					return pairs[i].substring((pairs[i].indexOf("=")+1));
				}
			}
		}
		return "";
	}
}
/* fix for video streaming bug */
deconcept.SWFObjectUtil.cleanupSWFs = function() {
	var objects = document.getElementsByTagName("OBJECT");
	for (var i = objects.length - 1; i >= 0; i--) {
		objects[i].style.display = 'none';
		for (var x in objects[i]) {
			if (typeof objects[i][x] == 'function') {
				objects[i][x] = function(){};
			}
		}
	}
}
// fixes bug in some fp9 versions see http://blog.deconcept.com/2006/07/28/swfobject-143-released/
if (deconcept.SWFObject.doPrepUnload) {
	if (!deconcept.unloadSet) {
		deconcept.SWFObjectUtil.prepUnload = function() {
			__flash_unloadHandler = function(){};
			__flash_savedUnloadHandler = function(){};
			window.attachEvent("onunload", deconcept.SWFObjectUtil.cleanupSWFs);
		}
		window.attachEvent("onbeforeunload", deconcept.SWFObjectUtil.prepUnload);
		deconcept.unloadSet = true;
	}
}
/* add document.getElementById if needed (mobile IE < 5) */
if (!document.getElementById && document.all) { document.getElementById = function(id) { return document.all[id]; }}

/* add some aliases for ease of use/backwards compatibility */
var getQueryParamValue = deconcept.util.getRequestParameter;
var FlashObject = deconcept.SWFObject; // for legacy support
var SWFObject = deconcept.SWFObject;

//news add
function getLeft(e){		  
			var l=e.offsetLeft;
			while(e=e.offsetParent){
				l+=e.offsetLeft;
				}
			return l;
		}
function getTop(e){		  
			var l=e.offsetTop;
			while(e=e.offsetParent){
				l+=e.offsetTop;
				}
			return l;
		}
function holdPlayer()
{
	try
	{
		
	    $("#dplayer").css({'top':getTop(document.getElementById("flash"))+"px" ,'left':getLeft(document.getElementById("flash"))+"px",'display':''});
	}
	catch(e)
    {
	}
}

//showplay1.js

var xpos,ypos,locationobj;

function showBtn(obj,url){
	var scrox = document.documentElement.scrollLeft;
	var scroy = document.documentElement.scrollTop;
	//alert(scrox );
	getAbsPoint(obj);
	locationobj = url;
	document.getElementById("btn1").style.display = 'block';
	document.getElementById("btn1").style.left = xpos+scrox+25+"px";
	document.getElementById("btn1").style.top = ypos+scroy+15+"px";
}
function showBtn1(obj,url){
	//var scrox = document.documentElement.scrollLeft;
	//var scroy = document.documentElement.scrollTop;
	//alert(scrox );
	//getAbsPoint(obj);
	//locationobj = url;
	//document.getElementById("btn1").style.display = 'block';
	//document.getElementById("btn1").style.left = xpos+scrox+25+"px";
	//document.getElementById("btn1").style.top = ypos+scroy+15+"px";
}
function hiddnBtn(){
	//document.getElementById("btn1").style.display = 'none';
}

function openPage(){
	//window.location.href=locationobj;
}

function showContinue(obj){
	//obj.style.display = 'block';
}

function getAbsPoint(obj){   
    var oRect = obj.getBoundingClientRect();  
	xpos=oRect.left   
	ypos=oRect.top  
}


/******************记录播放进度***********************/
function setlist( cookie_name , channelid , videoid , vlength , time)
{
    var cookie_list_str=jQuery.cookie(cookie_name);
    //alert("setlist:"+cookie_name+":"+cookie_list_str);
    if(cookie_list_str ==null)
	{
		var expiration = new Date((new Date()).getTime() + 525600 * 60000);
		var list="{'list':[{'channelid':'"+channelid+"','videoid':'"+videoid+"','vlength':'"+vlength+"','time':'"+time+"'}]}";
		//var list='[{"channelid":channelid,"videoid":videoid,"vlength":vlength,"time":"40"}]';	
		jQuery.cookie(cookie_name, list,{path:"/",  expires:  expiration,domain:"joy.cn" });
			
	}
	else
	{
	    var data = (new Function("return " + cookie_list_str))();
		var cookie_list=data.list;
		var list_arr=new Array();	    
	    for(var i=0;i<cookie_list.length;i++)
		{		    
		    if(channelid==cookie_list[i].channelid && videoid==cookie_list[i].videoid && vlength==cookie_list[i].vlength)
			{	
				list_arr.unshift("{'channelid':'"+channelid+"','videoid':'"+videoid+"','vlength':'"+vlength+"','time':'"+time+"'}");	
				for(var j=(i+1);j<cookie_list.length;j++)
				{
				    list_arr.push("{'channelid':'"+cookie_list[j].channelid+"','videoid':'"+cookie_list[j].videoid+"','vlength':'"+cookie_list[j].vlength+"','time':'"+cookie_list[j].time+"'}");	
				}
				var list=list_arr.join(",");//alert(list_arr.length);
				list="{'list':["+list+"]}";//alert(list);
				var expiration = new Date((new Date()).getTime() + 525600 * 60000);
		        jQuery.cookie(cookie_name, list,{path:"/",  expires:  expiration,domain:"joy.cn" });
			    return ;
			}
			list_arr.push("{'channelid':'"+cookie_list[i].channelid+"','videoid':'"+cookie_list[i].videoid+"','vlength':'"+cookie_list[i].vlength+"','time':'"+cookie_list[i].time+"'}");	
		}
		
		list_arr.unshift("{'channelid':'"+channelid+"','videoid':'"+videoid+"','vlength':'"+vlength+"','time':'"+time+"'}");
		if(list_arr.length>5)
		{
		    list_arr.pop();			
		}
		
		var list="{'list':["+list_arr.join(",")+"]}";//alert(list);
	    var expiration = new Date((new Date()).getTime() + 525600 * 60000);
		jQuery.cookie(cookie_name, list,{path:"/",  expires:  expiration,domain:"joy.cn" });
	}
}
function getlist( cookie_name , channelid , videoid , vlength)
{	
    var cookie_list_str=jQuery.cookie(cookie_name);
	//alert("getlist:"+cookie_name+":"+cookie_list_str);
    if(cookie_list_str ==null)
	{
	    return 0;
	}
	else
	{
	    var data = (new Function("return " + cookie_list_str))();
		var cookie_list=data.list;
	    for(var i=0;i<cookie_list.length;i++)
		{
		    if(channelid==cookie_list[i].channelid && videoid==cookie_list[i].videoid && vlength==cookie_list[i].vlength)
			{
				if(cookie_name=="playinglist")
			        return cookie_list[i].time;
				else
				    return  1; 

			}
		}
		return 0;
	}
}
function dellist(cookie_name , channelid , videoid , vlength)
{
    var cookie_list_str=jQuery.cookie(cookie_name);
	//alert("dellist:"+cookie_name+":"+cookie_list_str);
    if(cookie_list_str ==null)
	{
	    return 0;
	}
	else
	{
	    var data = (new Function("return " + cookie_list_str))();
		var cookie_list=data.list;
		var list_arr=new Array();	    
	    for(var i=0;i<cookie_list.length;i++)
		{	  
		    if(channelid!=cookie_list[i].channelid || videoid!=cookie_list[i].videoid || vlength!=cookie_list[i].vlength)
			{	
			    list_arr.push("{'channelid':'"+cookie_list[i].channelid+"','videoid':'"+cookie_list[i].videoid+"','vlength':'"+cookie_list[i].vlength+"','time':'"+cookie_list[i].time+"'}");
				
				
			}
				
		}

		if(list_arr.length==0)
		{
		    jQuery.cookie(cookie_name, null,{path:"/",domain:"joy.cn" });
		}
		else
		{
		    var list=list_arr.join(",");//alert(list_arr.length);
			list="{'list':["+list+"]}";//alert(list);
			var expiration = new Date((new Date()).getTime() + 525600 * 60000);
		    jQuery.cookie(cookie_name, list,{path:"/",  expires:  expiration,domain:"joy.cn" });
		}		

	}
}

/******************记录播放进度结束***********************/
