var xmlHttp = null;
try{
	xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(err1){
	try{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	catch(err2){
		xmlHttp = new XMLHttpRequest();
	}
}

String.prototype.trim1 = function(){
	return this.replace(/(^\s*)|(\s*$)/g, "");
}

function check_get(url,strOnHandler){
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange = eval(strOnHandler);
	xmlHttp.send(null);
}

function getRequestBody(sFormItemIds){
	var aFormItemId = sFormItemIds.split(",");
	var aParams=new Array();
	for(var i=0;i<aFormItemId.length;i++){
		var oFormItem=document.getElementsByName(aFormItemId[i]);
		for(var j=0;j<oFormItem.length;j++){
			var sParam=escape(aFormItemId[i]);
			sParam+="=";
			if(oFormItem[j].type.toLowerCase() == "radio" || oFormItem[j].type.toLowerCase() =="checkbox"){
				if(oFormItem[j].checked){
					sParam+=escape(oFormItem[j].value.trim1());
					aParams.push(sParam);
					if(oFormItem[j].type.toLowerCase() == "radio"){break;}
				}
			}
			else{
				sParam+=escape(oFormItem[j].value.trim1());
				aParams.push(sParam);
			}
		}
	}
	return aParams.join("&");
}
function check_post(url,strOnHandler,sFormItemIds){
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlHttp.onreadystatechange = eval(strOnHandler);
	var sBody=getRequestBody(sFormItemIds);
	xmlHttp.send(sBody);
}

function check_comment(){
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status==200){ 
			var isValid = xmlHttp.responseText;
			if(isValid == "新闻不存在"){
				alert("你要发表评论的新闻不存在！");
			}
			else if(isValid == "不允许评论"){
				alert("该新闻不允许评论！");
			}
			else if(isValid == "姓名为空"){
				alert("非匿名发表，姓名不能为空！");
			}
			else if(isValid == "评论内容为空"){
				alert("你要发表评论的内容不能为空！");
			}
			else if(isValid == "系统错误"){
				alert("程序系统出错误！");
			}
			else if(isValid == "操作出错"){
				alert("你操作出错了！");
			}
			else{
				if(isValid == "等待审核"){
					alert("成功发表评论！\n请等待审核员审核通过...");
				}
				else{
					alert("成功发表评论！");
				}
				document.getElementById("commentname").value = "";
				document.getElementById("comment").value = "";
				var objCommentTable = document.getElementById("CommentTable");
				objCommentTable.style.display = "";
				var objCommentFrame = document.getElementById("commentframe");
				objCommentFrame.contentWindow.freash_page();
			}
		} 
		else{
			alert("抱歉，装载数据失败。原因：" + xmlHttp.statusText);
		} 
	}
}

function check_comment_delete(){
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status==200){ 
			var isValid = xmlHttp.responseText;
			if(isValid == "无权删除"){
				alert("你无权删除此评论！");
			}
			else if(isValid == "评论不存在"){
				alert("你要删除的评论不存在！");
			}
			else if(isValid == "系统错误"){
				alert("程序系统出错误！");
			}
			else if(isValid == "操作出错"){
				alert("你操作出错了！");
			}
			else{
				alert("成功删除评论！");
				var objCommentFrame = document.getElementById("commentframe");
				objCommentFrame.contentWindow.freash_page();
			}
		} 
		else{
			alert("抱歉，装载数据失败。原因：" + xmlHttp.statusText);
		} 
	}
}

function check_comment_auditing(){
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status==200){ 
			var isValid = xmlHttp.responseText;
			if(isValid == "无权审核"){
				alert("你无权审核此评论！");
			}
			else if(isValid == "评论不存在"){
				alert("你要删除的评论不存在！");
			}
			else if(isValid == "系统错误"){
				alert("程序系统出错误！");
			}
			else if(isValid == "操作出错"){
				alert("你操作出错了！");
			}
			else{
				if(isValid == "成功取消审核"){
					alert("成功取消审核此评论！");
				}
				else{
					alert("成功通过审核此评论！");
				}
				var objCommentFrame = document.getElementById("commentframe");
				objCommentFrame.contentWindow.freash_page();
			}
		} 
		else{
			alert("抱歉，装载数据失败。原因：" + xmlHttp.statusText);
		} 
	}
}

function check_papergather(){
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status==200){ 
			var isValid = xmlHttp.responseText;
			if(isValid == "选择日期未发行期刊" || isValid == "期刊已经装载"){
				document.getElementById("loading").innerHTML=isValid;
				setTimeout("hidden_login_dialogBox();",2000);
			}
			else{
				document.location.replace(isValid);
			}
		} 
		else{
			//alert("抱歉，装载数据失败。原因：" + xmlHttp.statusText);
			document.getElementById("loading").innerHTML="抱歉，装载数据失败。";
			setTimeout("hidden_login_dialogBox();",2000);
		} 
	}
}

function check_papergetdate(){
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status==200){ 
			var isValid = xmlHttp.responseText;
			newCalendar(isValid);
			hidden_login_dialogBox();
		} 
		else{
			//alert("抱歉，装载数据失败。原因：" + xmlHttp.statusText);
			document.getElementById("loading").innerHTML="抱歉，装载数据失败。";
			setTimeout("hidden_login_dialogBox();",2000);
		} 
	}
}

function check_paperspace(){
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status==200){ 
			var isValid = xmlHttp.responseText;
			if(isValid == "选择版面不存在" || isValid == "版面已经装载"){
				document.getElementById("loading1").innerHTML=isValid;
				setTimeout("hidden_login_dialogBox1();",2000);
			}
			else{
				document.getElementById("PaperPreviewTd").innerHTML=isValid;
			}
		} 
		else{
			//alert("抱歉，装载数据失败。原因：" + xmlHttp.statusText);
			document.getElementById("loading1").innerHTML="抱歉，装载数据失败。";
			setTimeout("hidden_login_dialogBox1();",2000);
		} 
	}
}

function hidden_login_dialogBox(){
	document.getElementById("dialogBoxDisabled").style.display="none";
	document.getElementById("loading").style.display="none";
}
function hidden_login_dialogBox1(){
	document.getElementById("dialogBoxDisabled1").style.display="none";
	document.getElementById("loading1").style.display="none";
}
