function ById(id){
	return document.getElementById(id);
}
function desativarDiv(id){
	//$("#"+id).fadeOut("normal");
	ById(id).style.display = 'none';
	return;
}
function ativarDiv(id, id2){
	if (id2){
		desativarDiv(id2);
	}
	$("#"+id).fadeIn("normal");
	//ById(id).style.display = 'block';
}

/* VALIDAÇÃO DO CADASTRO DE OUVINTE */
function copiarInformacoesOuvinte()
{
	//ById('conta_td') = ById('').value;
	for (i=0;i<document.formulario_ouvinte.valor.length;i++){ 
       if (document.formulario_ouvinte.valor[i].checked) 
          break; 
    } 
	var valor = document.formulario_ouvinte.valor[i].value;
	if (valor == 0){
		ById('credito_td').innerHTML = "<span class='fonte_11px_verde'>R$ " + valor + ",00 (Sem Crédito) *</span>";
	}else{
		ById('credito_td').innerHTML = "R$ " + valor + ",00 (TREVO " + valor + ")";
	}
	
	ById('preco_td').innerHTML = "R$ " + valor + ",00";
	ById('nome_td').innerHTML = ById('nome').value + " " + ById('sobrenome').value;
	ById('email_td').innerHTML = ById('email').value + "  <span class=\"fonte_12px_cinza_escuro\">(senha oculta)</span>";
	
	if (valor != 0)
	{		
			ById('sem_credito_tr').style.display = 'none';
			ById('bonus_tr').style.display = '';
			ById('forma_pagamento_tr').style.display = '';
			for (i=0;i<document.formulario_ouvinte.forma_pagamento.length;i++){ 
		       if (document.formulario_ouvinte.forma_pagamento[i].checked) 
		          break; 
		    } 
			var forma_pagamento = document.formulario_ouvinte.forma_pagamento[i].value;
			if (forma_pagamento == "B"){
				ById('forma_pagamento_td').innerHTML = "Boleto Bancário";
			}else if (forma_pagamento == "CM"){
				ById('forma_pagamento_td').innerHTML = "Mastercard";
				ById('cpf_conf').style.display = '';
				ById('cpf_confirmacao').value = ById('cpf').value;
			}else{
				ById('forma_pagamento_td').innerHTML = "Visa";
				ById('cpf_conf').style.display = '';
				ById('cpf_confirmacao').value = ById('cpf').value;
			}
		
			if (ById('bonus').value){
				ById('bonus_td').innerHTML = "Sim  &nbsp;<span class='fonte_12px_cinza_escuro'>" + ById('bonus').value; + "</span>";
			}else{
				ById('bonus_td').innerHTML = "Não";
			}
	}else{
		ById('sem_credito_tr').style.display = '';
		/*ById('bonus_tr').style.display = 'none';*/
		ById('forma_pagamento_tr').style.display = 'none';
		if (ById('bonus').value){
			ById('bonus_td').innerHTML = "Sim  &nbsp;<span class='fonte_12px_cinza_escuro'>" + ById('bonus').value; + "</span>";
		}else{
			ById('bonus_td').innerHTML = "Não";
		}
	}	
}

function validarCadastroOuvinteForm3()
{
	var k = 0;
	
	$.post("ajax.php",
	{
		cpf: ById('cpf_confirmacao').value,
		acao:'ajaxValidarCPF'
	},function(xml)
	{
		if (xml == 0){
			ById('cpf_alert_confirmacao').innerHTML = "CPF Inválido.";
			$("#cpf_confirmacao").val();
			ById('cpf_confirmacao').focus();
		}else{
			ById('cpf_alert_confirmacao').innerHTML = "";
			document.formulario_ouvinte.submit();
		}
	});  
}

function desativarControleOuvinte(id)
{
	if (id){
		if (ById(id).checked == true){
			ById('valor0').checked = false;
			ById('valor1').checked = false;
			ById('valor2').checked = false;
			ById('valor3').checked = false;
			ById('valor4').checked = false;
			ById(id).checked = true;
		}
	}
	if (!ById('valor1').checked && !ById('valor2').checked && !ById('valor3').checked && !ById('valor4').checked)
	{
		ById('valor0').checked = true;
	}
	
	if (ById('valor0').checked)
	{
		//ById('cpf_tr').style.display = 'none';
		ById('btn_controle_normal').style.display = 'none';
		ById('btn_controle_dif').style.display = 'block';
		ById('btn_controle_normal2').style.display = 'none';
		ById('btn_controle_dif2').style.display = 'block';
	}else{
		//ById('cpf_tr').style.display = '';
		ById('btn_controle_dif').style.display = 'none';
		ById('btn_controle_normal').style.display = 'block';
		ById('btn_controle_dif2').style.display = 'none';
		ById('btn_controle_normal2').style.display = 'block';
	}
	
}

