/**
* Classes included in this file:
*     AjaxProcessorBase
* This file requires the use of the following files:
*     base.js
*     base_classes.js
*     cls_ajax.js
*     cls_java_window.js
**/
function AjaxProcessorBase(p_instanceName, p_ajax, p_processPage, p_succesRedirectTo, p_windowButtonImageFolderPath)
{
    /// <summary modifiers="public abstract" type="class">Represents a base object that provides the core functionality for sending and parsing AJAX requests. This class can automatically parse plain text, HTML, and JSON return strings, depending on the string returned and values of certain class properties.</summary>
    /// <param name="p_instanceName"                type="String" optional="false">The name of the JavaScript variable that the instance of this object is assigned to.</param>
    /// <param name="p_ajax"                        type="Ajax"   optional="false">The <see cref="Ajax"/> object to use to perform AJAX requests.</param>
    /// <param name="p_processPage"                 type="String" optional="false">The path to the AJAX processor page, generally relative to the root of the website.</param>
    /// <param name="p_succesRedirectTo"            type="String" optional="true">The URL that the user is redirected to upon a successful AJAX call if an auto-redirect is specified.</param>
    /// <param name="p_windowButtonImageFolderPath" type="String" optional="true">The path to where the button and loading images for the <see cref="JavaWindow"/> class reside.</param>
    /// <field name="_NoResizeFlag"      type="Boolean"           modifiers="private">Used internally to specify that the window can not be resized.</field>
    /// <field name="_ProcessPageBackup" type="String"            modifiers="private">Used internally to backup the process page when it is being overriden.</field>
    /// <field name="Name"               type="String"            modifiers="public">Gets the current instance JavaScript variable name.</field>
    /// <field name="Ajax"               type="Ajax"              modifiers="public">Gets the <see cref="Ajax"/> instance to use for AJAX calls.</field>
    /// <field name="ProcessPage"        type="String"            modifiers="public">Gets or sets the path to the AJAX processor page, generally relative to the root of the website.</field>
    /// <field name="Redirect"           type="String"            modifiers="public">Gets or sets the default page to redirect to after a successful AJAX request.</field>
    /// <field name="SessionGuid"        type="String"            modifiers="public">Gets or sets the current XML session GUID, if there is one. This property is automatically populated from the current session cookie, if one exists.</field>
    /// <field name="ViewState"          type="String"            modifiers="public">Gets or sets an object that represents the current view state of the page. Generally a string, but can be any object that can be converted to a string that is 1500 characters or less in length.</field>
    /// <field name="AutoAddScrollPos"   type="Boolean"           modifiers="public">Gets or sets a value indicating if the current X and Y coordinates of where the user is located on the page (scroll bar position) will be automatically added to the query string when a redirect is performed. Defaults to false.</field>
    /// <field name="AutoAddViewState"   type="Boolean"           modifiers="public">Gets or sets a value indicating if the ViewState object will be automatically added to the query string when a redirect is performed. Defaults to false.</field>
    /// <field name="AutoCloseWindow"    type="Boolean"           modifiers="public">Gets or sets a value indicating if the status window will automatically be closed on a successful AJAX request. Defaults to true.</field>
    /// <field name="AutoProcessAsJson"  type="Boolean"           modifiers="public">Gets or sets a value indicating if the AJAX request return text will be automatically parsed as a JSON string, if a valid JSON string is returned. Defaults to true.</field>
    /// <field name="AutoEvalJavaScript" type="Boolean"           modifiers="public">Gets or sets a value indicating if javascript returned by the AJAX call should be auto-executed. Defaults to true.</field>
    /// <field name="Window"             type="JavaWindow"        modifiers="public">Gets the current <see cref="JavaWindow"/> instance that is used for displaying statuses, results, and errors.</field>
    /// <field name="StatusWindowSize"   type="Size"              modifiers="public">Sets the size of the status window dialog.</field>
    /// <field name="_Ref"               type="AjaxProcessorBase" modifiers="private static">Depricated.</field>
    this._NoResizeFlag      = false;
    this._ProcessPageBackup = '';
    this.Name               = p_instanceName;
    this.Ajax               = p_ajax;
    this.ProcessPage        = p_processPage;
    this.Redirect           = p_succesRedirectTo;
    this.ViewState          = null;
    this.AutoAddScrollPos   = false;
    this.AutoAddViewState   = false;
    this.AutoCloseWindow    = true;
    this.AutoProcessAsJson  = true;
    this.AutoEvalJavaScript = true;
    this.Window             = new JavaWindow('jw_' + p_instanceName, p_instanceName + '.Window', 'Status', false);
    this.StatusWindowSize   = new Size(300, 150);
    this.Window.Parent      = this;
    try
    {
        this.SessionGuid = new HttpCookies().Item('SessionGUID');
    }
    catch (e)
    {
        this.SessionGuid = '';
    }
    var v_query = QueryString.Load();
    if (v_query.Contains('viewstate'))
    {
        this.ViewState = v_query.Item('viewstate');
    }
    if (p_windowButtonImageFolderPath != null)
    {
        this.Window.TitleBar.SetImageFolderPath(p_windowButtonImageFolderPath);
    }
    return;
}
Extend(AjaxProcessorBase, OptionBase);
AjaxProcessorBase._Ref = null;

