function slideshow(){
	listaSlides = new Array();
	listaTempos = new Array();
	
	if (total > 0){
		for (i=1;i<=total;i++){
			pos = i-1;
			listaSlides[pos] = i+'.jpg'; 	
			listaTempos[pos] = tempo; 	
		}
	} else {
		listaSlides = Imagens.split(',');
		if (tempo == 0) {
			listaTempos = Tempos.split(',');	
		} else {
			for (i=1;i<=listaSlides.length;i++){
				pos = i-1;
				listaTempos[pos] = tempo; 	
			}	
		}
	}
	banner1 = path+listaSlides[0];
	banner2 = path+listaSlides[1];	
	
	if (wrapper == '') wrapper = 'slideshow';
	dimensoes = dimensoes.split(',');
	w = dimensoes[0];
	h = dimensoes[1];	
	$('#'+wrapper).html('');
	$('#'+wrapper).html('<div class="banner">' +
	    '<div id="banner2" style="position:absolute; display:none;"><img src="'+banner2+'" width="'+w+'" height="'+h+'"></div>' +
    	'<div id="banner1" style="position:absolute;"><img src="'+banner1+'" width="'+w+'" height="'+h+'"></div>' +
    '</div>')
	
	slideAtual  = 0;
	trocaSlide(0);	
}

function trocaSlide(painel){
	if (painel == 0){
		tempoAtual = listaTempos[slideAtual];
		timer = setTimeout('trocaSlide(1)', tempoAtual);	
	} else {
		totalSlides = listaSlides.length;		
		clearTimeout(timer);		
		
		tempoAtual = listaTempos[slideAtual];		
		slideAtual++;
		if (slideAtual >= totalSlides) slideAtual = 0;			

		proximoSlideImg = listaSlides[slideAtual];
		
		if (painel == 1){
			$("div#banner2").css('display', 'block');
				$("div#banner1").fadeOut('slow', function(){
				$("div#banner1 img").attr('src', path+proximoSlideImg);
				//$("div#banner1 a").attr('href', lstBnr[prxBnr]+'.html');			
				timer = setTimeout('trocaSlide(2)', tempoAtual);
			});
			
		} else if (painel == 2){
			$("div#banner1").fadeIn('slow', function(){
				$("div#banner2 img").attr('src', path+proximoSlideImg);
				//$("div#banner2 a").attr('href', lstBnr[prxBnr]+'.html');			
				timer = setTimeout('trocaSlide(1)', tempoAtual);
			})
		}
	};
}