function ValidarCampoOuvinte(id, id_alerta, msg, tipo){
	
	switch (tipo)
	{
		case 'cpf':
			if (ById(id).value == "___.___.___-__"){
				ById(id_alerta).innerHTML = msg;
			}
		break;
		case 'cep':
			if (ById('cep').value == "_____-___"){
				ById(id_alerta).innerHTML = msg;
			}
		break;
		default:
			if (ById(id).value == ""){
				ById(id_alerta).innerHTML = msg;
			}
		break;
	}
	
}

function validarAlteracaoOuvinte()
{
		
	var  campos = ["nome","sobrenome","cidade", "endereco", "numero", "cep"];
	var  campos2 = ["Nome","Sobrenome", "Cidade", "Endereço", "Número", "CEP"];
	var  campos3 = ["nome_alert","sobrenome_alert","cidade_alert","endereco_alert", "numero_alert", "cep_alert"];
	
	var k = 0;
	for (i=0; i<campos.length; i++){
		if (document.getElementById(campos[i]).value == ""){
			ById(campos3[i]).innerHTML = "";
			ById(campos3[i]).innerHTML = "Por favor preencher o campo "+campos2[i]+".";
			k=1;
			//ById(campos[i]).focus();
		}else{
			ById(campos3[i]).innerHTML = "";
		}
    }
	
	if (k==0)
	{
		document.formulario_ouvinte.submit();
	}

}

function validarAlteracaoSenhaOuvinte()
{
		
	var  campos = ["email","senha","senha_confirma"];
	var  campos2 = ["E-mail","Senha", "Confirmação de Senha"];
	var  campos3 = ["email_alert","senha_alert","confirmar_senha_alert"];
	
	var k = 0;
	for (i=0; i<campos.length; i++){
		if (document.getElementById(campos[i]).value == ""){
			ById(campos3[i]).innerHTML = "";
			ById(campos3[i]).innerHTML = "Por favor preencher o campo "+campos2[i]+".";
			k=1;
			//ById(campos[i]).focus();
		}else{
			ById(campos3[i]).innerHTML = "";
		}
    }
	
	if (ById('senha').value != ById('senha_confirma').value)
	{
		ById('confirmar_senha_alert').innerHTML = "Senha e Confirmação preenchidos diferentes."
	}
		
	if (k==0)
	{
		document.formulario_ouvinte.submit();
	}

}

function verificarSuporteOuvinte()
{
	var  campos = ["nome","email","assunto", "mensagem"];
	var  campos2 = ["Nome","E-mail", "Assunto", "Mensagem"];
	
	var k = 0;
	for (i=0; i<campos.length; i++){
		if (document.getElementById(campos[i]).value == ""){
			alert("Por favor, preencher o campo " + campos2[i] + ".");
			k=1;
			return false;
		}
    }
			
}

function validarCadastroForm1(id, id2)
{
	/*  Para validar os campos basta inserir os dados no array */
	var  campos = ["nome","sobrenome","estado", "cidade", "endereco", "numero", "cep", "email","senha","senha_confirma"];
	var  campos2 = ["Nome","Sobrenome","Estado", "Cidade", "Endereco", "Número", "CEP", "E-mail","Senha","Confirmação de Senha"];
	var  campos3 = ["nome_alert","sobrenome_alert","estado_alert", "cidade_alert", "endereco_alert", "numero_alert", "cep_alert", "email_alert","senha_alert","confirma_senha_alert"];
	
	var k = 0;
	
	for (i=0; i<campos.length; i++){
		if (document.getElementById(campos[i]).value == ""){
			ById(campos3[i]).innerHTML = "";
			ById(campos3[i]).innerHTML = "Por favor preencher o campo "+campos2[i]+".";
			k=1;
			//ById(campos[i]).focus();
		}else{
			ById(campos3[i]).innerHTML = "";
		}
    }
    
    if (ById('senha').value != ById('senha_confirma').value){
    	ById('confirma_senha_alert').innerHTML = "Senha e Confirmação estão diferentes.";
    	k=1;
    }
    if (k == 0){
    	ativarDiv(id, id2);
    }
	
}

