﻿// ---------------------------------------------------------------------------------------------------------------
// Phoenix Internet Designs - AJAX Manager Component - This script has been validated using Internet Explorer
// (Versions 6 & 7), Netscape (Version 8), Firefox (2.0.0.2), Opera (9.10) and Safari (BETA 3.0).
// NEVER MODIFY OR ADD CLIENT / PROJECT SPECIFIC CODE TO THIS SCRIPT
// ---------------------------------------------------------------------------------------------------------------
// DEPENDENCIES:
//      Variable / Constants - The following variables and constants MUST be declared in the project specific
//      script:
//          AJAX_TIMEOUT - Contains the timeout value for the AJAX connection, if no timeout is to be specified 
//                         this must be set to zero.
//          AJAX_TARGET  - The ID of the DIV that is to be used as the AJAX region.
//      Methods - The following methods must exist in the project specific script, even though there is no required
//      processing a stub must exist.
//          onAJAXConnection() - Code to excute after a successful AJAX connection has been made and the target DIV
//                               updated.
//          onAJAXFail()       - Code to execute if the AJAX connection failed to download the requested page.
// ---------------------------------------------------------------------------------------------------------------
var displayElement = "";

// Input Criteria: fully qualified path and name of web page to load; plus any required QueryString parameters.
function loadAjax(_srequestedpage) 
{          
    var s_target = AJAX_OVERRIDE;
    if(s_target == "")s_target = AJAX_TARGET;
    displayElement = $get(s_target);
    web_request =  new Sys.Net.WebRequest();
    Sys.Net.WebRequestManager.add_completedRequest(On_WebRequestCompleted);
    Sys.Net.WebRequestManager.add_invokingRequest(On_InvokingRequest);   
    if(AJAX_TIMEOUT > 0)Sys.Net.WebRequestManager.set_defaultTimeout(AJAX_TIMEOUT);
    web_request.set_url(_srequestedpage);
    web_request.set_httpVerb("POST");
    Sys.Net.WebRequestManager.executeRequest(web_request);
    
}
function RemoveDefaultHandlers() 
{ 
    Sys.Net.WebRequestManager.remove_completedRequest(On_WebRequestCompleted);    
    Sys.Net.WebRequestManager.remove_invokingRequest(On_InvokingRequest);   
}
function On_InvokingRequest(executor, eventArgs){ }
function On_WebRequestCompleted(executor, eventArgs) 
{
    if(executor.get_responseAvailable()) 
    {
        displayElement.innerHTML = "";
        displayElement.innerHTML  += executor.get_responseData();
        onAJAXConnection();
    } else {
        onAJAXFail();
    }
}
if (typeof(Sys) !== "undefined") Sys.Application.notifyScriptLoaded();

