function agendarProvaAula(idag, idcli, id_tipoAgI, id_vd, acao, Id, id_tipo)
	{
	
	campo = "btnag"+idag;
	document.getElementById(campo).style.display = "none";
		
	document.getElementById("iframe_login").src = document.ssl.str_http.value+document.domain+"/site/area_cliente/acoes/ifr_agendamento.php?idag="+idag+"&idcli="+idcli+"&videoAbertoCaderno="+id_vd+"&id_tipo="+id_tipo+"&acao="+acao+"&Id="+Id+"&id_tipoAgI="+id_tipoAgI;
	
		
	
	}



function paisOrigem(origem,id_cliente)
	{

	
	if(id_cliente=="106") 
		{	
		if(document.formCadastra.pais_origem.value=="9999") 
			{
			document.getElementById("btnFinalizaCadastroAltera").style.display = "";
			document.getElementById("DIV_SEGMENTOS").style.display = "none";		
			document.getElementById("DIV_CRM").style.display  = "none";		
			document.getElementById("DIV_CRM2").style.display = "none";		
			
			
			
			}
		else
			{
			document.getElementById("btnFinalizaCadastroAltera").style.display = "none";		
			document.getElementById("DIV_SEGMENTOS").style.display = "";		
			
			
			
			}
		
		
		
		}
		
	
	
	if(document.formCadastra.pais_origem.value=="9999") 
		{
		document.getElementById("DIV_CPF_CNPJ").style.display = "none";	
		document.getElementById("DIV_ENDERECO_COMPLETO").style.display = "none";		
		document.getElementById("DIV_ENDERECO_INTERNACIONAL").style.display = "";		
		
		document.getElementById("DIV_BOTAO_CAD_ACESSO").style.display = "";		
		
		}
	else
		{		
		document.getElementById("DIV_ENDERECO_COMPLETO").style.display = "";	
		document.getElementById("DIV_ENDERECO_INTERNACIONAL").style.display = "none";		
				
		document.getElementById("DIV_CPF_CNPJ").style.display = "";	
		document.getElementById("DIV_BOTAO_CAD_ACESSO").style.display = "none";			
		}
	
	
	}
  
  
  
  

function alteraSegmento(id_cliente, id_segmento,logado)
	{
	
	document.formCadastra.id_segmentoOp.value = id_segmento;
	
	
	if(id_cliente=="106") 
		{
		console.log(id_cliente);
		console.log(id_segmento);
		if(id_segmento=="13") //MEDICO
			{
			if(logado!="sim")
			document.getElementById("btnFinalizaCadastroAltera").style.display = "none"; // ESCONDE BOTAO
			document.getElementById("btnFinalizaCadastroAltera").style.display = "";
			
			document.getElementById("DIV_CRM").style.display = "";
			document.getElementById("DIV_CRM2").style.display = "none";		
			}
		else
		    {
			if(logado!="sim")
			document.formCadastra.crm.value = "";
				
				
			document.getElementById("btnFinalizaCadastroAltera").style.display = "";
			document.getElementById("DIV_CRM").style.display = "none";
			document.getElementById("DIV_CRM2").style.display = "";		
		    }
		
		}
	else
		{
		
		document.getElementById("btnFinalizaCadastroAltera").style.display = "";
		
		}
	}






function abreTermoUso(url){ 
  
  window.open(url,'consulta','top=10,left=10,dependent=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=750,height=600');
  
  }
  
  




function realizaCadastroDocumentoAVA()
	{
	
	
	if(document.formEnviaDocs.documento_id_up.value=="")	
		{
		alertt('Selecione o tipo do documento que deseja enviar','Aviso','warning_center');
		document.getElementById("documento_id_up").focus();
		}
	else {
	if(document.formEnviaDocs.documento_up.value=="")	
		{
		alertt('Selecione um documento para enviar','Aviso','warning_center');
		}
	else 
		{
		loading();		
		document.formEnviaDocs.acao.value	= "upload_documento";
		document.formEnviaDocs.submit(); 	
		}
	}
	}
	
	

function abrirModalEnviarDocumentos(id_pedido, id_item, id_anuncio, id_cli)
	{	
	if(document.getElementById("modalEnviaDocumentos")){
	document.formEnviaDocs.acao.value = "abrir";
	document.formEnviaDocs.id_cliente_cliente.value = id_cli; 
	document.formEnviaDocs.id_anuncio.value = id_anuncio; 
	document.formEnviaDocs.id_pedido_clienteD.value = id_pedido; 
    document.formEnviaDocs.id_itemD.value = id_item;    
	document.formEnviaDocs.submit()	
	}
	}
	

function abrirModalAtestadoMatriculaL(id_pedido, id_item, id_cli)
	{	
	document.formAtMatL.acao.value = "abrir";
	document.formAtMatL.id_cliente_cliente.value = id_cli; 
	document.formAtMatL.id_pedido_clienteD.value = id_pedido; 
    document.formAtMatL.id_itemD.value = id_item;    
	document.formAtMatL.submit()	
	}
	

function abrirModalAtestadoMatricula(id_pedido, id_item, id_cli)
	{	
	document.formAtMat.acao.value = "abrir";
	document.formAtMat.id_cliente_cliente.value = id_cli; 
	document.formAtMat.id_pedido_clienteD.value = id_pedido; 
    document.formAtMat.id_itemD.value = id_item;    
	document.formAtMat.submit()	
	}



function emiteCertificado(id_anuncio,id_cliente,identificador)
	{
		
	loading();
	document.getElementById("iframe_aux").src = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/certificado/valida_emissao_certificado.php?id_anuncio="+id_anuncio+"&id_cliente="+id_cliente+"&identificador="+identificador;
	}
	
function geraCertificado(url)	
	{
	window.open(url,'Certificado','top=10,left=10,dependent=yes,directories=no,status=no,scrollbars=yes,resizable=yes,width=750,height=600');
	}
	


 
//function abreProvaAluno(id,primeiroAcesso)
	/*
	ESTA EM area_cliente_inicial.php pois a MERDA DOS ACENTOS NAO FUNCIONAVA DE JEITO NENHUM
	*/
	

function copyfieldvalue2(url)
	{

	
	const texto = url;
	//Cria um elemento input (pode ser um textarea)
	inputTest = document.createElement("input");
	inputTest.value = texto;
	//Anexa o elemento ao body
	document.body.appendChild(inputTest);
	//seleciona todo o texto do elemento
	inputTest.select();
	//executa o comando copy
	//aqui é feito o ato de copiar para a area de trabalho com base na seleção
	document.execCommand('copy');
	//remove o elemento
	document.body.removeChild(inputTest);
	
	alertt("Link copiado para a &aacute;rea de transfer&ecirc;ncia.","","success");
	}






/*######### DESABILITADO############ */
function salvaSituacaoVideoVistoAt(Id)
	{
	document.getElementById("iframe_aux").src = document.ssl.str_http.value+document.domain+"/site/area_cliente/acoes/ifr_video_visto_situacao.php?id_situacao=2&gravaAt=sim&videoAberto="+Id;
	}
	
function salvaSituacaoVideoVisto()
	{
	document.getElementById("iframe_aux").src = document.ssl.str_http.value+document.domain+"/site/area_cliente/acoes/ifr_video_visto_situacao.php?Id="+document.getElementById("id_video_visto").value+"&id_situacao="+document.getElementById("id_situacao_video_visto").value+"&videoAberto="+document.getElementById("videoAberto").value;
	}
	
	

function buscaComissoesAfiliado()
	{
	
	url = document.ssl.str_http.value+document.domain+"/site/area_cliente/acoes/ifr_lista_afiliados_comissoes.php?mes_mensalidade="+document.formComissao.mes_mensalidade.value+"&ano_mensalidade="+document.formComissao.ano_mensalidade.value;	
	
	var xhr = new XMLHttpRequest();
	xhr.open("POST", url, !0);
	
	xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
	loading();
	xhr.send();
	
	xhr.onreadystatechange = function () 
		{
		if (xhr.readyState === 4 && xhr.status === 200) 
			{
			$('#h_comissoes').html(xhr.responseText);
			loadingF();
			}
	
		
	}
	
	}
	
	




