//文件名称:function.js
//函数功能:批量加载和移除广告
//版权作者:rym1020 www.52tian.net
//编写日期:2007-4-2

setInterval('self.status="天上人间动漫网欢迎您的光临，如果您有任何问题请联系本站客服QQ：15691969 33893379！";',5000);

function $(id) {
	return document.getElementById(id);
}

function RndNum(min,max) { 
	return Math.floor(Math.random()*(max-min+1)+min);
}

function AJAXRequest() {
	var xmlObj = false;
	var CBfunc,ObjSelf;
	ObjSelf=this;
	try { xmlObj=new XMLHttpRequest; }
	catch(e) {
		try { xmlObj=new ActiveXObject("MSXML2.XMLHTTP"); }
		catch(e2) {
			try { xmlObj=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch(e3) { xmlObj=false; }
		}
	}

	if (!xmlObj) return false;
	this.method="POST";
	this.url;
	this.async=true;
	this.content="";
	this.callback=function(cbobj) {return;}
	this.abort=function() { if(xmlObj) xmlObj.abort(); }
	this.send=function() {
		if(!this.method||!this.url||!this.async) return false;
		xmlObj.open (this.method, this.url, this.async);
		if(this.method=="POST") xmlObj.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		xmlObj.onreadystatechange=function() {
			if(xmlObj.readyState==4) {
				if(xmlObj.status==200) {
					ObjSelf.callback(xmlObj);
				}
			 	delete xmlObj; 
				xmlObj=null;
			}
		}
		if(this.method=="POST") xmlObj.send(this.content);
		else xmlObj.send(null);
	}
}

function showTip(el, m, tipstr, e) { 
	var cx, cy; 
	e = window.event?window.event:e; 
	if (!e) {
		cx = window.event.x;
		cy = window.event.y;
	} 
	else {
		cx = e.clientX;
		cy = e.clientY;
	}
	m = document.getElementById(m);
	if (tipstr.length > 1) { 
		if ( m) { 
			var sl = document.documentElement.scrollLeft || document.body.scrollLeft; 
			var st = document.documentElement.scrollTop || document.body.scrollTop; 
			m.style.left = sl + cx + 10 + "px"; 
			m.style.top = st + cy + "px"; 
			m.innerHTML = ""; 
			m.innerHTML = tipstr; 
			m.style.display="";
		} 
	} 
}
function closetip(divid){
	if($(divid)) $(divid).style.display="none";
}

function setCookie(name, value, seconds, path, domain, secure) {
	var expires = new Date();
	if(seconds)
		expires.setTime(expires.getTime() + seconds*1000 );		//失效时间（单位：秒）
	else
		expires = new Date(expires.getFullYear(),expires.getMonth(),expires.getDate()+1); //设为0则当天24点过期
	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 = articleid + "|" + title;			// 用|号间隔开articleid和标题
	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;
	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] +"/\">" + temparray2[1] + "<\/A><\/DIV>";
	}
}

function setUfav() {
	var str = articleid + "|" + title;		// 用|号间隔开articleid和标题
	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] +"/\">" + temparray2[1] + "<\/A><\/DIV>";
	}
}

function getOtherLooked(objid){
	var obj = document.getElementById(objid);
	var ajaxobj = new AJAXRequest;			// 创建AJAX对象
	ajaxobj.method="POST";				// 设置请求方式为POST
	ajaxobj.url="/GetMovieInfo.asp";
	ajaxobj.async = true;
	ajaxobj.content = "movieid=" + articleid + "&now=" + new Date().getTime();
	ajaxobj.callback = function(xmlobj) {
		obj.innerHTML = xmlobj.responseText;
	}
	ajaxobj.send();
}