function validarCadastroForm2(id, id2)
{
	var k = 0;
	var msg = "";
	
	for (i=0;i<document.formulario_ouvinte.forma_pagamento.length;i++){ 
		if (document.formulario_ouvinte.forma_pagamento[i].checked) 
			break; 
	} 
	var forma_pagamento = document.formulario_ouvinte.forma_pagamento[i].value;
	
	if (k == 0){
    	ativarDiv(id, id2);
    }
	
	
}

/* VALIDAÇÃO DO CADASTRO DE ARTISTA */

function validarCadastroForm1Artista()
{
	if (ById('aceito_contrato').checked == true)
	{
		document.formulario_artista1.submit();
	}
	else
	{
		alert("Por favor, leia o contrato e clique em \"Eu Aceito\" para continuar seu cadastro.");
	}
}

function validarCadastroForm2Artista(id, id2)
{
	/*  Para validar os campos basta inserir os dados no array */
	var  campos = ["nome_responsavel", "endereco", "numero", "cidade", "cep", "telefone", "nome_artista", "diretorio", "email", "confirmar_email", "senha", "confirmar_senha", "endereco_corresp", "cidade_corresp", "cep_corresp"];
	var  campos2 = ["Nome", "Endereço", "Número", "Cidade", "CEP", "Telefone", "Nome do Artista", "URL", "E-mail", "Confirmar E-mail", "Senha", "Confirmar Senha", "Endereço", "Cidade", "CEP"];
	var  campos3 = ["nome_alert", "endereco_alert", "numero_alert", "cidade_alert", "cep_alert", "telefone_alert", "nome_artista_alert", "diretorio_alert", "email_alert", "confirmar_email_alert", "senha_alert", "confirmar_senha_alert", "endereco_corresp_alert", "cidade_corresp_alert", "cep_corresp_alert"];
	
	var k = 0;
	
	for (i=0; i<campos.length; i++){
		if (document.getElementById(campos[i]).value == ""){
			ById(campos3[i]).innerHTML = "";
			ById(campos3[i]).innerHTML = "Por favor preencher o campo "+campos2[i]+".";
			k=1;
			//ById(campos[i]).focus();
		}else{
			ById(campos3[i]).innerHTML = "";
		}
    }
    
    if (ById('email').value != ById('confirmar_email').value){
    	ById('confirmar_email_alert').innerHTML = "E-mail e Confirmação estão diferentes.";
    	k=1;
    }
    if (ById('senha').value != ById('confirmar_senha').value){
    	ById('confirmar_senha_alert').innerHTML = "Senha e Confirmação estão diferentes.";
    	k=1;
    }
    
    if (k == 0){
    	if (ById('cpf')){
    		ById('cpf_cnpj').value = ById('cpf').value;
    	}
    	if (ById('cnpj')){
    		ById('cpf_cnpj').value = ById('cnpj').value;
    	}
    	ById('numero_crumb2').src = 'img/numero2_breadcrumb_artista_inativo.jpg';
    	ById('numero_crumb3').src = 'img/numero3_breadcrumb_artista_ativo.jpg';
    	ativarDiv(id, id2);
    }
}

