var http_request = false;
//返回目标所出现地span_id
var span_id = "";

function makeRequest(url) 
{
	http_request = false;

	if (window.XMLHttpRequest) 
	{   // code for Mozilla, etc.
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) 
		{
			http_request.overrideMimeType('text/xml');
		}
	} 
	else if (window.ActiveXObject) 
	{ // code for IE 
		try 
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) 
		{
			try 
			{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (e) 
			{}
		}
	}

	if (!http_request) 
	{
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}

	http_request.onreadystatechange = showContents;
	http_request.open('GET', url, true);
	http_request.send(null);
}

function showContents() 
{
	if (http_request.readyState == 4) 
	{// if complete
		if (http_request.status == 200) 
		{
			//if "OK"		
			if(span_id) document.getElementById(span_id).innerHTML = http_request.responseText;	
		} 
		else 
		{
			alert('There was a problem with the request.');
		}
	}

}

function AjaxOption(TargetUrl, TargetID)
{
	if(TargetID) span_id = TargetID;
	
	url = TargetUrl;
	makeRequest(url);

}
function checkItem(target_url,checked_id,target_id,warn_lang){
	String.prototype.trim = function ()  
	{ 
		return this.replace(/(^[\s]*)|([\s]*$)/g, ""); 
	}; 
	if(!warn_lang) warn_lang='This Is Empty!';
	username=document.getElementById(checked_id).value.trim();
	if(!username){
		alert(warn_lang);
		return false;
	}else{
		thisurl=target_url+username;
		AjaxOption(thisurl,target_id);
	}
}
function setAttribute(target_url,target_id){
	AjaxOption(target_url,target_id);
}