function setOtherLooked(){
	var temparray = getData("Ulooked");
	var str = "";
	if (temparray != "" && temparray != undefined)
		str = temparray[0];				// 取最后一次浏览值
	if (str.split('|')[0]==articleid) return;
	var ajaxobj = new AJAXRequest;				// 创建AJAX对象
	ajaxobj.method="POST";					// 设置请求方式为POST
	ajaxobj.url="/LookedMovie.asp";
	ajaxobj.async = true;
	ajaxobj.content = "movieid=" + articleid + "&looked=" + escape(str) + "&now=" + new Date().getTime();
	//escape一下，否则会发送乱码
	ajaxobj.send();
}

function dingcai(action){
	var str = articleid + "|" + title;				// 用|号间隔开articleid和标题
	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="/DingMovie.asp";
		ajaxobj.async = true;
		ajaxobj.content = "movieid=" + articleid + "&action="+action+"&now=" + new Date().getTime();
		ajaxobj.send();
	}
	if (action=="ding")
		alert('《' + title + '》已被您顶到最前面，天上人间感谢您的参与！');
	else
		alert('《' + title + '》已被您踩到沉入大海，天上人间感谢您的参与！');
}


/*******************************加载广告*******************************/
function loadad(objlist) {
	//objlist:字符串,要加载的广告位ID序列,用,号把每个obj的ID分隔,只有一个obj则不用逗号
	if(!objlist) return;
	//创建IE:download对象
	//var loadadobj = document.createElement("IE:DOWNLOAD");
	//loadadobj.id = "loadadobj";
	//loadadobj.style.behavior = "url(#default#download)";
	//document.body.appendChild(loadadobj);

	var adobjarray = objlist.split(",");
	for (var i=0; i<adobjarray.length; i++) {
		getad(adobjarray[i]);
		//var obj = $(objarray[i]);
		//if(!obj) continue;
		//var url = "/gg/"+obj.id.toString()+".htm"
		//回调函数只有当广告下载完毕后才执行，如果放在循环中
		//则每个回调函数执行时obj都是循环最后的结果
		//因此用eval动态的生成每次循环的回调函数中的obj的ID
		//eval("$('loadadobj').startDownload(url,function(result){set_innerHTML('"+obj.id+"',result,1000);if(result.replace(/<!--(.+)-->/gi,'')!='') $('"+obj.id+"').style.display='block';})");
	}

	//统计信息放最后，延迟一定时间，不然会与广告错位
	setTimeout('getad("webstat")',5000);
}

function getad(objid){
	var adobj = $(objid);
	if(!adobj) return;
	var now = new Date();
	var ajaxobj = new AJAXRequest;		// 创建AJAX对象
	ajaxobj.method="GET";			// 设置请求方式为GET,htm文件不能用POST
	ajaxobj.url = "/gg/"+objid+".htm?"+now.getSeconds();
	ajaxobj.async = true;
	ajaxobj.callback = function(xmlobj) {
		set_innerHTML(objid,xmlobj.responseText,1000);
		if(xmlobj.responseText.replace(/<!--(.+)-->/gi,'') != '')
			$(objid).style.display = 'block';
	}
	ajaxobj.send();

	//当广告全部加载完毕后显示“屏蔽广告”按钮
	if(objid=='webstat') {
		var removead = $('removead');
		if(removead) removead.style.display = 'inline-block';
	}
}
/*******************************加载广告*******************************/

/*******************************移除广告*******************************/
//移除指定id的广告，支持多个id批量移除
function removead(objlist) {
	//objlist:字符串,要移除的广告位ID序列,用,号把每个obj的ID分隔,只有一个obj则不用逗号
	if(!objlist) return;
	var objarray = objlist.split(",");
	for (var i=0; i<objarray.length; i++) {
		var obj = $(objarray[i]);
		if(!obj) continue;
		obj.innerHTML = "";
	}
}

