/**
* Classes included in this file:
*     Ajax
*     SoapParameters
* Files required by this file:
*     None
**/
//Object.Serialize = function(obj)
//{
//    /// <summary modifiers="public static">Serializes the current object into a standardized XML format that can be easily deserialized back into a javascript object. This method is recursive.</summary>
//    /// <param name="obj" type="Object" optional="false">The object to serialize. Can be null.</param>
//    /// <returns type="String">The object serialized as an XML string.</returns>
//    var v_xml = '';
//    if (obj == null)
//        return '';

//    switch (typeof obj)
//    {
//        case 'function': break;
//        case 'string': v_xml += obj.toString().replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;'); break;
//        case 'number': v_xml += obj.toString(); break;
//        case 'boolean': v_xml += obj.toString(); break;
//        case 'object':
//            if (typeof obj.Serialize == 'function')
//                v_xml += obj.Serialize();

//            else if (obj.constructor.toString().indexOf('function Date()') > -1)
//            {
//                var v_year = obj.getFullYear().toString();
//                var v_month = (obj.getMonth() + 1).toString(); v_month = (v_month.length == 1) ? '0' + v_month : v_month;
//                var v_date = obj.getDate().toString(); v_date = (v_date.length == 1) ? '0' + v_date : v_date;
//                var v_hours = obj.getHours().toString(); v_hours = (v_hours.length == 1) ? '0' + v_hours : v_hours;
//                var v_minutes = obj.getMinutes().toString(); v_minutes = (v_minutes.length == 1) ? '0' + v_minutes : v_minutes;
//                var v_seconds = obj.getSeconds().toString(); v_seconds = (v_seconds.length == 1) ? '0' + v_seconds : v_seconds;
//                var v_milliseconds = obj.getMilliseconds().toString();
//                var v_tzminutes = Math.abs(obj.getTimezoneOffset());
//                var v_tzhours = 0;
//                while (v_tzminutes >= 60)
//                {
//                    v_tzhours++;
//                    v_tzminutes -= 60;
//                }
//                v_tzminutes = v_tzminutes.toString(); (v_tzminutes.length == 1) ? '0' + v_tzminutes : v_tzminutes;
//                v_tzhours = v_tzhours.toString(); (v_tzhours.length == 1) ? '0' + v_tzhours : v_tzhours;
//                var v_timezone = ((obj.getTimezoneOffset() < 0) ? '+' : '-') + v_tzhours + ':' + v_tzminutes;
//                v_xml += v_year + '-' + v_month + '-' + v_date + 'T' + v_hours + ':' + v_minutes + ':' + v_seconds + '.' + v_milliseconds + v_timezone;
//            }
//            else if (obj.constructor.toString().indexOf('function Array()') > -1)
//            {
//                for (var v_index in obj)
//                {
//                    if (!isNaN(v_index)) // linear array
//                    {
//                        (/function\s+(\w*)\s*\(/ig).exec(obj[v_index].constructor.toString());
//                        var v_type = RegExp.$1;
//                        switch (v_type)
//                        {
//                            case '': v_type = typeof obj[v_index]; break;
//                            case 'String': v_type = 'string'; break;
//                            case 'Number': v_type = 'int'; break;
//                            case 'Boolean': v_type = 'bool'; break;
//                            case 'Date': v_type = 'DateTime'; break;
//                        }
//                        v_xml += '<' + v_type + '>' + Object.Serialize(obj[v_index]) + '<\/' + v_type + '>';
//                    }
//                    else
//                        v_xml += '<' + v_index + '>' + Object.Serializet(obj[v_index]) + '<\/' + v_index + '>'; // associative array
//                }
//            }
//            else
//            {
//                for (var v_name in obj)
//                    v_xml += '<' + v_name + '>' + Object.Serialize(obj[v_name]) + '<\/' + v_name + '>';
//            }
//            break;
//        default: break;
//    }
//    return v_xml;
//}
//Object.Deserialize = function(xmlNode, type)
//{
//    /// <summary modifiers="public static">Deserializes a XML node into a javascript object. This method is recursive.</summary>
//    /// <param name="xmlNode" type="XmlDOMNode" optional="false">The XML node to deserialize. Can be null.</param>
//    /// <param name="type"    type="String"     optional="true">The type name of the object to deserialize the XML into. Defaults to "string". Can be null.</param>
//    /// <returns type="Object">The object deserialized from the specified XML node, or null if the XML node is null.</returns>
//    if (xmlNode == null)
//        return null;

