function agenda_ingresso_carrinho(){
	carregaAjax('php/ingressos_carrinho.php','dv_ingressos_carrinho','dv_ingressos_carrinho_carregando');
	}
	
//---->


function ingresso_insere_carrinho(id_busca){
	
	quantidade = document.getElementById('cp_ingresso_quantidade_'+id_busca);
	if(quantidade.value=='0'){
		alert('Selecione a quantidade de ingressos');
		return false;
		}
		
	carregaAjax('php/ingressos_carrinho.php?modo=add&id_add='+id_busca+'&quantidade='+quantidade.value,'dv_ingressos_carrinho','dv_ingressos_carrinho_carregando');
	}
	
//----->

function ingresso_remove_carrinho(id_excluir){
	carregaAjax('php/ingressos_carrinho.php?modo=del&id_excluir='+id_excluir,'dv_ingressos_carrinho','dv_ingressos_carrinho_carregando');
	}
	
//----->

function ingresso_carrinho_over(){
	$('#dv_ingresso_carrinho_lista').slideDown("fast",function(){
															$("#dv_ingressos_carrinho").bind("mouseleave", function(e){
																	$('#dv_ingresso_carrinho_lista').slideUp("fast");
																	});														   
															   });
	}
	
//----->

function ingresso_carrinho_out(){
	ingresso_exibe_btn_excluir_oculta();
	setTimeout(function(){
		ocultaCorte('dv_ingresso_carrinho_lista');
        },1000);
	}
	
//----->

function ingresso_exibe_btn_excluir_exibe(i){
	$('#ingresso_icon_lista_excluir_'+i).animate({
        width: "28px",
		left: "-28px"
      }, 500);
	}


//----->	

function ingresso_exibe_btn_excluir_oculta(){
	$('#dv_ingresso_carrinho_lista .item_lista .excluir').animate({
        width: "0px",
		left: "0px"
      }, 500);
	}

//----->

function ingresso_sedex_alterna(){
	
	alternaDisplayCorte('dv_entrega_sedex');
	alternaImagens('img_sedex','imagens/ingresso_seta_baixo.png','imagens/ingresso_seta_cima.png');
	
	}

//----->

function ingresso_retirada_alterna(){
	
	alternaDisplayCorte('dv_entrega_retirada');
	alternaImagens('img_retirada','imagens/ingresso_seta_baixo.png','imagens/ingresso_seta_cima.png');
	
	}
	
//----->

function ingresso_local_alterna(){
	
	alternaDisplayCorte('dv_entrega_local');
	alternaImagens('img_local','imagens/ingresso_seta_baixo.png','imagens/ingresso_seta_cima.png');
	
	}

//---->

function ingresso_confere_form_calculo_frete(){
	formulario = document.getElementById('form_calculo_frete');
	cep = document.getElementById('cp_sedex_cep');
	
	if(cep.value==''){
		alert('Informe corretamente seu cep para recebimento da compra');
		cep.focus();
		return false;
		}
	if(cep.value.length!=8){
		alert('Informe corretamente seu cep para recebimento da compra');
		cep.focus();
		return false;
		}
		
	formulario.submit();
		
	}
	
//---->	

function ingresso_selecionar_frete(){
	formulario = document.getElementById('form_calculo_frete');
	cep = document.getElementById('cp_sedex_cep');
	
	if(cep.value==''){
		alert('Informe corretamente seu cep para recebimento da compra');
		cep.focus();
		return false;
		}
	if(cep.value.length!=8){
		alert('Informe corretamente seu cep para recebimento da compra');
		cep.focus();
		return false;
		}
		
	formulario.submit();
		
	}
	
//---->	

function ingresso_escolher_frete(valor,tipo,rotulo_tipo,tipo_id,cep){
	
	$('.borda').slideUp("fast");
	
	exibeCorte('dv_ingressos_modo_envio_final');
	$('#cp_ingressos_frete_fecha_valor').val(valor);
	$('#cp_ingressos_frete_fecha_tipo').val(tipo);
	$('#cp_ingressos_frete_fecha_tipo_id').val(tipo_id);
	$('#cp_ingressos_frete_fecha_cep').val(cep);
	$('#rotulo_ingressos_frete_fecha_tipo').text(rotulo_tipo);
	$('#rotulo_ingressos_frete_fecha_valor').text(valor);
	
	}

//////// --------- >

function ingresso_enviar_formulario_pedido(){
	
	parcelas = $('#cp_ingresso_quant_parcela').val();
	
	if(parcelas==''){
		alert('Selecione a forma de parcelamento da sua compra');
		return false;
		}
	
	
	formulario = document.getElementById('form_pedido');
	if(confere_form('form_nome,form_email,form_cpf,form_endereco,form_numero,form_bairro,form_cidade,form_uf,form_cep,form_pais,form_telefone')==false){
		return false;
		}
	
	cpf = document.getElementById('form_cpf');
	if(ingressoConfereCPF(cpf.value)==false){
		alert('Preencha corretamente seu CPF');
		alternaEstilo('form_cpf','borda_erro');
		cpf.focus();
		return false;
		}
	
	formulario.submit();
	}
	
//////// --------- >	

function ingressoConfereCPF(c){

	c = c.toString()
	c = c.replace(".","")
	c = c.replace(".","")
	c = c.replace(".","")
	c = c.replace("-","")

	var i; 
	s = c;
	var c = s.substr(0,9); 
	var dv = s.substr(9,2); 
	var d1 = 0; 
	var v = false;
	
	for (i = 0; i < 9; i++) { 
		d1 += c.charAt(i)*(10-i); 
		} 
	
	if (d1 == 0){ 
		v = true; 
		return false; 
		} 

	d1 = 11 - (d1 % 11); 
	if (d1 > 9){
		d1 = 0; 
		}
	if (dv.charAt(0) != d1) { 
		v = true;
		return false; 
		} 

	d1 *= 2; 
	
	for (i = 0; i < 9; i++) { 
		d1 += c.charAt(i)*(11-i); 
		} 
		
	d1 = 11 - (d1 % 11); 
	
	if (d1 > 9){ 
		d1 = 0; 
		}
		
	if (dv.charAt(1) != d1) { 
		v = true;
		return false; 
		} 
	if (!v) {
		return true
		}
}

//////// --------- >

function ingresso_escolher_parcelamento(valor,num_parcela){
	
	$('#cp_ingresso_valor_parcela').val(valor);
	$('#cp_ingresso_quant_parcela').val(num_parcela);
	
	}

//////// --------- >

function ingresso_concluir_compra(){
	
	formulario = document.getElementById('form_pag_seguro');
	formulario.submit();
	
	setTimeout("ingresso_redirecionar()",3000);
	
	}

//////// --------- >

function ingresso_redirecionar(){
	location.href="ingressos_pagto_enviado.php";
	}

