var curInfo = new Array();

function changeInfo(infNum, newInfo)
{
	if( curInfo[infNum] && curInfo[infNum] != "" )
		setObjVisibility(curInfo[infNum], "hidden");

	curInfo[infNum] = newInfo;

	if( newInfo != "" )
		setObjVisibility(curInfo[infNum], "visible");
}


function movAndClip( id, x, y, destx, desty, clipx, clipy, incx, incy, w, h, type )
{
	x += incx;
	clipx += incx;

	if( type == 1 )
	  {
		clipx1 = 0;
		clipx2 = w - clipx;
	  }
	else if( type == 2 )
	  {
		clipx1 = -clipx;
		clipx2 = w;
	  }

	if( incx > 0 )
	  {
		if( x > destx )
		  {
			clipx += destx - x;
		  	x = destx;
		  }
	  }
	else if( incx < 0 )
	  {
		if( x < destx )
		  {
			clipx += destx - x;
		  	x = destx;
		  }
	  }
	else x = destx;
	movObj(id, x, y);

	clipObj(id, clipx1, 0, clipx2, h);

	y = desty;

	if( x != destx || y != desty )
	     setTimeout( "movAndClip('" + id + "', " + x + ", " + y + ", " + destx + ", " + desty + ", " + clipx + ", " + clipy + ", " + incx + ", " + incy + ", " + w + ", " + h + ", " + type +")", 50 );

}

function flashInfo( info, maxInfo, time )
{
	if( maxInfo > 1 )
	  {
		if( curInfo["flash"] && curInfo["flash"] != "" )
			movAndClip( curInfo["flash"], 1, 1, -170, 1, 0, 20, -5, 0, 171, 48, 2 );
		if( ++info > maxInfo )
	  		info = 1;
	
		curInfo["flash"] = "inf" + info;

		movAndClip( curInfo["flash"], 169, 1, 1, 1, 170, 0, -5, 0, 171, 48, 1 );
		setObjVisibility( curInfo["flash"], "visible" );
		setTimeout( "flashInfo( " + info + "," + maxInfo + "," + time + ")", time );
	  }
	else if( maxInfo == 1 )	  
     	  {
     	  	setObjVisibility( "inf1", "visible" );
     	  	movObj("inf1", 0, 0);
	  }
}


var txtTickerTimeout;
var txtTickerMsg = "";

function chgTxtTickerMsg(divId, infId, message)
{
	obj = document.getElementById(divId);
	if( !obj.innerHTML )
	  {
	    changeInfo(divId, infId);
	    return;
	  }
	
	clearTimeout(txtTickerTimeout);
	if( message == "" )
		txtTickerMsg = "";
	else
	  {
		for( i = 0; i < message.length && i < txtTickerMsg.length; i++ )
		  if( message.charAt(i) != txtTickerMsg.charAt(i) )
		  	break;
		if( i < message.length )
			txtTickerMsg = txtTickerMsg + message.charAt(i);
			
		txtTickerTimeout = setTimeout( "chgTxtTickerMsg('" + divId + "', \"" + message + "\")", Math.random() * 50 + 50);
	  }
	
	obj.innerHTML = txtTickerMsg;
}
