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 = 11
		if(navigator.cookieEnabled){
			var innerStr = "";
                        var liStr = "";
			for(var i =nameArray.length - 1; i >= 0; i--){
				var textCount = nameArray[i].replace(/[^\x00-\xff]/g,"cc").length;
				if(textCount <= n*2){
					texts = nameArray[i];
				}else{
						texts = nameArray[i].substr(0,n)+"...";
				}
				liStr += "<li><a href=\"" + urlArray[i] + "\"" + " title=\"" + nameArray[i] + "\">" + texts + "</a>&nbsp;播放</li>"
                     
			}
if(liStr!=''){
				innerStr+=''+liStr+'';
			}

			if (innerStr.length>0){set(tag,innerStr)}
		}else{
			 set(tag,"您浏览器关闭了cookie功能，不能为您自动保存最近浏览过的网页。")
		}
	}
	this.addPlayHistory=function (name,url){
		var count = 6; //播放历史列表调用条数
		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='';
function _GC(){
document.getElementById('playhistory').innerHTML="<li><center>暂无播放历史列表!</center></li>";
 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()