//    var v_type_defined = type != undefined && type != null;
//    if (xmlNode.nodeType == 3 || xmlNode.nodeType == 4)
//    {
//        var v_value = xmlNode.nodeValue;
//        if (v_type_defined)
//        {
//            switch (type.toLowerCase())
//            {
//                default:
//                case 'string': return v_value != null ? String(v_value) + '' : '';
//                case 'boolean': return v_value == 'true';
//                case 'short':
//                case 'int':
//                case 'long': return (v_value != null) ? parseInt(v_value, 10) : 0;
//                case 'float':
//                case 'double': return (v_value != null) ? parseFloat(v_value) : 0;
//                case 'datetime':
//                    if (v_value == null || v_value.length <= 0)
//                        return null;
//                    else
//                    {
//                        v_value = v_value.substring(0, (v_value.lastIndexOf('.') == -1 ? v_value.length : v_value.lastIndexOf('.')));
//                        v_value = v_value.replace(/T/gi, ' ');
//                        v_value = v_value.replace(/-/gi, '/');
//                        return new Date(Date.parse(value));
//                    }
//            }
//        }
//        return v_value != null ? String(v_value) + '' : '';
//    }
//    if (xmlNode.childNodes.length == 1 && (xmlNode.childNodes[0].nodeType == 3 || xmlNode.childNodes[0].nodeType == 4))
//        return Object.Deserialize(xmlNode.childNodes[0], type);

