﻿//-------创建Ajax--------
var xmlHttp;
if (window.ActiveXObject){
  var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
  var xmlHttp = new XMLHttpRequest();
}

//-------显示URL页内容--------
function AjaxShow(url){
	xmlHttp.open("get", url, true);
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-Length",length);
	xmlHttp.onreadystatechange = AjaxShowReadyStateChange;
	xmlHttp.send();
}
function AjaxShowReadyStateChange(){
	if (xmlHttp.readyState == 4){
		if (xmlHttp.status == 200){
			AjaxShowAskSearchLoad.innerHTML=(xmlHttp.ResponseText);
  		}
  	}
}

//-------显示子菜单--------
function AjaxClassSelect(url){
	xmlHttp.open("get", url, false);
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-Length",length);
	xmlHttp.send();
	
	AjaxClassSelectLoad.innerHTML="<img border=0 src=loading.gif> 数据加载中,请稍后...";
	if (xmlHttp.readyState == 4){
		AjaxClassSelectLoad.innerHTML=xmlHttp.ResponseText;
  	}else{
  		alert("数据加载失败, 请刷新页面!");
  	}
}

//-------支持反对--------
function PostData(Url,DivId,Numb){

	xmlHttp.open("get", Url, false);
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-Length",length);
	xmlHttp.send();
	
	eval(DivId).innerHTML=Numb+1;
}

//-------举报提问--------
function ImpeachPostAsk(Url,DivId,Numb){
	if (Number(eval(DivId).innerHTML)==Numb){
		reason = prompt("请注明举报原因","");
		if (reason!=null && reason!=0)
		{
			var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
			xmlDoc.async="false";
			xmlDoc.load(Url+"&ImpeachdCause="+encodeURIComponent(reason));
			root = xmlDoc.documentElement;
			alert(xmlDoc.getElementsByTagName("Message")[0].childNodes[0].xml);

			eval(DivId).innerHTML=Numb+1;
		}
	}else{
		alert("您已经举报过此问题了！");
	}
}

//-------举报回复--------
function ImpeachPost(Url,DivId,Numb){
	if (Number(eval(DivId).innerHTML)==Numb){
		reason = prompt("请注明举报原因","");
		if (reason!=null && reason!=0)
		{
			var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
			xmlDoc.async="false";
			xmlDoc.load(Url+"&ImpeachdCause="+encodeURIComponent(reason));
			root = xmlDoc.documentElement;
			alert(xmlDoc.getElementsByTagName("Message")[0].childNodes[0].xml);

			eval(DivId).innerHTML=Numb+1;
		}
	}else{
		alert("您已经举报过此回复了！");
	}
}

//-------显示BBS--------未使用
function ShowBBS(url){
	xmlHttp.open("get", url, false);
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-Length",length);
	xmlHttp.onreadystatechange = ShowBBSReadyStateChange;
	xmlHttp.send();
}
function ShowBBSReadyStateChange(){
	if (xmlHttp.readyState == 4){
		if (xmlHttp.status == 200){
			ShowBbsData.innerHTML=(xmlHttp.ResponseText);
		}
  	}
}

//-------添加文章到收藏夹--------未使用
function AddFavorite(Url,TitleStr){
	var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
	xmlDoc.async="false";
	xmlDoc.load(Url+"&TableTitle="+encodeURIComponent(TitleStr));
	root = xmlDoc.documentElement;
	alert(xmlDoc.getElementsByTagName("Message")[0].childNodes[0].xml);
}