/*VAR*/
press_button = false;

/*#CONTINUAR #*/	//Fazer novas inscrições
function carrinho_continuar() {
	location.href					= 'default.asp';
}

/*#LIMPAR#*/	//Cancelar Inscrições
function carrinho_limpar(sessaoID) {
    if (!press_button)	{
		press_button				= true;
		codigo.location.href		= 'codigos/carrinho_limpar.asp?sessaoID='+sessaoID;
	}
}


/*#REMOVER#*/
function carrinho_remover(pacoteID,sessaoID)	{
    if (!press_button)	{
		press_button	= true;
		codigo.location.href		= 'codigos/carrinho_remover.asp?pacoteID='+pacoteID+'&sessaoID='+sessaoID;
	}
}

/*#INSERIR#*/	//inscreva-se
function carrinho_inserir(pacoteID,sessaoID)	{
    if (!press_button)	{
		press_button	= true;
		codigo.location.href		= 'codigos/carrinho_inserir.asp?pacoteID='+pacoteID+'&sessaoID='+sessaoID;
	}
}


/*#FINALIZAR #*/	//Continuar
function carrinho_finalizar(actB) {
	location.href					= 'default.asp?actA=5';
}

/*# CADASTRO #*/
function cadastro() {
	location.href					= 'default.asp?actA=14';
}


/*# CARRINHO PAGAMENTO #*/
function carrinho_pagamento() {
	id_conhecimento	= 0;
	erroVC			= '';
	
	//Desativa o link e exibe o botão processando
	document.getElementById("td_continuarBT").innerHTML	= '<img src="../imagens/layout/bt_34.gif" alt="Processando">';
	//Nessa etapa o pedido será sempre zero, pq ainda não foi cadastrado.
	id_pedido			= 0;
	//Pega o valor do meio de pagamento escolhido.
	it_pagamento_tipo	= get_radio_value(document.pagamentoFRM.pagamento_tipoIT);
	
	//Verifica se foi escolhido alguma forma de pagto.
	if (!it_pagamento_tipo) {
	 	erroVC	= erroVC + '- Escolha a Forma de Pagamento!\n';
	}
	
	//Verifica se foi escolhido algum como ficou sabendo. SE já, atribui a variavel
	if (document.getElementById("conhecimentoID").value == 0) {
	 	erroVC	= erroVC + '- Escolha Como você ficou sabendo!\n';	
	}else{
		id_conhecimento	= document.getElementById("conhecimentoID").value;
		vc_conhecimento = document.getElementById("conhecimentoVC").value;
		
		if((id_conhecimento == 3 || id_conhecimento == 4 || id_conhecimento == 7 || id_conhecimento == 11) && vc_conhecimento.length == 0){
	 		erroVC	= erroVC + '- Preencha Como você ficou sabendo!\n';	
		}
	
	}
	
	//Se tiver escolhido forma de pagto e como conheceu prossegue no pagamento, SENÃO exibe o alerta e retorna pra tela de escolha de pagto.
	if (erroVC.length == 0){
		//Tipo do Pagamento Escolhido.  (Representado pelo valor antes do hífen no value).
		id_pagamento_tipo	= it_pagamento_tipo.split("-")[0];
		
		//Se o pagamento for 3 ou 4 (DEPÓSITO) chamará o código_pagamento no iframe codigo, senão chama um popup com os procedimentos de cada banco e atualizara o site pra uma tela de aguardo.
		if (id_pagamento_tipo == 3 || id_pagamento_tipo == 4 ){
			codigo.location.href = 'codigos/pagamento.asp?pedidoID='+id_pedido+'&pagamento_tipoIT='+it_pagamento_tipo+'&conhecimentoVC='+vc_conhecimento+'&conhecimentoID='+id_conhecimento;
		}else{
			//Dimensões do popup
			it_width 	= 780;
			it_height 	= 482
			
			window.open('codigos/pagamento.asp?pedidoID='+id_pedido+'&pagamento_tipoIT='+it_pagamento_tipo+'&conhecimentoVC='+vc_conhecimento+'&conhecimentoID='+id_conhecimento,'pagamento','width='+it_width+',height='+it_height+',top=50,left=50,location=no,status=no,menubar=no,scrollbars=auto,resizable=no,directories=no,toolbar=no');
			location.href = '../?actA=17'; 
		}
	}else{
		alert('ATENÇÃO!\n\n' + erroVC);
		document.getElementById("td_continuarBT").innerHTML = '<input type="image" class="img_02" src="imagens/layout/bt_13.gif" onClick="carrinho_pagamento();" alt="Continuar" />';
		return false;
	}
}

/*REEMISSÃO DA FORMA DE PAGTO (CARTÃO)*/
function pagamento_reemitir(id_pedido,id_pagamento_tipo,W,H) {
	var X = Math.ceil( (window.screen.height - H) / 2 ) - 20;
	var Y = Math.ceil( (window.screen.width - W) / 2 ) - 16;
	
	//REEMISSÃO REDECARD
	if (id_pagamento_tipo == 5 || id_pagamento_tipo == 6){
		vc_pagamento_tipo	= 'redecard';
	//REEMISSÃO VISA
	}else if (id_pagamento_tipo == 7) {
		vc_pagamento_tipo	= 'visa';
	//REEMISSÃO BOLETO
	}else if (id_pagamento_tipo == 2){
		vc_pagamento_tipo	= 'itau';	 
	}

	window.open('pagamentos/'+vc_pagamento_tipo+'.asp?pedidoID='+id_pedido,'pagamento','width='+W+',height='+H+',top='+X+',left='+Y+',location=no,status=no,menubar=no,scrollbars=auto,resizable=no,directories=no,toolbar=no');
	location.href = '../?actA=17'; 
}

function exibeConhecimento(id_conhecimento)
{
	if(id_conhecimento == 3 || id_conhecimento == 4 || id_conhecimento == 7 || id_conhecimento == 11)
	{
		document.getElementById('trConhecimento').style.position = 'relative';
		document.getElementById('trConhecimento').style.visibility = 'visible';
	}
	else
	{
		document.getElementById('trConhecimento').style.position = 'absolute';
		document.getElementById('trConhecimento').style.visibility = 'hidden';
	}
}
