var xmlHttp
var currCtrl
var ips

//显示异步信息
function showData(urls,ctrl)
{
	if (urls.length==0)
	{ 
		document.getElementById(ctrl).innerHTML="";
		return;
	}
	ips = urls.split("=")[2];
	currCtrl = ctrl;
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("do not support ajax.");
		return;
	} 
	var url = urls;
	xmlHttp.onreadystatechange = stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
} 
function stateChanged()
{ 
	if (xmlHttp.readyState==4)
	{ 
		try
		{
			if(navigator.userAgent.indexOf("MSIE") != -1)
			{
				// IE
				document.getElementById(currCtrl).innerHTML = Trim(bs2str(xmlHttp.responseBody));
			}
			else
			{
				// Fire Fox
				//document.getElementById(currCtrl).innerHTML = Trim(xmlHttp.responseBody);
				document.getElementById(currCtrl).innerHTML = ips ;
			}
		}
		catch (e)
		{
			alert(e);
		}
	}
}

//专为显示IP详细地址定制的函数，短地址
function showShortIpData(urls,ctrl)
{
	if (urls.length==0)
	{ 
		document.getElementById(ctrl).innerHTML="";
		return;
	}
	currCtrl = ctrl;
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("do not support ajax.");
		return;
	} 
	var url = urls;
	xmlHttp.onreadystatechange = stateChangedShortIp;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
} 

function stateChangedShortIp()
{ 
	// 如果不是IE，不应用新特性
	if(navigator.userAgent.indexOf("MSIE") <= -1) return;
	document.getElementById(currCtrl).innerHTML = "Loading..";
	if (xmlHttp.readyState==4)
	{ 
		try
		{
			if(navigator.userAgent.indexOf("MSIE") != -1)
			{
				document.getElementById(currCtrl).innerHTML = Trim(bs2str(xmlHttp.responseBody)).split(" ")[0];
			}
			else
			{
				document.getElementById(currCtrl).innerHTML = Trim(xmlHttp.responseBody).split(" ")[0];
			}
		}
		catch (e)
		{
			alert(e);
		}
	}
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}
function bs2str(str)
{
	if(!bs2str.ss) bs2str.ss = [];
	return unescape(escape(jsMidB(str,1)).replace(/..(..)(..)/g, "%$2%$1").replace(/%(\D.)%(..)/g,function(a,a1,a2){var s=a1+a2;if(!bs2str.ss[s]) return bs2str.ss[s]=jsChr("&h"+s);return bs2str.ss[s];}));
}

function SetValue(ctrl,val)
{
	try
	{
		document.getElementById(ctrl).innerHTML = val;
	}
	catch(e)
	{
	}
}

function LTrim(str) 
{ 
	var i; 
	for(i=0;i<str.length;i++) 
	{ 
		if(str.charAt(i)!=" "&&str.charAt(i)!=" ")break; 
	} 
	str=str.substring(i,str.length); 
	return str; 
} 
function RTrim(str) 
{ 
	var i; 
	for(i=str.length-1;i>=0;i--) 
	{ 
		if(str.charAt(i)!=" "&&str.charAt(i)!=" ")break; 
	} 
	str=str.substring(0,i+1); 
	return str; 
} 
function Trim(str) 
{ 
	return LTrim(RTrim(str)); 
} 
function URLenc(strEnc){
var strR='';
for (var i=0; i<strEnc.length;i++ )
{
	strR += '&#' +strEnc.charCodeAt(i) + ';';
}
return strR;
}