//    var v_is_array = false; //!v_type_defined ? false : type.toLowerCase().indexOf('arrayof') != -1;
//    var v_obj = v_is_array ? [] : (xmlNode.hasChildNodes() ? {} : null);
//    for (var i = 0; i < xmlNode.childNodes.length; i++)
//    {
//        var v_node = xmlNode.childNodes[i];
//        var v_type = v_type_defined ? type[v_node.nodeName] : null;
//        v_obj[v_is_array ? i : v_node.nodeName] = Object.Deserialize(v_node, v_type);
//    }
//    return v_obj;
//}
///*******************************************************************************/
//function SoapParameters()
//{
//    /// <summary modifiers="public sealed" type="class">Represents the paramaters for a function call of a SOAP method.</summary>
//}
//SoapParameters.prototype.GetType = function()
//{
//    /// <summary modifiers="public">Gets the current object type.</summary>
//    /// <returns type="String">The current object type.</returns>
//    return 'SoapParameters';
//}
//SoapParameters.prototype.GetHashCode = function()
//{
//    /// <summary modifiers="public">Gets a hash code that represents this object instance.</summary>
//    /// <returns type="String">A hash code that represents this object instance.</returns>
//    return this.ToString();
//}
//SoapParameters.prototype.ToString = function()
//{
//    /// <summary modifiers="public">Gets a string that represents this object instance.</summary>
//    /// <returns type="String">A string that represents this object instance.</returns>
//    var t = this, v_string = '[Object: SoapParameters] { ';
//    for (var v_name in t)
//    {
//        if (typeof t[v_name] != 'function' && t[v_name] != undefined)
//            v_string += v_name + ' : ' + t[v_name].toString() + ', ';
//    }
//    return v_string.substr(0, v_string.length - 2) + ' }';
//}
//SoapParameters.prototype.toString = function()
//{
//    /// <summary modifiers="public">Gets a string that represents this object instance.</summary>
//    /// <returns type="String">A string that represents this object instance.</returns>
//    return this.ToString();
//}
//SoapParameters.prototype.ToXml = function()
//{
//    /// <summary modifiers="public">Gets a XML string that represents the serialized version of this object.</summary>
//    /// <returns type="String">A XML string that represents the serialized version of this object.</returns>
//    return Object.Serialize(this);
//}
//SoapParameters.prototype.Add = function(name, value)
//{
//    /// <summary modifiers="public">Adds a parameter to the <see cref="SoapParameters"/> instance.</summary>
//    /// <param name="name"  type="String">The name of the parameter to add.</param>
//    /// <param name="value" type="Object">The value of the parameter. Can be null.</param>
//    /// <returns type="SoapParameters">The <see cref="SoapParameters"/> instance that had the parameter added, returned so that calls may be chained.</returns>
//    this[name] = value;
//    return this;
//}
//SoapParameters.prototype.Remove = function(name)
//{
//    /// <summary modifiers="public">Removes the specified parameter from the <see cref="SoapParameters"/> instance.</summary>
//    /// <param name="name" type="String">The name of the parameter to remove.</param>
//    /// <returns type="SoapParameters">The <see cref="SoapParameters"/> instance that had the parameter removed, returned so that calls may be chained.</returns>
//    this[name] = undefined;
//    return this;
//}
//SoapParameters.Create = function(paramObject)
//{
//    /// <summary modifiers="public">Creates the <see cref="SoapParameters"/> object from the specified object, ussually a JSON object.</summary>
//    /// <param name="paramObject" type="Object">An object that represents the <see cref="SoapParameters"/>.</param>
//    /// <returns type="SoapParameters">The <see cref="SoapParameters"/> object.</returns>
//    var v_sp = new SoapParameters();
//    for (var v_name in paramObject)
//    {
//        if (typeof (paramObject[v_name]) != 'function')
//            v_sp.Add(v_name, paramObject[v_name]);
//    }
//    return v_sp;
//}
///*******************************************************************************/
function Ajax(mimeType, async)
{
    /// <summary modifiers="public sealed" type="class">Represents a global cross-browser interface that can be used for making AJAX calls.</summary>
    /// <param name="mimeType" type="String"  optional="true">The MIME type to use for AJAX requests made with this object. Defaults to "text/xml". Can be null.</param>
    /// <param name="async"    type="Boolean" optional="true">A value indicating if the AJAX calls should be asyncronus. Defaults to true.</param>
    /// <field name="MimeType"              type="String"  modifiers="public">Gets or sets the MIME type used to make the AJAX requests.</field>
    /// <field name="Async"                 type="Boolean" modifiers="public">Gets or sets a value indicating if the AJAX calls made should be asyncronus.</field>
    /// <field name="IENSCustom"            type="String"  modifiers="public static">Gets or sets the custom XML namespaces to use when loading a WSDL file.</field>
    /// <field name="_IEProgId"             type="String"  modifiers="private static">Internal field used for the IE XML HTTP request ActiveXObject.</fi
    /// <field name="_SoapWdslCache"        type="Object"  modifiers="private static">Internal field used for SOAP calls.</field>
    /// <field name="_SoapMethodTypesCache" type="Object"  modifiers="private static">Internal field used for SOAP calls.</field>
    this.MimeType = mimeType ? mimeType : 'text/xml';
    this.Async = async || async == undefined ? true : false;
}
Ajax.prototype.GetType = function()
{
    /// <summary modifiers="public">Gets the current object type.</summary>
    /// <returns type="String">The current object type.</returns>
    return 'Ajax';
}
Ajax.prototype.GetHashCode = function()
{
    /// <summary modifiers="public">Gets a hash code that represents this object instance.</summary>
    /// <returns type="String">A hash code that represents this object instance.</returns>
    return 'Ajax';
}
Ajax.prototype.ToString = function()
{
    /// <summary modifiers="public">Gets a string that represents this object instance.</summary>
    /// <returns type="String">A string that represents this object instance.</returns>
    return '[Object: Ajax]';
}
Ajax.prototype.toString = function()
{
    /// <summary modifiers="public">Gets a string that represents this object instance.</summary>
    /// <returns type="String">A string that represents this object instance.</returns>
    return this.ToString();
}
Ajax.prototype.Execute = function(url, params, callback, useGetMethod, identifier)
{
    /// <summary modifiers="public">Performs an AJAX request to the specified URL using the specified parameters.</summary>
    /// <param name="url"          type="String"       optional="false">The URL to send the AJAX request to.</param>
    /// <param name="params"       type="String"       optional="true">Parameters to send with the AJAX request. Can be null.</param>
    /// <param name="callback"     type="AjaxCallback" optional="true">A callback method that is called when the AJAX request is completed. Only called if <see cref="Ajax.Async"/> is true. Can be null.</param>
    /// <param name="useGetMethod" type="Boolean"      optional="true">A value indicating if the GET method should be used instead of the POST method. Defaults to false.</param>
    /// <param name="identifier"   type="Object"       optional="true">An object that identifies the AJAX request. Can be null.</param>
    /// <returns type="String">If <see cref="Ajax.Async"/> is true, returns null, otherwise returns the response HTML string of the AJAX call.</returns>
    var t = this, v_xmlhttp = new Ajax.XmlHttpWrapper(t.MimeType, t.Async, String(url), identifier);
    if (t.Async)
        v_xmlhttp.XmlHttp.onreadystatechange = function()
        {
            if (v_xmlhttp.XmlHttp.readyState == 4)
                __StateChangedCallback();
        };

    v_xmlhttp.Send(String(params), useGetMethod);
    if (!t.Async)
        return __StateChangedCallback();

    function __StateChangedCallback()
    {
        var v_status = 0, v_response = '';
        try
        {
            v_status = v_xmlhttp.XmlHttp.status;
            v_response = v_xmlhttp.XmlHttp.responseText;
        }
        catch (e)
        {
            v_status = 500;
            v_response = e.toString();
        }
        if (!v_xmlhttp.Async)
        {
            if (v_status != 200)
                throw new Error(v_status, v_response);
            return v_response;
        }
        else if (typeof callback == 'function')
            callback(v_status == 200, v_response, v_status, identifier);
        return null;
    }
    return null;
}
Ajax.prototype.SubmitForm = function(formObject, url, callback, useGetMethod, identifier, skipNamesArray)
{
    /// <summary modifiers="public">Performs an AJAX request to the specified URL by converting all of the form elements of the specified form DOM object into the parameters that are passed to the AJAX call.</summary>
    /// <param name="formObject"     type="HtmlDOMElement" optional="false">The HTML DOM element that contains the form elements to submit. Does not have to be a DOM form, can be any DOM element.</param>
    /// <param name="url"            type="String"         optional="false">The URL to send the AJAX request to.</param>
    /// <param name="callback"       type="AjaxCallback"   optional="true">A callback method that is called when the AJAX request is completed. Only called if <see cref="Ajax.Async"/> is true. Can be null.</param>
    /// <param name="useGetMethod"   type="Boolean"        optional="true">A value indicating if the GET method should be used instead of the POST method. Defaults to false.</param>
    /// <param name="identifier"     type="Object"         optional="true">An object that identifies the AJAX request. Can be null.</param>
    /// <param name="skipNamesArray" type="Array"          optional="true">An array of form element names to skip over (not send with the AJAX call). Can be null.</param>
    /// <returns type="String">If <see cref="Ajax.Async"/> is true, returns null, otherwise returns the response HTML string of the AJAX call.</returns>
    return this.Execute(url, Ajax.ParseFormValues(formObject, skipNamesArray), callback, useGetMethod, identifier);
}
Ajax.__SAFARI_IFRAME_ID = 'safari_submit_file_form';
Ajax.prototype.SubmitFileForm = function(formObject, url, callback, identifier)
{
    /// <summary modifiers="public">Performs an AJAX request to the specified URL by submitting the specified form object. This call is always done asynchronously. The AJAX call is performed in a way that a file upload can be performed with the AJAX request.</summary>
    /// <param name="formObject" type="HtmlDOMForm"  optional="false">The HTML DOM form to submit.</param>
    /// <param name="url"        type="String"       optional="false">The URL to send the AJAX request to.</param>
    /// <param name="callback"   type="AjaxCallback" optional="true">A callback method that is called when the AJAX request is completed. Can be null.</param>
    /// <param name="identifier" type="Object"       optional="true">An object that identifies the AJAX request. Can be null.</param>
    var v_frame = document.getElementById(Ajax.__SAFARI_IFRAME_ID);
    if (v_frame == null || v_frame == undefined)
    {
        var v_name = 'f_' + Math.floor(Math.random() * 99999), v_frame_div = document.createElement('div');
        v_frame_div.setAttribute('id', v_name + '_div');
        v_frame_div.innerHTML = '<iframe style="display: none;" src="about:blank" id="' + v_name + '" name="' + v_name + '" onload="Ajax._FileFormLoaded(\'' + v_name + '\', false);"></iframe>';
        document.body.appendChild(v_frame_div);
        v_frame = document.getElementById(v_name);
    }
    else
        v_frame.onload = function() { Ajax._FileFormLoaded(Ajax.__SAFARI_IFRAME_ID, true); };

    v_frame.Identifier = identifier;
    v_frame.Callback = callback;
    var v_original_target = formObject.target, v_original_action = formObject.action;
    formObject.target = v_frame.id;
    formObject.action = url;
    formObject.submit();
    formObject.target = v_original_target;
    formObject.action = v_original_action;
}
Ajax._FileFormLoaded = function(frameName, isSafari)
{
    /// <summary modifiers="private static">Internal callback method used by <see cref="Ajax.SubmitFileForm"/>.</summary>
    var v_response_doc = null, v_frame = document.getElementById(frameName);
    if (v_frame.contentDocument)
        v_response_doc = v_frame.contentDocument;

    else if (v_frame.contentWindow)
        v_response_doc = v_frame.contentWindow.document;

    else
        v_response_doc = window.frames[frameName].document;

    var v_response = '';
    try
    {
        v_response = v_response_doc.location.href == 'about:blank' ? '' : v_response_doc.body.innerHTML;
    }
    catch (e) { }
    if (typeof v_frame.Callback == 'function')
        v_frame.Callback(true, v_response, 200, v_frame.Identifier);

    if (!isSafari)
        setTimeout('document.body.removeChild(document.getElementById("' + frameName + '_div"));', 1);
}
//Ajax.prototype.ExecuteSoapMethod = function(url, method, params, callback, identifier)
//{
//    /// <summary modifiers="public">Executes a SOAP method call. This function will only work with SOAP calls that are on the same domain that this script is run from.</summary>
//    /// <param name="url"        type="String"         optional="false">The URL of the SOAP call.</param>
//    /// <param name="method"     type="String"         optional="false">The name of the method to call.</param>
//    /// <param name="params"     type="SoapParameters" optional="true">The parameters to pass to the method. Can be null.</param>
//    /// <param name="callback"   type="AjaxCallback"   optional="true">A callback method that is called when the SOAP call is completed. Only called if <see cref="Ajax.Async"/> is true. Can be null.</param>
//    /// <param name="identifier" type="Object"         optional="true">An object that identifies the SOAP call. Can be null.</param>
//    /// <returns type="Object">If <see cref="Ajax.Async"/> is true, returns null, otherwise returns the result of the SOAP method call.</returns>
//    var t = this, v_wdsl = Ajax.LoadWsdl(url);
//    var v_name_space = (v_wdsl.documentElement.attributes['targetNamespace'] == undefined) ? v_wdsl.documentElement.attributes.getNamedItem('targetNamespace').nodeValue : v_wdsl.documentElement.attributes['targetNamespace'].value;
//    var v_soap_xml = '<?xml version="1.0" encoding="utf-8"?>'
//		+ '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'
//		+ '<soap:Body>'
//		+ '<' + method + ' xmlns="' + v_name_space + '">'
//		+ params.ToXml()
//		+ '<\/' + method + '><\/soap:Body><\/soap:Envelope>';