// Public
AjaxProcessorBase.prototype.GetType = function()
{
    /// <summary modifiers="public">Gets the current object type.</summary>
    /// <returns type="String">The current object type.</returns>
    return 'AjaxProcessorBase';
}
AjaxProcessorBase.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.Name;
}
AjaxProcessorBase.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: AjaxProcessorBase: ' + this.Name + ']';
}

// Protected
AjaxProcessorBase.prototype.OverrideProcessPage = function(p_url)
{
    /// <summary modifiers="protected">Allows the process page that the next AJAX request will be sent to to be overriden.</summary>
    /// <param name="p_url" type="String" optional="false">The URL to send the next AJAX request to.</param>
    this._ProcessPageBackup = this.ProcessPage;
    this.ProcessPage = p_url;
    return;
}
AjaxProcessorBase.prototype.AddViewState = function(p_query)
{
    /// <summary modifiers="protected">Adds the current view state object, if there is one, to the specified <see cref="QueryString"/> instance.</summary>
    /// <param name="p_query" type="QueryString" optional="false">The <see cref="QueryString"/> to add the current view state to.</param>
    var v_viewstate = '';
    try
    {
        v_viewstate = this.ViewState.toString();
    }
    catch (e)
    {
        v_viewstate = '';
    }
    if (v_viewstate.length > 1500)
    {
        v_viewstate = v_viewstate.substr(0, 1500);
    }
    if (v_viewstate.length > 0)
    {
        p_query.Add('viewstate', v_viewstate, true);
    }
    return;
}
AjaxProcessorBase.prototype.GetLoadImage = function(p_styleString)
{
    /// <summary modifiers="protected virtual">Gets the loading image HTML string.</summary>
    /// <param name="p_styleString" type="String" optional="false">Custom CSS styles to use for the image.</param>
    /// <returns type="String">The loading image HTML string.</returns>
    var v_style = TypeOf(p_styleString) == 'String' && p_styleString.length > 0 ? ' style="' + p_styleString + '"' : '';
    return '<img src="' + this.Window.TitleBar.ImageFolderPath + '/javawin_images/loading.gif" alt="Loading..." title=""' + v_style + ' />';
}
AjaxProcessorBase.prototype.ShowWindow = function(p_width, p_height, p_wait, p_statusBarVisible, p_title, p_content, p_restore, p_showHelp, p_onHelpClick)
{
    /// <summary modifiers="protected">Shows a <see cref="JavaWindow"/> with the specified properties.</summary>
    /// <param name="p_width"            type="Number"       optional="false">The width of the window.</param>
    /// <param name="p_height"           type="Number"       optional="false">The height of the window.</param>
    /// <param name="p_wait"             type="Boolean"      optional="false">A value indicating if the window should default to using the "wait" cursor.</param>
    /// <param name="p_statusBarVisible" type="Boolean"      optional="false">A value indicating if the status bar is visible.</param>
    /// <param name="p_title"            type="String"       optional="false">The title of the window.</param>
    /// <param name="p_content"          type="String"       optional="true">The content of the window. Can be null.</param>
    /// <param name="p_restore"          type="Boolean"      optional="true">A value indicating if the window should be restored to it's default size if there is already a window visible or if it has previously been resized.</param>
    /// <param name="p_showHelp"         type="Boolean"      optional="true">A value indicating if the help button is visible.</param>
    /// <param name="p_onHelpClick"      type="ClickHandler" optional="true">The callback method to use when the help button is clicked. Can be null.</param>
    /// <returns type="JavaWindow">The <see cref="JavaWindow"/> that was displayed.</returns>
    p_restore  = TypeOf(p_restore)  == 'Boolean' ? p_restore  : false;
    p_showHelp = TypeOf(p_showHelp) == 'Boolean' ? p_showHelp : false;
    var v_visible_flag = false;
    if (this.Window.Visible)
    {
        this.Window.Close();
        v_visible_flag = true;
    }
    this.Window.TitleBar.HelpButton.Visible = p_showHelp;
    this.Window.TitleBar.HelpButton.Click   = p_showHelp ? p_onHelpClick : null;
    if ((v_visible_flag && p_restore) || !v_visible_flag)
    {
        this.Window.Restore(true, true);
    }
    this.Window.TitleBar.Text     = p_title;
    this.Window.StatusBar.Visible = p_statusBarVisible;
    this.Window.StatusBar.Text    = '';
    this.Window.Size.Set(p_width, p_height);
    this.Window.Show();
    if (p_wait)
    {
        this.Window.SetCursor('wait');
    }
    this.Window.SetContent(p_content);
    return this.Window;
}
AjaxProcessorBase.prototype.ShowStatusWindow = function(p_text, p_showLoadImage)
{
    /// <summary modifiers="protected">Shows a status window.</summary>
    /// <param name="p_text" type="String" optional="false">The text of the status window.</param>
    /// <param name="p_showLoadImage" type="Boolean" optional="false">A value indicating if the loading image should be displayed.</param>
    this.ShowWindow(this.StatusWindowSize.Width, this.StatusWindowSize.Height, true, false, 'Status', '<div style="text-align: center; padding-top: 20px;">' + p_text + (p_showLoadImage ? '<br />' + this.GetLoadImage('padding-top: 5px;') : '') + '</div>', true, false, null);
    return;
}
AjaxProcessorBase.prototype.ShowErrorWindow = function(p_text, p_object, p_identifier)
{
    /// <summary modifiers="protected">Shows an error window for an error from an AJAX call.</summary>
    /// <param name="p_text"       type="String"                           optional="false">The text of the error window.</param>
    /// <param name="p_object"     type="AjaxProcessorBase.ResponseObject" optional="false">The object or string that was returned by the AJAX call.</param>
    /// <param name="p_identifier" type="Object"                           optional="true">An object that identifies the AJAX call.</param>
    if (!this.Window.Visible)
    {
        this.Window.TitleBar.Text = 'Error Message';
        this.Window.Show();
    }
    this.Window.SetContent(p_text);
    if (this.Window.StatusBar.Visible)
    {
        this.Window.StatusBar.SetText('Errors detected.');
    }
    var v_can_resize = this.ErrorWinOperations(p_object, p_identifier);
    if (TypeOf(v_can_resize) != 'Boolean')
    {
        v_can_resize = true;
    }
    if (!this._NoResizeFlag && v_can_resize)
    {
        this.Window.ResizeTo(400, 300);
        this.Window.CenterWindow();
    }
    this.Window.SetCursor('default');
    this.Window.ScrollToTop();
    return;
}
AjaxProcessorBase.prototype.DoRedirect = function(p_url)
{
    /// <summary modifiers="protected">Redirects the current page to the specified URL. If no URL is specified, the value of the <see cref="AjaxProcessorBase.Redirect"/> property is used.</summary>
    /// <param name="p_url" type="String" optional="true">A <see cref="String"/> or <see cref="Uri"/> instance to redirect the page to. Can be null.</param>
    var v_uri;
    if (TypeOf(p_url) == 'String')
    {
        v_uri = new Uri(p_url);
    }
    else if (TypeOf(p_url) == 'Uri')
    {
        v_uri = p_url;
    }
    else
    {
        v_uri = new Uri(this.Redirect);
    }
    if (this.AutoAddScrollPos)
    {
        Utils.AddScrollPosition(v_uri.Query);
    }
    if (this.AutoAddViewState)
    {
        this.AddViewState(v_uri.Query);
    }
    var v_current_url = Uri.Load();
    if (v_current_url.Path + v_current_url.File == v_uri.Path + v_uri.File)
    {
        v_uri.Hash = ''; // We can't have a hash in the redirect if we are redirecting to the same page or the refresh won't occur.
    }
    window.location.replace(v_uri.ToString());
    return;
}
AjaxProcessorBase.prototype.ErrorWinOperations = function(p_object, p_identifier)
{
    /// <summary modifiers="protected virtual">Allows custom operations to be performed immediately before the error window is displayed.</summary>
    /// <param name="p_object"     type="AjaxProcessorBase.ResponseObject" optional="false">The object or string that was returned by the AJAX call.</param>
    /// <param name="p_identifier" type="Object"                           optional="true">An object that identifies the AJAX call.</param>
    /// <returns type="String">A value indicating if the error window can be resized to a default size.</returns>
    return true;
}
AjaxProcessorBase.prototype.Reset = function(p_identifier)
{
    /// <summary modifiers="protected virtual">Allows custom actions to be performed immediately after an error window is displayed.</summary>
    /// <param name="p_identifier" type="Object" optional="true">An object that identifies the AJAX call.</param>
    return;
}
AjaxProcessorBase.prototype.Execute = function(p_params, p_customCallback, p_successCallbackOrRedirect, p_returnsJson, p_identifier, p_failCallback)
{
    /// <summary modifiers="protected">Sends an AJAX request to the current processing page.</summary>
    /// <param name="p_params"                    type="String"       optional="true">Parameters to send with the AJAX request. Can be null.</param>
    /// <param name="p_customCallback"            type="AjaxCallback" optional="true">The custom callback that is called when the AJAX call completes. If you want the callback to be auto-processed by this class, pass false for this parameter. Can be null.</param>
    /// <param name="p_successCallbackOrRedirect" type="Object"       optional="true">
    /// Can be one of four types:
    /// <ul>
    /// <li><see cref="Boolean"/> - true to redirect to the URL specified in the <see cref="AjaxProcessorBase.Redirect"/> property upon success, false for no redirection or if nothing needs to be done upon success or failure.</li>
    /// <li><see cref="String"/> or <see cref="Uri"/> - the URL to redirect to upon success.</li>
    /// <li><see cref="AjaxProcessorBase.SuccessCallback"/> - The callback method to execute upon success.</li>
    /// </ul>
    /// The value can also be null, which is the same as passing false.
    /// </param>
    /// <param name="p_returnsJson"  type="Boolean"                        optional="true">A value indicating if the response string is a JSON formatted string. Defaults to true.</param>
    /// <param name="p_identifier"   type="Object"                         optional="true">An object that identifies the AJAX call.</param>
    /// <param name="p_failCallback" type="AjaxProcessorBase.FailCallback" optional="true">The method that is called if the AJAX call fails. Can be null.</param>
    var v_this = this;
    this._SetRef();
    this.Ajax.Execute(this.ProcessPage, p_params, __internal_callback, false, p_identifier);
    this.__RestoreProcessPageOverride();
    function __internal_callback(p_success, p_responseText, p_status, p_identifier)
    {
        if (typeof (p_customCallback) == 'function')
        {
            p_customCallback(p_success, p_responseText, p_status, p_identifier);
            return;
        }
        v_this.__callback2(p_success, p_responseText, p_identifier, p_successCallbackOrRedirect, p_returnsJson, p_failCallback);
        return;
    }
    return;
}
AjaxProcessorBase.prototype.SubmitForm = function(p_form, p_customCallback, p_successCallbackOrRedirect, p_returnsJson, p_identifier, p_failCallback, p_skipNamesArray)
{
    /// <summary modifiers="protected">Sends an AJAX request to the current processing page 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="p_form"                      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="p_customCallback"            type="AjaxCallback"   optional="true">The custom callback that is called when the AJAX call completes. If you want the callback to be auto-processed by this class, pass false for this parameter. Can be null.</param>
    /// <param name="p_successCallbackOrRedirect" type="Object"         optional="true">
    /// Can be one of four types:
    /// <ul>
    /// <li><see cref="Boolean"/> - true to redirect to the URL specified in the <see cref="AjaxProcessorBase.Redirect"/> property upon success, false for no redirection or if nothing needs to be done upon success or failure.</li>
    /// <li><see cref="String"/> or <see cref="Uri"/> - the URL to redirect to upon success.</li>
    /// <li><see cref="AjaxProcessorBase.SuccessCallback"/> - The callback method to execute upon success.</li>
    /// </ul>
    /// The value can also be null, which is the same as passing false.
    /// </param>
    /// <param name="p_returnsJson"    type="Boolean"                        optional="true">A value indicating if the response string is a JSON formatted string. Defaults to true.</param>
    /// <param name="p_identifier"     type="Object"                         optional="true">An object that identifies the AJAX call.</param>
    /// <param name="p_failCallback"   type="AjaxProcessorBase.FailCallback" optional="true">The method that is called if the AJAX call fails. Can be null.</param>
    /// <param name="p_skipNamesArray" type="Array"                          optional="true">An array of form element names to skip over (not send with the AJAX call). Can be null.</param>
    var v_this = this;
    this._SetRef();
    this.Ajax.SubmitForm(p_form, this.ProcessPage, __internal_callback, false, p_identifier, p_skipNamesArray);
    this.__RestoreProcessPageOverride();
    function __internal_callback(p_success, p_responseText, p_status, p_identifier)
    {
        if (typeof (p_customCallback) == 'function')
        {
            p_customCallback(p_success, p_responseText, p_status, p_identifier);
            return;
        }
        v_this.__callback2(p_success, p_responseText, p_identifier, p_successCallbackOrRedirect, p_returnsJson, p_failCallback);
        return;
    }
    return;
}
AjaxProcessorBase.prototype.SubmitFileForm = function(p_form, p_customCallback, p_successCallbackOrRedirect, p_returnsJson, p_identifier, p_failCallback)
{
    /// <summary modifiers="protected">Sends an AJAX request to the current processing page 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="p_form"                      type="HtmlDOMForm"  optional="false">The HTML DOM form to submit.</param>
    /// <param name="p_customCallback"            type="AjaxCallback" optional="true">The custom callback that is called when the AJAX call completes. If you want the callback to be auto-processed by this class, pass false for this parameter. Can be null.</param>
    /// <param name="p_successCallbackOrRedirect" type="Object"       optional="true">
    /// Can be one of four types:
    /// <ul>
    /// <li><see cref="Boolean"/> - true to redirect to the URL specified in the <see cref="AjaxProcessorBase.Redirect"/> property upon success, false for no redirection or if nothing needs to be done upon success or failure.</li>
    /// <li><see cref="String"/> or <see cref="Uri"/> - the URL to redirect to upon success.</li>
    /// <li><see cref="AjaxProcessorBase.SuccessCallback"/> - The callback method to execute upon success.</li>
    /// </ul>
    /// The value can also be null, which is the same as passing false.
    /// </param>
    /// <param name="p_returnsJson"  type="Boolean"                        optional="true">A value indicating if the response string is a JSON formatted string. Defaults to true.</param>
    /// <param name="p_identifier"   type="Object"                         optional="true">An object that identifies the AJAX call.</param>
    /// <param name="p_failCallback" type="AjaxProcessorBase.FailCallback" optional="true">The method that is called if the AJAX call fails. Can be null.</param>
    var v_this = this;
    this.Ajax.SubmitFileForm(p_form, this.ProcessPage, __internal_callback, p_identifier);
    this.__RestoreProcessPageOverride();
    function __internal_callback(p_success, p_responseText, p_status, p_identifier)
    {
        if (typeof (p_customCallback) == 'function')
        {
            p_customCallback(p_success, p_responseText, p_status, p_identifier);
            return;
        }
        v_this.__callback2(p_success, p_responseText, p_identifier, p_successCallbackOrRedirect, p_returnsJson, p_failCallback);
        return;
    }
    return;
}

