

// end changes - TG - 2007-09-21

//============================================================================//
// Functions for onload events
//============================================================================//

//function WindowOnload( function_IN )
//{
//	var previousOnloadFunction=window.onload;
//	window.onload=function(){ if( previousOnloadFunction ){ previousOnloadFunction(); } function_IN(); }
//}

/*
 * Accepts a reference to a function we want added to the page's onload event
 *    handler and a boolean that tells the function whether we want the function
 *    to be added to the beginning or the end of the list of onload functions
 *    if there is already an onload function.  If there is no onload function,
 *    then it makes the function passed in the onload event.  If there is
 *    already a function, it creates a new composite onload function that calls
 *    the existing onload function and the function passed in, with the boolean
 *    second argument telling this function whether we want the new call to be
 *    before or after the existing onload() event.
 * Preconditions: Must pass a function reference, not a call to a function.
 *    This means you shouldn't put any parenthese on the end of the function's
 *    name when you pass it to this function - just pass the name of the
 *    function. Example - if you want to add the function "outputJonIsAwesome()"
 *    before anything currently in window.onload, you would call this function
 *    as follows:
 *       addOnLoadEvent( outputJonIsAwesome, true );
 *    not like this:
 *       addOnLoadEvent( outputJonIsAwesome(), true );
 * Parameters:
 *    1) func_IN - the function we want added to the page's onload event
 *       handler.
 *    2) addBefore_IN - tells this function where to put the call to the
 *       function passed in in relation to an existing onLoad event.  If true,
 *       puts the function passed in before the call to any existing onLoad
 *       function.  If false, places it after.
 */
function addOnLoadEvent( func_IN, addBefore_IN )
{
	// declare variables
	var oldonload = window.onload;
	var addBefore = false;

	// see if we have an existing onload function.
	if (typeof window.onload != 'function')
	{
		// no, so just add the function passed in.
		//alert ( "No onload event! Just chucking the function passed in, func_IN, into window.onload" );
		window.onload = func_IN;
	}
	else
	{
		// we have an existing function.  Place function passed in before or
		//    after?
		//alert ( "Existing onload event!" );
		if ( ( addBefore_IN != null ) && ( addBefore_IN != "" ) )
		{
			if ( ( addBefore_IN == true ) || ( addBefore_IN.toUpperCase() == "TRUE" ) )
			{
				// some type of true passed in, so set flag to true.
				addBefore = true;
			}
			else // not true, so set to false.
			{
				// not true passed in, so set flag to false.
				addBefore = false;
			}
		}
		else //-- nothing passed in... set to false --//
		{
			addBefore = false;
		}

		// now, add create the new function, placing call before or after
		//    depending on the flag passed in.
		if ( addBefore == true )
		{
			//alert ( "Adding the function passed in, func_IN, before the old window.onload" );
			// make new onload with function passed in before old function.
			window.onload = function()
			{
				func_IN();
				if (oldonload)
				{
			        oldonload();
				}
			}
		}
		else //-- not before, so after. --//
		{
			//alert ( "Adding the function passed in, func_IN, after the old window.onload" );
			// make new onload with function passed in before old function.
			window.onload = function()
			{
				if (oldonload)
				{
			        oldonload();
				}
				func_IN();
			}
		} //-- end check to see if we add before or after. --//
	} //-- end check to see if the existing onload is a function. --//
} //-- end function addOnLoadEvent() --//

/*
 * accepts the number and name of the section we want to be the current section
 *    in the top nav.  If both are passed in, creates an onload function that
 *    first sets the current section, then initializes the top-nav and adds it
 *    to onload.  If not, just adds the initialization function to onload.
 */
function initializeNavigation( sectionNumber_IN, sectionName_IN )
{
	// declare variables
	var gotSection = false;

	// see if we have values passed in.
	if ( ( sectionNumber_IN != null ) && ( sectionNumber_IN != "" ) )
	{
		// we have a section number.  Do we have a name?
		if ( ( sectionName_IN != null ) && ( sectionName_IN != "" ) )
		{
			// we have both
			gotSection = true;
		}
		else
		{
			// missing name - set gotSection to false.
			gotSection = false;
		}
	}
	else //-- no section number --//
	{
		// no section number, set gotSection to false.
		gotSection = false;
	}

	// if we have a section, make onload set section, then call init.
	if ( gotSection == true )
	{
		// call the addOnLoadEvent function with a function that first calls
		addOnLoadEvent( function(){
				P7_TBMmark( sectionNumber_IN, sectionName_IN );
				P7_initTBM(1,0,1,1,200,1);
			}, true );
	}
	else //-- no section, just add init. --//
	{
		// call the addOnLoadEvent function with a function that first calls
		addOnLoadEvent( function(){
				P7_initTBM(1,0,1,1,200,1);
			}, true );
	}
} //-- end function initializeNavigation() --//
