function setCookie(name, value, seconds, path, domain, secure) {
	var expires = new Date();
	expires.setTime(expires.getTime() + seconds*1000 );		//失效时间（单位：秒）
	var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
	document.cookie = curCookie;
}

function deleteCookie(name, path, domain) {
	if (getCookie(name))
		document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}

function getCookie(name) {
	var prefix = name + "=";
	var cookieStartIndex = document.cookie.indexOf(prefix);
	if (cookieStartIndex == -1)	return null;
	var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length);
	if (cookieEndIndex != -1)
		return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex));
	else
		return unescape(document.cookie.substring(cookieStartIndex + prefix.length));
}


/*******************************点播页使用方法*******************************/
function getData(name) {
	var temp = getCookie(name);
	;
	if (temp == "" || temp == null) return "";
	var temparray = temp.split('$');
	if (temparray.length<1) return "";
	return temparray;
}

function setUlooked() {
	
	var str = zt_id + "|" + title;			// 用|号间隔开zt_id和标题
	var temp = getCookie("Ulooked");
	if (temp == undefined || temp == "") temp = "";
	if (temp.indexOf(str) != -1) return;	// 已存在cookies里则不添加
	if (temp != "")
		str += "$";						// 用$号间隔开多条记录
	setCookie("Ulooked",str+temp,8640000,"\/");// 失效时间100天
}

function showUlooked(objid){
	var obj = document.getElementById(objid);
	
	var temparray = getData("Ulooked");
	var temparray2;
	if (temparray == "" || temparray == undefined) return;
	obj.innerHTML = "";
	for (var i=0;i<temparray.length;i++) {
		if (i>=10) break;				// 最多显示十条
		temparray2 = temparray[i].split('|');
		if (temparray2.length<2) continue;
		obj.innerHTML += "<DIV>·<A href=\"\/html\/movie\/"+ temparray2[0] +"\/index.html\">" + temparray2[1] + "<\/A><\/DIV>";
	}
}

function setUfav() {
	var str = zt_id + "|" + title;		// 用|号间隔开zt_id和标题
	var temp = getCookie("Ufav");
	if (temp == undefined || temp == "") temp = "";
	if (temp.indexOf(str) == -1) {		// 不存在cookies里时才添加
		if (temp != "") str += "$";	// 用$号间隔开多条记录
		setCookie("Ufav",str+temp,8640000,"\/");// 失效时间100天
	}
	alert('《' + title + '》已成功添加到您收藏的节目列表！');
	window.location.reload();
}

function showUfav(objid) {
	var obj = document.getElementById(objid);
	var temparray = getData("Ufav");
	var temparray2;
	if (temparray == "" || temparray == undefined) return;
	for (var i=0;i<temparray.length;i++) {
		if (i>=10) break;				// 最多显示十条
		temparray2 = temparray[i].split('|');
		if (temparray2.length<2) continue;
		obj.innerHTML += "<DIV>·<A href=\"\/html\/movie\/"+ temparray2[0] +"\/index.html\">" + temparray2[1] + "<\/A><\/DIV>";
	}
}

function dingcai(action){
	var str = zt_id + "|" + title;				// 用|号间隔开zt_id和标题
	var temp = getCookie("Uding");
	if (temp == undefined || temp == "") temp = "";
	if (temp.indexOf(str) == -1) {				// 没顶过或踩过才更新
		if (temp != "") str += "$";			// 用$号间隔开多条记录
		setCookie("Uding",str+temp,8640000,"\/");	// 失效时间100天
		var ajaxobj = new AJAXRequest;			// 创建AJAX对象
		ajaxobj.method="POST";				// 设置请求方式为POST
		ajaxobj.url="/inc/hits.asp";
		ajaxobj.async = true;
		ajaxobj.content = "action="+action+"&zt_id=" + zt_id + "&now=" + new Date().getTime();
		ajaxobj.send();
	}
	if (action=="ding")
		alert('《' + title + '》已被您顶到最前面，幻影动漫网感谢您的参与！');
	else
		alert('《' + title + '》已被您踩到沉入大海，幻影动漫网感谢您的参与！');
}