/*****************************************************
MaxCms2.0
Web:http://www.bokecc.com   http://www.maxcms.net   
BBS:http://bbs.bokecc.com
2005-2009 Dreamwindows Inc. All rights reserved
Author:石头(ElapsedBloom)  2008-01-05 00:54
*****************************************************/
function PlayHistoryClass(){
	var cookieStr,nameArray,urlArray,allVideoArray;
	this.getPlayArray=function (){
		cookieStr = document.cookie;
		//alert(cookieStr)
		var start = cookieStr.indexOf("max_cms2_v=") + "max_cms2_v=".length,end = cookieStr.indexOf("_$_|",start),allCookieStr= unescape(cookieStr.substring(start,end))
		if(end==-1){allCookieStr="";return;}
		allVideoArray = allCookieStr.split("_$_");
		nameArray = new Array(),urlArray = new Array();
		for(var i = 0; i < allVideoArray.length; i++){
			var singleVideoArray = allVideoArray[i].split("^");
			nameArray[i] = singleVideoArray[0];urlArray[i] = singleVideoArray[1];
		}
	}
	this.viewPlayHistory=function (div){
		var tag = $(div),n = 16, j=0
		if(navigator.cookieEnabled){
			var innerStr = "";
			for(var i =nameArray.length - 1; i >= 0; i--){
				j=j+1
				var textCount = nameArray[i].replace(/[^\x00-\xff]/g,"cc").length;
				if(textCount <= n*2){
					texts = nameArray[i];
				}else{
						texts = nameArray[i].substr(0,n)+"...";
				}
				
				innerStr += "<li> <b>"+j+"</b><a class=a_blue href=\"" + urlArray[i] + "\"" + " title=\"" + nameArray[i] + "\">" + texts + "</a></li>"
			}
			if (innerStr.length>0){set(tag,innerStr)}
		}else{
			 set(tag,"您浏览器关闭了cookie功能，不能为您自动保存最近浏览过的网页。")
		}
	}
	this.addPlayHistory=function (name,url){
		var count = 7; //播放历史列表调用条数
		var code_name = escape(name) + "^",code_url = escape(url) + "_$_",expireTime = new Date(new Date().setDate(new Date().getDate() + 30)),timeAndPathStr = "|; expires=" + expireTime.toGMTString() + "; path=/";
		if(cookieStr.indexOf("max_cms2_v=") != -1 || cookieStr.indexOf("_$_|") != -1){
			var newCookieStr = "";
			if(allVideoArray.length < count){
				for(i in allVideoArray){
					if(nameArray[i] == name) continue;
					newCookieStr += escape(nameArray[i]) + "^" + escape(urlArray[i]) + "_$_" ;
				}
			}else{
				for(var i = 1; i < count; i++){
					if(nameArray[i] == name) continue;
					newCookieStr += escape(nameArray[i]) + "^" + escape(urlArray[i]) + "_$_" ;
				}
			}
			document.cookie = "max_cms2_v=" + newCookieStr + code_name + code_url + timeAndPathStr;
		}else{
			document.cookie = "max_cms2_v="+ code_name + code_url + timeAndPathStr;
		}
	}
}
var cookiedomain="6pindao.com";
function _GC(){
document.getElementById('playhistory').innerHTML="<center>暂无播放历史列表...</center>";
 var expdate=new Date(1970, 1, 1);
 SetCookie("max_cms2_v","",expdate,"/",cookiedomain,false);
 SetCookie("max_cms2_v","",expdate,"/",null,false);
}
function SetCookie(name,value){
 var argv=SetCookie.arguments;
 var argc=SetCookie.arguments.length;
 var expires=(2<argc)?argv[2]:null;
 var path=(3<argc)?argv[3]:null;
 var domain=(4<argc)?argv[4]:null;
 var secure=(5<argc)?argv[5]:false;
 document.cookie=name+"="+escape(value)+((expires==null)?"":("; expires="+expires.toGMTString()))+((path==null)?"":("; path="+path))+((domain==null)?"":("; domain="+domain))+((secure==true)?"; secure":"");
}
var PlayHistoryObj=new PlayHistoryClass()
PlayHistoryObj.getPlayArray()