var sitefolder = "http://news.arsenal.com.cn/"
function fav(){
	window.external.addFavorite(this.location.href,"阿森纳新闻中心 - News.Arsenal.com.cn");
}
//==========获取对像
	function $(obj){
	if (document.getElementById && document.getElementById(obj)) {
		return document.getElementById(obj);
    } else if (document.all && document.all[obj]) {
		return document.all[obj];
	} else if (document.layers && document.layers[obj]) {
		return document.layers[obj];
	} else {
		return null;
    }
}
//是否为正整数
function isPosInteger(str){
	var result=str.match(/^\d+$/);
	if(result==null) return false;
	if(parseInt(str,10)>0) return true;
	return false;
}
//是否为正整数
function chkpage(form,maxpage){
	var p = form.pg.value;
	if( !isPosInteger(p) ){
		alert('请输入正确的数字！')
		form.pg.select()
		return false
	}
	if ( p > maxpage ) { p = maxpage }
	if ( p == 1 ) {
		location = "index.html"
	} else {
		location = "index_" + p + ".html"
	}
	return false;
}
function chkarch(form)	{
	var y = form.y.options[form.y.selectedIndex].value
	var m = form.m.options[form.m.selectedIndex].value
	if ( y == 0 ) {
		alert("请选择有效的年份！")
		form.y.focus()
		return false
	}
	if ( m == 0 ) {
		alert("请选择有效的月份！")
		form.m.focus()
		return false
	}
	var d = new Date()
	if ( y == d.getYear() && m > (d.getMonth() + 1) ) {
		alert("您选择的月份尚没有任何文章，请重新选择！")
		form.m.focus()
		return false
	}
	if ( m < 10 ) m = "0" + m
	location = sitefolder + "html/arch/" + y + m + ".html"
	return false
}
function resizepic() {
	var pic = document.getElementById("pic")
	var img = document.getElementById("tpic")
	if ( img != null ) {
		var pshow = document.getElementById("pshow")
		var u = document.getElementById("purl")
		if ( pshow == null ) return
		if ( u == null ) return
		var w = pshow.width
		var h = pshow.height
		var m = 600
		if ( w > m ) {
			h = Math.floor(m / w * h)
			w = m
			img.innerHTML = "<a href=\"" + u + "\"><img src=\"" + pshow.src + "\" width=\"" + w + "\" height=\"" + h + "\" alt=\"" + pshow.alt + "\" \/></a><br \/><a href=\"http://www.arsenal.com.cn/html/images.html?" + pshow.src + "|" + pshow.alt + "\" target=\"_blank\">您看到的图片可能是按一定比例显示的，点击这里察看原图<\/a> <a href=\"" + u + "\">点击图片浏览下一张<\/a>"
		}
	}
	if ( pic != null ) {
		var pshow = document.getElementById("pshow")
		if ( pshow == null ) return
		var w = pshow.width
		var h = pshow.height
		var m = 600
		if ( w > m ) {
			h = Math.floor(m / w * h)
			w = m
			pic.innerHTML = "<a href=\"http://www.arsenal.com.cn/html/images.html?" + pshow.src + "|" + pshow.alt + "\" target=\"_blank\"><img src=\"" + pshow.src + "\" width=\"" + w + "\" height=\"" + h + "\" alt=\"" + pshow.alt + "\" \/></a><br \/><a href=\"http://www.arsenal.com.cn/html/images.html?" + pshow.src + "|" + pshow.alt + "\" target=\"_blank\">您看到的图片可能是按一定比例显示的，点击这里察看原图<\/a>"
		}
	}
}
function chkvote(form) {
	var vopt = document.getElementById("voption")
	if ( vopt == null ) return false
	var opt = form.option
	if ( opt == null ) return false
	var n = 0
	var etc = "ID=" + form.id.value + "&option="
	for ( var i = 0; i < opt.length; i++ ) {
		if ( opt[i].checked == true ) {
			n++
			etc+=","+opt[i].value
		}
	}
	if ( n < 1 ) {
		alert("您没有作出选择，请重新选择！")
		return false
	}
	var sc = xmlHttp()
	sc.open ("post","http://api.arsenal.com.cn/vote.asp",false);
	sc.setRequestHeader("Content-Length",etc.length);
	sc.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded");
	sc.send(etc)
	var result	= sc.responseText
	if ( result == 1 ) {
		alert("您已经投过票了，不能重复投票！感谢您的支持！")
		return false
	} else if ( result == 2 ) {
		alert("该投票不存在或已被删除，请重试！感谢您的支持！")
		return false
	} else if ( result == 3 ) {
		alert("投票已结束或已被关闭，不能投票！感谢您的支持！")
		return false
	} else if ( result == 4 ) {
		alert("投票已过期！感谢您的支持！")
		return false
	} else {
		vopt.style.display = "none"
		set_cookie("vote" + form.id.value,"ok",1)
		var _arr = result.split("|")
		var _tag = document.getElementById("vresult")
		if ( _tag == null ) {
			alert("投票成功！感谢您的支持！")
			location.reload()
			return false
		}
		var _obj = ""
		_obj+='<div class="rlist"><div class="vtit"><strong>投票结果：</strong></div><div class="clear"></div></div>'
		for ( var i = 2;i < _arr.length; i++ ) {
			_t = _arr[i].split(",")
			_sub = document.getElementById("opt" + _t[0])
			if ( _sub == null ) {
				alert("投票成功！感谢您的支持！")
				location.reload()
				return false
			}
			_obj+='<div class="rlist"><div class="vtit">' + (i - 1) + '、' + _sub.innerHTML + '</div><div class="vrlt" style="width: ' + Math.floor(_t[2]) + 'px;"></div><div class="vtot">' + _t[1] + '(' + _t[2] + '%)</div><div class="clear"></div></div>'
		}
		_obj+='<div class="clear"></div>'
		var _tot = document.getElementById("total")
		_tot.innerHTML = _arr[1]
		_tag.innerHTML = _obj
		alert("投票成功！感谢您的支持！")
	}
	return false
}
function chkvotd(form) {
	var vopt = document.getElementById("ulist")
	if ( vopt == null ) return false
	var opt = form.option
	if ( opt == null ) return false
	var n = 0
	var voted	= get_cookie("vote" + form.id.value)
	if ( voted == "ok" ) {
		alert("您已经投过票了，不能重复投票！感谢您的支持！")
		return false
	}
	var etc = "ID=" + form.id.value + "&option="
	for ( var i = 0; i < opt.length; i++ ) {
		if ( opt[i].checked == true ) {
			n++
			etc+=","+opt[i].value
		}
	}
	if ( n < 1 ) {
		alert("您没有作出选择，请重新选择！")
		return false
	}
	var sc = xmlHttp()
	sc.open ("post","http://api.arsenal.com.cn/vote.asp",false);
	sc.setRequestHeader("Content-Length",etc.length);
	sc.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded");
	sc.send(etc)
	var result	= sc.responseText
	if ( result == 1 ) {
		alert("您已经投过票了，不能重复投票！感谢您的支持！")
		return false
	} else if ( result == 2 ) {
		alert("该投票不存在或已被删除，请重试！感谢您的支持！")
		return false
	} else if ( result == 3 ) {
		alert("投票已结束或已被关闭，不能投票！感谢您的支持！")
		return false
	} else if ( result == 4 ) {
		alert("投票已过期！感谢您的支持！")
		return false
	} else {
		set_cookie("vote" + form.id.value,"ok",1)
		var _arr = result.split("|")
		var _obj = ""
		_obj+='<div class="rlist"><div class="vtitle"><strong>投票结果：</strong>(共' + _arr[1] + '票)</div><div class="clear"></div></div>'
		for ( var i = 2;i < _arr.length; i++ ) {
			_t = _arr[i].split(",")
			_sub = document.getElementById("opt" + _t[0])
			if ( _sub == null ) {
				alert("投票成功！感谢您的支持！")
				location.reload()
				return false
			}
			_obj+='<div class="rlist"><div class="vtitle">' + (i - 1) + '、' + _sub.innerHTML + '</div><div class="vrlt" style="width: ' + Math.floor(_t[2]) + 'px;"></div><div class="vtot">' + _t[1] + '(' + _t[2] + '%)</div><div class="clear"></div></div>'
		}
		_obj+='<div class="clear"></div>'
		vopt.style.display = "none"
		document.getElementById("zlist").innerHTML = _obj
		document.getElementById("zlist").style.display = ""
		alert("投票成功！感谢您的支持！")
	}
	return false
}
function hidvote(id) {
	var vopt = document.getElementById("voption")
	if ( vopt == null ) return
	var voted	= get_cookie("vote" + id)
	if ( voted == "ok" ) vopt.style.display = "none"
}
function addSenToEventHandle(EHObj,insSen){ /*插入语句到已有事件句柄中，返回一个新的Function对象*/ 
	var preSen; 
	if (EHObj!=null){ 
		preSen=EHObj.toString(); 
	}else { 
		preSen=""; 
	} 
	var reg=/^(function +[\w|\$|\.]+ *\([\w|\$|\,|\.]*\) *\{)([\W|\w]*)(\})$/; 
	var preBody=preSen.replace(reg,"$2"); 
	var newFunObj=new Function(preBody+insSen); 
	return newFunObj; 
}
//==========获取cookies
function get_cookie(name) { 
	var arg = name + "="; 
	var alen = arg.length; 
	var clen = document.cookie.length; 
	var i = 0; 
	while (i < clen) { 
		var j = i + alen; 
		if (document.cookie.substring(i, j) == arg) 
		return getCookieVal (j); 
		i = parseInt(document.cookie.indexOf(" ", i)) + 1; 
		if (i == 0) break;
	} 
	return null;
}

