
//Mascara para inputs
$(document).ready( function() {
  
  //Form de Solicitar Informações, Contato 
  $("#telefone").mask("(99) 9999-9999");
  $("#fax").mask("(99) 9999-9999");
  
  //Cadastro de Cliente
  $("#cli_telefone").mask("(99) 9999-9999");
  $("#cli_fax").mask("(99) 9999-9999");
  $("#cli_cep").mask("99999-999");
  
  //Inscrição Online
  $(".ins_dtnascimento").mask("99/99/9999");
  $(".ins_cpf").mask("999.999.999-99");
  $(".ins_rg").mask("99.999.999-*");
  $(".ins_telefonecomercial").mask("(99) 9999-9999");
  $("#ins_celular").mask("(99) 9999-9999");
  $("#ins_cnpj").mask("99.999.999/9999-99");
  $("#ins_cepempresa").mask("99999-999");
  $("#ins_cepentrega").mask("99999-999");
  $("#ins_faxempresa").mask("(99) 9999-9999");
  $("#ins_telefoneentrega").mask("(99) 9999-9999");
  $("#ins_telefoneempresa").mask("(99) 9999-9999");
  
  
});


//Lightbox Init
$(function() {
    $('#galeria_fotos a').lightBox();
});

//Init Frame em Lightbox
function window_visa(){
    var GB_ANIMATION = true;
    
      $(document).ready(function(){
          //var t = this.title || $(this).text() || this.href;
          GB_show('Termo de Autorização VISA','termo-cartao-visa.php',325,480);
          return false;
          
        //$("a.greybox").click(function(){
        //  var t = this.title || $(this).text() || this.href;
        //  GB_show(t,this.href,470,600);
        //  return false;
        //});
        
      });
}

//Exibir imagem dos produtos do carrinho
$(document).ready( function() {
    $("#img_pagseguro").hide();
    $('#info').mouseover( function(){
		$(this).next('#img_pagseguro').fadeIn('fast');
		$(this).mouseout( function(){
			$(this).next('#img_pagseguro').fadeOut('fast');
		});
	});
});

function fechar() {
	document.getElementById('banner-exp-hexa').style.display='none';
}


/*Pagina de insricao*/
$(document).ready(function(){
    
    var contar_abas = function(){
        //Adicionando numeros dos participantes
        var i = 1;
        $('#participantes').children('.participante').each(function(){
            i++;
        });
        return i;
    }
    
    var numero_abas = function(){
        //Adicionando numeros dos participantes
        var i = 1;
        $('#participantes').children('.participante').each(function(){
            $(this).children('h3').children('.index').html(i++)
        });
    }
    
    var investimento = function(){
        //Adicionando numeros dos participantes
        var i = 0;
        $('#participantes').children('.participante').each(function(){
            i++;
        });
        
        var valor = ($('#valor_investimento').val()) * parseInt(i);
        
        var aux = document.createElement("input");
		aux.id = 'aux';
		aux.type = 'hidden';
		$('body').append(aux);
        
        var number = new Number();
		number=Math.sqrt(valor);
		$('#aux').val(valor.toFixed(2));
        
        $('#aux').priceFormat({
            prefix: '',
            centsSeparator: ',',
            thousandsSeparator: '.'
        });
        
        valor =  $('#aux').val();
        
        return valor;
    }
    
    var remove_participante = function(){
        $('.remove').click(function(){
            $(this).parent().parent('.participante').remove();
            numero_abas();
            $("#investimento").text( investimento() );
        });
    }
    
    /*Evento nas abas*/
    var abas = function(e){
	    /*
        e.click(function(){
            e.next("span").slideToggle("fast").siblings("span:hidden").slideUp("fast");
            e.toggleClass("active");
            e.removeClass("active");            
        });*/
        e.next("span").show();
        numero_abas();
        if(contar_abas() > 2)
            e.append('<a href="javascript:void(0)" class="remove">x</a>');
        remove_participante();
        $("#investimento").text( investimento() );        
	}
    
    //$("#participantes span.conteudo").hide(); //Recolhe o conteudo de todas as abas
	abas($("#participantes h3"));
    
    //Adicionar participante
    $('#add').click(function(){
        $('#participantes').append("<div class='participante'>"+$(this).prev('#participantes').children('.participante').html()+"</div>");
        var participante = $('#participantes').children('.participante:last').children('h3');
        abas(participante); //Evento na aba criada
        //participante.next("span").hide();
        participante.toggleClass("active");
        participante.removeClass("active");
        
        participante.next('span.conteudo').children("p").children("input, select, textarea").each(function(){
            $(this).val('');
        });
        participante.next('span.conteudo').children("p").children("input.ins_nome").focus();
        
        //Aplicando mascaras
        participante.next('span.conteudo').children("p").children("input.ins_dtnascimento").mask("99/99/9999");
        participante.next('span.conteudo').children("p").children("input.ins_cpf").mask("999.999.999-99");
        participante.next('span.conteudo').children("p").children("input.ins_rg").mask("99.999.999-*");
        participante.next('span.conteudo').children("p").children(".fone2").children("input.ins_telefonecomercial").mask("(99) 9999-9999");
    });
	
	$('#ins_declaro').click(function(){
		if(this.checked)
			$('#submit').attr('disabled', false); 
		else
			$('#submit').attr('disabled', true); 
	});
});