function validarCadastroForm2selo(id, id2)
{
	if (ById('id_selo').value == ""){	
		/*  Para validar os campos basta inserir os dados no array */
		var  campos = ["cnpj", "nome_responsavel", "nome_empresa", "inscricao_estadual", "inscricao_municipal", "endereco",  "numero", "cidade", "cep", "telefone", "nome_artista", "diretorio", "email", "confirmar_email", "senha", "confirmar_senha", "endereco_corresp", "cidade_corresp", "cep_corresp"];
		var  campos2 = ["CNPJ", "Nome do Responsável", "Nome da Empresa", "Inscrição Estadual", "Inscrição Municipal", "Endereço", "Número", "Cidade", "CEP",  "Telefone",  "Nome do Artista", "URL", "E-mail", "Confirmação de E-mail", "Senha", "Confirmação de Senha", "Endereço", "Cidade", "CEP"];
		var  campos3 = ["cnpj_alert", "nome_responsavel_alert", "nome_empresa_alert", "inscricao_estadual_alert", "inscricao_municipal_alert", "endereco_alert", "numero_alert", "cidade_alert", "cep_alert","telefone_alert", "nome_artista_alert", "diretorio_alert", "email_alert", "confirmar_email_alert", "senha_alert", "confirmar_senha_alert", "endereco_corresp_alert", "cidade_corresp_alert", "cep_corresp_alert"];
		
		var k = 0;
		
		for (i=0; i<campos.length; i++){
			//alert(campos3[i]);
			if (document.getElementById(campos[i]).value == ""){
				ById(campos3[i]).innerHTML = "";
				ById(campos3[i]).innerHTML = "Por favor preencher o campo "+campos2[i]+".";
				k=1;
				//ById(campos[i]).focus();
			}else{
				ById(campos3[i]).innerHTML = "";
			}
	    }
	    
	    
	    if (ById('email').value != ById('confirmar_email').value){
	    	ById('confirmar_email_alert').innerHTML = "E-mail e Confirmação estão diferentes.";
	    	k=1;
	    }
	    if (ById('senha').value != ById('confirmar_senha').value){
	    	ById('confirmar_senha_alert').innerHTML = "Senha e Confirmação estão diferentes.";
	    	k=1;
	    }
	    
	    if (k == 0){
	    	if (ById('cnpj')){
    			ById('cpf_cnpj').value = ById('cnpj').value;
    		}
	    	ById('numero_crumb2').src = 'img/numero2_breadcrumb_artista_inativo.jpg';
    		ById('numero_crumb3').src = 'img/numero3_breadcrumb_artista_ativo.jpg';
	    	ativarDiv(id, id2);
	    }
	}else{
		var  campos = ["cnpj", "nome_artista", "diretorio", "email", "confirmar_email", "senha", "confirmar_senha"];
		var  campos2 = ["CNPJ", "Nome do Artista", "URL", "E-mail", "Confirmação de E-mail", "Senha", "Confirmação de Senha"];
		var  campos3 = ["cnpj_alert", "nome_artista_alert", "diretorio_alert", "email_alert", "confirmar_email_alert", "senha_alert", "confirmar_senha_alert"];
		
		var k = 0;
		
		for (i=0; i<campos.length; i++){
			if (document.getElementById(campos[i]).value == ""){
				ById(campos3[i]).innerHTML = "";
				ById(campos3[i]).innerHTML = "Por favor preencher o campo "+campos2[i]+".";
				k=1;
				//ById(campos[i]).focus();
			}else{
				ById(campos3[i]).innerHTML = "";
			}
	    }
	    
	    
	    if (ById('email').value != ById('confirmar_email').value){
	    	ById('confirmar_email_alert').innerHTML = "E-mail e Confirmação estão diferentes.";
	    	k=1;
	    }
	    if (ById('senha').value != ById('confirmar_senha').value){
	    	ById('confirmar_senha_alert').innerHTML = "Senha e Confirmação estão diferentes.";
	    	k=1;
	    }
	    
	    if (k == 0){
	    	
	    	ById('numero_crumb2').src = 'img/numero2_breadcrumb_artista_inativo.jpg';
    		ById('numero_crumb4').src = 'img/numero4_breadcrumb_artista_ativo.jpg';
	    	ativarDiv(id, id2);
	    }		
		
	}
}