//说明:这4个函数是为了能在广告显示前不显示“屏蔽广告”按钮，并在第一次点击时提示先点广告
function removead0() {
	alert('请支持本站发展，先点击本页面所有广告后再点此按钮！');
}
function removead1() {
	//removead0();
	//setTimeout(removead2,10000);
	//$('removead').onclick = removead0;
	removead3();
}
function removead2() {
	$('removead').onclick = removead3;
}
function removead3() {
	var objarray = ["bannerad1","indexcenterad1","indexbottomad1","indexotherad1","movieotherad1","movieleftad1","movierightad1","moviead500a1","moviead500b1","moviead500c1","classtopad1","classleftad1","classrightad1","classotherad1","allmovieleftad1","allmovietopad1","allmovieotherad1","playerotherad1","playertopad1","playerleftad1","playerbottomad1","playerrightad1","flv250ad1","playerbottomad7601","playerbottomad5001","playerright3601","playerbottom9501","objbottom","_u114qq","rightfloat","indexleftad1","bannerad960","serverleftad1","serverrightad1","serverad500a1","serverad500b1","serverad500c1"];
	for (var i=0; i<objarray.length; i++) {
		if(!$(objarray[i])) continue;
		//$(objarray[i]).innerHTML = "";
		$(objarray[i]).outerHTML = "";
	}
	//$('removead').style.display = 'none';
	//alert('本页面大部分广告已屏蔽，部分广告由于广告商问题我们无法屏蔽，希望您喜欢本站！');
}

function hidead() {
	setCookie("hidead","yes",0,"\/");
	removead3();
	alert('恭喜，您已屏蔽本站所有广告，无广告有效时间至今天晚上24点整！\n广告是本站唯一的收入来源，用以支撑高额的服务器费用，支持本站发展请您在显示一遍本站所有广告之后再打开该功能！\n如果该设置无法屏蔽广告，请点击左上角的“网站报错”将情况反馈给我们，谢谢！');
}
function showad() {
	deleteCookie("hidead","\/");
	alert('您已恢复所有广告的显示，感谢您支持天上人间！');
}



/*******************************移除广告*******************************/


/*******************************切换列表*******************************/
function ShowList(str,n,max) {
	for (var i=1;i<=max;i++)
		$(str+i).style.display = "none";
	$(str+n).style.display = 'block';
}
/*******************************切换列表*******************************/

/*******************************全屏播放*******************************/
function quanping() {
	$('player').width=window.screen.availWidth-30;
	$('player').height=window.screen.availHeight-130;
	$('player').scrollIntoView();
	$('player').focus();
}

function escqp() {
	$('player').width='100%';
	$('player').height='100%';
	$('player').scrollIntoView();
	$('player').focus();
}

function s_52tian() {
	$("floatad").style.visibility = "visible";
}
function h_52tian() {
	$("floatad").style.visibility = "hidden";
}
var cs_uid=1054;
function popad() {
	document.writeln("<scr"+"ipt type=\"text/javascript\" src=\"http://cs01.csyouxi.com/p/p.js\"></s"+"cript>");
}

function floatad() {
	document.writeln("<scr"+"ipt language='javascript' src='/gg/popWinScript.js'></scr"+"ipt>");
}

function extpop() {
	//if(!window.open(popURL1,"_blank")) {
		//document.body.innerHTML += "<object id=iie width=0 height=0 classid='CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6'></object>";
		$("iie").launchURL(popURL1);
	//}
	setCookie("exitpop","displayed",0,"\/");
}
function showtab(n) {
	for (var i=1;i<=4;i++) {
		if (i==n) {
			document.getElementById("piccomic"+n).style.display = 'block';
			document.getElementById("type"+n).className = "selected";
			continue;
		}
		document.getElementById("piccomic"+i).style.display = "none";
		document.getElementById("type"+i).className = "unselected";
	}
}

function Vpop(width, height, iframe,vpopdiv) {
	if(!vpopdiv) vpopdiv = $("vpopdiv");
	vpopdiv.innerHTML = "<div style='position:absolute; z-index: 9999;left:" + ( (document.documentElement.clientWidth - width)/2 ) + "px;top:" + ( document.documentElement.scrollTop + (document.documentElement.clientHeight - height - 28)/2  ) +"px;width:"+width+"px;overflow:hidden;border: 3px solid #166AEE;border-top:0px;'><div style='background:url(/images/vpopbg.gif) repeat-x;height:28px;overflow:hidden;position:relative;color:#fff;font-size:14px;font-weight:bold;line-height:28px;padding-left:10px;'>天上人间为您推荐 - Microsoft Internet Explorer<span style='position:absolute;top:1px;right:-3px;cursor:pointer;background:url(/images/vpopclose.gif);width:87px;height:28px;' onclick=\"this.parentNode.parentNode.outerHTML = ''\"></span></div><iframe frameborder='0' vspace='-350' scrolling='yes' width='"+width+"' height='1180' src='"+iframe+"'></iframe></div>";
}

