atual = 0;
total = imagens.length;
function anterior(){
	if(atual > 0){ 
		atual = atual -1; 
		location.href='#' + atual;
		//$("#fotogrande").fadeIn(); 
		$('#fotogrande').html('<img src="'+ imagens[atual] +'" alt="" border="0" />'); 
		$('#legenda').html('Foto ' + (atual + 1) + '/'+ total);
		$('#foto_legenda').html(fotolegenda[atual]);
		//$("#fotogrande").fadeIn('slow');	
	} 
}
function proxima(){
	if(atual < (total - 1)){
		atual++; 
		location.href='#' + atual;
		//$("#fotogrande").fadeIn();
		$('#fotogrande').html('<img src="'+ imagens[atual] +'" alt="" border="0" />');
		$('#legenda').html('Foto ' + (atual + 1) + '/'+ total);
		$('#foto_legenda').html(fotolegenda[atual]);
		//$("#fotogrande").fadeIn('slow');
	} 
}

function show(){
	$('#start').hide();
	$('#stop').show();
	$(this).everyTime(3000, 'slideshow', function() {if(atual < (total - 1)){proxima();} else {atual = -1; proxima();}});
}

function stop(){
	$('#stop').hide();$('#start').show();$(this).stopTime('slideshow');
}

var active = false;

function init() {

gup = function(){
	var regexS = "(#[0-9]\[0-9]?\[0-9]?)";
	//var regexS = "([\\#][^]*)";
	var regex = new RegExp(regexS);
	var results = regex.exec( window.location.href );
	if(results == null) { var atual = 0; }
	else {
		var atual = results[0].substring(1);
		atual = parseInt(atual);
	}
	return atual;
} 

var atual = gup();

$('#fotogrande').html('<img src="'+ imagens[atual] +'" alt="" border="0" />');
$('#legenda').html('Foto ' + (atual + 1) + '/'+ total);
$('#foto_legenda').html(fotolegenda[atual]);
}

window.onload = init;