function validarCadastroForm3Artista(id, id2)
{
	var k = 0;
	var i;
    for (i=0;i<document.formulario_artista2.modo_verificacao.length;i++){
       if (document.formulario_artista2.modo_verificacao[i].checked)
          break;
    }
    var valor = document.formulario_artista2.modo_verificacao[i].value ;
	if (valor == ""){
		alert("Por favor, escolher uma forma de verificação de dados e preencher os dados referentes a escolha.");
		k = 1;
	}
    var aux1 = 0;
    var aux2 = 0;
	if (valor == "cnpj_cpf")
	{
		if (ById('cpf_cnpj').value == ""){
			k = 1;
		}
		if (k == 1)
		{
			alert("Por favor, preencher o CNPJ ou CPF para verificação.");			
		}
		$.post("ajax.php",
		{
			cnpj: ById('cpf_cnpj').value,
			acao:'ajaxValidarCNPJ'
		},function(xml)
		{
			if (xml == 0){
				aux1 = 1;
				$.post("ajax.php",
				{
					cpf: ById('cpf_cnpj').value,
					acao:'ajaxValidarCPF'
				},function(xml)
				{
					if (xml == 0){
						aux2 == 0;
						alert("CNPJ/CPF inválido, por favor digite novamente.");
					}else{
						if (k == 0)
						{
							ById('numero_crumb2').src = 'img/numero2_breadcrumb_artista_inativo.jpg';
							ById('numero_crumb3').src = 'img/numero3_breadcrumb_artista_inativo.jpg';
		    				ById('numero_crumb4').src = 'img/numero4_breadcrumb_artista_ativo.jpg';
							ativarDiv(id, id2);
						}
					}
				}); 
			}else{
				if (k == 0)
				{
					ById('numero_crumb2').src = 'img/numero2_breadcrumb_artista_inativo.jpg';
					ById('numero_crumb3').src = 'img/numero3_breadcrumb_artista_inativo.jpg';
    				ById('numero_crumb4').src = 'img/numero4_breadcrumb_artista_ativo.jpg';
					ativarDiv(id, id2);
				}
			}
		});  
		
		
		
	}else{
		if (k == 0)
		{
			ById('numero_crumb2').src = 'img/numero2_breadcrumb_artista_inativo.jpg';
			ById('numero_crumb3').src = 'img/numero3_breadcrumb_artista_inativo.jpg';
			ById('numero_crumb4').src = 'img/numero4_breadcrumb_artista_ativo.jpg';
			ativarDiv(id, id2);
		}
	}
	
	
	
		
}

function copiarInfoEndArtista()
{
	if (ById('corresp').checked == true){
		ById('endereco_corresp').value = ById('endereco').value;
		ById('cidade_corresp').value = ById('cidade').value;
		ById('estado_corresp').value = ById('estado').value;
		ById('cep_corresp').value = ById('cep').value;
	}else{
		ById('endereco_corresp').value = "";
		ById('cidade_corresp').value = "";
		ById('cep_corresp').value = "";
	}
}


function verificarAlterarSenha()
{
	var k = 0;
	if (ById('senha_atual').value != ""){
		$.post("ajax.php",
		{
			senha: ById('senha_atual').value,
			acao:'ajaxBuscarSenha'
		},function(xml)
		{
			if (xml == 0) {
				ById('senha_atual_alert').innerHTML = "Senha atual inválida.";
				k = 1;
			}
		});  
	}else{
		ById('senha_atual_alert').innerHTML = "Por favor, preencher a senha atual.";
		k = 1;
	}

	if (ById('senha').value != ById('senha_confirma').value)
	{
		ById('senha_alert').innerHTML = "Senha e confimação estão diferentes.";
		k = 1;
	}else{
		ById('senha_alert').innerHTML = "";
	}


	if (ById('senha').value == "")
	{
		ById('senha_alert').innerHTML = "Por favor, preencher a nova senha.";
		k = 1;
	}else
	{
		ById('senha_alert').innerHTML = "";
	}
	
	if (ById('senha_confirma').value == "")
	{
		ById('confirmar_senha_alert').innerHTML = "Por favor, preencher a confirmação de senha.";
		k = 1;
	}else{
		ById('confirmar_senha_alert').innerHTML = "";
	}

	if (k == 0)
	{
		document.formulario_artista2.submit();	
	}
}




/* FUNÇÕES GERAIS DE TROCA DE DIV PARA FAQ ETC...*/
var allPageTags = new Array(); 

function zera(theClass)
{
var allPageTags=document.getElementsByTagName("*");
	for (i=0; i<allPageTags.length; i++)
	{
		if (allPageTags[i].className==theClass)
		{
			if(theClass == 'menuLat')
			{
				allPageTags[i].style.backgroundImage = "url('img/btn_menu_flechacinza.jpg')";
			}else{
				allPageTags[i].style.display = "none";
			}
		}
	}
}

function mudaBG(idMuda)
{
	zera('menuLat')
	zera('conteudo')
	document.getElementById(idMuda).style.backgroundImage = "url('img/btn_menu_flechaverde.jpg')";
	idMuda = idMuda+"_conteudo"
	document.getElementById(idMuda).style.display = "block";
} 


/* VALIDAÇÕES DE CADASTRO DE OBRAS */

