//ajaxlogin
function initxmlhttp()
{
  var xmlhttp
  try {
    xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
   } catch (e) {
     try {
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
     } catch (E) {
        xmlhttp=false;
     }
  }
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
        try {
                xmlhttp = new XMLHttpRequest();
        } catch (e) {
                xmlhttp=false;
        }
}
if (!xmlhttp && window.createRequest) {
        try {
                xmlhttp = window.createRequest();
        } catch (e) {
                xmlhttp=false;
        }
}
  return xmlhttp;
}

function CheckLogin(name,pass) {
	var xmlhttp=initxmlhttp();
	xmlhttp.open("post", "/users/ajax_ShowLoginMessage.asp", true);
	xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		xmlhttp.onreadystatechange = function(){
		if(xmlhttp.readyState == 4){
			if(xmlhttp.status == 200){
				if(xmlhttp.responseText=='userandpasserror'){
					alert("非法登陆，请确认密码的正确性！\n或者已经被管理员锁定！");
					document.getElementById("ajaxlogin").innerHTML='我心依旧用户登陆:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:CloseDiv()">关闭</a><br /><table width="230" border="0" align="center" cellpadding="0" cellspacing="5"><tr class="txt"><td><div align="center" class="td"><font color="#000000">用户名</font> <input name="MemName" type="text" class="input" id="MemName" style="CURSOR: hand"></div></td></tr><tr class="txt"> <td> <div align="center" class="td"><font color="#000000">密　码</font> <input name="Password" type="Password" class="input" id="MemPassword" style="CURSOR: hand"></div></td></tr><tr><td><div align="center"><a href="/Users/Register.asp" class="txt">免费注册</a>&nbsp;<a href="/Users/User_GetPassword.asp" class="txt">忘记密码</a>&nbsp;<input type="button" name="Submit" value="登陆" onclick="CheckLogindata();"></div></td></tr></table>';

					return;
				}
				if(xmlhttp.responseText==0){
					alert("出现异常请联系管理员：webmaster@5719.cn");
					return;
				}
			document.getElementById("ajaxlogin").innerHTML='<div id="ajaxlogin">我心依旧用户登陆：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:CloseDiv()">关闭</a><br /><br /><br /><div align="center">登陆成功!<br />2秒钟后本窗口自动关闭</div></div>';
			setTimeout("CloseDiv()",2000);
			results = xmlhttp.responseText.split('|');
			document.getElementById("rbox").innerHTML= results[0];
			document.getElementById("Username").value=results[1];
			document.getElementById("Password").value=results[2];
			document.getElementById("NoName").checked=false;
			}
		}else{
				document.getElementById("ajaxlogin").innerHTML='<div id="ajaxlogin">我心依旧用户登陆：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:CloseDiv()">关闭</a><br /><br /><br /><div align="center">请稍后,数据提交中……</div></div>';
				}
	} 
	xmlhttp.send("MemName="+escape(name)+"&Password="+pass+"&action=Check");
}

function ShowLoginMessage(){
	var xmlhttp=initxmlhttp();
	xmlhttp.open("get", "/users/ajax_ShowLoginMessage.asp", true);
		xmlhttp.onreadystatechange = function(){
		if(xmlhttp.readyState == 4) {
			if(xmlhttp.status == 200 ||xmlHttp2.status == 500) {
				if(xmlhttp.responseText!=0){
					results = xmlhttp.responseText.split('|');
					document.getElementById("rbox").innerHTML= results[0];
				}
			}
		}
	}
	xmlhttp.send(null);	
}

function LetOut(){
	var xmlhttp=initxmlhttp();
	xmlhttp.open("get", "/users/Comm/ajax_LetOut.asp", true);
		xmlhttp.onreadystatechange = function(){
		if(xmlhttp.readyState == 4) {
			if(xmlhttp.status == 200 ||xmlHttp2.status == 500) {
				if(xmlhttp.responseText=='YES'){
					results = xmlhttp.responseText.split('|');
					document.getElementById("rbox").innerHTML= results[0];
				}
			}
		}
	}
	xmlhttp.send(null);	
}