// Private
AjaxProcessorBase.prototype.__RestoreProcessPageOverride = function()
{
    /// <summary modifiers="private">Internal method used by <see cref="AjaxProcessorBase.Execute"/>, <see cref="AjaxProcessorBase.SubmitForm"/>, and <see cref="AjaxProcessorBase.SubmitFileForm"/>.</summary>
    if (TypeOf(this._ProcessPageBackup) == 'String' && this._ProcessPageBackup.length > 0)
    {
        this.ProcessPage = this._ProcessPageBackup;
        this._ProcessPageBackup = '';
    }
    return;
}
AjaxProcessorBase.prototype.__ShowErrorWinFromCallback = function(p_text, p_object, p_identifier)
{
    /// <summary modifiers="private">Internal method used by <see cref="AjaxProcessorBase.__callback2"/>.</summary>
    this.ShowErrorWindow(p_text, p_object, p_identifier);
    this._NoResizeFlag = false;
    this.Reset(p_identifier);
    return;
}
AjaxProcessorBase.prototype.__callback2 = function(p_success, p_responseText, p_identifier, p_successCallbackOrRedirect, p_returnsJson, p_failCallback)
{
    /// <summary modifiers="private">Internal method used to parse and handle the results of an AJAX call.</summary>
    var v_auto_process = true;
    if (p_success)
    {
        var v_can_close = false;
        if (TypeOf(p_returnsJson) != 'Boolean')
        {
            p_returnsJson = true;
        }
        if (this.AutoProcessAsJson && p_returnsJson)
        {
            var v_retval = new Object();
            try
            {
                eval('v_retval = ' + p_responseText);
            }
            catch (e)
            {
                if (typeof (p_failCallback) == 'function')
                {
                    var v_fail_retval = p_failCallback(p_responseText, p_identifier);
                    v_auto_process = TypeOf(v_fail_retval) == 'Boolean' ? v_fail_retval : true;
                }
                if (v_auto_process)
                {
                    this.__ShowErrorWinFromCallback(p_responseText, null, p_identifier);
                }
                return;
            }
            if (TypeOf(v_retval.ReturnId) != 'Number')
            {
                v_retval.ReturnId = 0;
            }
            if (TypeOf(v_retval.ReturnMessage) != 'String')
            {
                v_retval.ReturnMessage = '';
            }
            if (TypeOf(v_retval.CanClose) != 'Boolean')
            {
                v_retval.CanClose = true;
            }
            if (v_retval.ReturnId > 0)
            {
                if (typeof (p_successCallbackOrRedirect) == 'function')
                {
                    p_successCallbackOrRedirect(v_retval, p_identifier);
                    v_can_close = v_retval.CanClose;
                }
                else if (TypeOf(p_successCallbackOrRedirect) == 'Boolean' && p_successCallbackOrRedirect)
                {
                    this.DoRedirect();
                }
                else if (TypeOf(p_successCallbackOrRedirect) == 'String' || TypeOf(p_successCallbackOrRedirect) == 'Uri')
                {
                    this.DoRedirect(p_successCallbackOrRedirect);
                }
                else
                {
                    v_can_close = true;
                }
                if (this.AutoCloseWindow && v_can_close)
                {
                    this.Window.Close();
                }
                if (this.AutoEvalJavaScript && TypeOf(v_retval.JavaScript) == 'String' && v_retval.JavaScript.length > 0)
                {
                    eval(v_retval.JavaScript);
                }
            }
            else
            {
                if (typeof (p_failCallback) == 'function')
                {
                    var v_fail_retval = p_failCallback(v_retval, p_identifier);
                    v_auto_process = TypeOf(v_fail_retval) == 'Boolean' ? v_fail_retval : true;
                }
                if (v_auto_process)
                {
                    this.__ShowErrorWinFromCallback(v_retval.ReturnMessage, v_retval, p_identifier);
                }
            }
            return;
        }
        else if (p_responseText == '1')
        {
            if (typeof (p_successCallbackOrRedirect) == 'function')
            {
                p_successCallbackOrRedirect(p_responseText, p_identifier); v_can_close = true;
            }
            else if (TypeOf(p_successCallbackOrRedirect) == 'Boolean' && p_successCallbackOrRedirect)
            {
                this.DoRedirect();
            }
            else if (TypeOf(p_successCallbackOrRedirect) == 'String' || TypeOf(p_successCallbackOrRedirect) == 'Uri')
            {
                this.DoRedirect(p_successCallbackOrRedirect);
            }
            else
            {
                v_can_close = true;
            }
            if (this.AutoCloseWindow && v_can_close)
            {
                this.Window.Close();
            }
            return;
        }
    }
    if (typeof (p_failCallback) == 'function')
    {
        var v_fail_retval = p_failCallback(p_responseText, p_identifier);
        v_auto_process = TypeOf(v_fail_retval) == 'Boolean' ? v_fail_retval : true;
    }
    if (v_auto_process)
    {
        this.__ShowErrorWinFromCallback(p_responseText, null, p_identifier);
    }
    return;
}