//    var v_xmlhttp = new Ajax.XmlHttpWrapper('text/xml', String(url), t.Async, identifier);
//    if (t.Async)
//        v_xmlhttp.XmlHttp.onreadystatechange = function()
//        {
//            if (v_xmlhttp.XmlHttp.readyState == 4)
//                __StateChangedCallback();
//        };

//    var v_soap_action = ((v_name_space.lastIndexOf('/') != v_name_space.length - 1) ? v_name_space + '/' : v_name_space) + method;
//    v_xmlhttp.XmlHttp.open('POST', v_xmlhttp.Url, t.Async);
//    v_xmlhttp.XmlHttp.setRequestHeader('SOAPAction', v_soap_action);
//    v_xmlhttp.XmlHttp.setRequestHeader('Content-Type', 'text/xml; charset=utf-8');
//    v_xmlhttp.XmlHttp.send(v_soap_xml);
//    if (!t.Async)
//        return __StateChangedCallback();

//    function __StateChangedCallback()
//    {
//        var v_status = 0;
//        var v_response = null;
//        try
//        {
//            v_status = v_xmlhttp.XmlHttp.status;
//        }
//        catch (e)
//        {
//            v_status = 500;
//            v_response = e.toString();
//            if (!v_xmlhttp.Async)
//                throw new Error(v_status, v_response);
//        }

