var newsBanner1Counter = 0;
var vztBanner1TimerTimeout;
var opacityCounter = 0;
var opacityTimeout;

var maxvalue;
var last;

function startBanner1Timer()
{
	maxvalue = parseInt( document.getElementById( 'maxbanner1' ).value );
	vztBanner1TimerTimeout = setTimeout(banner1TimerStart, 0);
}

function banner1TimerStart() {
	vztBanner1TimerTimeout = setInterval(showHideBanner1TimerBoxes, 4000);
}

function showHideBanner1TimerBoxes()
{
	clearTimeout( opacityTimeout );
	
	last = newsBanner1Counter;
	newsBanner1Counter = newsBanner1Counter+1;
	if ( newsBanner1Counter == maxvalue )
		newsBanner1Counter = 0;

	for( var i=0;i<maxvalue;i++ )
	{
		if ( i == newsBanner1Counter )
			showBanner( i );
		else
			document.getElementById( 'image' + i ).style.display = 'none';
	}
}

var active;
var next;

function showBanner( pointer )
{
	//alert( "active = image" + last + ". next = " + pointer );
    active = document.getElementById( 'image' + last );
	next = document.getElementById( 'image' + pointer );

	document.getElementById( 'quicklink' + pointer ).className = 'quicklink quicklinkselected';
	document.getElementById( 'quicklink' + last ).className = 'quicklink';

	active.style.display = 'inline';
	next.style.display = 'inline';
	
	opacityTimeout = setTimeout(opacityTimerStart, 0);
}

function opacityTimerStart() {
	opacityTimeout = setInterval(opacityx, 50);
}

function opacityx()
{
	opacityCounter = opacityCounter + 1;
	var opacityMinus = 10-opacityCounter;

	active.style.opacity = '0.' + opacityMinus;
	active.style.filter = "alpha(opacity:"+opacityMinus*10+")"; 

	if ( opacityCounter < 10 )
	{
		next.style.opacity = '0.' + opacityCounter;
		next.style.filter = "alpha(opacity:"+opacityCounter*10+")"; 
	}
	
	if ( opacityCounter >= 10 )
	{
		active.style.display = 'none';
		next.style.display = 'inline';
		next.style.opacity = '1.0';
		next.style.filter = "alpha(opacity:100)"; 
		opacityCounter = 0;
		clearTimeout( opacityTimeout );
	}
}


function goToSlide( pointer )
{
	if ( pausexxx == 1 )
	{
		pausexxx = 0;
		document.getElementById( 'quicklinkpause' ).className = 'quicklink quicklinkpause';
		startBanner1Timer();		
	}
	
	newsBanner1Counter = pointer;
	for( var i=0;i<maxvalue;i++ )
	{
		if ( i == pointer )
		{
			document.getElementById( 'image' + i ).style.opacity = '1.0';
			document.getElementById( 'image' + i ).style.display= 'inline';
			document.getElementById( 'image' + i ).style.filter = "alpha(opacity:100)"; 
			document.getElementById( 'quicklink' + i ).className = 'quicklink quicklinkselected';
		}
		else
		{
			document.getElementById( 'image' + i ).style.opacity = '0.0';
			document.getElementById( 'image' + i ).style.filter = "alpha(opacity:0)"; 
			document.getElementById( 'image' + i ).style.display= 'none';
			document.getElementById( 'quicklink' + i ).className = 'quicklink';
		}
	}
	
	clearTimeout( vztBanner1TimerTimeout );
	startBanner1Timer();
}

var pausexxx = 0;

function pauseMe()
{
	if ( pausexxx	== 0 )
	{
		pausexxx = 1;
		document.getElementById( 'quicklinkpause' ).className = 'quicklink quicklinkpaused';
		clearTimeout( vztBanner1TimerTimeout );
	}
	else
	{
		pausexxx = 0;
		document.getElementById( 'quicklinkpause' ).className = 'quicklink quicklinkpause';
		startBanner1Timer();	
	}
}

function goToURL( url )
{
	this.location = url;	
}

function setSelected( div )
{
	document.getElementById( div ).className = 'menuitem selected';
}

function removeSelected( div )
{
	document.getElementById( div ).className = 'menuitem';
}