function buscaProvasRealizadas(id_cliente)	
	{	
	document.getElementById("iframe_aux").src = "../../iadm/clientes_clientes/iframes/provas_realizadas.php?do_ava=sim&id_cliente_cliente="+id_cliente;
	}	
	

function buscaAvisos()
	{	

	
	url = document.ssl.str_http.value+document.domain+"/site/area_cliente/acoes/ifr_aviso_lista.php";	
	ajax(url,'#h_avisos');

	}	

function marcaAvisoLido(id_aviso)	
	{	
	document.getElementById("iframe_aux").src = document.ssl.str_http.value+document.domain+"/site/area_cliente/acoes/ifr_aviso_visualizado.php?id_aviso="+id_aviso;	
	}


function abreAulaDireto()
	{
	/*DESATIVADO*/
	document.getElementById("iframe_aux").src = document.ssl.str_http.value+document.domain+"/site/area_cliente/acoes/ifr_caderno_acao.php?carrega_caderno=sim&videoAbertoCaderno="+id;
	
	}

function salvarCaderno()
	{
		
	var sHTML1 = $('.summernote').eq(0).code();		
	document.formCaderno.texto_caderno.value = sHTML1;	
	document.formCaderno.videoAbertoCaderno.value = document.eadVids.videoAberto.value;	
	document.formCaderno.submit();
	
	}
	
	
	
function inicializa_summernote(heightV)
	{
	
	if(heightV=="300")	$('.summernote').summernote({  height: 300,   minHeight: null,  maxHeight: 300,  focus: true, toolbar: [['text', ['bold', 'italic', 'underline', 'color', 'clear']],['size', ['fontsize']],['misc', [ 'codeview', 'undo', 'redo']]], onpaste :  function (e) {	var bufferText = ((e.originalEvent || e).clipboardData || window.clipboardData).getData('Text'); e.preventDefault();document.execCommand('insertText', false, bufferText);			}  });
	if(heightV=="200")	$('.summernote').summernote({  height: 200,   minHeight: null,  maxHeight: 200,  focus: true, toolbar: [['text', ['bold', 'italic', 'underline', 'color', 'clear']],['size', ['fontsize']],['misc', [ 'codeview', 'undo', 'redo']]], onpaste :  function (e) {	var bufferText = ((e.originalEvent || e).clipboardData || window.clipboardData).getData('Text'); e.preventDefault();document.execCommand('insertText', false, bufferText);			}  });
	
	}
	
	


function abreBoletosPendentesAva(id_pedido)
	{
	document.getElementById("iframe_login").src = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/pedidos/boletos.php?id_pedido_anuncio="+id_pedido;		  
	}
	

function abreBoletosPendentes(id_pedido)
	{
	document.getElementById("iframe_login").src = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/pedidos/boletos.php?id_pedido="+id_pedido;		  
	}

function validaNomeCompleto(pVal)
	{
		//var nomeCompleto = /[A-z][ ][A-z]/;
		var nomeCompleto = /[A-zÀ-ú][ ][A-zÀ-ú]/;
		return nomeCompleto.test(pVal);
	}
	
function printPedido(identificador)
	{
//	alert('a');
	window.open(document.ssl.str_http.value+document.domain+'/iadm/pedidos/impressao_pedido/print_pedido.php?identificador='+identificador+'','consulta','top=10,left=10,dependent=yes,directories=no,status=no,scrollbars=yes,resizable=yes,width=750,height=600');
	}
	

	
function abreAtualizaEmail()
 {
 if(document.getElementById('trMudaEmail0').style.display=='none')
 	{
	 document.getElementById('trMudaEmail0').style.display = '';
	 document.getElementById('trMudaEmail1').style.display = 'none';
	 document.getElementById('trMudaEmail').style.display = 'none'; 
	}
 else
 	{
	 document.getElementById('trMudaEmail0').style.display = 'none';
	 document.getElementById('trMudaEmail1').style.display = '';
	 document.getElementById('trMudaEmail').style.display = ''; 
	}
 }
 
 
 
 function ondeConheceu()
	{
	if(document.getElementById("onde_conheceuOp").value=="Outro")
		{
		document.getElementById("onde_conheceu").style.display = "";
		document.getElementById("onde_conheceu").value = "";
		document.getElementById("onde_conheceu").focus();
		}
	else
		{
		document.getElementById("onde_conheceu").style.display = "none";
		document.getElementById("onde_conheceu").value = document.getElementById("onde_conheceuOp").value;		
		}
	
	}


function mostraObsDoc(id)
	{
	
	display = eval("document.getElementById('obs1_"+id+"').style.display");
	if(display=="none")
		{
		eval("document.getElementById('obs1_"+id+"').style.display = ''");
		eval("document.getElementById('obs2_"+id+"').style.display = ''");
		eval("document.getElementById('obs3_"+id+"').style.display = ''");
		eval("document.getElementById('maisDoc_"+id+"').src = '../images/menos.jpg'");
		}
	else
		{
		eval("document.getElementById('obs1_"+id+"').style.display = 'none'");
		eval("document.getElementById('obs2_"+id+"').style.display = 'none'");
		eval("document.getElementById('obs3_"+id+"').style.display = 'none'");
		eval("document.getElementById('maisDoc_"+id+"').src = '../images/mais.jpg'");
		
		}
	}

function realizaRespostaSac(id)
	{
	if(validateForm('mensagem_sac:1:Resposta')==true) 
	    {  	
		document.getElementById("acaoSAC").value = "responderSAC";
		document.getElementById("idSAC").value = id;
		document.formSAC.submit();	   
		}	 
	}
function realizaSac(){
	
	if(validateForm('assunto:1:Assunto,mensagem_sac:1:Descrição Detalhada')==true) 
	    {  	
		document.getElementById("acaoSAC").value = "abrirSAC";		
		document.formSAC.submit();	   
		}	 
	}

function buscaChamados(tipo,radio)
	  {
	  document.getElementById("iframe_login").src = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/sac/monta_sac.php?tipo_pesquisa="+tipo+"&radio="+radio;		  
	  }	  
	  
	  
function buscaDocs(tipo,radio)
	  {
		
		
	  if(document.getElementById("id_subsubcategoria")) parSubSub = "&id_subsubcategoria="+document.getElementById("id_subsubcategoria").value;
	  else											    parSubSub = "";
	  	
	  if(document.getElementById("id_subcategoria")) parSub = "&id_subcategoria="+document.getElementById("id_subcategoria").value;
	  else											 parSub = "";
	  
	  if(document.getElementById("id_categoria")) parCat = "&id_categoria="+document.getElementById("id_categoria").value;
	  else										  parCat = "";
	  
	  if(document.getElementById("mes_inicio")) parMi = "&mes_inicio="+document.getElementById("mes_inicio").value;
	  else										parMi = "";
	  
	  if(document.getElementById("ano_inicio")) parAi = "&ano_inicio="+document.getElementById("ano_inicio").value;
	  else										parAi = "";
	  
	  
	  document.getElementById("iframe_login").src = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/docs/monta_docs.php?tipo_pesquisa="+tipo+"&radio="+radio+parCat+parSub+parMi+parAi+parSubSub;		  
	  }	  	  
	  

function carregaMunicipioEntrega(){	
	
		document.getElementById("iframe_login").src = document.ssl.str_http.value+document.domain+"/site/area_cliente/forms/municipios_montaCombo.php?id_uf="+document.formEnderecoEntrega.id_estado.value;		  
	
	}
	
	
function carregaMunicipio()
	{

	document.getElementById("iframe_login").src = document.ssl.str_http.value+document.domain+"/site/area_cliente/forms/municipios_montaCombo.php?id_uf="+document.formCadastra.id_estado.value;
	
	}
function buscaPedidos()
	{
	
	url = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/pedidos/meus_pedidos.php";	
	
	var xhr = new XMLHttpRequest();
	xhr.open("POST", url, !0);
	
	xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
	loading();
	xhr.send();
	
	xhr.onreadystatechange = function () 
		{
		if (xhr.readyState === 4 && xhr.status === 200) 
			{
			$('#h_pedidos').html(xhr.responseText);
			loadingF();
			}
	
		
	}
				
				
//	document.getElementById("iframe_login").src = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/pedidos/meus_pedidos.php";		  
	
	}