//        if (v_status == 200)
//        {
//            var v_nodes = null;
//            try
//            {
//                v_nodes = v_xmlhttp.XmlHttp.responseXML.selectNodes(".//*[local-name()=\"" + method + "Result\"]");
//            }
//            catch (e)
//            {
//                v_nodes = v_xmlhttp.XmlHttp.responseXML.getElementsByTagName(method + 'Result');
//            }
//            if (v_nodes == null || v_nodes.length == 0)
//            {
//                if (v_xmlhttp.XmlHttp.responseXML.getElementsByTagName('faultcode').length > 0)
//                {
//                    v_response = v_xmlhttp.XmlHttp.responseXML.getElementsByTagName('faultstring')[0].childNodes[0].nodeValue;
//                    if (!v_xmlhttp.Async)
//                        throw new Error(v_status, v_response);
//                }
//                else
//                {
//                    v_status = 500;
//                    v_response = 'An error occured when retriving the webservice results set.';
//                    if (!v_xmlhttp.Async)
//                        throw new Error(v_status, v_response);
//                }
//            }
//            else
//                v_response = Object.Deserialize(v_nodes[0], Ajax._GetReturnTypeArrayFromWsdl(method, v_wdsl));
//        }

//        if (!v_xmlhttp.Async)
//            return v_response;

//        else if (typeof callback == 'function')
//            callback(v_status == 200, v_response, v_status, v_xmlhttp.Id);

