// JavaScript Document
var _activeRequestPage = '';
function Ajax( _id )
{
this.id = _id;
this.toString = function() { return "Ajax"; }
this.ftype = ".inc.php";
this.isFlashEnabled = true;
this.mastHeadAnimeReady = true;
//Create HTTPRequest object, add listener (callback) method, and send request
this.makeRequest = function( _method, _url, _callbackMethod )
{
_activeRequestPage = _url;
var targetURL = _url + this.ftype;
this.request = ( window.XMLHttpRequest )? new XMLHttpRequest() : new ActiveXObject( "MSXML2.XMLHTTP" );
this.request.onreadystatechange = _callbackMethod;
this.request.open( _method, targetURL, true );
this.request.send( targetURL );
}
/*
Wrapper methods for makeRequest'
*/
this.doRequest = function( urlRequest )
{
this.makeRequest( "POST", urlRequest, this.doPageTransfer );
}
/*
Callback methods for HTTPRequest object
*/
//attached via doRequest wrapper method
this.doPageTransfer = function( )
{
//alert( "Ajax status: " + this.readyState ); //Fires four times, once for each status
switch( this.readyState )
{
//case 'zero' is "uninitialized"
//Loading...
case 1:
break;
//Loaded.
case 2:
break;
//Interactive.
case 3:
break;
//Complete.
case 4:
var isFlashOn = true;
//activate Toy Solidier animation
if ( isFlashOn )
{
var anime = window.document.OHPHeaderAnime; //attatch Flash masthead animation
anime.toySoldierCaneTwirl() ; //do callback method inside animation
anime.browserAjaxReinstantiation() ; //do callback method inside animation
}
document.getElementById( "pageHub" ).innerHTML = this.responseText;
}
}//End doPageTransfer method
}
//method is called whenever the animation needs to speak to the browser
function doAlertFromFlash( message )
{
var errorMessage = message;
alert( message );
}
//Flash animation JS methods
function doAjaxByFlash()
{
switch ( _activeRequestPage )
{
case "pages/parade_participants" :
alert( Spry.Widget.SlidingPanels.onloadDidFire );
break;
default:
}
}
|