function paginaEadVideos(act)
	{
	if(act=="prev")
		{
		$('#owl-demo-meu').trigger('owl.prev');
		if(document.eadVids.currentVideo.value=="1")
		document.eadVids.currentVideo.value = document.eadVids.qtdVideos.value;
		else
		document.eadVids.currentVideo.value = parseInt(document.eadVids.currentVideo.value)-1;
		}
		
	if(act=="next")
		{
		$('#owl-demo-meu').trigger('owl.next');
		if(document.eadVids.currentVideo.value==document.eadVids.qtdVideos.value)
		document.eadVids.currentVideo.value = 1;
		else
		document.eadVids.currentVideo.value = parseInt(document.eadVids.currentVideo.value)+1;
		}	
		
	campo = 'js-copytextarea_'+document.eadVids.currentVideo.value;
	if(document.getElementById(campo)) 	document.getElementById("btnCopyKey").style.display = "";
	else								document.getElementById("btnCopyKey").style.display = "none"; 
	
	}






/*
function loopTempoOnline()
	{

		
		if(document.getElementById("tempo_libera_prova")){
			
		
		if(document.formCadastra.dev.value=="sim")
		urlGravaTempo = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/grava_tempo.php?id_video=0&acao=TempoOnline&id_anuncio_online="+document.getElementById("id_anuncio_online").value+"&id_prova="+document.getElementById("id_prova").value+"&tempo_libera_prova="+document.getElementById("tempo_libera_prova").value+"&id_cliente_aux_grava_tempo="+document.formCadastra.id_cliente_aux_grava_tempo.value+"&segundos=60&prova_liberada="+document.eadVids.prova_liberada.value;
		else
		urlGravaTempo = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/grava_tempo.php?id_video=0&acao=TempoOnline&id_anuncio_online="+document.getElementById("id_anuncio_online").value+"&id_prova="+document.getElementById("id_prova").value+"&tempo_libera_prova="+document.getElementById("tempo_libera_prova").value+"&id_cliente_aux_grava_tempo="+document.formCadastra.id_cliente_aux_grava_tempo.value+"&segundos=60&prova_liberada="+document.eadVids.prova_liberada.value;
		
		$.ajax({
			
			
			type: "POST",		
			url: urlGravaTempo,
			
			processData: false, 
			contentType: false, 
			evalScripts: true, 
			
			
			success: 
				function(response)
					{
					if(document.getElementById("segundos_restantes"))
						{
						console.log('T');
						tempo = 60000;
						
						
						
						if(document.getElementById("tempoLibProva"))
						document.getElementById("tempoLibProva").innerHTML = response;
						
						if(document.getElementById("runscriptGT"))
						eval(document.getElementById("runscriptGT").innerHTML);
						
						//if(parseInt(document.getElementById("tempo_libera_prova").value)>0)
						setTimeout('loopTempoOnline()', tempo);
						
						//alertt("a ","","success_tr");
						}
					}
		});
	}
	
	}
*/	
	
	

function loopTempoAssistindo(id,obs)
	{
		
	var dt = new Date( ); 
	getSecondsAx = dt.getSeconds();	
	
	if(document.getElementById("videoAberto").value==id)
		{
		
		if((getSecondsAx==document.getElementById("segundosControl").value) || (obs=="START"))
			{
			//console.log(obs);	
			campoduracao = "duracao_"+id;								
			campoduracao = document.getElementById(campoduracao).value;
			
			console.log(obs+ 'GRAVA '+document.getElementById("videoAberto").value+' '+dt.getMilliseconds()+' '+id+' '+ getSecondsAx+' - DURACAO '+campoduracao+' - ID CURSO '+document.getElementById("id_anuncio_online").value );
			
		
		
			if(obs=="START")
			segundosAdd = 2;
			else
			segundosAdd = 60;
			
			
			
			if(document.formCadastra.dev.value=="sim")
			urlLoop = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/grava_tempo.php?segundos="+segundosAdd+"&id_video="+document.getElementById("videoAberto").value+"&id_cliente_aux_grava_tempo="+document.formCadastra.id_cliente_aux_grava_tempo.value+"&campoduracao="+campoduracao+"&id_anuncioTM="+document.getElementById("id_anuncio_online").value+"&acao_obs="+obs+"&id_pedido_ava="+document.getElementById("id_pedido_ava").value;
			else
			urlLoop = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/grava_tempo.php?segundos="+segundosAdd+"&id_video="+document.getElementById("videoAberto").value+"&id_cliente_aux_grava_tempo="+document.formCadastra.id_cliente_aux_grava_tempo.value+"&campoduracao="+campoduracao+"&id_anuncioTM="+document.getElementById("id_anuncio_online").value+"&acao_obs="+obs+"&id_pedido_ava="+document.getElementById("id_pedido_ava").value;
			
			console.log(urlLoop);
			$.ajax({
				
				
				
				type: "POST",		
				url: urlLoop,
				
				processData: false, /* DATA TYPE */
				contentType: false, /* DATA TYPE */		
				evalScripts: true, 
				
				success: 
					function(response)
						{
						
						document.getElementById("divGravaTempo").innerHTML = response;
						
						if(document.getElementById("runscriptAT")) 
						eval(document.getElementById("runscriptAT").innerHTML);
						
						
						
						}
				});
			}
		
		tempo = 1000;
		setTimeout('loopTempoAssistindo('+id+',"CONT")', tempo);
		}
	
	}
	
	
	
	
	
