function setToCurrent( id )
{
	var button = document.getElementById( id );
	button.style.backgroundColor = "#C1E8CF";
}

function MM_preloadImages()
{ //v3.0
	var d = document;
	if( d.images )
	{
		if( !d.MM_p )
			d.MM_p = new Array();
		var i,
			j = d.MM_p.length,
			a = MM_preloadImages.arguments;
		for( i = 0;  i < a.length;  i++ )
		{
			if( a[ i ].indexOf( "#" ) != 0 )
			{
				d.MM_p[ j ] = new Image;
				d.MM_p[ j++ ].src = a[ i ];
			}
		}
	}
}

/**
	Arguments:
	0th: Menu name (or text): home, sampling-tools, etc.
	1st: ???: an empty string ('')
	2nd: the path to the file to be "swapped in"
	3rd: ???: it's always 1
*/
function MM_swapImage()
{ //v3.0
	var i,
		j = 0,
		x,
		a = MM_swapImage.arguments;

		//	Don't change anything if the button we're hovering over
		//	is the one that's currently set  [JB 2007-05-07]
	dbWriteln( "MM_swapImage(): document.MM_current = " + document.MM_current );
	if( document.MM_current == a[ 0 ] ) return;

	JB_printArgs( a );
	document.MM_sr = new Array();
	for( i = 0;  i < a.length - 2;  i += 3 )
	{
		if( ( x = MM_findObj( a[ i ] ) ) != null )
		{
			dbWriteln( "MM_swapImage(): found " + x.id );
			document.MM_sr[ j++ ] = x;
			if( !x.oSrc )
				x.oSrc = x.src;
			x.src = a[ i + 2 ];
		}
		else
			dbWriteln( "MM_swapImage(): nothing found " );
	}
}

function setImage()
{
	var i,
		j = 0,
		x,
		a = setImage.arguments;
	JB_printArgs( a );
	document.MM_sr = new Array();

		//  Save the id of the button being set [JB 2007-05-07]
	parent.banner.document.MM_current = a[ 0 ];
	dbWriteln( "MM_setImage(): " +
		"[parent.banner.]document.MM_current = " +
		document.MM_current );

	for( i = 0;  i < a.length - 2;  i += 3 )
	{
		if( ( x = MM_findObj( a[ i ], parent.banner.document ) ) != null )
		{
			dbWriteln( "setImage(): found " + x.id );
			document.MM_sr[ j++ ] = x;
			if( !x.oSrc )
				x.oSrc = x.src;
			x.src = a[ i + 2 ];
		}
		else
			dbWriteln( "setImage(): nothing found " );
	}
}

function MM_swapImgRestore()
{ //v3.0
	var i,
		x,
		a = document.MM_sr;

		//	Don't change anything if the button we're hovering over
		//	is the one that's currently set  [JB 2007-05-07]
	dbWriteln( "MM_swapImgRestore(): document.MM_current = " + document.MM_current );
	if( document.MM_current == a[ 0 ] ) return;

	for( i = 0;
		 a  &&
		   i < a.length  &&
		   ( x = a[ i ] )  &&
		   x.oSrc;
		 i++ )
		x.src = x.oSrc;
}

function MM_findObj( n, d )
{ //v4.01
	alert( "in MM_findObj(); n = " + n );
	var p,
		i,
		x;
	if( !d )
		d = document;
	dbWriteln( "MM_findObj: looking for " + n + " in " + d );
	dumpElement( d, "MM_findObj" );
	if( ( p = n.indexOf( "?" ) ) > 0  &&  parent.frames.length )
	{
		d = parent.frames[ n.substring( p + 1 ) ].document;
		n = n.substring( 0, p );
	}
	if( !( x = d[ n ] )  &&  d.all )
		x = d.all[ n ];
	dbWriteln( "MM_findObj: x at 1 = " + x );
	for( i = 0;
		 !x  &&
		   i < d.forms.length;
		 i++ )
		x = d.forms[ i ][ n ];
	dbWriteln( "MM_findObj: x at 2 = " + x );
	for( i = 0;
		 !x  &&
		   d.layers  &&
		   i < d.layers.length;
		 i++ )
		x = MM_findObj( n, d.layers[ i ].document );
	dbWriteln( "MM_findObj: x at 3 = " + x );
	if( !x  &&  d.getElementById )
		x = d.getElementById( n );
	return x;
}

function MM_openBrWindow( theURL, winName, features ) { //v2.0
	window.open( theURL, winName, features );
}

function MM_reloadPage( init )
{  //reloads the window if Nav4 resized
	if( init == true ) with (navigator)
	{
		if ( ( appName=="Netscape" )  &&  ( parseInt( appVersion ) == 4 ) )
		{
		  document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage;
		}
	}
	else
		if( innerWidth != document.MM_pgW  ||  innerHeight != document.MM_pgH )
			location.reload();
}

//	Extra debugging functions
function JB_printArgs( args )
{
	var i;
	dbWriteln( "Printing args" );
	for( i = 0;  i < args.length;  ++ i )
		dbWriteln( args[ i ] );
}

function isIE()
{
	var isIE = navigator.appName.indexOf( "Microsoft" ) != -1;
	return isIE;
}