var newsid;
var boxs;
function adddiv(){
			var e;
			e=document.createElement("span"); 
			e.id="info";
			e.innerHTML="";
			document.getElementById("review_form").appendChild(e);
			return e;
}
//新标准的评论加载函数
function loadComment(newid) {
	newsid=newid;
	var xmlHttp=initxmlhttp();
		if(boxs==null)
		{
			boxs=adddiv();
		}
	xmlHttp.open("get","/ajax_ReviewContent.asp?Newsid="+newid,true);
	xmlHttp.setRequestHeader("Cache-Control","no-cache");
		xmlHttp.onreadystatechange=function(){
		if(xmlHttp.readyState == 4) {
			if(xmlHttp.status == 200) {
				var content = xmlHttp.responseText.split('|');
				document.getElementById("comm_content").innerHTML= content[0];
				boxs.innerHTML='';
				if(content[1]==""){
					document.getElementById("NoName").checked=true;
					}else{
					ShowLoginMessage();
					document.getElementById("Username").value=content[1];
					document.getElementById("Password").value=content[2];
				}
			}
		}else{
					boxs.innerHTML='<div id="loader">评论加载中……</div>'; 
			}
	}
	xmlHttp.send(null);
}
function ShowContentPl(newid) {
	newsid=newid;
	var xmlHttp=initxmlhttp();
		if(boxs==null)
		{
			boxs=adddiv();
		}
	xmlHttp.open("get","/ajax_ReviewContent_old.asp?Newsid="+newid,true);
	xmlHttp.setRequestHeader("Cache-Control","no-cache");
		xmlHttp.onreadystatechange=function(){
		if(xmlHttp.readyState == 4) {
			if(xmlHttp.status == 200) {
				var content = xmlHttp.responseText.split('|');
				document.getElementById("comm_content").innerHTML= content[0];
				boxs.innerHTML='';
				if(content[1]==""){
					document.getElementById("NoName").checked=true;
					}else{
					ShowLoginMessage();
					document.getElementById("Username").value=content[1];
					document.getElementById("Password").value=content[2];
				}
			}
		}else{
					boxs.innerHTML='<div id="loader">评论加载中……</div>'; 
			}
	}
	xmlHttp.send(null);
}
//新的标准的添加评论函数
function commSubmit(newid) {
	var xmlHttp=initxmlhttp();
	var name,pass,noname,content
	if(boxs==null)
		{
			boxs=adddiv();
		}
	name=document.getElementById("Username").value;
	pass=document.getElementById("Password").value;
	noname=document.getElementById("NoName").checked;
	content=document.getElementById("RevContent").value;
	if(name=='' && noname==false)
	{
		alert("请填写用户名或者钩选'匿名'选框！");
		return;
	}
	if(content.length<5)
	{
		alert("评论内容应该在5个字以上!");
		return;
	}
	document.getElementsByName("Submit")[0].disabled=true; 
	xmlHttp.open("post", "/ajax_AddNewsReview.asp", true);
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		xmlHttp.onreadystatechange = function() {
		if(xmlHttp.readyState == 4) {
			if(xmlHttp.status == 200) {
				if(xmlHttp.responseText=="YES"){
					boxs.innerHTML='<div id="loader">评论提交成功!</div>'; 
					loadComment(newid);
					boxs.innerHTML='';
					document.getElementById("RevContent").value="";
					document.getElementsByName("Submit")[0].disabled=false;
				}else if(xmlHttp.responseText=="NO"){
					alert("你填写的内容中有非法内容!\n我站不允许评论中包含网址等非法信息!");
					boxs.innerHTML='';
					document.getElementById("RevContent").value="";
					document.getElementsByName("Submit")[0].disabled=false;
				}else if(xmlHttp.responseText=="time"){
					alert("错误：两次评论的间隔不得少于半分钟,请稍后在评论!");
					boxs.innerHTML='';
					document.getElementById("RevContent").value="";
					document.getElementsByName("Submit")[0].disabled=false;
				}else if(xmlHttp.responseText=="error"){
					alert("错误：没有这个用户,或者密码错误，请重新填写！");
					boxs.innerHTML='';
					document.getElementById("RevContent").value="";
					document.getElementsByName("Submit")[0].disabled=false;
					}

				}
			}else {
			boxs.innerHTML='<div id="loader">评论处理中 ...</div>'; 
		} 
	}
	xmlHttp.send("action=add&NewsID="+newid+"&MemName="+escape(name)+"&Password="+pass+"&NoName="+noname+"&RevContent="+escape(content));
}
function CheckAddcomm(newid) {
	var xmlHttp=initxmlhttp();
	var name,pass,noname,content
	if(boxs==null)
		{
			boxs=adddiv();
		}
	name=document.getElementById("Username").value;
	pass=document.getElementById("Password").value;
	noname=document.getElementById("NoName").checked;
	content=document.getElementById("RevContent").value;
	if(name=='' && noname==false)
	{
		alert("请填写用户名或者钩选'匿名'选框！");
		return;
	}
	if(content.length<5)
	{
		alert("评论内容应不少于5个字符!");
		return;
	}
	document.getElementsByName("Submit")[0].disabled=true; 
	xmlHttp.open("post", "/ajax_AddNewsReview_old.asp", true);
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		xmlHttp.onreadystatechange = function() {
		if(xmlHttp.readyState == 4) {
			if(xmlHttp.status == 200) {
				if(xmlHttp.responseText=="YES"){
					boxs.innerHTML='<div id="loader">评论提交成功!</div>'; 
					loadComment(newid);
					boxs.innerHTML='';
					document.getElementById("RevContent").value="";
					document.getElementsByName("Submit")[0].disabled=false;
				}else if(xmlHttp.responseText=="NO"){
					alert("你填写的内容中有非法内容!\n我站不允许评论中包含网址等非法信息!");
					boxs.innerHTML='';
					document.getElementById("RevContent").value="";
					document.getElementsByName("Submit")[0].disabled=false;
				}else if(xmlHttp.responseText=="time"){
					alert("错误：两次评论的间隔不得少于2分钟,请稍后在评论!");
					boxs.innerHTML='';
					document.getElementById("RevContent").value="";
					document.getElementsByName("Submit")[0].disabled=false;
				}else if(xmlHttp.responseText=="error"){
					alert("错误：没有这个用户,或者密码错误，请重新填写！");
					boxs.innerHTML='';
					document.getElementById("RevContent").value="";
					document.getElementsByName("Submit")[0].disabled=false;
					}

				}
			}else {
			boxs.innerHTML='<div id="loader">评论处理中 ...</div>'; 
		} 
	}
	xmlHttp.send("action=add&NewsID="+newid+"&MemName="+name+"&Password="+pass+"&NoName="+noname+"&RevContent="+content);
}