function jaVistoVdOpen(id,i,div,sequencial,idAnterior,obrigatorio,id_tipo,id_disciplina,id_modulo,id_moduloA, id_disciplinaAnt)
	{
		
	
	
	
	if(obrigatorio==0) idAnterior=0;
	
	/*########## CONTROLE DO SEQUENACIAL #########################*/
	if((sequencial=="nao")  || (obrigatorio==0) || (idAnterior==0))
		{	
		liberaVd = "sim"; 
		}
	else
		{
		if(i==1)
			{
			liberaVd = "sim";
			}
		else
			{
			iAx = i-1;
			campoVis = "video_visto_"+idAnterior;
			
			if(document.getElementById(campoVis).value=="1")
				{
				liberaVd = "sim";
				
				}
			else
				{
				liberaVd = "nao";	
				}
			}
		
			
		}
	/*########## CONTROLE DO SEQUENACIAL #########################*/
	

	
	


	
	
	if(liberaVd=="sim")
		{
		
		campoDivVd  = "embed_video_div_"+id;
		campoDivVdV = "embed_video_"+id;
		campoDivVdClose = "";
		if(document.getElementById(campoDivVd)) 
			{
			
			if(document.getElementById("tipo_ava").value=="lista")
			document.getElementById(campoDivVd).innerHTML = document.getElementById(campoDivVdV).value;
			else
			document.getElementById("embed_video_modal").innerHTML = document.getElementById(campoDivVdV).value;
			
			
			if(document.getElementById("videoAberto").value!=0)
				{
				campoDivVdClose  = "embed_video_div_"+document.getElementById("videoAberto").value;				
				}
			}
		
		campoDivArquivoVd = "arquivo_vd_"+id;
		document.getElementById("embed_vd_arquivo").innerHTML = document.getElementById(campoDivArquivoVd).value;
		if(document.getElementById(campoDivArquivoVd).value=="") 
			{
			document.getElementById("MATERIALAPOIO1").style.display = "none";
			document.getElementById("MATERIALAPOIO2").style.display = "none";
			}
		else
			{
			document.getElementById("MATERIALAPOIO1").style.display = "";
			document.getElementById("MATERIALAPOIO2").style.display = "";
			}
			
		
		
		
		
		
		if((document.getElementById("videoAberto").value!=0) && (document.getElementById("videoAberto").value!=id))
			{
			
			
			divF = "#collapseOneVds"+document.getElementById("videoAberto").value;
			
			
			if(document.getElementById("tipo_ava").value=="lista")
			$(divF).toggle(500,'linear');
			
			
			campo = "collapseStatus"+document.getElementById("videoAberto").value;
			document.getElementById(campo).value = "0";
			}
		
		
		
		
		if(document.getElementById("tipo_ava").value=="lista")
			{
			$(div).toggle(500,'linear');
			}
			
			
		
		
		
		
		
		
		
		
		
		
		
		
		campo = "collapseStatus"+id;
		if(document.getElementById(campo).value=="1")
			{
			
			
			
			/*########## FECHA MODAL OU LISTA #########################*/
			/*########## FECHA MODAL OU LISTA #########################*/
			
			document.getElementById(campo).value = "0";
			document.getElementById("estaAberto").value = "0";
			document.getElementById("videoAberto").value = "0";
			//alertt('A','','success');
			
			post = "&acao=fecha";
			
			if(document.getElementById("tipo_ava").value=="modal")
				{						
				
				document.getElementById("summernote_pai").innerHTML = '<div class="summernote" id="textCaderno"></div>';
				
				/*CLIC DUPLO*/
				campoLinkAbreModal = "linkAbreCurso_"+id;				
				document.getElementById(campoLinkAbreModal).style.display = ''; 
				/*CLIC DUPLO*/
				campoLinkAbreModal = "linkAbreCursoDis_"+id;
				document.getElementById(campoLinkAbreModal).style.display = 'none';
				
				}
			
			
			
			
			document.getElementById("iframe_login").src = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/marca_video_visto.php?comAlertt=nao&id="+id+post+"&viuTodos="+document.eadVids.viuTodos.value+"&qtdVideos="+document.eadVids.qtdVideos.value; 
			
			/*########## FECHA MODAL OU LISTA #########################*/
			/*########## FECHA MODAL OU LISTA #########################*/
			
			
			}
		else
			{
				
				
			/*########## ABRE MODAL OU LISTA #########################*/
			/*########## ABRE MODAL OU LISTA #########################*/
			
			//alertt('F','','success');
			document.getElementById(campo).value = "1";
			document.getElementById("estaAberto").value = "1";
			document.getElementById("videoAberto").value = id;
			
			//loopTempoAssistindo(id);
			

			
			
			if(document.getElementById("tipo_ava").value=="modal")
				{						
				btnModalClose  = "<button type='button' class='btn btn-rw btn-default'  data-dismiss='modal' onClick=\"jaVistoVdOpen("+id+",'"+i+"','"+div+"','"+sequencial+"','"+idAnterior+"')\">Fechar</button>";			
				
				btnModalCloseX = "<button type='button' class='close' data-dismiss='modal' onClick=\"jaVistoVdOpen("+id+",'"+i+"','"+div+"','"+sequencial+"','"+idAnterior+"')\"><span aria-hidden='true'>X</span><span class='sr-only'>Fechar</span></button>";
				
				
				
				modalTitle = "modal_title_"+id;				
				
				
				document.getElementById("largeModalAVATitle").innerHTML = document.getElementById(modalTitle).value;
				
				document.getElementById("btnCloseModal").innerHTML = btnModalClose;			
				document.getElementById("btnCloseModalX").innerHTML = btnModalCloseX;			
				
				document.getElementById("btnCloseModal_Pro").innerHTML = btnModalClose;			
				document.getElementById("btnCloseModalX_Pro").innerHTML = btnModalCloseX;			
				
				
				
				//if(campoDivVdClose!="") document.getElementById(campoDivVdClose).innerHTML = "";
				
				//post = "&acao=abre";
				
				/*MODAL SHOW DEPOIS DE CARREGAR CADERNO*/
				campoduracao = "duracao_"+id;								
				campoduracao = document.getElementById(campoduracao).value;
			
				loading();
				document.getElementById("iframe_aux").src = document.ssl.str_http.value+document.domain+"/site/area_cliente/acoes/ifr_caderno_acao.php?carrega_caderno=sim&videoAbertoCaderno="+id+"&sequencial="+sequencial+"&idAnterior="+idAnterior+"&campoduracao="+campoduracao+"&id_anuncioTM="+document.getElementById("id_anuncio_online").value+"&id_tipo="+id_tipo+"&id_disciplina="+id_disciplina+"&id_item_anuncio="+document.getElementById("id_item_anuncio").value+"&id_modulo="+id_modulo+"&id_moduloA="+id_moduloA+"&id_disciplinaAnt="+id_disciplinaAnt;
				
				}
			
			
			/*########## ABRE MODAL OU LISTA #########################*/
			/*########## ABRE MODAL OU LISTA #########################*/
			
			
			}
		
		
		
		
//		if(campoDivVdClose!="") document.getElementById(campoDivVdClose).innerHTML = "";		document.getElementById("iframe_login").src = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/marca_video_visto.php?comAlertt=nao&id="+id+post+"&viuTodos="+document.eadVids.viuTodos.value+"&qtdVideos="+document.eadVids.qtdVideos.value; 
	
		
		
		
		}
	else
		{
		alertt("Voc&ecirc; precisa conclu&iacute;r 100% da aula anterior para continuar o curso.","Aten&ccedil;&atilde;o","warning");
		}
	
	
	}
	


	
function jaVistoVd(id)
	{
	/*FORA DE USO*/
	
	if(document.formCadastra.dev.value=="sim")
	document.getElementById("iframe_login").src = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/marca_video_visto.php?comAlertt=sim&id="+id;
	else
	document.getElementById("iframe_login").src = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/marca_video_visto.php?comAlertt=sim&id="+id;
	
	
	}
	
	
function copySenhaEad(id)
	{
	 clase = '.js-copytextarea_'+id;
	
	 var copyTextarea = document.querySelector(clase);
	  copyTextarea.select();
	
	
	
	  try {
		
		var successful = document.execCommand('copy');
		alertt('A Senha foi copiada com sucesso, basta colar a senha no campo Password para assistir esse v&iacute;deo','','success_tr');
		
	  } catch (err) {
		
	  }
	}







function verResultado(id_prova_realizada)
	{
	if(document.formCadastra.dev.value=="sim")
	document.getElementById("iframe_login").src = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/prova_grava_respostas.php?resultado=sim&id_prova_realizada="+id_prova_realizada+"&id_item_anuncio="+document.eadVids.id_item_anuncio.value;			
	else
	document.getElementById("iframe_login").src = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/prova_grava_respostas.php?resultado=sim&id_prova_realizada="+id_prova_realizada+"&id_item_anuncio="+document.eadVids.id_item_anuncio.value;			
	
	}

function setResposta(id_questao, correta,peso,id_prova_realizada,respondida,opcao,op)
	{
	
	resposta  = "resposta_"+id_questao;
	resultado = "resultado_"+id_questao;
	
	document.getElementById(resposta).value = op;
	
	if(document.getElementById(resposta).value==correta)
		{
		document.getElementById(resultado).value = "CERTO";
		resultadoP = 1;
		}
	else
		{
		document.getElementById(resultado).value = "ERRADO";
		resultadoP = 0;
		}
		
	if(respondida==0)
		{
		if(document.formCadastra.dev.value=="sim")	
		document.getElementById("iframe_login").src = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/prova_grava_respostas.php?id_questao="+id_questao+"&id_prova_realizada="+id_prova_realizada+"&opcao="+document.getElementById(resposta).value+"&correta="+resultadoP+"&peso="+peso;		
		else
		document.getElementById("iframe_login").src = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/prova_grava_respostas.php?id_questao="+id_questao+"&id_prova_realizada="+id_prova_realizada+"&opcao="+document.getElementById(resposta).value+"&correta="+resultadoP+"&peso="+peso;		
		}
	else
		{
		
		}
	
	
	}
	
	
	
function proximaQuestao(atual,proxima)
	{
	campo1 = "DIV_QUESTAO_"+atual;
	campo2 = "DIV_QUESTAO_"+proxima;
	resposta = "resposta_"+atual;
	
	if(document.getElementById(resposta).value!="")
		{	
		document.getElementById(campo1).style.display = "none";
		document.getElementById(campo2).style.display = "";
		}
	else
		{
		alertt("Para avan&ccedil;ar voc&ecirc; precisa escolher uma das respostas.","Aten&ccedil;&atilde;o","warning_tr");
		}
	
	
	
	
	}


