var imagemAtual = 0;
var totalImagem = 1;
MontaGaleria = {
	init : function(json){
		this.JSON = eval(json);
		if(this.JSON.length){
			$('#boxImagemProduto').attr('src', 'files/produtos/imagem/'+this.JSON[0].arquivo);
			if(this.JSON[0].legenda!='') $('#boxLegenda').html(this.JSON[0].legenda).css('display', 'block');
		}
		MontaGaleria.ShowPages();
	},
	ShowPages : function(){
		if(this.JSON.length > 1){
			$('.fff').html('Imagem ' + (imagemAtual+1) + ' /');
			$('.totalImagem').html(this.JSON.length);
			$('.title').css('display', 'block');
		}
	},
	Move : function(){
		$('#boxImagemProduto').attr('src', 'files/produtos/imagem/'+this.JSON[(imagemAtual)].arquivo).css('display', 'none').fadeIn('slow');
		if(this.JSON[(imagemAtual)].legenda!='')
			$('#boxLegenda').html(this.JSON[(imagemAtual)].legenda).css('display', 'block');
		else
			$('#boxLegenda').css('display', 'none');
		MontaGaleria.ShowPages();
	},
	Next : function(){
		if(this.JSON.length){
			if(imagemAtual<(this.JSON.length-1)){
				imagemAtual++;		
				MontaGaleria.Move();
			}
		}
	},
	Prev : function(){
		if(this.JSON.length){
			if(imagemAtual>0){
				imagemAtual--;
				MontaGaleria.Move();
			}
		}
	},
	SemGaleria : function(){
		$('#divbarra').addClass('divbarranewconfg');
		$('.jScrollPaneContainer').addClass('jScrollPaneContainernewconfg');
	}
}
$(window).load(function(){
	$('.bt_prox').click(function(){ MontaGaleria.Next(); });
	$('.bt_ant').click(function(){ MontaGaleria.Prev(); });
});
