function xhrobject(id) 
{
	var xhreq = init(); 
	var mydiv = id;
	if(xhreq)
		xhreq.onreadystatechange = processRequest; 
	else
		return;
	
	function init() 
	{
			var xmlhttp;
			try
			{
				xmlhttp = new XMLHttpRequest();
			}
			catch(e)
			{
				var XmlHttpVersions = new Array('MSXML2.XMLHTTP.6.0',
										 		'MSXML2.XMLHTTP.5.0',
										 		'MSXML2.XMLHTTP.4.0',
										 		'MSXML2.XMLHTTP.3.0',
												'MSXML2.XMLHTTP',
												'Microsoft.XMLHTTP');
				for (var i=0; i<XmlHttpVersions.length && !xmlhttp; i++)
				{
					try
					{
						xmlhttp = new ActiveXObject(XmlHttpVersions[i]);
					}
					catch (e)	{}
				}
			}
			if(!xmlhttp)
				alert("你的机器不支持AJAX技术，请更换浏览器");
			else
				return xmlhttp;
	}
	
	function processRequest() 
	{
		if (xhreq.readyState == 4) 
		{ 
			if (xhreq.status == 200) 
			{
				try
				{
					handleServerResponse();
				}
				catch (e)
				{
					alert("Error reading the response:" + e.toString());
				}
			}
			else
			{
				alert("There was a problem retrieving the data:\n" + xhreq.statusText);
			}
		}
		else return;
	}
	
	function handleServerResponse()
	{
		xmlResponse = xhreq.responseText;
		document.getElementById(mydiv).innerHTML = xmlResponse;
	}
	
	this.doPost = function(body)
	{
		xhreq.open("POST", "memo_select.php", true); 
		xhreq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xhreq.send(body);
	}
	
	this.doPostN = function(body)
	{
		xhreq.open("POST", "navi_select.php", true); 
		xhreq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xhreq.send(body);
	}
}

function c_select(key, y_begin, y_end) 
{
	divObject = document.getElementById('content');
	divObject.innerHTML = "数据加载中...";
	var myxhr = new xhrobject('content');
	if(myxhr)
	{
		try
		{
			myxhr.doPost("keyname=" + key + "&y_section_b=" + y_begin + "&y_section_e=" + y_end);
		}
		catch (e)
		{
			alert("Can't connect to server:\n" + e.toString());
		}
	}
}

function n_select(key, flag, tp, cp) 
{
	divObject = document.getElementById('nbleft');
	divObject.nextSibling.innerHTML = "Loading...";
	newcp = flag + cp;
	var myxhr = new xhrobject('nbdiv');
	if(myxhr)
	{
		try
		{
			myxhr.doPostN("keyname=" + key + "&tp=" + tp + "&cp=" + newcp);
		}
		catch (e)
		{
			alert("Can't connect to server:\n" + e.toString());
		}
	}
}

function changebg(handle,param)
{
	if (param == 1)
	{
		handle.style.backgroundColor = '#ffa800';
		handle.style.cursor = 'pointer';
	}
	else
	{
		handle.style.backgroundColor = '';
		handle.style.cursor = 'default';
	}
}

function changestyle(handle,param)
{
	if (param == 1)
	{
		handle.style.color = '#ffa800';
		handle.style.cursor = 'pointer';
	}
	else
	{
		handle.style.color = '';
		handle.style.cursor = 'default';
	}
}