jQuery(function($){
	
	$('#banners_slide').cycle({ 
		fx:     'fade', 
		timeout: 5000
	 });
	
	//Mascara
	$("#tiDDD").mask("99");
	$("#tiTelefone").mask("9999-9999");
	
	$("#tcDDD").mask("99");
	$("#tcCelular").mask("9999-9999");
	
	//Mascara curriculos
	$("#cep").mask("99999-999");
	$("#tel_res").mask("9999-9999");
	$("#tel_cel").mask("9999-9999");
	$("#tel_com").mask("9999-9999");
	$("#nascimento").mask("99/99/9999");
	
	$.easing.backout = function(x, t, b, c, d){
		var s=0;
		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
	};

	
	
	//Fotos
	$('.exibeLightbox').lightBox();
	
	$('#thumbs_car').scrollShow({
		view:'#slideshow',
		content:'#images',
		easing:'backout',
		wrappers:'crop',
		navigators:'a[id]',
		circular:false,
		start:0
	});

});

function fontSize(action, container){
	
    baseSize = parseInt($(container).css("font-size"))

    $els = $(container)
 
    $els.each(function(){
        $fs = parseInt($(this).css("font-size"))
        if(action=="plus" && baseSize<16 ) $fs+=1
        else if(action=="minus" && baseSize>13) $fs-=1
        $(this).css("font-size", $fs)
    });
}

$(function(){
    $("#liDiminuiFonte").click(function(){ fontSize("minus","#conteudo_corpo .texto") }).blur()
    $("#liAumentaFonte").click(function(){ fontSize("plus","#conteudo_corpo .texto") }).blur()
});

function validaNewsletter()
{ 
	var erro = '';
	var email = document.getElementById('email'); 
	if(!email.value) { erro = erro + '- E-mail\n'; }
	
	if(erro) {
		alert('Preencha o campo E-mail!');
		return false;
	}
	
	//E-mail
	if(!validaemail(email.value)) {
		alert('E-mail inválido.');
		return false;
	}
	
	return true;
}

function validaemail(email)
{
	p=email.indexOf("@");
	z=email.indexOf(".");
	if ((p<1 || p==(email.length-1)) || (z<1 || z==(email.length-1))) 
		return false;
	return true;
}

function abrirUrl(URL){
	window.open('http://'+URL)
}

function textCounter(campo, countcampo, maxlimit) {
	if (campo.value.length > maxlimit) 
		campo.value = campo.value.substring(0, maxlimit); 
	else
		countcampo.value = maxlimit - campo.value.length; 
}

function external(path) { // pass in the correct path to the function so we only need one <A> for infinite amount of calls from  flash                          
// if the lightbox does not exist we will make it                       
	if ($('a#lightbox').length == 0) {                             
		$("body").append("</A><A id='lightbox' style='visibility: hidden; position: absolute; left: -9999px;' href='http://www.thetruetribe.com/+path+'>calling js lightbox from flash</A>");                            
		$('a#lightbox').lightBox();                   
		// if it already exists but the path is different we will set the new path                      
	} else if ($('a#lightbox').attr("href") != path) {                             
		$('a#lightbox').attr("href", path);                   
	}      
	// now we will simulate the click here.                         
	$('a#lightbox').trigger("click");      
}


function fechar_popup(){
    $("#popup").hide();
};

function trocaImagem(IMG){
	$("#previewPaneFoto").attr("src","thumb.php?im="+IMG);
	$("#target_foto_gg").attr("href",IMG );
}


