function checkComment() {
  if (commentform.content.value == "")
  {
    alert("评论内容不能为空！");
    commentform.content.focus();
    return false;
  }
  return true;
}

var objXml;
function getCommentList(p,id,flag)
{
	if (window.ActiveXObject)
		objXml = new ActiveXObject("Microsoft.XMLHTTP");
	else if (window.XMLHttpRequest)
		objXml = new XMLHttpRequest();
	
	var rnd = (new Date()).getTime();
	objXml.onreadystatechange = getComment_handle;
	objXml.open("GET", "/cgi/get_comment_list.php?id="+id+"&flag="+flag+"&rnd="+rnd+"&p="+p, true);
	objXml.send(null);
}

function getComment_handle()
{
	if (objXml.readyState == 4)
    {
        if (objXml.status == 200)
        {
            var result = objXml.responseText;
            document.getElementById("comment_list").innerHTML = result;
        }
    }
}

var sortid,objectid,title,from;
function addFavourite(sortid,objectid,title,from)
{
	this.sortid = sortid;
	this.objectid = objectid;
	this.title = title;
	this.from = from;

	if (window.ActiveXObject)
		objXml = new ActiveXObject("Microsoft.XMLHTTP");
	else if (window.XMLHttpRequest)
		objXml = new XMLHttpRequest();
	
	var rnd = (new Date()).getTime();
	objXml.onreadystatechange = getFavourite_handle;
	objXml.open("GET", "/cgi/has_login.php?rnd="+rnd, true);
	objXml.send(null);
}

function getFavourite_handle()
{
	if (objXml.readyState == 4)
	{
		if (objXml.status == 200)
		{
			var result = objXml.responseText;
			if (result.indexOf("YES") > -1)
				addFavourite2();
			else
				window.location = "/cgi/login_tmp.php?from="+from;
		}
	}
}

function addFavourite2()
{
	if (window.ActiveXObject)
		objXml = new ActiveXObject("Microsoft.XMLHTTP");
	else if (window.XMLHttpRequest)
		objXml = new XMLHttpRequest();
	
	var rnd = (new Date()).getTime();
	objXml.onreadystatechange = getFavourite_handle2;
	objXml.open("GET", "/cgi/add_favourite.php?objectid="+objectid+"&rnd="+rnd+"&t="+sortid+"&title="+escape(title), true);
	objXml.send(null);
}

function getFavourite_handle2()
{
	if (objXml.readyState == 4)
	{
		if (objXml.status == 200)
		{
			var result = objXml.responseText;
			if (result.indexOf("YES") > -1)
				alert("加入收藏成功！");
			else
				alert("您已收藏过该信息！");
		}
	}
}

var uid,username,top_y;
function sendMessage(uid,username,from)
{
	this.uid = uid;
	this.username = username;
	this.from = from;
	this.top_y = document.documentElement.scrollTop + (document.documentElement.clientHeight-370)/2;

	if (window.ActiveXObject)
		objXml = new ActiveXObject("Microsoft.XMLHTTP");
	else if (window.XMLHttpRequest)
		objXml = new XMLHttpRequest();
	
	var rnd = (new Date()).getTime();
	objXml.onreadystatechange = getMessage_handle;
	objXml.open("GET", "/cgi/has_login.php?rnd="+rnd, true);
	objXml.send(null);
}

function getMessage_handle()
{
	if (objXml.readyState == 4)
	{
		if (objXml.status == 200)
		{
			var result = objXml.responseText;
			if (result.indexOf("YES") > -1)
				sendMessage2();
			else
				window.location = "/cgi/login_tmp.php?from="+from;
		}
	}
}

function sendMessage2()
{
	if (window.ActiveXObject)
		objXml = new ActiveXObject("Microsoft.XMLHTTP");
	else if (window.XMLHttpRequest)
		objXml = new XMLHttpRequest();
	
	var rnd = (new Date()).getTime();
	objXml.onreadystatechange = getMessage_handle2;
	objXml.open("GET", "/cgi/message_form.php?rnd="+rnd+"&uid="+uid+"&username="+username, true);
	objXml.send(null);

}

function getMessage_handle2()
{
	if (objXml.readyState == 4)
	{
		if (objXml.status == 200)
		{
			var result = objXml.responseText;
			document.getElementById("mask_div").style.display = "";
			document.getElementById("message_div").style.top = top_y;
			document.getElementById("message_div").innerHTML = result;
			document.getElementById("message_div").style.display = "";
		}
	}
}

function sendSms(uid,from,username)
{
	this.uid = uid;
	this.from = from;
	this.username = username;
	this.top_y = document.documentElement.scrollTop + (document.documentElement.clientHeight-370)/2;

	if (window.ActiveXObject)
		objXml = new ActiveXObject("Microsoft.XMLHTTP");
	else if (window.XMLHttpRequest)
		objXml = new XMLHttpRequest();
	
	var rnd = (new Date()).getTime();
	objXml.onreadystatechange = getSms_handle;
	objXml.open("GET", "/cgi/has_login.php?rnd="+rnd, true);
	objXml.send(null);
}

function getSms_handle()
{
	if (objXml.readyState == 4)
	{
		if (objXml.status == 200)
		{
			var result = objXml.responseText;
			if (result.indexOf("YES") > -1)
				sendSms2();
			else
				window.location = "/cgi/login_tmp.php?from="+from;
		}
	}
}

function sendSms2()
{
	if (window.ActiveXObject)
		objXml = new ActiveXObject("Microsoft.XMLHTTP");
	else if (window.XMLHttpRequest)
		objXml = new XMLHttpRequest();
	
	var rnd = (new Date()).getTime();
	objXml.onreadystatechange = getSms_handle2;
	objXml.open("GET", "/cgi/sms_form.php?rnd="+rnd+"&uid="+uid+"&username="+username, true);
	objXml.send(null);

}

function getSms_handle2()
{
	if (objXml.readyState == 4)
	{
		if (objXml.status == 200)
		{
			var result = objXml.responseText;
			document.getElementById("mask_div").style.display = "";
			document.getElementById("sms_div").style.top = top_y;
			document.getElementById("sms_div").innerHTML = result;
			document.getElementById("sms_div").style.display = "";
		}
	}
}