function validarFormObras()
{
	var  campos = ["nome_artista", "cidade", "titulo", "preco_total"];
	var  campos2 = ["Nome do Artista", "Cidade", "titulo", "Preço Total"];
	var  campos3 = ["nome_artista_alert", "cidade_alert", "titulo_alert", "preco_total_alert"];
	var  imagem = ById('imagem').value;
	var k = 0;
	var s = imagem.substr(imagem.length-3, imagem.length);
	
	if (imagem != ""){
		if (s != "jpg"){
			ById('imagem_alert').innerHTML = "Imagem com extensão inválida.";
			k = 1;
		}
	}
	
	for (i=0; i<campos.length; i++){
		if (document.getElementById(campos[i]).value == ""){
			ById(campos3[i]).innerHTML = "";
			ById(campos3[i]).className = "fonte_11px_verde margem_esq_15px";
			ById(campos3[i]).innerHTML = "Por favor preencher o campo "+campos2[i]+".";
			k=1;
		}else{
			ById(campos3[i]).innerHTML = "";
		}
    }
	
    if (k == 0){
    	document.formulario_obra.submit();
    }
    
}

/* VALIDAÇÃO DO FORMULÁRIO DE CADASTRO DE MÚSICAS */

function validarFormMusica()
{
	var  campos = ["titulo", "autor"];
	var  campos2 = ["Título", "Autor"];
	var  campos3 = ["album_alert", "album_alert"];
	
	var k = 0;
	
	for (i=0; i<campos.length; i++){
		if (document.getElementById(campos[i]).value == ""){
			ById(campos3[i]).innerHTML = "";
			ById(campos3[i]).className = "fonte_11px_verde margem_esq_15px";
			ById(campos3[i]).innerHTML = "Por favor preencher o campo "+campos2[i]+".";
			k=1;
		}else{
			ById(campos3[i]).innerHTML = "";
		}
    }
	
   if (ById('registro').value == 1 && ById('numero_registro').value == ""){
    	ById('registro_alert').innerHTML = "";
		ById('registro_alert').className = "fonte_11px_verde margem_esq_15px";
		ById('registro_alert').innerHTML = "Por favor preencher o campo Registro.";
    	k = 1;	
    }else{
    	ById('registro_alert').innerHTML = "";
    }
    
    if (k == 0){
    	document.formulario_musica_info.submit();
    }
}


function validarFormMusicaEdit()
{
	var  campos = ["autor"];
	var  campos2 = ["Autor"];
	var  campos3 = ["autor_alert"];
	
	var k = 0;
	
	for (i=0; i<campos.length; i++){
		if (document.getElementById(campos[i]).value == ""){
			ById(campos3[i]).innerHTML = "";
			ById(campos3[i]).className = "fonte_11px_verde margem_esq_15px";
			ById(campos3[i]).innerHTML = "Por favor preencher o campo "+campos2[i]+".";
			k=1;
		}else{
			ById(campos3[i]).innerHTML = "";
		}
    }
	
    if (ById('registro').value == 1 && ById('numero_registro').value == ""){
    	ById('registro_alert').innerHTML = "";
		ById('registro_alert').className = "fonte_11px_verde margem_esq_15px";
		ById('registro_alert').innerHTML = "Por favor preencher o campo Registro.";
    	k = 1;	
    }else{
    	ById('registro_alert').innerHTML = "";
    }
	
    if (k == 0){
    	document.formulario_musica_info_edit.submit();
    }
}


/* VALIDAÇÃO DE DADOS BANCÁRIOS */
function validarInfoBanco(tipo_pessoa){

	var k = 0;
	var msg = '';
	
	if(tipo_pessoa == 'PJ'){
		if (ById('cnpj')){
			var  campos = ["cnpj","banco", "agencia", "conta", "titular_conta"];
			var  campos2 = ["CNPJ","Banco", "Agência", "Conta", "Titular da Conta"];	
		}else{
			var  campos = ["banco", "agencia", "conta", "titular_conta"];
			var  campos2 = ["Banco", "Agência", "Conta", "Titular da Conta"];	
		}
	}else{
		if (ById('cpf')){
			var  campos = ["cpf","banco", "agencia", "conta", "titular_conta"];
			var  campos2 = ["CPF","Banco", "Agência", "Conta", "Titular da Conta"];	
		}else{
			var  campos = ["banco", "agencia", "conta", "titular_conta"];
			var  campos2 = ["Banco", "Agência", "Conta", "Titular da Conta"];	
		}
	}
	
	for (i=0; i<campos.length; i++){
		if (document.getElementById(campos[i]).value == ""){
			msg += "Por favor preencher o campo " + campos2[i] + ". <br />";
			k=1;
		}
    }
	if (ById('cnpj') || ById('cpf')){
	    if(tipo_pessoa == 'PJ'){
			$.post("ajax.php",
			{
				cnpj: ById('cnpj').value,
				acao:'ajaxValidarCNPJ'
			},function(xml)
			{
				if (xml == 0){
					k=1;
					msg += "Por favor preencher um CNPJ válido. <br />";
					ById("info_alert").innerHTML = msg;
				}else{
					if (k == 0){
						document.fomulario_banco.submit();		
					}
				}
			});
		}else{
			$.post("ajax.php",
			{
				cpf:  ById('cpf').value,
				acao:'ajaxValidarCPF'
			},function(xml)
			{
				if (xml == 0){
					k = 1;
					msg += "Por favor preencher um CPF válido. <br />";
					ById("info_alert").innerHTML = msg;
				}else{
					if (k == 0){
						document.fomulario_banco.submit();		
					}
				}
			});
		}
	}else{
		if (k == 0){
			document.fomulario_banco.submit();		
		}
	}
}