// Depricated
AjaxProcessorBase.prototype.SetScrollPosition = function()
{
    /// <summary modifiers="public">Depricated. Use <see cref="Utils.SetScrollPosition"/> instead.</summary>
    Utils.SetScrollPosition();
    return;
}
AjaxProcessorBase.prototype.AddScrollPosition = function(p_query)
{
    /// <summary modifiers="protected">Depricated. Use <see cref="Utils.AddScrollPosition"/> instead.</summary>
    Utils.AddScrollPosition(p_query);
    return;
}
AjaxProcessorBase.prototype._AddScrollPos = function(p_query)
{
    /// <summary modifiers="protected">Depricated. Use <see cref="AjaxProcessorBase.AddScrollPosition"/> instead.</summary>
    this.AddScrollPosition(p_query);
    return;
}
AjaxProcessorBase.prototype._AddViewState = function(p_query)
{
    /// <summary modifiers="protected">Depricated. Use <see cref="AjaxProcessorBase.AddViewState"/> instead.</summary>
    this.AddViewState(p_query);
    return;
}
AjaxProcessorBase.prototype._ShowWin = function(p_width, p_height, p_wait, p_statusBarVisible, p_title, p_content, p_restore, p_showHelp, p_onHelpClick)
{
    /// <summary modifiers="protected">Depricated. Use <see cref="AjaxProcessorBase.ShowWindow"/> instead.</summary>
    return this.ShowWindow(p_width, p_height, p_wait, p_statusBarVisible, p_title, p_content, p_restore, p_showHelp, p_onHelpClick);
}
AjaxProcessorBase.prototype._ShowStatusWin = function(p_text)
{
    /// <summary modifiers="protected">Depricated. Use <see cref="AjaxProcessorBase.ShowStatusWindow"/> instead.</summary>
    this.ShowStatusWindow(p_text);
    return;
}
AjaxProcessorBase.prototype._ShowErrorWin = function(p_text, p_object)
{
    /// <summary modifiers="protected">Depricated. Use <see cref="AjaxProcessorBase.ShowErrorWindow"/> instead.</summary>
    this.ShowErrorWindow(p_text, p_object);
    return;
}
AjaxProcessorBase.prototype._ErrorWinOperations = function(p_object)
{
    /// <summary modifiers="protected">Depricated. Use <see cref="AjaxProcessorBase.ErrorWinOperations"/> instead.</summary>
    return this.ErrorWinOperations(p_object);
}
AjaxProcessorBase.prototype._Reset = function()
{
    /// <summary modifiers="protected">Depricated. Use <see cref="AjaxProcessorBase.Reset"/> instead.</summary>
    this.Reset();
    return;
}
AjaxProcessorBase.prototype._SetRef = function()
{
    /// <summary modifiers="private">Depricated. Previously used to set an internal reference that <see cref="AjaxProcessorBase.__callback"/> uses.</summary>
    AjaxProcessorBase._Ref = this;
    return;
}
AjaxProcessorBase.prototype.__callback = function(p_success, p_responseText, p_status, p_identifier)
{
    /// <summary modifiers="private">Depricated. Previously used as a callback method for an AJAX call.</summary>
    if (p_responseText == '1')
    {
        AjaxProcessorBase._Ref.DoRedirect();
        return;
    }
    AjaxProcessorBase._Ref.__ShowErrorWinFromCallback(p_responseText, null);
    return;
}