function iniciaProva(id_prova,id_questao,sequencial)
	{
	liberaProva = "nao";
	
	
	if((parseInt(document.eadVids.viuTodos.value)>=parseInt(document.eadVids.qtdVideos.value)) && (document.getElementById("segundos_restantes").value==0))
	liberaProva = "sim";
	
	
	if(sequencial=="nao") liberaProva = "sim";
	
	
	if(document.eadVids.prova_liberada.value=="1") liberaProva = "sim";
	
	
	
	
	if(liberaProva=="sim")
		{
		if(document.formCadastra.dev.value=="sim")	
		url = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/prova.php?id_prova="+id_prova+"&id_questao="+id_questao;	
		else
		url = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/prova.php?id_prova="+id_prova+"&id_questao="+id_questao;	
		
		loading();
		
		//document.getElementById("h_cursoPlay").innerHTML = "";
		
		var xhr = new XMLHttpRequest();
		xhr.open("POST", url, !0);
		
		xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
		//loading();
		xhr.send();
		
		xhr.onreadystatechange = function () 
			{
			if (xhr.readyState === 4 && xhr.status === 200) 
				{
				$('#h_cursoPlay').html(xhr.responseText);
				
				if(id_questao==0)
				$('#largeModal').modal('show');
				
				
				eval(document.getElementById("runscript").innerHTML); 
				loadingF();
				}
			}	
		}
	else
		{
		if(parseInt(document.eadVids.viuTodos.value)<parseInt(document.eadVids.qtdVideos.value)) 
			{			
			alertt("Voc&ecirc; precisa assistir todas v&iacute;deo-aulas para realizar a prova.","Aten&ccedil;&atilde;o","warning");
			}
		else {
		if(document.getElementById("segundos_restantes").value>0)
			{
			alertt("Sua prova ainda n&atilde;o foi liberada, aguarde...","Aten&ccedil;&atilde;o","warning");
			}
		}
		}
	}




function abreCursoDisciplina(id,id_disciplina,tipo,id_disciplinaA)
	{
//	alert(id_disciplinaA);
	if(document.formCadastra.dev.value=="sim")
	url = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/b.area_aluno_planos.php?id="+id+"&id_disciplina="+id_disciplina+"&innerHeight="+window.innerHeight+"&innerWidth="+window.innerWidth+"&tipo="+tipo+"&id_disciplinaAnt="+id_disciplinaA;	
	else
	url = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/b.area_aluno_planos.php?id="+id+"&id_disciplina="+id_disciplina+"&innerHeight="+window.innerHeight+"&innerWidth="+window.innerWidth+"&tipo="+tipo+"&id_disciplinaAnt="+id_disciplinaA;	
	
	loading();
	
	//document.getElementById("h_cursoPlay").innerHTML = "";
	
	var xhr = new XMLHttpRequest();
	xhr.open("POST", url, !0);
	
	xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
	//loading();
	xhr.send();
	
	xhr.onreadystatechange = function () 
		{
		if (xhr.readyState === 4 && xhr.status === 200) 
			{
			$('#h_eadPedidos').html(xhr.responseText);
			
			
			loadingF();
			}
		}
	}
	


function abreCursoMateria(id,id_materia,tipo)
	{
	if(document.formCadastra.dev.value=="sim")
	url = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/b.area_aluno_planos.php?id="+id+"&id_materia="+id_materia+"&innerHeight="+window.innerHeight+"&innerWidth="+window.innerWidth+"&tipo="+tipo;	
	else
	url = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/b.area_aluno_planos.php?id="+id+"&id_materia="+id_materia+"&innerHeight="+window.innerHeight+"&innerWidth="+window.innerWidth+"&tipo="+tipo;	
	loading();
	
	//document.getElementById("h_cursoPlay").innerHTML = "";
	
	var xhr = new XMLHttpRequest();
	xhr.open("POST", url, !0);
	
	xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
	//loading();
	xhr.send();
	
	xhr.onreadystatechange = function () 
		{
		if (xhr.readyState === 4 && xhr.status === 200) 
			{
			$('#h_eadPedidos').html(xhr.responseText);
			
			
			loadingF();
			}
		}
	}
	

	
	
function abreCurso(id,tipo)
	{
	loading();
	
	
	if(document.formCadastra.dev.value=="sim")
	url = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/b.area_aluno_planos.php?startLoopTempoOnline=sim&id="+id+"&innerHeight="+window.innerHeight+"&innerWidth="+window.innerWidth+"&tipo="+tipo;	
	else
	url = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/b.area_aluno_planos.php?startLoopTempoOnline=sim&id="+id+"&innerHeight="+window.innerHeight+"&innerWidth="+window.innerWidth+"&tipo="+tipo;		
	
	
	
	var xhr = new XMLHttpRequest();
	xhr.open("POST", url, !0);
	
	xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
	
	
	xhr.send();
	
	console.log('1');
	xhr.onreadystatechange = function () 
		{
		console.log('2');
		if (xhr.readyState === 4 && xhr.status === 200) 
			{
			console.log('3');
			$('#h_eadPedidos').html(xhr.responseText);
			loadingF();
			}
		}
	}


function abreCursosPlanos(id,tipo,id_anuncio)
	{
	loading();
	
	
	if(document.formCadastra.dev.value=="sim")
	url = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/b.area_aluno_planos.php?startLoopTempoOnline=sim&id="+id+"&innerHeight="+window.innerHeight+"&innerWidth="+window.innerWidth+"&tipo="+tipo+"&id_anuncioPlano="+id_anuncio;	
	else
	url = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/b.area_aluno_planos.php?startLoopTempoOnline=sim&id="+id+"&innerHeight="+window.innerHeight+"&innerWidth="+window.innerWidth+"&tipo="+tipo+"&id_anuncioPlano="+id_anuncio;		
	
	
	
	var xhr = new XMLHttpRequest();
	xhr.open("POST", url, !0);
	
	xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
	
	
	xhr.send();
	
	console.log('1');
	xhr.onreadystatechange = function () 
		{
		console.log('2');
		if (xhr.readyState === 4 && xhr.status === 200) 
			{
			console.log('3');
			$('#h_eadPedidosPlanos').html(xhr.responseText);
			loadingF();
			}
		}
	}






	




function buscaPedidosEadDocs()
	{	
	
	//$("#largeModalProvas").modal("hide");
	//$("#largeModalAva").modal("hide")
	
	
	document.getElementById("h_eadPedidos").innerHTML = "";	
	
	
	if(document.formCadastra.dev.value=="sim")	
	url = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/a.meus_cursos.php?abaDocumentos=sim";	
	else
	url = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/a.meus_cursos.php?abaDocumentos=sim";	
	
	ajax(url,'#h_eadPedidosDocs');

	}	
	
	
		

function buscaPedidosEadBtn()
	{	
	
	if(document.formCadastra.dev.value=="sim")
	url = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/a.meus_cursos.php";	
	else
	url = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/a.meus_cursos.php";	
	
	
	ajax(url,'#h_eadPedidos');

	}	
	
			
function buscaPedidosEadOLD()
	{	
	if(document.getElementById("videoAberto")) {}
	else
		{
		document.getElementById("h_eadPedidosDocs").innerHTML = "";	
			
		if(document.formCadastra.dev.value=="sim")	
		url = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/a.meus_cursos.php";	
		else
		url = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/a.meus_cursos.php";	
		
		ajax(url,'#h_eadPedidos');
		}
	}	
	
function buscaPedidosEad()
	{	
	
		document.getElementById("h_eadPedidosDocs").innerHTML = "";	
			
		if(document.formCadastra.dev.value=="sim")	
		url = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/a.meus_cursos.php";	
		else
		url = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/a.meus_cursos.php";	
		
		ajax(url,'#h_eadPedidos');
	
	}	
		

function buscaPedidosEadPlanosBtn()
	{	
	
	if(document.formCadastra.dev.value=="sim")
	url = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/a.meus_cursos.php?carrega_planos=sim";	
	else
	url = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/a.meus_cursos.php?carrega_planos=sim";	
	
	
	ajax(url,'#h_eadPedidosPlanos');

	}	
		
	
	