var docEle = function() {
  return document.getElementById(arguments[0]) || false;
}
function openNewDiv(_id,m) {
  if (docEle(_id)) document.removeChild(docEle(_id));
  if (docEle(m)) document.removeChild(docEle(m));
  // 新激活图层
  var newDiv = document.createElement("div");
  newDiv.id = _id;
  newDiv.style.position = "absolute";
  newDiv.style.zIndex = "9999";
  newDiv.style.width = "270px";
  newDiv.style.height = "150px";
  newDiv.style.top = "150px";
  newDiv.style.left = (parseInt(document.body.scrollWidth) - 300) / 2 + "px"; // 屏幕居中
  newDiv.style.background = "#EFEFEF";
  newDiv.style.border = "1px solid #fff3f5";
  newDiv.style.padding = "5px";
  newDiv.innerHTML = '<div id="ajaxlogin">我心依旧用户登陆：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:CloseDiv()">关闭</a><br /><table width="230" border="0" align="center" cellpadding="0" cellspacing="5"><tr class="txt"><td><div align="center" class="td"><font color="#000000">用户名</font> <input name="MemName" type="text" class="input" id="MemName" style="CURSOR: hand"></div></td></tr><tr class="txt"> <td> <div align="center" class="td"><font color="#000000">密　码</font> <input name="Password" type="Password" class="input" id="MemPassword" style="CURSOR: hand"></div></td></tr><tr><td><div align="center"><a href="/Users/Register.asp" class="txt">免费注册</a>&nbsp;<a href="/Users/User_GetPassword.asp" class="txt">忘记密码</a>&nbsp;<input type="button" name="Submit" value="登陆" onclick="CheckLogindata();"></div></td></tr></table></div>';
  document.body.appendChild(newDiv);
  // mask图层
  var newMask = document.createElement("div");
  newMask.id = m;
  newMask.style.position = "absolute";
  newMask.style.zIndex = "1";
  newMask.style.width = document.body.scrollWidth + "px";
  newMask.style.height = document.body.scrollHeight + "px";
  newMask.style.top = "0px";
  newMask.style.left = "0px";
  newMask.style.background = "#333";
  newMask.style.filter = "alpha(opacity=20)";
  newMask.style.opacity = "0.40";
  document.body.appendChild(newMask);
}
function CloseDiv(){
   document.body.removeChild(docEle('newDiv'));
   document.body.removeChild(docEle('mask'));
  }
function ajax_login(){
	//openNewDiv('newDiv','mask');
	window.open("http://www.5719.cn/member/login.php");
}
function CheckLogindata() 
{
	var name=document.getElementById("MemName").value;
	var pass=document.getElementById("MemPassword").value;
	if(name =="" ) {
	alert("请输入用户名！")
	LoginForm.MemName.focus()
	return false;
}
	if(pass =="" ) {
	alert("请输入密码！")
	LoginForm.Password.focus()
	return false;
}
CheckLogin(name,pass);
}
function killErrors() {
return true;
}
window.onerror = killErrors;