function adicionaPlayer(id){
	if (ById(id).style.display == 'none'){
		ById(id).style.display = 'block';
	}else{
		ById(id).style.display = 'none';
	}
}

/* VALIDAÇÃO DE COMPRA DE + CRÉDITOS */
function validarCompraCreditos()
{
	for (i=0;i<document.formulario_renovar.forma_pagamento.length;i++){ 
		if (document.formulario_renovar.forma_pagamento[i].checked) 
			break; 
	} 
	var forma_pagamento = document.formulario_renovar.forma_pagamento[i].value;
	
	for (i=0;i<document.formulario_renovar.credito.length;i++){ 
		if (document.formulario_renovar.credito[i].checked) 
			break; 
	} 
	var valor = document.formulario_renovar.credito[i].value;
	
	var k = 0;
	if (forma_pagamento == "TC" && ById('bonus').value == ""){
			k=1;
			ById('erro_alert').innerHTML = "Por favor, digite o código TREVO CARD.";
			ById('forma_pagamento_td').innerHTML = "Trevo Card";
			ById('credito_td').innerHTML = "TREVO (10)";
			ById('credito_td').innerHTML = "R$ 10,00";
	}
	
	if (forma_pagamento == "CV"){
		ById('forma_pagamento_td').innerHTML = "Cartão de Crédito - VISA";
		ById('credito_td').innerHTML = "TREVO ("+ valor +")";
		ById('preco_td').innerHTML = "R$ " + valor + ",00";
		
		if (ById('cpf_conf')){
			ById('cpf_conf').style.display = '';
		}
	}
	if (forma_pagamento == "CM"){
		ById('forma_pagamento_td').innerHTML = "Cartão de Crédito - Master Card";
		ById('credito_td').innerHTML = "TREVO ("+ valor +")";
		ById('preco_td').innerHTML = "R$ " + valor + ",00";
		
		if (ById('cpf_conf')){
			ById('cpf_conf').style.display = '';
		}
		
	}
	if (forma_pagamento == "B"){
		ById('forma_pagamento_td').innerHTML = "Boleto Bancário";
		if (valor > 20){
			ById('credito_td').innerHTML = "TREVO ("+ valor +")";
			ById('preco_td').innerHTML = "R$ " + valor + ",00";
		}else{
			ById('credito_td').innerHTML = "TREVO ("+ valor +")";
			valor = parseInt(valor) + 2;
			ById('preco_td').innerHTML = "R$ " + valor + ",10";
		}
	}
		
	if (k == 0){
		ativarDiv('compra_2','compra_1');
	}
}

function validarCompraCreditosForm2()
{
	var k = 0;
	if (ById('cpf_conf')){
		$.post("ajax.php",
		{
			cpf:  ById('cpf_confirmacao').value,
			acao:'ajaxValidarCPF'
		},function(xml)
		{
			if (xml == 0){
				k = 1;
				ById("cpf_alert_confirmacao").innerHTML = "Por favor preencher um CPF válido.";
				return false;
			}else{
				if (k == 0){
					return true;
				}
			}
		});		
	}else{
		return true;
	}
}


function toggleTrevoBox(el){
	if(el.checked){jQuery('#boxTrevoBox').show()}else{jQuery('#boxTrevoBox').hide()}
}