/* ------------ Carregando ------------- */
function boot_carregando(){
	$("#carregando").hide();
	$("#carregando").ajaxStart(function(){
	   $(this).fadeIn(500);
	});
	$("#carregando").ajaxStop(function(){
	   $(this).fadeOut(500);
	});
}

/* ------------ Ampliar ------------- */
function boot_ampliar(){
	jQuery.each($('img.ampliar'),function(i,val){
		var tag = $(this).parent().get(0).tagName;
		if ( tag != 'A' ){
			var caminho = $(this).attr('src');
			var cam = caminho;
			var partes = cam.split('/');
			var ok = false;
			
			var caminhox = '';
			
			var caminho1 = 'fotos/r-180-140-90';
			var caminho2 = 'fotos/r-760-600-80';
			jQuery.each(partes,function(i,val){
				if ( ok ){
					caminho1 += '/'+val;
					caminho2 += '/'+val;
					caminhox += '/'+val;
				}
				if ( val.substr(0,2) == 's-' || val.substr(0,2) == 'q-' || val.substr(0,2) == 'r-' ){
					ok = true;
					caminhox += 'fotos/'+val; 
				}
			});
			if ( ! ok ){
				caminho1 += '/'+caminho;
				//caminho1 = caminho;
				caminho2 += '/'+caminho;
				
				caminhox += '/'+caminho;
			}
			$(this).attr('src',caminhox);
			
			//alert(caminhox);
			
			$(this).before('<a rel="lightbox" class="lb lb_'+i+'" href="'+caminho2+'"></a>');
			$(this).appendTo($('a.lb_'+i));
			var alt = $(this).attr('alt');
			if ( alt != '' ){
				$('a.lb_'+i).append('<br />'+alt);
				$('a.lb_'+i).attr('title',alt);
			}
			$('a.lb_'+i).addClass($(this).attr('class'));
			//$('a.lb_'+i).width(186);
			
			$(this).load(function(){
				$('a.lb_'+i).width($(this).width()+10);
			});
			
			
			$('a.lb_'+i).removeClass('lb_i');
		}
	});
}

/* ------------ Alinhamento vertical ------------- */
function boot_vertical(){
	jQuery.each($('.vertical'),function(i,val){
		var elemento = $(this).parent().get(0);
		var imagem = $(this).children().get(0);
		var tipo = $(this).children().get(0).tagName;
		
		var diferenca = ( $(elemento).height() - $(imagem).height() ) / 2;
		if ( $(imagem).height() > 10 ){
			$(imagem).css('margin-top',diferenca);
		}
		
		
		if ( tipo == 'IMG' ){
			$(imagem).load(function(){
				var diferenca = ( $(elemento).height() - $(imagem).height() ) / 2;
				if ( $(imagem).height() > 10 ){
					$(imagem).css('margin-top',diferenca);
				}
			});
		}
	});
}

/* ------------ Blank ------------- */
function boot_blank(){
	jQuery.each($('a[rel="externo"], a.externo'),function(){
		$(this).attr('target','_blank');
		$(this).addClass('trans');
	});
}

/* ------------ Light Box ------------- */
function boot_lightbox(){
	$('a.lb').lightBox();
}

/* ------------ MP3 Player ------------- */
function boot_mp3(){
	$("a[href$='mp3'][class!='simples']").flash(
		{ 
			src: 'flash/mp3.swf', 
			height: 20, 
			width: largura_audio,
			wmode: 'transparent',
			flashvars: { 
				backColor: '006600',
				frontColor: 'FFFFFF'
			} 
		},
		{ version: 7 },
		function(htmlOptions) {
			$this = $(this);
			htmlOptions.flashvars.file = $this.attr('href');
			$this.before($.fn.flash.transform(htmlOptions));	
			$(this).remove();		
			htmlOptions.title = 'ABCdeFg';
		}
	);
}

/* ------------ Tags ------------- */
function boot_tags(){
	$('div.keys').hide();
}

/* -----------Tabelas------------- */
function boot_tabelas(){
	var contador = 0;
	$.each($('table.zebra tr'),function(){
		contador++;
		if ( contador % 2 != 0){
			$(this).addClass('sim');
		} else {
			$(this).removeClass('sim');
		}
	});
}