var $MH={
	id:'rendie_history',
	limit:10,
	width:960,
	height: 170,
	style: 'pic',
	page:0,
	setCookie: function(name, value) {
		var Days = 365;
		var exp = new Date;
		exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
		document.cookie = name + ("=" + (value) + ";expires=" + exp.toGMTString() + ";path=/;");
	},
	getCookie: function(name) {
		var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
		if (arr != null) {
			return (arr[2]);
		}
		return null;
	},
	getDc: function(){
		var x,y=document.getElementById($MH.id);
		return y;
	},
	bwlist: function (){
		var a = $MH.getCookie($MH.id),current,img_li = "";
		a = (a !='' && ''+a != 'null') ? $MH.tryjosn(a)  : {video:[]} ;
		current=a.video.length
		if($MH.page+6<current){current=$MH.page+6;}
		for(var i=$MH.page;i<current;i++){
			if(a.video[i].url && a.video[i].pic && a.video[i].name)
			{
				img_li += '<li><span><img src="'+a.video[i].pic+'" width="26" height="53" /></span><b><a href="'+a.video[i].url+'">'+a.video[i].name+'</a><p>市场价：<u>￥271</u></p><p>商城价：<strong>￥226</strong></p></b></li>'
			}
		}
		return img_li
	},
	WriteHistoryBox: function(){
		this.showHistory(0);
	},
	showHistory: function(ac) {
		var a = $MH.getCookie($MH.id),dc=$MH.getDc();
		var ishistory = $MH.getCookie("ishistory");
		if(!dc) return;
		if (ac == 0){ishistory = 1;	}
		if (ac == 1){
			if (ishistory != 1) {
				$MH.setCookie("ishistory", 1);
				ishistory = 1;
			} else {
				$MH.setCookie("ishistory", 0);
				ishistory = 0;
			}
		}
		if (ac == 2){
			ishistory = 0;
			$MH.setCookie("ishistory", 0);
			$MH.setCookie($MH.id, 'null');
		}
		if (ac == 3){if($MH.page>4){$MH.page=$MH.page-6}}
		if (ac == 4){$MH.page=$MH.page+6}
		if(ishistory == 1){
			dc.innerHTML = $MH[$MH.style+'list']();
			dc.style.display = "";
		} else {
			dc.innerHTML = "";
			dc.style.display = "none";
		}
	},
	recordHistory: function(video){
		var a = $MH.getCookie($MH.id), b = new Array();
		if(a !='' && a != null && a != 'null'){
			a = $MH.tryjosn(a);
			for(var i=0;i<a.video.length;i++)
			{
				if(video.url != a.video[i].url && a.video[i].pic)
				{
					b.push('{"name":"'+ $MH.u8(a.video[i].name) +'","url":"'+ $MH.u8(a.video[i].url) +'","pic":"'+ $MH.u8(a.video[i].pic) +'"}');
				}
			}
		}
		b.unshift('{"name":"'+ $MH.u8(video.name) +'","url":"'+ $MH.u8(video.url) +'","pic":"'+ $MH.u8(video.pic) +'"}');
		$MH.setCookie($MH.id,'{video:['+ b.join(",") +']}');
		b = null;
		a=null;
	},
	u8: function (s){
		return unescape(escape(s).replace(/%u/ig,"\\u")).replace(/;/ig,"\\u003b");
	},
	tryjosn: function (json){
		try{
			return eval('('+ json +')');
		}catch(ig){
			return {video:[]};
		}
	}
}