function buscaPedidosEadPlanos()
	{	
	if(document.getElementById("videoAberto")) {}
	else
		{
			
		if(document.formCadastra.dev.value=="sim")	
		url = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/a.meus_cursos.php?carrega_planos=sim";	
		else
		url = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/a.meus_cursos.php?carrega_planos=sim";	
		
		ajax(url,'#h_eadPedidosPlanos');
		}
	}	
	
	
	

function buscaAulas()
	{
	if(document.formCadastra.dev.value=="sim")	
	url = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/a.meus_cursos.php?aulas=sim";	
	else
	url = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/a.meus_cursos.php?aulas=sim";	
	
	ajax(url,'#h_eadCursos');
	
	}


function buscaAulasOLD()
	{
	if(document.formCadastra.dev.value=="sim")	
	url = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/a.meus_cursos.php";	
	else
	url = document.ssl.str_http.value+document.domain+"/site/area_cliente/area_cliente/area_aluno/a.meus_cursos.php";	
	
	
	var xhr = new XMLHttpRequest();
	xhr.open("POST", url, !0);
	
	xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
	loading();
	xhr.send();
	
	xhr.onreadystatechange = function () 
		{
		if (xhr.readyState === 4 && xhr.status === 200) 
			{
			$('#h_ead').html(xhr.responseText);
			loadingF();
			}
		}
			
			
	}
	  

	  

	  
	  



/*
function abreLogin(origem, caminho_pedido)
	{	 
	
	if(document.getElementById("TrFlash905")) document.getElementById("TrFlash905").style.display = "none";
	if(document.getElementById("TrListagemBanner")) document.getElementById("TrListagemBanner").style.display = "none";
	
	
	
	document.getElementById("iframe_login").src = document.ssl.str_http.value+document.domain+"/site/area_cliente/ifr_area_cliente.php?origem="+origem+"&var_caminho_pedido="+caminho_pedido;	
	}
*/

function trim(str) { return str.replace(/^\s+|\s+$/g,""); }


function realizaLogin(form)
	{

	 if(validateForm('emaill:3:E-mail,senhaAcesso:1:Senha'))
			{ 
			strAction = document.ssl.str_http.value+document.domain+"/site/area_cliente/acoes/ifr_login_logoff_acao.php";
			 
			eval("document."+form+".acaoLg.value = 'login';");
			eval("document."+form+".action = '"+strAction+"';");
			
			loading(); 		
			
			setTimeout(function(){ eval("document."+form+".submit();"); }, 1000);
			
			}
	
	 }
	 

function logoffCliente()
	{
	loading(); 		
	document.getElementById("iframe_login").src = document.ssl.str_http.value+document.domain+"/site/area_cliente/acoes/ifr_login_logoff_acao.php?acaoLg=logoff";		
	}

function logoffClienteComunidade()
	{
	//loading(); 		
	document.getElementById("iframe_login").src = document.ssl.str_http.value+document.domain+"/site/area_cliente/acoes/ifr_login_logoff_acao.php?acaoLg=logoff&logoffComunidade=sim";		
	}


 
function atualizaEmail(cor)
 {
	 
 
 if(document.getElementById('emailNovo2').value!=document.getElementById('emailNovo').value) {alert("O novo e-mail e a confirmação não conferem.")}else{
 
 if(validateFormColor('emailAntigo:1:Seu e-mail anitgo,emailNovo:1:Seu novo e-mail,emailNovo2:1:Repita o novo e-mail,senhaTrocaEmail:1:Senha',cor)){
	
	document.getElementById("iframe_login").src = document.ssl.str_http.value+document.domain+"/site/area_cliente/acoes/ifr_altera_email.php?email="+document.getElementById('emailAntigo').value+"&novoEmail="+document.getElementById('emailNovo').value+"&senhaTrocaEmail="+document.getElementById('senhaTrocaEmail').value;		
	 
 	}
 }
 }


function buscaCep(){
	if(document.getElementById('cep').value!="")
	document.getElementById("iframe_login").src = document.ssl.str_http.value+document.domain+"/site/area_cliente/acoes/ifr_pega_endereco_peloCEP.php?tipo=cad_cliente&cep="+document.getElementById('cep').value;
	else
	alert("Preencha o CEP");
	 
	}
	

function buscaCepPag(){
	if(document.getElementById('billingAddressPostalCode').value!="")
	document.getElementById("iframe_login").src = document.ssl.str_http.value+document.domain+"/site/area_cliente/acoes/ifr_pega_endereco_peloCEP.php?tipo=carrinho&cep="+document.getElementById('billingAddressPostalCode').value;
	else
	alert("Preencha o CEP");
	 
	}
	
		
function buscaCepEntrega(){
	 document.getElementById("iframe_login").src = document.ssl.str_http.value+document.domain+"/site/area_cliente/acoes/ifr_pega_endereco_peloCEP.php?tipo=entrega&cep="+document.getElementById('cep').value;
	}



