window.onerror = function(){return true;};

var Top_Key;

String.prototype.sub = function(n) {
	var r = /[^\x00-\xff]/g;
	if(this.replace(r, "mm").length <= n) return this;
	n = n - 3;
	var m = Math.floor(n/2);
	for(var i=m; i<this.length; i++) {
		if(this.substr(0, i).replace(r, "mm").length >= n) {
			return this.substr(0, i) +"...";
		}
	}
	return this;
}

loadXML = function(xmlFile) {
	var xmlDoc;
	if(window.ActiveXObject) {
		xmlDoc = new ActiveXObject('Microsoft.XMLDOM');
		xmlDoc.async = false;
		xmlDoc.load(xmlFile);
	}
	else if (document.implementation&&document.implementation.createDocument) {
		xmlDoc = document.implementation.createDocument('', '', null);
		xmlDoc.load(xmlFile);
		}
	else {
		return null;
    }
	return xmlDoc;
}

checkXMLDocObj = function(xmlFile) { 
    var xmlDoc = loadXML(xmlFile); 
    if(xmlDoc == null) { 
        alert('您的浏览器不支持xml文件读取,于是本页面禁止您的操作,推荐使用IE5.0以上可以解决此问题!'); 
        window.location.href='/Index.asp'; 
    }
    return xmlDoc; 
}

function Close_Top_Key() {
	if (document.all.Show_Top_Key.style.display != "none") {
		Top_Key = setInterval('Close_Top_Key_A()',150);
	}
	else {
		clearInterval(Top_Key);
	}
}

function Close_Top_Key_A() {
	document.all.Show_Top_Key.style.display = "none";
	document.all.Show_Top_Key.innerHTML = "";
	clearInterval(Top_Key);
}

function Open_Top_Key() {
	clearInterval(Top_Key);
	var get_key = document.Top_Search.Search_Key.value;
	if (get_key != '') {
		var html_mode = 0;
		var html_temp = '<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"#CCCCCC\"><tr><td bgcolor=\"#FFFFFF\"><table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\">';
		var xmlDoc = checkXMLDocObj('/index/xml_key.asp?Search_Key=' + get_key);
		var l = xmlDoc.getElementsByTagName('channel')[0].childNodes.length - 5;
		if (l > 0) {
			document.all.Show_Top_Key.style.display = "";
			for(var i=0; i<10; i++) {
				if (l <= i) break;
				html_temp = html_temp + '<a href=\"javascript:void(null);\" onClick=\"Close_Top_Key_A();top.location.href=\'\/movie_view\/view_' + xmlDoc.getElementsByTagName('channel/item/id')[i].childNodes[0].nodeValue + '\.html\';\"><tr onMouseOver=\'this.style.backgroundColor=\"#CCCCCC\";\' onMouseOut=\'this.style.backgroundColor=\"\";\' style=\"cursor:hand;\"><td title=\"List_ID=' + xmlDoc.getElementsByTagName('channel/item/id')[i].childNodes[0].nodeValue + '\"><div id=\"tkey_' + i + '\" style=\"color:#000000;font-weight: bold;\" title=\"List_ID=' + xmlDoc.getElementsByTagName('channel/item/id')[i].childNodes[0].nodeValue + '\">' + xmlDoc.getElementsByTagName('channel/item/title')[i].childNodes[0].nodeValue + '</div></td></tr></a>';
			}
			html_temp = html_temp + '</table></td></tr></table>';
			document.all.Show_Top_Key.innerHTML = html_temp;
		}
		else {
			document.all.Show_Top_Key.style.display = "none";
		}
	}
	else {
		document.all.Show_Top_Key.style.display = "none";
	}
}

function ChkSearch() {
	if (document.Search.Search_Key.value == "" || document.Search.Search_Key.value == "输入搜索关键字") {
		alert("请填写搜索关键字！");
		document.Search.Search_Key.focus();
		return false;
	}
	if (document.Search.Search_Key.value == "输入关键字,也可以直接搜索。") {
		top.location.href = "/List.asp?Sort_ID=" + document.Search.Search_Sort.value;
		return false;
	}
	return true;
}

function Chk_Search() {
	if (document.Top_Search.Search_Key.value == "" || document.Top_Search.Search_Key.value == "输入搜索关键字") {
		alert("请填写搜索关键字！");
		document.Top_Search.Search_Key.focus();
		return false;
	}
	return true;
}

function Show_PySearch() {
	var bdy = (document.documentElement && document.documentElement.clientWidth)?document.documentElement:document.body;
	document.all.Show_PySearch_Div0.style.display = 'block';
	if (bdy.scrollHeight < document.body.clientHeight) {
		document.all.Show_PySearch_Div0.style.height = document.body.clientHeight;
		document.all.Show_PySearch_Table0.style.height = document.body.clientHeight;
	}
	else {
		document.all.Show_PySearch_Div0.style.height = bdy.scrollHeight;
		document.all.Show_PySearch_Table0.style.height = bdy.scrollHeight;
	}
	document.all.Show_PySearch_Div1.style.top = bdy.scrollTop;
	document.all.Show_PySearch_Div1.style.display = 'block';
	document.all.Show_PySearch_Div1.style.height = document.body.clientHeight;
	document.all.Show_PySearch_Table1.style.height = document.body.clientHeight;
	document.all.Show_PySearch_If.src = '/PySearch.htm';
}

function Show_PySearchX() {
	var bdy = (document.documentElement && document.documentElement.clientWidth)?document.documentElement:document.body;
	document.all.Show_PySearch_Div0.style.display = 'block';
	if (bdy.scrollHeight < document.body.clientHeight) {
		document.all.Show_PySearch_Div0.style.height = document.body.clientHeight;
		document.all.Show_PySearch_Table0.style.height = document.body.clientHeight;
	}
	else {
		document.all.Show_PySearch_Div0.style.height = bdy.scrollHeight;
		document.all.Show_PySearch_Table0.style.height = bdy.scrollHeight;
	}
	document.all.Show_PySearch_Div1.style.top = bdy.scrollTop;
	document.all.Show_PySearch_Div1.style.display = 'block';
	document.all.Show_PySearch_Div1.style.height = document.body.clientHeight;
	document.all.Show_PySearch_Table1.style.height = document.body.clientHeight;
	document.all.Show_PySearch_If.src = '/PySearchX.htm';
}

function Close_PySearch() {
	document.all.Show_PySearch_If.src = 'about:blank';
	document.all.Show_PySearch_Div0.style.display = 'none';
	document.all.Show_PySearch_Div1.style.display = 'none';
}

function Change_Menu(i) {
}

function copyCode(copyTemp) {
	document.getElementById(copyTemp).select();
	document.execCommand("copy",null);
	alert("复制成功！");	
}