function getCookieVal(offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}
//==========设置cookies
function set_cookie(Name,value,d) {
	var expires = new Date();
	expires.setTime(expires.getTime()+1000*24*60*60*d);
	document.cookie = Name + "=" + value + "; path=/; expires=" + expires.toGMTString();
}
//建立xmlhttp对象
function xmlHttp(){
	var obj = null; 
	try{ 
		obj = new ActiveXObject("Msxml2.XMLHTTP") 
	}catch(e){ 
		try{ 
			obj = new ActiveXObject("Microsoft.XMLHTTP") 
		} catch(oc) { 
			obj = null 
		} 
	} 
	if ( !obj && typeof XMLHttpRequest != "undefined" ) obj = new XMLHttpRequest()
	return obj
}
function showflash(url,w,h) {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + w + '" height="' + h + '">')
	document.write('  <param name="movie" value="' + url + '" />')
	document.write('  <param name="quality" value="high" />')
	document.write('  <embed src="' + url + '" width="' + w + '" height="' + h + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>')
	document.write('</object>')
}
function loadflash(pics,links,texts) {
	var focus_width = 280
	var focus_height = 200
	var text_height = 0
	var swf_height = focus_height+text_height
	
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ focus_width +'" height="'+ swf_height +'">');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="movie" value="http://img.arsenal.com.cn/common/focus.swf" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="bgcolor" value="#707070" />');
	document.write('<param name="menu" value="false" />');
	document.write('<param name="wmode" value="opaque" />');
	document.write('<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'" />');
	document.write('<embed src="http://img.arsenal.com.cn/common/focus.swf" wmode="opaque" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'" menu="false" bgcolor="#707070" quality="high" width="'+ focus_width +'" height="'+ swf_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}