/**
* Ajax client
*
* @version 2.0
*/
function AjaxClient()
{
    try {
		this.connectionHandler = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			this.connectionHandler = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (oc) {
			this.connectionHandler = null;
		}
	}
	if(!this.connectionHandler && typeof XMLHttpRequest != "undefined")
		this.connectionHandler = new XMLHttpRequest();

    this.requestFile    = "";
}

AjaxClient.prototype.SendRequest = function( )
{
    this.connectionHandler.open( "POST", this.requestFile, true );
    this.connectionHandler.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

    _ajaxClientGlobalInstance = this;
    this.connectionHandler.onreadystatechange = function()
    {
		if (_ajaxClientGlobalInstance.connectionHandler.readyState != 4)
			return;

		var xmlData     = _ajaxClientGlobalInstance.connectionHandler.responseXML;
		var textData    = _ajaxClientGlobalInstance.connectionHandler.responseText;

        if( _ajaxClientGlobalInstance.connectionHandler.status == 404 )
        {
            alert('404: Response Script Not Found');
        }
        else
        {
		    _ajaxClientGlobalInstance.callbackFunction(xmlData, textData);
        }
	}
    this.postData = "";
    if( _ajaxClientGlobalInstance.SendRequest.arguments )
    {
        for (i = 0; i < _ajaxClientGlobalInstance.SendRequest.arguments.length; i++)
        {
	        this.postData = this.postData + "&args[]=" + escape(_ajaxClientGlobalInstance.SendRequest.arguments[i]);
        }
    }
    this.connectionHandler.send( this.postData );
}

AjaxClient.prototype.GetXMLNodeValue = function( node, key )
{
	if( node )
	{
		if( node.getElementsByTagName( key ) )
		{
			if( node.getElementsByTagName( key )[0] )
			{
				if( node.getElementsByTagName( key )[0].firstChild )
				{
					return node.getElementsByTagName( key )[0].firstChild.nodeValue;
				}
			}
		}
	}
	return '';
}