function ValidarCPF(Objcpf){
	
	
	var cpf = Objcpf; 
    
	cpf = cpf.toString().replace( ".", "" ); 
	cpf = cpf.toString().replace( ".", "" ); 
	cpf = cpf.toString().replace( "/", "" ); 
	cpf = cpf.toString().replace( "-", "" ); 
	
if (vercpf(cpf)) 
{return true;}else 
{errors="1";if (errors) 
document.retorno = (errors == '');}}
function vercpf (cpf) 
{if (cpf.length != 11 || cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999")
return false;
add = 0;
for (i=0; i < 9; i ++)
add += parseInt(cpf.charAt(i)) * (10 - i);
rev = 11 - (add % 11);
if (rev == 10 || rev == 11)
rev = 0;
if (rev != parseInt(cpf.charAt(9)))
return false;
add = 0;
for (i = 0; i < 10; i ++)
add += parseInt(cpf.charAt(i)) * (11 - i);
rev = 11 - (add % 11);
if (rev == 10 || rev == 11)
rev = 0;
if (rev != parseInt(cpf.charAt(10)))
return false;
return true;

}






function ValidarCNPJ(cnpj)
      {
	  cnpj = cnpj.toString().replace( ".", "" ); 
	  cnpj = cnpj.toString().replace( ".", "" ); 
	  cnpj = cnpj.toString().replace( "/", "" ); 
	  cnpj = cnpj.toString().replace( "-", "" ); 	  
		  
      var numeros, digitos, soma, i, resultado, pos, tamanho, digitos_iguais;
      digitos_iguais = 1;
      if (cnpj.length < 14 && cnpj.length < 15)
            return false;
      for (i = 0; i < cnpj.length - 1; i++)
            if (cnpj.charAt(i) != cnpj.charAt(i + 1))
                  {
                  digitos_iguais = 0;
                  break;
                  }
      if (!digitos_iguais)
            {
            tamanho = cnpj.length - 2
            numeros = cnpj.substring(0,tamanho);
            digitos = cnpj.substring(tamanho);
            soma = 0;
            pos = tamanho - 7;
            for (i = tamanho; i >= 1; i--)
                  {
                  soma += numeros.charAt(tamanho - i) * pos--;
                  if (pos < 2)
                        pos = 9;
                  }
            resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
            if (resultado != digitos.charAt(0))
                  return false;
            tamanho = tamanho + 1;
            numeros = cnpj.substring(0,tamanho);
            soma = 0;
            pos = tamanho - 7;
            for (i = tamanho; i >= 1; i--)
                  {
                  soma += numeros.charAt(tamanho - i) * pos--;
                  if (pos < 2)
                        pos = 9;
                  }
            resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
            if (resultado != digitos.charAt(1))
                  return false;
            return true;
            }
      else
            return false;
      } 




function forcaTipoCadastro()
	{
	
	}
function tipoCadastro(tipo)
	{
	
	//alertt(document.formCadastra.pessoa.value,'','info');
	
	if(tipo=='fisica')	//FISICA
	  {
	   
	   
	   document.getElementById("fisica").checked = true;
	   document.getElementById("juridica").checked = false;
	   
	   document.formCadastra.id_tipo_cadastro.value = 'fisica';
	    	  
			  
			  
	   document.getElementById('LabelSimplesNacional').style.display = 'none';
	   document.getElementById('simples_nacional').checked = false;
	   
	   
	   
	   document.getElementById('LabelNomeCad').innerHTML = "Nome:";	   
	   document.getElementById('LabelCPF_CNPJ').innerHTML = "CPF:";	   
	   document.getElementById('LabelRG_IE').innerHTML = "RG:";
	   document.getElementById('LabelNascimento').innerHTML = "Nascimento:";
	   
	   document.formCadastra.nome_fantasia.value 		 = '';
	   document.formCadastra.cnpj.value 				 = '';
	   document.formCadastra.contato.value 				 = '';
	   document.getElementById('LabelNomeFantasia').style.display = 'none';
	   document.getElementById('nome_fantasia').style.display = 'none';
	   
	   document.getElementById('cpf').style.display = '';
	   document.getElementById('cnpj').style.display = 'none';
	   
	   document.getElementById("cpf").required = true;
	   document.getElementById("cnpj").required = false;
	   document.getElementById("contato").required = false;
	   
	   
	   $('#ie_rg').attr('placeholder','Preencha com seu RG');
	   
	   
	   document.getElementById('LabelContato').style.display = 'none';
	   document.getElementById('contato').style.display = 'none';
	   
	   /*document.getElementById('tipoJuridica1').style.display = 'none';
	   document.getElementById('tipoJuridica2').style.display = 'none';
	   document.getElementById('tipoJuridica3').style.display = 'none';
	   document.getElementById('tipoJuridica4').style.display = 'none';
	   
	   document.getElementById('tr_nomeFantasia1').style.display = 'none';
	   document.getElementById('tr_nomeFantasia2').style.display = 'none';
	   
	   
	   
	   */
	   
	   
	  }
	else //JURIDICA
	  {
	   
	   document.getElementById('LabelSimplesNacional').style.display = '';
	   	  
	   document.getElementById("fisica").checked = false;
	   document.getElementById("juridica").checked = true;		  
	   document.formCadastra.id_tipo_cadastro.value = 'juridica';
	   
	   document.getElementById('LabelNomeCad').innerHTML = "Raz&atilde;o Social:";
	   document.getElementById('LabelCPF_CNPJ').innerHTML = "CNPJ:";	
	   document.getElementById('LabelRG_IE').innerHTML = "IE:";	
	   document.getElementById('LabelNascimento').innerHTML = "Abertura:";
	   
	   document.formCadastra.cpf.value 		 = '';
	   
	   
	   $('#ie_rg').attr('placeholder','Preencha com sua IE');
	   

	   document.getElementById('LabelNomeFantasia').style.display = '';
	   document.getElementById('nome_fantasia').style.display = '';	  
	   
	   document.getElementById('cpf').style.display = 'none';
	   document.getElementById('cnpj').style.display = '';
	   
	   document.getElementById("cpf").required = false;
	   document.getElementById("cnpj").required = true;
	   document.getElementById("contato").required = true;
	   
	   
	   document.getElementById('LabelContato').style.display = '';
	   document.getElementById('contato').style.display = '';
	   
	  /* document.getElementById('tipoJuridica1').style.display = '';
	   document.getElementById('tipoJuridica2').style.display = '';
	   document.getElementById('tipoJuridica3').style.display = '';
	   document.getElementById('tipoJuridica4').style.display = '';
	   
	   document.getElementById('tr_nomeFantasia1').style.display = '';
	   document.getElementById('tr_nomeFantasia2').style.display = '';
	   
	   
	   */
	   

	   
	   
	   
	  }
	}








/*function show_formulario_cadastroOLD()
		{
        
        console.log("VAI");
		document.getElementById("formulario_login").style.opacity = '0';
		document.getElementById("formulario_cadastro").style.opacity = '1';
		
		setTimeout(function(){
			document.getElementById("formulario_login").style.display = 'none';
			document.getElementById("formulario_cadastro").style.display = 'block';
			document.getElementById("cpf").focus();
			
			}, 300);
		
			
		
        }


function show_formulario_cadastroOLD()
		{

		if(validateForm('nome_antesCadastro:1:Nome,email_antesCadastro:3:E-mail')==true) 
	    {  	
	
		
		document.formCadastra.email.value = document.formPreCadastro.email_antesCadastro.value;
		document.formCadastra.nome.value  = document.formPreCadastro.nome_antesCadastro.value;
		
		document.getElementById("formulario_login").style.opacity = '0';
		document.getElementById("formulario_cadastro").style.opacity = '1';
		
		setTimeout(function(){
			document.getElementById("formulario_login").style.display = 'none';
			document.getElementById("formulario_cadastro").style.display = 'block';
			document.getElementById("cpf").focus();
			
			}, 300);
		}
			
		
	
	
}
*/




function cadastroRapido(){
	
//	
//	
	if (!validaNomeCompleto(document.formPreCadastro.nome_antesCadastro.value))
		{
		
		alertt('Informe o nome completo','','warning');
		
		}
	else
	{
	if(validateForm('nome_antesCadastro:1:Nome,email_antesCadastro:3:E-mail')==true) 	   
		{
		if((document.formPreCadastro.keySeantes.value==document.formPreCadastro.key2antes.value)&&(document.formPreCadastro.key2antes.value!=""))
			{
		
		
		
			document.formCadastra.email.value = document.formPreCadastro.email_antesCadastro.value;
			document.formCadastra.nome.value  = document.formPreCadastro.nome_antesCadastro.value;
			document.formCadastra.key2.value  = document.formPreCadastro.key2antes.value;
			document.formCadastra.keySe.value  = document.formPreCadastro.keySeantes.value;
			
			
			document.formCadastra.action = document.ssl.str_http.value+document.domain+"/site/area_cliente/acoes/ifr_cadastra.php?cadastroRapido=sim";
				
			loading(); 		
			setTimeout(function(){ document.formCadastra.submit(); }, 1000);
			
			}
		else
			{
			alertt("As senhas devem ser iguais","","error");
			}
		
		
		}
	
	
	}
	
	
	}
	
	



function realizaCadastro(){
	
//	
//	
	if (!validaNomeCompleto(document.formCadastra.nome.value))
		{
		if(document.formCadastra.id_tipo_cadastro.value=="fisica")	
		alertt('Informe o nome completo','','warning');
		else
		alertt('Informe a Raz&atilde;o Social completa','','warning');
		}
	else
	{
	
	
	if((document.formCadastra.keySe.value==document.formCadastra.key2.value)&&(document.formCadastra.key2.value!=""))
	{
	
	if(document.formCadastra.id_tipo_cadastro.value=="fisica")
	  {
		  
		  
	   
	   
	   
	   if(document.getElementById("pais_origem")) 
			{		
			if(document.formCadastra.pais_origem.value=="9999") document.formCadastra.pre_cadastro.value = "sim";		
			}
		  
		  
		  
		  
	   if(document.formCadastra.pre_cadastro.value=="nao")
	 	 {	  
		 
		 form_validado = "sim";
		 
		 
		 //######## BCTRIMS ##############
		 if(document.getElementById("id_segmento"))
		 	{
			
			if(document.formCadastra.id_segmentoOp.value=="13")
				{					
				if(document.getElementById("crm").value=="")
					{
					alertt("Preencha o CRM","CRM Inv&aacute;lido","error");
					form_validado = "nao";
					}
				} 
			else
				{
				if(document.getElementById("numero_reg_prof").value=="")
					{
					alertt("Preencha o N&uacute;mero de Registro Profissional ou Matr&iacute;cula","Aten&ccedil;&atilde;o","error");
					form_validado = "nao";
					}
				}	
			
			if(form_validado=="sim") {
			if(validateForm('nome:1:Nome Completo,ddd:2:DDD,fone:2:Telefone,id_onde:1:Onde nos conheceu,nascimento:4:Nascimento,profissao:1:Atua&ccedil;&acirc;o,email:3:E-mail,cep:1:CEP,enderecoc:1:Endere&ccedil;o,numero:1:N&uacute;mero,bairroc:1:Bairro,id_estado:1:Estado,id_cidade:1:Cidade')==false) 
			  {
			  form_validado = "nao";										
			  }
			}
			
			} 
			
		 //######## BCTRIMS ##############
		 
		 
		 
		 if(form_validado=="sim") 
				 {
				  if(validateForm('nome:1:Nome Completo,ddd:2:DDD,fone:2:Telefone,id_onde:1:Onde nos conheceu,nascimento:4:Nascimento,email:3:E-mail,cep:1:CEP,enderecoc:1:Endere&ccedil;o,numero:1:N&uacute;mero,bairroc:1:Bairro,id_estado:1:Estado,id_cidade:1:Cidade')==true) 
					  {			  
					  if(ValidarCPF(document.formCadastra.cpf.value)) 
						{
											
						if( (document.getElementById("optionsEquipe")) && (document.formCadastra.time.value=="") )
							{
							alertt("Escolha sua Equipe","","error");				
							}
						else
							{
							document.formCadastra.action = document.ssl.str_http.value+document.domain+"/site/area_cliente/acoes/ifr_cadastra.php";
							loading(); 		
							setTimeout(function(){ document.formCadastra.submit(); }, 1000);			
							}
						
						}
					   else {alertt("O CPF informado &eacute; Inv&aacute;lido","","error"); document.formCadastra.cpf.disabled = false; }
					  }
				 }
		 
		 }
		else
			{			
					
				 if(validateForm('nome:1:Nome Completo,ddd:2:DDD,fone:2:Telefone,id_onde:1:Onde nos conheceu,email:3:E-mail')==true) 
					{		
					
					form_validado = "sim";
					
					if(document.getElementById("pais_origem")) 
						{					
						if((document.formCadastra.pais_origem.value=="9999") && ((document.formCadastra.id_pais.value=="") || (document.formCadastra.cidade_ex.value=="")))
							{
							alertt("Selecione o pa&iacute;s e a Cidade","","warning"); 
							form_validado = "nao";
							}
						}
					
					if(form_validado=="sim") 
						{
						document.formCadastra.action = document.ssl.str_http.value+document.domain+"/site/area_cliente/acoes/ifr_cadastra.php";
						loading(); 		
						setTimeout(function(){ document.formCadastra.submit(); }, 1000);			
						}
					
					
					}
				
			}
	  
	  
	  
	  }
	else
	  {
	  if(validateForm('nome:1:Raz&atilde;o Social,nome_fantasia:1:Nome Fantasia,ddd:2:DDD,fone:2:Telefone,id_onde:1:Onde nos conheceu,contato:1:Contato,nascimento:4:Abertura,email:3:E-mail,cep:1:CEP,enderecoc:1:Endere&ccedil;o,numero:1:N&uacute;mero,bairroc:1:Bairro,id_estado:1:Estado,id_cidade:1:Cidade')==true) 
		  {			  
		  if(ValidarCNPJ(document.formCadastra.cnpj.value)) 
			{
			document.formCadastra.action = document.ssl.str_http.value+document.domain+"/site/area_cliente/acoes/ifr_cadastra.php";
			loading(); 		
			setTimeout(function(){ document.formCadastra.submit(); }, 1000);
			}
		   else {alertt("O CNPJ informado &eacute; Inv&aacute;lido","","error"); }
	  
		  }
	  }
	}else alertt("As senhas devem ser iguais","","error");
	
	}
	}




function enviaSenha()
	{
	 if(validateForm('emaill:1:E-mail')==true) 
	    {  	
		strAction = document.ssl.str_http.value+document.domain+"/site/area_cliente/acoes/ifr_login_logoff_acao.php";
			 
		console.log(strAction);
		eval("document.formFinalizar.action = '"+strAction+"';");
		
		loading();
		document.getElementById("acaoLg").value = "senha";
		document.formFinalizar.submit();
		}	 
	}	 

function enviaSenhaTop()
	{
	 if(validateForm('emaill:1:E-mail')==true) 
	    {  	
		strAction = document.ssl.str_http.value+document.domain+"/site/area_cliente/acoes/ifr_login_logoff_acao.php";
			 
		console.log(strAction);
		eval("document.formFinalizarT.action = '"+strAction+"';");
		
		loading();
		document.getElementById("acaoLg").value = "senha";
		document.formFinalizarT.submit();
		
		$('#login').modal('hide');
		}	 
	}






function clickedOutsideElement(elemId) {
  var theElem = getEventTarget(window.event);
  while(theElem != null) {
    if(theElem.id == elemId)
      return false;
    theElem = theElem.offsetParent;
  }
  return true;
}

function getEventTarget(evt) {
  var targ = (evt.target) ? evt.target : evt.srcElement;
  if(targ != null) {
    if(targ.nodeType == 3)
      targ = targ.parentNode;
  }
  return targ;
}

document.onclick = function() {
  if(clickedOutsideElement('popup_troquei_email_bg')){
    //Outside the element!
  }
  else{
    //Inside the element!
	if( document.getElementById("popup_troquei_email_bg").style.opacity=='1' ){
		fechar_popup_troquei_email();
		}
  }
	
}







function fechar_popup_troquei_email(){
	
	popup_bg = document.getElementById("popup_troquei_email_bg");
	
	popup_bg.style.opacity = '0';
	
	setTimeout(function(){
		popup_bg.style.display = 'none';
		}, 300);
	
}

function abrir_popup_troquei_email(){
	popup_bg = document.getElementById("popup_troquei_email_bg");
	
	popup_bg.style.display = 'block';
	
	setTimeout(function(){
		popup_bg.style.opacity = '1';
		}, 100);
	
}

function marcar_pessoa(pessoa){
	
	if(pessoa=='f'){document.getElementById("fisica").checked = true;}
	if(pessoa=='j'){document.getElementById("juridica").checked = true;}
	
}

function voltar_ao_login(){
	
	document.formCadastra.reset();
	
	document.getElementById("formulario_login").style.opacity = '1';
	document.getElementById("formulario_cadastro").style.opacity = '0';
	
	document.formFinalizar.emaill.focus();
	
	//alertt('Informe seu e-mail e senha de acesso.','J&aacute; &eacute; cliente?','info_tr');
	
	setTimeout(function(){
		document.getElementById("formulario_login").style.display = 'table';
		document.getElementById("formulario_cadastro").style.display = 'none';
		}, 300);
	
}





function show_formulario_cadastro()
		{

		    document.formCadastra.email.value = document.formPreCadastro.email_antesCadastro.value;
            document.formCadastra.nome.value  = document.formPreCadastro.nome_antesCadastro.value;

            document.getElementById("formulario_login").style.opacity = '0';
            document.getElementById("formulario_cadastro").style.opacity = '1';

            setTimeout(function(){
                document.getElementById("formulario_login").style.display = 'none';
                document.getElementById("formulario_cadastro").style.display = 'block';
                document.getElementById("cpf").focus();

                }, 300);
            
	
        }
/*
function show_formulario_cadastro()
		{

		if(validateForm('nome_antesCadastro:1:Nome,email_antesCadastro:3:E-mail')==true) 
            {  	


            document.formCadastra.email.value = document.formPreCadastro.email_antesCadastro.value;
            document.formCadastra.nome.value  = document.formPreCadastro.nome_antesCadastro.value;

            document.getElementById("formulario_login").style.opacity = '0';
            document.getElementById("formulario_cadastro").style.opacity = '1';

            setTimeout(function(){
                document.getElementById("formulario_login").style.display = 'none';
                document.getElementById("formulario_cadastro").style.display = 'block';
                document.getElementById("cpf").focus();

                }, 300);
            }
	
        }
*/


function show_formulario_cadastroDireto()
		{

		
		document.getElementById("formulario_login").style.opacity = '0';
		document.getElementById("formulario_cadastro").style.opacity = '1';
		
		setTimeout(function(){
			document.getElementById("formulario_login").style.display = 'none';
			document.getElementById("formulario_cadastro").style.display = 'block';
			
			}, 300);
		
			
		if(document.getElementById("faturamento")) document.getElementById("faturamento_c").value = document.getElementById("faturamento").value;
	
	
	}	

