var http_request=false;
var loading = "<div id=\"loading\">loading</div>";
var comment_con;

function send_request(obj,url,POSTstr)
{//初始化，指定处理函数，发送请求的函数
	http_request=false;
	//开始初始化XMLHttpRequest对象
	if(window.XMLHttpRequest)
	{
		//Mozilla浏览器
		http_request=new XMLHttpRequest();
		if(http_request.overrideMimeType)
		{

		}
	}
	else if(window.ActiveXObject)
	{
		//IE浏览器
		try
		{
			http_request=new ActiveXObject("Msxml2.XMLHttp");
		}
		catch(e)
		{
			try
			{
				http_request=new ActiveXObject("Microsoft.XMLHttp");
			}
			catch(e){}
		}
	}

	if(!http_request)
	{//异常，创建对象实例失败
		window.alert("创建XMLHttp对象失败！");
		return false;
	}
		http_request.onreadystatechange=processrequest;
		//确定发送请求方式，URL，及是否同步执行下段代码
		http_request.open("POST",url,true);
		http_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		http_request.send(POSTstr);

	}

	//处理返回信息的函数
	function processrequest()
	{
		if(http_request.readyState==4)
		{//判断对象状态
			if(http_request.status==200)
			{//信息已成功返回，开始处理信息
				var requestText = http_request.responseText;
				comment_con.innerHTML = requestText;
			}
			else
			{
				alert("您所请求的页面不正常！");
			}
	}
}


function dopage(obj,url)
{
    comment_con = document.getElementById(obj);
	document.getElementById(obj).innerHTML=loading;
	send_request(document.getElementById(obj),url);
}

//中文字符串加密
function urlencode(text)
{
	text = escape(text.toString()).replace(/\+/g, "%2B");
	var matches = text.match(/(%([0-9A-F]{2}))/gi);
	if (matches)
	{
		for (var matchid = 0; matchid < matches.length; matchid++)
		{
			var code = matches[matchid].substring(1,3);
			if (parseInt(code, 16) >= 128)
			{
				text = text.replace(matches[matchid], '%u00' + code);
			}
		}
	}
	text = text.replace('%25', '%u0025');

	return text;
}
