/**
 * 
 * @param id_produto
 * @return
 */
function carrinho_exibe_detalhe(id_produto)
{
	$("#divDetalhesProduto"+id_produto).toggle();
}

/**
 * 
 * @param obj
 * @return
 */
function atualiza_opt_ins(obj)
{
	$.ajax({
		url: "ajax.php",
		type: 'post',
		cache: false,
		data: {acao: 'atualiza_opt_ins', id_optin: obj.value, checked: obj.checked},
		dataType: 'json',
		success: function(retorno)
		{
			$("#td_total_geral").html(retorno.total_geral);
		},
		error: function(XMLHttpRequest, textStatus, errorThrown)
		{
			alert(textStatus);
		}
	});
}

/**
 * 
 * @param msg
 * @return
 */
function carrinho_exibir(msg)
{
	$("#msg").val(msg);
	$("#acao_site").val('exibir');
	$("#dados").attr("action", "carrinho.php");
	$("#dados").submit();
}

/**
 * 
 * @param indice
 * @return
 */
function carrinho_inscricao_excluir(indice)
{
	if (confirm('Confirma exclusão ?'))
	{		
		$("#botao_finalizar_pedido").attr('disabled', true);
		$("#botao_carrinho_limpar").attr('disabled', true);
		$("#botao_adicionar_novas").attr('disabled', true);
		$.ajax({
			url: "ajax.php",
			type: 'post',
			cache: false,
			data: {acao: 'carrinho_inscricao_excluir', indice: indice},
			dataType: 'json',
			success: function(retorno)
			{
				carrinho_exibir();
			},
			error: function(XMLHttpRequest, textStatus, errorThrown)
			{
				alert(textStatus);
			}
		});	
	}
}

/**
 * 
 * @return
 */
function carrinho_limpar()
{
	if (confirm('Confirma ?'))
	{
		$.ajax({
			url: "ajax.php",
			type: 'post',
			cache: false,
			data: {acao: 'carrinho_limpar'},
			dataType: 'json',
			success: function(retorno)
			{
				home_exibir();
			},
			error: function(XMLHttpRequest, textStatus, errorThrown)
			{
				alert(textStatus);
			}
		});	
	}
}

/**
 * 
 * @param obj
 */
function carrinho_seleciona_pgto(codigo)
{
	$("input[name='forma_pgto']").each(function(i,n){
		if (n.value == codigo)
		{
			n.checked = true;
		}
	});	
}
