var qtd = 4;                 //qtd de items

theDuration = 1000;          //duracao da transicao
IntervalBetween = 4000;      //o tempo que cada imagem mostra

w = 264;
h = 188;

var imagens = Array(qtd);

imagens[1] = "/media/pubs/image1_PT.jpg";
imagens[2] = "/media/pubs/image2_PT.jpg";
imagens[3] = "/media/pubs/image3_PT.jpg";
imagens[4] = "/media/pubs/image4_PT.jpg";

var links = Array(qtd);

links[1] = "http://www.petercafesport.com/whale_watching/index.php";
links[2] = "http://www.petercafesport.com/media.php";
links[3] = "http://www.petercafesport.com/actividades/index.php";
links[4] = "http://www.petercafesport.com/blog/index.php";

// ------------------ NÃO MEXAER DAQUI PRA BAIXO ----------------------

function show(whichOne){
	if (whichOne == 1) {
		tDiv = "div" + qtd;
		vDiv = "div1";
	} else {
		tDiv = "div" + (whichOne-1);
		vDiv = "div" + whichOne;
	}
	
	if($(tDiv).fx){$(tDiv).fx.stop();}
	if($(vDiv).fx){$(vDiv).fx.stop();}
	
	$(tDiv).fx = $(tDiv).effect('opacity', {duration: theDuration}).start(0);
	$(vDiv).fx = $(vDiv).effect('opacity', {duration: theDuration}).start(1);
}

x = 1;

document.write('<div id="div_pub_peter" style="height:' + h + 'px; display: block;">');

for (x=1; x<=qtd; x++)
	document.write('<div id="div' + x + '" style="position:absolute; opacity: 0;"><a href="' + links[x] + '" target="_blank"><img id="image' + x + '" src="' + imagens[x] + '" width="' + w + '" height="' + h + '"  border="0" /></a></div>');

document.write('</div>');

function showCicle(y) {
	show(y);
	
	if(y==qtd) y=1;
	else y++;
	
	window.setTimeout("showCicle(" + y + ");", IntervalBetween);
}

showCicle(1); //chama o 1º