//        return null;
//    }
//    return null;
//}
///*******************************************************************************/
// XML HTTP object wrapper helper class.
Ajax.XmlHttpWrapper = function(mimeType, async, url, id)
{
    /// <summary modifiers="private sealed" type="class">Internal helper class that represents a single AJAX call.</summary>
    /// <params name="mimeType" type="String"  optional="false">The MIME type to use for the AJAX request.</param>
    /// <params name="async"    type="Boolean" optional="false">A value indicating if the AJAX request will be asyncronus.</param>
    /// <params name="url"      type="string"  optional="false">The URL to send the AJAX request to.</param>
    /// <params name="id"       type="Object"  optional="false">An object that identifies the AJAX request. Can be null.</param>
    /// <field name="Id"      type="Object"         modifiers="public">Gets or sets object that identifies the AJAX request.</field>
    /// <field name="Async"   type="Boolean"        modifiers="public">Gets or sets a value indicating if the AJAX call should be asyncronus.</field>
    /// <field name="Url"     type="String"         modifiers="public">Gets or sets the URL of the AJAX call.</field>
    /// <field name="XmlHttp" type="XMLHttpRequest" modifiers="public">Gets the XMLHttpRequest (or the ActiveXObject in IE) that performs the AJAX call.</field>
    var t = this;
    t.Id = id;
    t.Async = async;
    t.Url = url;
    t.XmlHttp = Ajax.GetXmlHttpObject(mimeType);
}
Ajax.XmlHttpWrapper.prototype.GetType = function()
{
    /// <summary modifiers="public">Gets the current object type.</summary>
    /// <returns type="String">The current object type.</returns>
    return 'Ajax.XmlHttpWrapper';
}
Ajax.XmlHttpWrapper.prototype.GetHashCode = function()
{
    /// <summary modifiers="public">Gets a hash code that represents this object instance.</summary>
    /// <returns type="String">A hash code that represents this object instance.</returns>
    return this.Id + this.Url;
}
Ajax.XmlHttpWrapper.prototype.toString = function()
{
    /// <summary modifiers="public">Gets a string that represents this object instance.</summary>
    /// <returns type="String">A string that represents this object instance.</returns>
    return this.ToString();
}
Ajax.XmlHttpWrapper.prototype.ToString = function()
{
    /// <summary modifiers="public">Gets a string that represents this object instance.</summary>
    /// <returns type="String">A string that represents this object instance.</returns>
    return '[Object: Ajax.XmlHttpWrapper]';
}
Ajax.XmlHttpWrapper.prototype.Send = function(params, useGetMethod)
{
    /// <summary modifiers="public">Sends the AJAX request.</summary>
    /// <params name="params"       type="String"  optional="true">The parameters to send with the AJAX call. Must be in an URI encoded string format. Can be null.</param>
    /// <params name="useGetMethod" type="Boolean" optional="true">A value indicating if the GET method should be used instead of the POST method. Defautls to false.</param>
    var t = this, v_method = useGetMethod ? 'GET' : 'POST';
    if (v_method == 'POST')
    {
        t.XmlHttp.open(v_method, t.Url, t.Async);
        t.XmlHttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
        t.XmlHttp.setRequestHeader('Content-length', params.length);
        t.XmlHttp.setRequestHeader('Connection', 'close');
        t.XmlHttp.send(params);
    }
    else
    {
        var v_url_string = t.Url;
        if (params != null && params.length > 0)
            v_url_string += '?' + params;

        t.XmlHttp.open(v_method, v_url_string, t.Async);
        t.XmlHttp.send('');
    }
}
/*******************************************************************************/
// Global static methods/members.
Ajax._IEProgId = '';
Ajax.GetXmlHttpObject = function(mimeType)
{
    /// <summary modifiers="public static">Gets the browser independent XML HTTP request object that can be used to make AJAX calls.</summary>
    /// <params name="mimeType" type="String" optional="true">The MIME type to use for AJAX calls made with the XML HTTP request object. Can be null. Not used with IE.</param>
    /// <returns type="XMLHttpRequest">The XML HTTP request object (ActiveXObject for IE).</returns>
    if (window.ActiveXObject)
    {
        if (Ajax._IEProgId != '')
            return new ActiveXObject(Ajax._IEProgId);

        var v_ieprogids = ['Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP'];
        for (var i = 0; i < v_ieprogids.length; i++)
        {
            try
            {
                var v_xmlhttp = new ActiveXObject(v_ieprogids[i]);
                Ajax._IEProgId = v_ieprogids[i];
                return v_xmlhttp;
            }
            catch (e) { }
        }
    }
    else if (window.XMLHttpRequest)
    {
        var v_xmlhttp = new XMLHttpRequest();
        if (typeof (mimeType) == 'string' && mimeType.length > 0 && v_xmlhttp.overrideMimeType)
            v_xmlhttp.overrideMimeType(mimeType);

        // Some versions of Mozilla do not support the readyState property and the onreadystate event so we patch it!
        if (v_xmlhttp.readyState == null)
        {
            v_xmlhttp.readyState = 1;
            v_xmlhttp.addEventListener('load', function() { v_xmlhttp.readyState = 4; if (typeof (v_xmlhttp.onreadystatechange) == 'function') { v_xmlhttp.onreadystatechange(); } return; }, false);
        }
        return v_xmlhttp;
    }
    alert('Your browser does not fully support the technology used on this page. Some features may not work the way they were intended to.');
    return null;
}
Ajax.ExecuteScript = function(element)
{
    /// <summary modifiers="public static">Looks for all HTML SCRIPT tags that are contained within the specified element and executes the javascript contained in the SCRIPT tags. This method is recursive.</summary>
    /// <params name="element" type="HtmlDOMElement" optional="false">The HTML DOM element to parse. Can be null.</param>
    if (element == null)
        return;

    if (element.tagName == 'SCRIPT')
    {
        eval(element.innerHTML.replace('//<![CDATA[', '').replace('//]]>', ''));
        return;
    }

    for (var i = 0; i < element.childNodes.length; i++)
        Ajax.ExecuteScript(element.childNodes[i]);
}
Ajax.ParseFormValues = function(htmlElement, skipNamesArray)
{
    /// <summary modifiers="public static">Converts all form elements within the specified HTML DOM element into an URI encoded name => value string. This method is recursive.</summary>
    /// <params name="htmlElement"    type="HtmlDOMElement" optional="false">The HTML DOM element to parse. Can be null.</param>
    /// <params name="skipNamesArray" type="Array"          optional="true">An array of form element names to skip. Can be null.</param>
    /// <returns type="String">An URI encoded name => value string that represents all of the form elements inside the specified HTML element.</returns>
    if (htmlElement == null)
        return '';

    if (!Ajax.__CheckIsArray(skipNamesArray))
        skipNamesArray = null;

    var v_params = '';
    for (var i = 0; i < htmlElement.childNodes.length; i++)
    {
        var v_element = htmlElement.childNodes[i];
        if (v_element.tagName == 'INPUT')
        {
            if (Ajax.__CheckSkipNames(skipNamesArray, v_element.name))
                continue;

            if (v_element.type == 'text' || v_element.type == 'hidden' || v_element.type == 'password')
                v_params += encodeURIComponent(v_element.name) + '=' + encodeURIComponent(v_element.value) + '&';

            else if (v_element.type == 'checkbox')
                v_params += encodeURIComponent(v_element.name) + '=' + (v_element.checked ? encodeURIComponent(v_element.value) : '') + '&';

            else if (v_element.type == 'radio')
            {
                if (v_element.checked)
                    v_params += encodeURIComponent(v_element.name) + '=' + encodeURIComponent(v_element.value) + '&';
            }
        }
        else if (v_element.tagName == 'SELECT')
        {
            if (Ajax.__CheckSkipNames(skipNamesArray, v_element.name))
                continue;

            if (v_element.multiple)
            {
                for (var j = 0; j < v_element.options.length; j++)
                {
                    if (v_element.options[j].selected)
                        v_params += encodeURIComponent(v_element.name) + '=' + encodeURIComponent(v_element.options[j].value) + '&';
                }
            }
            else if (v_element.selectedIndex > -1)
                v_params += encodeURIComponent(v_element.name) + '=' + encodeURIComponent(v_element.options[v_element.selectedIndex].value) + '&';
        }
        else if (v_element.tagName == 'TEXTAREA')
        {
            if (Ajax.__CheckSkipNames(skipNamesArray, v_element.name))
                continue;

            v_params += encodeURIComponent(v_element.name) + '=' + encodeURIComponent(v_element.value) + '&';
        }
        else
            v_params += Ajax.ParseFormValues(v_element, skipNamesArray);
    }
    return v_params;
}
Ajax.__CheckIsArray = function(obj)
{
    /// <summary modifiers="private static">Internal method used in <see cref="Ajax.ParseFormValues"/>.</summary>
    if (obj == null || obj == undefined)
        return false;
    return typeof (obj.push) == 'function';
}
Ajax.__CheckSkipNames = function(skipNamesArray, elementName)
{
    /// <summary modifiers="private static">Internal method used in <see cref="Ajax.ParseFormValues"/>.</summary>
    if (skipNamesArray != null)
    {
        for (var i = 0; i < skipNamesArray.length; i++)
        {
            if (skipNamesArray[i] == elementName)
                return true;
        }
    }
    return false;
}
/*******************************************************************************/
// SOAP static methods/members
//Ajax._SoapWdslCache = new Object();
//Ajax._SoapMethodTypesCache = new Object();
//Ajax.IENSCustom = '';
//Ajax.LoadWsdl = function(url)
//{
//    /// <summary modifiers="public static">Loads a WSDL document from the specified URL.</summary>
//    /// <param name="url" type="String" optional="false">The URL to load the WSDL from. The "?wsdl" is added automatically to the URL.</param>
//    /// <returns type="XmlDOMDocument">The WSDL at the specified URL.</returns>
//    var v_wsdl = Ajax._SoapWdslCache[url];
//    if (v_wsdl != undefined)
//        return v_wsdl;

