/*
 * canvia el color del fons d'una cel.la
 */
function cellcolor( cell, background_color )
{
	cell.bgColor = background_color;
}

/*
* redirecciona una url per el menu principal
*/

function redireccio( txtUrl ) {
	window.open( txtUrl, '_self');
}

/*
 * inciailitza una imatge (img<num>) amb la URL que hi hagi en l'array
 */
function inicialitza( num ) 
{
	// si no hi ha noticies, sortir
	if( total == 0 )
		return;

	// si arribem al final tornem a començar
	if (i == total) {
		i = 0;
	}
	
	var text = document.getElementById('img'+num);
	
	text.src = texts[i];

	// avançar apuntador	
	i++;
}

/*
 * funcio cicle per 1 imatges
 */
function cycle1() 
{
	// si no hi ha noticies, sortir
	if( total == 0 )
		return;

	// si arribem al final tornem a començar
	if (i == total) {
		i = 0;
	}
	
	var text = document.getElementById('img1');
	
	text.src = texts[i];

	// avançar apuntador i engegar timeout	
	i++;
	window.setTimeout("cycle1()",3000);
}

/*
 * funcio cicle per 2 imatges
 */
function cycle2() 
{
	// si no hi ha noticies, sortir
	if( total == 0 )
		return;

	// si arribem al final tornem a començar
	if (i == total) {
		i = 0;
	}
	
	// vars dels elements 
	if( i % 2 == 0 )
		var text = document.getElementById('img1');
	else 
		var text = document.getElementById('img2');
	
	text.src = texts[i];

	// avançar apuntador i engegar timeout	
	i++;
	window.setTimeout("cycle2()",5000);
}

/*
 * funcio cicle per 4 imatges
 */
function cycle4() 
{
	// si no hi ha noticies, sortir
	if( total == 0 )
		return;

	// si arribem al final tornem a començar
	if (i == total) {
		i = 0;
	}
	
	// vars dels elements 
	if( i % 4 == 0 )
		var text = document.getElementById('img1');
	else if( i % 4 == 1 )
		var text = document.getElementById('img2');
	else if( i % 4 == 2 )
		var text = document.getElementById('img3');
	else
		var text = document.getElementById('img4');
	
	text.src = texts[i];

	// avançar apuntador i engegar timeout	
	i++;
	window.setTimeout("cycle4()",5000);
}