// AJAX
function GetXMLHTTP()
{
	try {
		xmlhttpc = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	try {
		xmlhttpc = new ActiveXObject("Microsoft.XMLHTTP");
	} catch (e2) {
		xmlhttpc = false;
	}
	}
	if (!xmlhttpc && typeof XMLHttpRequest != 'undefined') {
		xmlhttpc = new XMLHttpRequest();
	}
	if (!xmlhttpc) {
		alert("无法创建XMLHttp对象!");
	}
	else
	{
		return xmlhttpc;
	}
}

function pop_announce(nodeid,id,weburl)
{ 
	if(nodeid == "" || id == "") {
	    alert("参数有误,查看公告信息失败!");
		return false
	}
	xmlhttp = GetXMLHTTP();
	URL = weburl+"/d/announce.php?&n="+nodeid+"&id="+id;
	xmlhttp.open("GET",URL);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlhttp.onreadystatechange = callback_announce;
	xmlhttp.send(null);
}

function callback_announce() 
{
    var backmsg = "";
		if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200))
		{
		    if(xmlhttp.responseText == "error") {
		        alert("获取数据时出错!");
				return false;
			}else if(xmlhttp.responseText == ""){
		        alert("没有取得需要的数据,请与管理员联系!");
				return false;
		    }else{
				backmsg = xmlhttp.responseText;
			}
			
			document.getElementById("pop_ann").style.display = '';
	        document.getElementById("pop_ann").innerHTML = backmsg ;
			delete(xmlhttp);
		}
}

function copycontent(nodeid,downid,jointime,weburl)
{ 
	if(nodeid == "" || downid == "") {
	    alert("参数有误,获取失败!");
		return false
	}
	xmlhttp = GetXMLHTTP();
	URL = weburl+"/d/axaj.php?mod=download&n="+nodeid+"&id="+downid+"&time="+jointime;
	xmlhttp.open("GET",URL);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlhttp.onreadystatechange = callback_copycontent;
	xmlhttp.send(null);
}

function callback_copycontent() 
{
    var backmsg = "";
		if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200))
		{
		    if(xmlhttp.responseText == "error") {
		        alert("获取数据时出错!");
				return false;
			}else if(xmlhttp.responseText == ""){
		        alert("没有取得需要的数据,请与管理员联系!");
				return false;
		    }else{
				backmsg = xmlhttp.responseText;
			}
			window.clipboardData.setData('Text',backmsg); 
			alert("己成功复制到简贴板!");
			delete(xmlhttp);
		}
}

function downvote(nodeid,downid,poll,weburl)
{ 
	if(downid == "" || poll == "") {
	    alert("参数有误,投票失败!");
		return false
	}
	xmlhttp = GetXMLHTTP();
	URL = weburl+"/d/axaj.php?mod=downvote&n="+nodeid+"&id="+downid+"&poll="+poll;
	xmlhttp.open("GET",URL);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlhttp.onreadystatechange = downvote_copycontent;
	xmlhttp.send(null);
}

function downvote_copycontent() 
{
    var backmsg = "";
		if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200))
		{
		    if(xmlhttp.responseText == "error") {
		        alert("投票出错!");
				return false;
			}else if(xmlhttp.responseText == ""){
		        alert("没有取得需要的数据,请与管理员联系!");
				return false;
		    }else{
				backmsg = xmlhttp.responseText;
			}
			if (backmsg == "1")
			{
				if (document.getElementById("good_count"))
				{
					document.getElementById("good_count").innerHTML = parseInt(document.getElementById("good_count").innerHTML)+1;
				}
				alert("投票成功!");
				return true;
			}else if(backmsg == "2") {
				if (document.getElementById("bad_count"))
				{
					document.getElementById("bad_count").innerHTML = parseInt(document.getElementById("bad_count").innerHTML)+1;
				}
				alert("投票成功!");
				return true;
			}else if(backmsg == "3") {
			    alert("您己经投过票了!");
			}
			delete(xmlhttp);
		}
}