toid	=	null;
tiid	=	setInterval("movebox()", 100);


function	clickbx( num )	{
	init_zindex();
	document.getElementById('bb' + num).style.zIndex = "40";
	unfadeall( num );
	fadeall(num);
	stop_reset_count();	
}

function	outbx( num )	{
//	unfadeall( num );
}

function	overbx( num )	{
	stop_reset_count();
}

function	init_zindex()	{
	document.getElementById('bb1').style.zIndex = "20";
	document.getElementById('bb2').style.zIndex = "18";
	document.getElementById('bb3').style.zIndex = "16";
	document.getElementById('bb4').style.zIndex = "14";
	document.getElementById('bb5').style.zIndex = "12";
}

function	fadeall( num )	{
	for( i=1; i<6; i++ )	{
		if( num != i )	{
			document.getElementById('bb' + i).style.MozOpacity=.2;
//			document.getElementById('bb' + i).filters.alpha.opacity=50
		}
	}
	stop_reset_count();
}


function	unfadeall( num )	{
//	alert(num);
	for( i=1; i<6; i++ )	{
		document.getElementById('bb' + i).style.MozOpacity=1;
//		document.getElementById('bb' + i).filters.alpha.opacity=100
	}
}

function	start_reset_count()	{

	stop_reset_count();
	toid	=	setTimeout("resetScreen()", 20000);
}

function	resetScreen()	{
	debug('reset');
	unfadeall('');
	init_zindex();
}

function	stop_reset_count()	{
	if( toid == null )	return;
	debug('clear');
	clearTimeout( toid );
	toid = null;
}

var	cx=50;
var	dir	=	.5;
function	movebox()	{

	if( cx > 344 || cx < 50 )	{	dir =- dir;	}
	cx += dir;
	
//	debug("movebox " + cx );
	document.getElementById('bkg').style.left = cx + "px";
}

function	debug( txt )	{


  var curtime = new Date();
  var curhour = curtime.getHours();
  var curmin = curtime.getMinutes();
  var cursec = curtime.getSeconds();
  var time = "";

  if(curhour == 0) curhour = 12;
  time = (curhour > 12 ? curhour - 12 : curhour) + ":" +
         (curmin < 10 ? "0" : "") + curmin + ":" +
         (cursec < 10 ? "0" : "") + cursec + " " +
         (curhour > 12 ? "PM" : "AM");

//   document.getElementById('debugbx').innerHTML	=	time + " - " + txt;
}