function updateTB() {
	try {
		var uid = /#(\d+)/.exec(location.href)[1];
		if(!document.referrer || document.referrer.indexOf("52tian.net")>0) return;//无来源或本站推广
		if(!uid || getCookie("addTB")) return;//非推广连接 或 已增加过积分

		document.writeln("<iframe width=0 height=0 frameborder=0 scrolling=no src='http://bbs.52tian.net/api/updatetb.php?uid=" + uid + "&refer=" + document.referrer+"'><\/iframe>");

		setCookie("addTB","true",8640000,"\/");
	} catch(e){}
}

function automaxwin() {
	try {
		if(getCookie("automax")=="yes") {
			if($("automax")) $("automax").checked = true;
			window.moveTo(0,0);
			window.resizeTo(window.screen.availWidth,window.screen.availHeight);
		}
	} catch(e) {}
}

function autoorder() {
	try {
		if( $("autoorder") && getCookie("autoorder")=="1" ) {
			$("autoorder").checked = true;
			changeorder();
		}
	} catch(e) {}
}

function changeorder() {
	var n=$("jishutable").childNodes;
	for (var i=n.length-1;i>-1;i--) $("jishutable").appendChild(n[i]);
}

if(top!=self) top.location=self.location;//禁止被它站iframe
if($("automax")) $("automax").onclick = function() {
	setCookie("automax",$("automax").checked ? "yes" : "no",8640000,"\/");
}

if($("autoorder")) $("autoorder").onclick  = function() {
	changeorder();
	setCookie("autoorder",$("autoorder").checked ? "1" : "0",8640000,"\/");
}

window.onload = function() {
	updateTB();
	if( getCookie("hidead")=="yes" ) removead3();
	setTimeout(automaxwin,3000);
}


var tb_links = new Array();
tb_links[0] = ["qq+%C5%A9%B3%A1","","8532118"];//QQ 农场
tb_links[1] = ["qq+%BB%E1%D4%B1","","8532118"];//QQ 会员
tb_links[2] = ["qq+%BB%C6%D7%EA","","8532118"];//QQ 黄钻
tb_links[3] = ["q%B1%D2","50011665","8532118"];//Q币
tb_links[4] = ["qq%BF%D5%BC%E4","40","8532118"];//QQ空间
tb_links[5] = ["%C7%E9%C2%C2+%B9%AB%D7%D0","","8532118"];//情侣 公仔
tb_links[6] = ["%D3%C6%CE%FB%BA%EF+%B1%A7%D5%ED","","8533702"];//悠嘻猴 抱枕
tb_links[7] = ["qq+%BA%C5%C2%EB","","8532118"];//QQ 号码
tb_links[8] = ["qq+%BA%EC%D7%EA","","8532118"];//QQ 红钻
tb_links[9] = ["qq%D0%E3","","8532118"];//QQ秀

var tb_link = tb_links[RndNum(0,tb_links.length-1)];
var tb_popurl = "http://www.alimama.com/membersvc/rd.do?w=mmp4ptest&f=http://search8.taobao.com/browse/search_easy.htm?keyword="+tb_link[0]+"%26catid="+tb_link[1]+"%26refpid=mm_14368537_2043859_"+tb_link[2]+"%26isinner=0";

if( getCookie("hidead")!="yes" ) {
	var cpro_id = 'u36824';
	document.writeln('<scr'+'ipt type="text/javascript" src="http://cpro.baidu.com/cpro/ui/f.js"></scr'+'ipt>');
}