// JavaScript Document

$(document).ready(function() {
	/*Shadowbox.init();*/
	$('#bt-tab-semana').click(function(event){
		$('#tabs-mes').hide();
		$('#tabs-dia').hide();
		$('#tabs-semana').show();
		$('#tabs-campeao').hide();
	}).css("cursor",'pointer');
	
	$('#bt-tab-dia').click(function(event){
		$('#tabs-mes').hide();
		$('#tabs-semana').hide();
		$('#tabs-dia').show();
		$('#tabs-campeao').hide();
	}).css("cursor",'pointer');
	
	$('#bt-tab-mes').click(function(event){
		$('#tabs-semana').hide();
		$('#tabs-dia').hide();
		$('#tabs-mes').show();
		$('#tabs-campeao').hide();
	}).css("cursor",'pointer');
	
	$('#bt-tab-campeao').click(function(event){
		$('#tabs-semana').hide();
		$('#tabs-dia').hide();
		$('#tabs-mes').hide();
		$('#tabs-campeao').show();
		
	}).css("cursor",'pointer');
	
	
	$('#tabs-semana').hide();
	$('#tabs-mes').hide();
	
	// CONTEUDO
	$('<span />').appendTo('.bloco');
	$('<span />').appendTo('.bloco-invertido');
	
	// ATLETAS - HOME
	$('.atleta-home table tr:nth-child(odd)').addClass('odd');
	$('.atleta-home table td:nth-child(odd)').addClass('odd');
	
	// ATLETAS - TABELAS
	$('.b-team table td:nth-child(odd)').addClass('odd');
	$('.b-team table td:nth-child(even)').addClass('even');
	$('.tab-produtos tbody tr td:nth-child(1)').css('text-align','left');
		
	
	
	// ATLETAS - TABELAS
	$('.campanha .produto .seta-menu:nth-child(2)').addClass('dois');
	
	//CONTATO RECLAMAÇÕES
	$('#assunto').change(display_reclamacoes);
	$('#cpf').setMask('999.999.999-99');
	$('#data_nascimento,#data_de_validade_do_produto').setMask('99/99/9999');
	$('#telefone, #celular').setMask('(99) 9999-9999');
	$('#cep').setMask('99999-999');
	
	$(".zend_form .errors").each(function(){
		$(this).css({'display':'none','position':'absolute','top':'1px','left':'1px'});
		$(this).parent().append('<img src="' + baseUri + '/images/error.png" />');
		var $error = $(this).html();
		$(this).prev('input, textarea').val(strip_tags($error)).css({'background-color':'#ccc'});
	});
	
});

function strip_tags($text){
	return $text.replace(/<\/?[^>]+>/gi, '');
}

$(function() {
    var galleries = $('.ad-gallery').adGallery();
    $('#switch-effect').change(
      function() {
        galleries[0].settings.effect = $(this).val();		
        return false;
      }	  
    );	
	
	// CLASSIFICACAO //
	
	$(".gt3").click(function(event){
		$(this).addClass("ativo");
		$(".gt4").removeClass("ativo");
		$(".truck").removeClass("ativo");
		$("#GTBR4").hide();
		$("#FTRUCK").hide();
		$("#GTBR3").show();
	}).css("cursor",'pointer');
	
	$(".gt4").click(function(event){
		$(this).addClass("ativo");
		$(".gt3").removeClass("ativo");
		$(".truck").removeClass("ativo");
		$("#GTBR3").hide();
		$("#FTRUCK").hide();
		$("#GTBR4").show();
	}).css("cursor",'pointer');
	
	$(".truck").click(function(event){
		$(this).addClass("ativo");
		$(".gt3").removeClass("ativo");
		$(".gt4").removeClass("ativo");
		$("#GTBR3").hide();
		$("#GTBR4").hide();
		$("#FTRUCK").show();
	}).css("cursor",'pointer');
	
	
	$('.classificacao .tabela tr td:first-child').addClass('td-posicoes');
	$('.classificacao .tabela tr td:last-child').addClass('td-pontos');
	
	// Drop down menu
	$(document).ready(function(){
		$('li.headlink').hover(
			function() { $('ul', this).css('display', 'block'); },
			function() { $('ul', this).css('display', 'none'); });
	});
	
});

function display_reclamacoes(){
	
	if($('#assunto').val() == "R"){
		$('#reclamacoes-element').css('display','block');
		$('.b-contato').animate({height:645},'200'); 
	}else{
		$('#reclamacoes-element').css('display','none');
		$('.b-contato').animate({height:514},'200'); 
	}
}