//    var v_xmlhttp = new Ajax.XmlHttpWrapper('text/xml', String(url), false, null);
//    v_xmlhttp.Send('wsdl', true);
//    var v_status = 0;
//    var v_status_text = '';
//    try
//    {
//        v_status = v_xmlhttp.XmlHttp.status;
//        v_status_text = v_xmlhttp.XmlHttp.statusText;
//    }
//    catch (e)
//    {
//        v_status = 500;
//        v_status_text = e.toString();
//    }
//    if (v_status != 200)
//        throw new Error(v_status, v_status_text);

//    v_wsdl = Ajax._SoapWdslCache[url] = v_xmlhttp.XmlHttp.responseXML;
//    return v_wsdl;
//}
//Ajax._GetReturnTypeArrayFromWsdl = function(method, wsdl)
//{
//    /// <summary modifiers="private static">Internal method used in <see cref="Ajax.ExecuteSoapMethod"/>.</summary>
//    if (Ajax._SoapMethodTypesCache[method] != undefined)
//        return Ajax._SoapMethodTypesCache[method];

//    var v_node = Ajax._XpathSelectSingleNode(wsdl, '/wsdl:definitions/wsdl:types/s:schema/s:element[@name="' + method + 'Response"]/s:complexType/s:sequence/s:element[@name="' + method + 'Result"]');
//    Ajax._GetReturnType(wsdl, Ajax._GetXmlElementAttributeValue(v_node, 'type'), Ajax._SoapMethodTypesCache[method]);
//    return Ajax._SoapMethodTypesCache[method];
//}
//Ajax._XpathSelectSingleNode = function(doc, xpath)
//{
//    /// <summary modifiers="private static">Internal method used in <see cref="Ajax.ExecuteSoapMethod"/>.</summary>
//    try // IE
//    {
//        doc.setProperty('SelectionNamespaces', 'xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"' + Ajax.IENSCustom);
//        return doc.selectSingleNode(xpath);
//    }
//    catch(e) // Mozilla
//    {
//        var v_ns_resolver = doc.createNSResolver(doc.ownerDocument == null ? doc.documentElement : doc.ownerDocument.documentElement);
//        var v_response_node = doc.evaluate(xpath, doc, v_ns_resolver, 9, null);
//        return v_response_node.singleNodeValue;
//    }
//}
//Ajax._GetXmlElementAttributeValue = function(element, attributeName)
//{
//    /// <summary modifiers="private static">Internal method used in <see cref="Ajax.ExecuteSoapMethod"/>.</summary>
//    if(element != null && element.nodeType == 1)
//    {
//        if (element.attributes[attributeName] != undefined)
//            return element.attributes[attributeName] == null ? '' : element.attributes[attributeName].value; // Mozilla based browsers.

