var FCKXml = function()
{}
function escapeHTML(text) {
text=text.replace('\n','');
text=text.replace('&','&');
text=text.replace('<','<');
text=text.replace('>','>');
return text;
}
 FCKXml.prototype.GetHttpRequest = function()
{
	if ( window.XMLHttpRequest )// Gecko
	return new XMLHttpRequest() ;
	else if ( window.ActiveXObject )// IE
	return new ActiveXObject("MsXml2.XmlHttp") ;
}
 
FCKXml.prototype.PostUrl = function( urlToCall, postString , asyncFunctionPointer,funcParam )
{
	var oFCKXml = this ;
	var bAsync = ( typeof(asyncFunctionPointer) == 'function' ) ;
	var oXmlHttp = this.GetHttpRequest() ;
	oXmlHttp.open( "GET", urlToCall, bAsync ) ;
	if ( bAsync )
	{
		oXmlHttp.onreadystatechange = function() 
		{
			if ( oXmlHttp.readyState == 4 )
			{
			result = oXmlHttp.responseText; //你可以自行换成oXmlHttp.responseXML,那么就是xml对象了。
			oFCKXml.DOMDocument = oXmlHttp.responseXML ;
			//alert(result);
			asyncFunctionPointer( result,funcParam ) ;
			}
		}
	}
	if (this.debug==1)alert(postString);
	oXmlHttp.setRequestHeader(  "CONTENT-TYPE","application/x-www-form-urlencoded");
	oXmlHttp.send( postString ) ;

	if ( ! bAsync )
	this.DOMDocument = oXmlHttp.responseXML ;
	}

	FCKXml.prototype.LoadUrl = function( urlToCall, asyncFunctionPointer,funcParam )
	{
		var oFCKXml = this ;
		var bAsync = ( typeof(asyncFunctionPointer) == 'function' ) ;
		var oXmlHttp = this.GetHttpRequest() ;
		oXmlHttp.open( "GET", urlToCall, bAsync ) ;
		if ( bAsync )
		{
			oXmlHttp.onreadystatechange = function() 
			{
				if ( oXmlHttp.readyState == 4 )
				{
					result = oXmlHttp.responseText; //你可以自行换成oXmlHttp.responseXML,那么就是xml对象了。
					oFCKXml.DOMDocument = oXmlHttp.responseXML ;
					//alert(oXmlHttp.responseXML.documentElement.xml);
					asyncFunctionPointer( result,funcParam ) ;
				}
			}
		}

		oXmlHttp.send( null ) ;

		if ( ! bAsync )
		this.DOMDocument = oXmlHttp.responseXML ;
	}

FCKXml.prototype.SelectNodes = function( xpath )
{
if ( document.all )// IE
return this.DOMDocument.selectNodes( xpath ) ;
else// Gecko
{
var aNodeArray = new Array();

var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument, 
this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), XPathResult.ORDERED_NODE_ITERATOR_TYPE, null) ;
if ( xPathResult ) 
{
var oNode = xPathResult.iterateNext() ;
 while( oNode )
 {
 aNodeArray[aNodeArray.length] = oNode ;
 oNode = xPathResult.iterateNext();
 }
} 
return aNodeArray ;
}
}

FCKXml.prototype.SelectSingleNode = function( xpath ) 
{
//alert( xpath + '=--' + this.DOMDocument.selectSingleNode( xpath ) +this.DOMDocument );
if ( document.all )// IE
return this.DOMDocument.selectSingleNode( xpath ) ;
else// Gecko
{
var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument,
this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), 9, null);

if ( xPathResult && xPathResult.singleNodeValue )
return xPathResult.singleNodeValue ;
else
return null ;
}
}
/* 
调用方法：
<script type='text/javascript'>
var oXML=new FCKXml();
var nowdate=new Date();
oXML.LoadUrl("default.asp?&nowdate="+nowdate,function(res){alert(res);},"");
</script>
*/
; 
