/* Function in this file:
BB_SetBrowser()								determines browser type
BB_RepController(LoopNum, RepFunction, FinishFunction)	repeats functional and finishes with end function
BB_StopRepController()							stops a repetition
BB_CheckMouseOver(MOFunction, MOTestVar, MODelay)			checks mouse over
BB_TestMouseOver(MOFunction, MOTestVar)					part of checking mouse over
BB_LostMouseOver(MOTestVar)						part of checking mouse over
*/

// Setup boolian variables to record the browser type 
var isNS4 = 0;
var isNS3 = 0;
var isIE4 = 0;
var isIE3 = 0;
var isOld = 0;
var isNew = 0;

// Setup variables for layer management
var docObj;
var styleObj;

// Setup variables for moving and repetition
var BB_RepStop = 0;
var BB_RepStop1 = 0;
var BB_Count1 = 0;

/* Call BB_SetBrowser during loading to set browser information */
function BB_SetBrowser()
	{
	var brow;
	brow = ((navigator.appName) + (parseInt(navigator.appVersion)));		// Determines the browser name and browser version 

// reassign variable depending on the browser 
	if (parseInt(navigator.appVersion >= 5))		
		{
		isNew = 1;
		}
	else if (brow == "Netscape4") 
		{
		isNS4 = 1;
		}
	else if (brow == "Netscape3") 
		{
		isNS3 = 1;
		}
	else if (brow == "Microsoft Internet Explorer4") 
		{
		isIE4 = 1;
		}
	else if (brow == "Microsoft Internet Explorer3") 
		{
		isIE3 = 1;
		}
	else 
		{
		isOld = 1;
		}
				
// initalizes layer object model
	if (isNS4 || isIE4 || isNew)
		{
		docObj = (isNS4) ? 'document' : 'document.all';
		styleObj = (isNS4) ? '' : '.style';
		}	
	}
	
//loops LoopNum times, executing RepFunction each time, Finish function at end
//You can interrupt by setting BB_RepStop at any time.
//BB_Count must be used to track the counting of this loop.
function BB_RepController(LoopNum, RepFunction, FinishFunction, TimeDelay)
	{
	var NextCount;
	if (BB_RepStop == 0)
		{
		return;
		}
	if (BB_Count < LoopNum)
		{
		eval(RepFunction);
		BB_Count++;
		NextCall = "BB_RepController(" + LoopNum + ", '" + RepFunction + "', '" + FinishFunction + "', " + TimeDelay + ");";
		setTimeout(NextCall, TimeDelay);
		}
	if ((BB_Count == LoopNum) && (FinishFunction != ''))
		{
		eval(FinishFunction);
		BB_RepStop = 0;
		}
	}
function BB_RepController1(LoopNum, RepFunction, FinishFunction, TimeDelay)
	{
	var NextCount;

	if (BB_RepStop1 == 0)
		{
		return;
		}
	if (BB_Count1 <= LoopNum)
		{
		eval(RepFunction);
		BB_Count1++;
		NextCall = "BB_RepController1(" + LoopNum + ", '" + RepFunction + "', '" + FinishFunction + "', " + TimeDelay + ");";
		setTimeout(NextCall, TimeDelay);
		}
	if ((BB_Count1 == LoopNum) && (FinishFunction != ''))
		{
		eval(FinishFunction);
		BB_RepStop1 = 0;
		}
	}

function BB_StopRepController()
	{
	BB_RepStop = 0;
	}
function BB_StopRepController1()
	{
	BB_RepStop1 = 0;
	}
	
/* Sometimes you need to make sure a mouse stays over an object for a bit before actually invoking an action.
This function sets a test variable and then waits a bit.  The next function, TestMouseOver, looks to see if the 
test variable is still set.  If so, the mouse-over function is called.  Caller must supply global variable MOTestVar.
Important: Both MOFunction and MOTestVar must be passed as strings.
*/
function BB_CheckMouseOver(MOFunction, MOTestVar, MODelay)
	{
	var NextCall, SetTest;
	NextCall = 'BB_TestMouseOver("' + MOFunction + '", "' + MOTestVar + '")';
	SetTest = MOTestVar + "= 1";
	eval(SetTest);
	
	setTimeout(NextCall, MODelay);
	}

function BB_TestMouseOver(MOFunction, MOTestVar)
	{
	var TempTest;
	
	eval("TempTest = " + MOTestVar);
	if (TempTest == 1)
		{
		eval(MOFunction);
		MOTestVar = 0;
		}
	}
	
function BB_LostMouseOver(MOTestVar)
	{
	eval(MOTestVar + "= 0");
	}