//        else if (element.attributes.getNamedItem(attributeName) != undefined)
//            return element.attributes.getNamedItem(attributeName) == null ? '' : element.attributes.getNamedItem(attributeName).nodeValue; // IE
//    }
//    return '';
//}
//Ajax._GetReturnType = function(wsdl, type, array)
//{
//    /// <summary modifiers="private static">Internal method used in <see cref="Ajax.ExecuteSoapMethod"/>. This method is recursive.</summary>
//    switch (type)
//    {
//        case 's:string': array = 'string'; break;
//        case 's:bool': array = 'bool'; break;
//        case 's:short': array = 'short'; break;
//        case 's:int': array = 'int'; break;
//        case 's:long': array = 'long'; break;
//        case 's:double': array = 'double'; break;
//        case 's:float': array = 'float'; break;
//        case 's:datetime': array = 'datetime'; break;
//        default:
//            array = {};
//            if (type.indexOf(':') != -1)
//                type = type.substr(type.indexOf(':') + 1, type.length);

//            var v_ct_node = Ajax._XpathSelectSingleNode(wsdl, '/wsdl:definitions/wsdl:types/s:schema/s:complexType[@name="' + type + '"]/s:sequence');
//            for (var i = 0; i < v_ct_node.childNodes.length; i++)
//            {
//                if (v_ct_node.childNodes[i].nodeName == 's:element')
//                {
//                    var v_ct_type = Ajax._GetXmlElementAttributeValue(v_ct_node.childNodes[i], 'type');
//                    var v_ct_name = Ajax._GetXmlElementAttributeValue(v_ct_node.childNodes[i], 'name');
//                    Ajax._GetReturnType(wsdl, v_ct_type, array[v_ct_name]);
//                }
//            }
//            break;
//    }
//}