var cTimeout = 5000;
var stop_flag = 0;
var actual = 1;
var img = new Array();

function init()
{	

	for (var i=1;i<4;i++)
	{
		// Precarrega Imatges
		img[i] = new Image();  
		img[i].src = "./img/portada"+i+".jpg";
	}
	// Timeout
	self.setTimeout('rollImatge()', cTimeout);
}


function rollImatge()
{
	if (!stop_flag)
	{
		if(++actual>3) actual=1;
		canviaImatge(actual)
		self.setTimeout('rollImatge()', cTimeout); 
	}
}


function canviaImatge(nova_imatge)
{
	document['imatge'].src=img[nova_imatge].src;
}

