// função para validar e adicionar novo anunciante __ads/anunciante/cad_anunciante_manut.php
function validar_form_ServicosPesquisa( theForm ) 
{
	theForm = document.getElementById( theForm );
	
	// PARAMETROS
	var empresa     = escape( theForm.empresa.value );
	var descricao   = escape( theForm.descricao.value );
	var listEstados = escape( theForm.listEstados.value );
	var listCidades = escape( theForm.listCidades.value );
	var categoria   = escape( theForm.categoria.value );
	
	var parametros  = '?empresa='+empresa+'&descricao='+descricao+'&listEstados='+listEstados+'&listCidades='+listCidades+
					  '&categoria='+categoria+
					  '&resposta_ajax=1';
	chamarAjax( 'ajaxServicosPesquisa', '/__user/servico/script_servicos.php', parametros, true );
		
}

// função para validar e adicionar novo anunciante __ads/anunciante/cad_anunciante_manut.php
function validar_form_AnuncianteAltADS( theForm ) 
{
	theForm = document.getElementById( theForm );
	msgini = "<font color='#cc3335'>* ";
	msgfim = "</font>";
	var lvai=true;
	
	if (isBlank(theForm.empresa)) { 
		document.getElementById("msgempresa").innerHTML =  msgini+"Empresa:"+msgfim;
		lvai = false;
	} else {
		document.getElementById("msgempresa").innerHTML = "Empresa:";
	}	
	
	if (isBlank(theForm.telefone)) { 
		document.getElementById("msgtelefone").innerHTML =  msgini+"Telefone:"+msgfim;
		lvai = false;
	} else {
		document.getElementById("msgtelefone").innerHTML = "Telefone:";
	}	

	if (isBlank(theForm.contato)) { 
		document.getElementById("msgcontato").innerHTML =  msgini+"Contato:"+msgfim;
		lvai = false;
	} else {
		document.getElementById("msgcontato").innerHTML = "Contato";
	}	
	
	if (!isBlank(theForm.email)) { 
		if(!isMail(theForm.email)) {
		  document.getElementById("msgemail").innerHTML =  msgini+"E-Mail incorreto:"+msgfim;
		  lvai = false;
		}
	} else {
	  document.getElementById("msgemail").innerHTML =  msgini+"E-Mail:"+msgfim;
	  lvai = false;
	}	
	
	if (theForm.listEstados.value == 0) { 
		document.getElementById("msgestado").innerHTML =  msgini+"Estado:"+msgfim;
		lvai = false;
	} else {
		document.getElementById("msgestado").innerHTML = "Estado";
	}	
	
	if (theForm.listCidades.value == 0) { 
		document.getElementById("msgcidade").innerHTML =  msgini+"Cidade:"+msgfim;
		lvai = false;
	} else {
		document.getElementById("msgcidade").innerHTML = "Cidade";
	}	
	
	if (isBlank(theForm.senha)) { 
		document.getElementById("msgsenha").innerHTML =  msgini+"Senha:"+msgfim;
		lvai = false;
	} else {
		if(theForm.senha.value == theForm.senha2.value){
		  document.getElementById("msgsenha").innerHTML =  "Senha:";
		  document.getElementById("msgconfirma").innerHTML =  "Confirmar Senha:";
		}else{
		  document.getElementById("msgsenha").innerHTML =  msgini+"Senha:"+msgfim;
		  document.getElementById("msgconfirma").innerHTML =  msgini+"Senha não confere:"+msgfim;
		  lvai = false;
		}
		document.getElementById("msgsenha").innerHTML = "Senha";
	}
	
  	if(lvai===false){
		alert("Preencha os campos obrigatórios.");
        return false;
	}else{
		// PARAMETROS
		var codigo         = escape( theForm.codigo.value );
		var empresa        = escape( theForm.empresa.value );
		var cnpj           = escape( theForm.cnpj2.value );
		var contato        = escape( theForm.contato.value );
		var email          = escape( theForm.email.value );
		var site           = escape( theForm.site.value );
		var telefone       = escape( theForm.telefone.value );
		var listEstados    = escape( theForm.listEstados.value );
		var listCidades    = escape( theForm.listCidades.value );
		var dtReqCad       = escape( theForm.dtReqCad.value );
		var senha          = escape( theForm.senha.value );
		var novaCat        = '';
		var termo          = '';
		var aceitatermo    = '';
		var logotipo       = escape( theForm.logotipo.value );
		var origemCadastro = escape( 'site' );
		
		var parametros  = '?codigo='+codigo+'&empresa='+empresa+'&cnpj='+cnpj+'&contato='+contato+'&email='+email+
						  '&site='+site+'&telefone='+telefone+'&listEstados='+listEstados+'&listCidades='+listCidades+
						  '&dtReqCad='+dtReqCad+'&senha='+senha+'&novaCat='+novaCat+'&termo='+termo+'&aceitatermo='+aceitatermo+
						  '&logotipo='+logotipo+'&origemCadastro='+origemCadastro +
						  '&resposta_ajax=1';
		chamarAjax( 'ajaxAnuncianteAltADS', '/__ads/anunciante/alt_anunciante.php', parametros, true );
		
	}
}


// função para validar e adicionar novo banner __ads/anunciante/ger_banners.php
function validar_form_BannersADS( theForm ) 
{
	theForm = document.getElementById( theForm );
	msgini = "<font color='#cc3335'>* ";
	msgfim = "</font>";
	var lvai=true;
	if (isBlank(theForm.dtInicial)){
		document.getElementById("msgdtInicial").innerHTML =  msgini+"Iniciar em:"+msgfim;
		lvai = false;
	} else {
		document.getElementById("msgdtInicial").innerHTML = "Iniciar em:";
	}	
	if (isBlank(theForm.texto)){
		document.getElementById("msgtexto").innerHTML =  msgini+"Titulo do banner:"+msgfim;
		lvai = false;
	} else {
		document.getElementById("msgtexto").innerHTML = "Titulo do banner:";
	}
	if(theForm.op.value=='INC'){
	  if (isBlank(theForm.urlbanner)){
		document.getElementById("msgurlbanner").innerHTML =  msgini+"Banners [Url completa]:"+msgfim;
		lvai = false;
	  } else {
		document.getElementById("msgurlbanner").innerHTML = "Banners [Url completa]:";
	  }
  	  var idBanner = 0;
	}else{
		var idBanner = escape( theForm.iden.value );
	}
	if (isBlank(theForm.destinoBanner) || theForm.destinoBanner.value == "http://"){
		document.getElementById("msgdestinoBanner").innerHTML =  msgini+"Destino [Url completa]:"+msgfim;
		lvai = false;
	} else {
		document.getElementById("msgdestinoBanner").innerHTML = "Destino [Url completa]:";
	}	
	
  	if(lvai===false){
		alert("Preencha os campos obrigatórios.");
        return false;
	}else{
		// PARAMETROS
		var codAnunciante = escape( theForm.codAnunciante.value );
		var email         = escape( theForm.email.value );
		var urlBanner     = escape( theForm.urlbanner.value );
		var destinoBanner = escape( theForm.destinoBanner.value );
		var texto         = escape( theForm.texto.value );
		var dtInicial     = escape( theForm.dtInicial.value );
		var imprime       = 9999999;
		var dimensao      = escape( theForm.dimensao.value );
		var statu         = 'A';
		var op            = escape( theForm.op.value );
		
		var parametros  = '?codAnunciante='+codAnunciante+'&email='+email+'&urlBanner='+urlBanner+
						  '&destinoBanner='+destinoBanner+'&texto='+texto+'&dtInicial='+dtInicial+
						  '&imprime='+imprime+'&dimensao='+dimensao+'&statu='+statu+'&urlBanner='+urlBanner+'&op='+op+'&idBanner='+idBanner+
						  '&resposta_ajax=1';
		chamarAjax( 'ajaxBannersADS', '/__ads/anunciante/insere_banner.php', parametros, true );
	}
}

// função para validar o envio de contato do formulário __ads/contato/contato.php
function checkEntrarContatoADS( theForm )
{
	theForm = document.getElementById( theForm );
		
	if (isBlank(theForm.nome))
	{
		alert("Preencha seu nome");
		jQuery("input#nome").focus(); 
		return false; 
	}
	
	if(!isBlank(theForm.email)) 
	{
		if(!isMail(theForm.email)) 
		{
			alert("Formato de e-Mail incorreto");
      		jQuery("input#email").focus();
			return false;
		} 
	}
	else
	{
		alert("Preencha o seu e-Mail");
		jQuery("input#email").focus();
		return false;
	}
	
	if (isBlank(theForm.assunto))
	{
		alert("Preencha o assunto");
		jQuery("input#assunto").focus(); 
		return false; 
	}
	
	if (isBlank(theForm.mensagem))
	{
		alert("Preencha a mensagem");
		jQuery("textarea#mensagem").focus(); 
		return false; 
	}
	
	var nome = escape( theForm.nome.value );
	var email = escape( theForm.email.value );
	var assunto = escape( theForm.assunto.value );
	var mensagem = escape( theForm.mensagem.value );
	
	var parametros = '?nome='+nome+'&email='+email+
					 '&assunto='+assunto+'&mensagem='+mensagem;
	
	chamarAjax( 'target', '../../__ads/contato/script_entrar_contato.php', parametros, true );
}

// função para validar e adicionar novo anuncio cidade __ads/anuncio/cad_anunciocid.php
function validar_form_AnunCid( theForm ) 
{
	theForm = document.getElementById( theForm );
	msgini = "<font color='#cc3335'>* ";
	msgfim = "</font>";
	var lvai=true;
	if (theForm.listEstados.value == 0) { 
		document.getElementById("msgestado").innerHTML =  msgini+"Estado:"+msgfim;
		lvai = false;
	} else {
		document.getElementById("msgestado").innerHTML = "Estado";
	}	
	
	if (theForm.listCidades.value == 0) { 
		document.getElementById("msgcidade").innerHTML =  msgini+"Cidade:"+msgfim;
		lvai = false;
	} else {
		document.getElementById("msgcidade").innerHTML = "Cidade";
	}	
	
  	if(lvai===false){
		alert("Preencha os campos obrigatórios.");
        return false;
	}else{
		// PARAMETROS
		var codAnunciante  = escape( theForm.cod_anunciante.value );
		var listEstados    = escape( theForm.listEstados.value );
		var listCidades    = escape( theForm.listCidades.value );
		
		var parametros  = '?codAnunciante='+codAnunciante+'&listEstados='+listEstados+'&listCidades='+listCidades+
						  '&resposta_ajax=1';
		chamarAjax( 'ajaxCadAnuncioCidADS', '/__ads/anuncio/insere_anunciocid.php', parametros, true );
		
	}
}

// função para validar o cadastro dos anuncios __ads/anuncio/cad_anuncio.php
function validar_form_AnuncioADS( theForm )  { 
//__ads/anuncio/cad_anuncid.php
	theForm = document.getElementById( theForm );
	msgini = "<font color='#cc3335'>* ";
	msgfim = "</font>";
	var lvai=true;
	var aux='nao';
	var cod_categoria='';

	if (isBlank(theForm.anuncio)) {  
		document.getElementById("msganuncio").innerHTML =  msgini+"Anúncio:"+msgfim;
		lvai = false;
	} else {
		document.getElementById("msganuncio").innerHTML = "Anúncio:";
	}	

    if (isBlank(theForm.nova_cat)) {  
		qtd = theForm.cod_categoria.length;
		aux = "";
		for (i=0;i<qtd;i++){ 
		  if (theForm.cod_categoria[i].checked){
		    cod_categoria = theForm.cod_categoria[i].value;
			aux = "achou";
		  }
		}
	
		if(aux != "achou"){
			document.getElementById("msgcategoria").innerHTML =  msgini+"Selecione a categoria para este an&uacute;ncio."+msgfim;
			lvai = false;
		} else {
			document.getElementById("msgcategoria").innerHTML = "Selecione a categoria para este an&uacute;ncio.";
		}	
	}
	
  	if(lvai===false){
		alert("Preencha os campos obrigatórios.");
        return false;
	}else{
		// PARAMETROS
		var cod_anuncio   = escape( theForm.cod_anuncio.value );
		var codAnunciante = escape( theForm.cod_anunciante.value );
		var codCategoria  = escape( cod_categoria );
		var titulo        = escape( '' );
		var anuncio       = escape( theForm.anuncio.value );
		var dataInicio    = escape( theForm.data_inicio.value );
		var dataFim       = escape( theForm.data_fim.value );
		var mese          = escape( theForm.mese.value );
		var valor         = escape( theForm.valor.value );
		var statu         = escape( theForm.statu.value );
		var novaCat       = escape( theForm.nova_cat.value );
		var op            = escape( theForm.op.value );
		var mod           = escape( theForm.mod.value );
		
		var parametros  = '?codAnunciante='+codAnunciante+'&codCategoria='+codCategoria+'&titulo='+titulo+'&anuncio='+anuncio+
						  '&dataInicio='+dataInicio+'&dataFim='+dataFim+'&mese='+mese+'&valor='+valor+
						  '&statu='+statu+'&novaCat='+novaCat+'&op='+op+'&codigo='+cod_anuncio+'&mod='+mod+
						  '&resposta_ajax=1';
		chamarAjax( 'ajaxCadAnunciosADS', '/__ads/anuncio/insere_anuncio.php', parametros, true );
		
	}	
}

// função para validar e adicionar novo anunciante __ads/anunciante/cad_anunciante.php
function validar_form_AnuncianteADS( theForm ) 
{
	theForm = document.getElementById( theForm );
	msgini = "<font color='#cc3335'>* ";
	msgfim = "</font>";
	var lvai=true;
	
	if (isBlank(theForm.empresa)) { 
		document.getElementById("msgempresa").innerHTML =  msgini+"Empresa:"+msgfim;
		lvai = false;
	} else {
		document.getElementById("msgempresa").innerHTML = "Empresa:";
	}	
	
	if (isBlank(theForm.telefone)) { 
		document.getElementById("msgtelefone").innerHTML =  msgini+"Telefone:"+msgfim;
		lvai = false;
	} else {
		document.getElementById("msgtelefone").innerHTML = "Telefone:";
	}	

	if (isBlank(theForm.contato)) { 
		document.getElementById("msgcontato").innerHTML =  msgini+"Contato:"+msgfim;
		lvai = false;
	} else {
		document.getElementById("msgcontato").innerHTML = "Contato";
	}	
	
	if (!isBlank(theForm.email)) { 
		if(!isMail(theForm.email)) {
		  document.getElementById("msgemail").innerHTML =  msgini+"E-Mail incorreto:"+msgfim;
		  lvai = false;
		}
	} else {
	  document.getElementById("msgemail").innerHTML =  msgini+"E-Mail:"+msgfim;
	  lvai = false;
	}	
	
	if (theForm.listEstados.value == 0) { 
		document.getElementById("msgestado").innerHTML =  msgini+"Estado:"+msgfim;
		lvai = false;
	} else {
		document.getElementById("msgestado").innerHTML = "Estado";
	}	
	
	if (theForm.listCidades.value == 0) { 
		document.getElementById("msgcidade").innerHTML =  msgini+"Cidade:"+msgfim;
		lvai = false;
	} else {
		document.getElementById("msgcidade").innerHTML = "Cidade";
	}	
	/*  
	if (document.getElementById('aceitatermo_0').checked == false) { 
		document.getElementById("msgtermo").innerHTML =  msgini+"Aceito:"+msgfim;
		lvai = false;
	} else {
		document.getElementById("msgtermo").innerHTML = "Aceito";
	}	
	*/  
	
	if (isBlank(theForm.senha)) { 
		document.getElementById("msgsenha").innerHTML =  msgini+"Senha:"+msgfim;
		lvai = false;
	} else {
		if(theForm.senha.value == theForm.senha2.value){
		  document.getElementById("msgsenha").innerHTML =  "Senha:";
		  document.getElementById("msgconfirma").innerHTML =  "Confirmar Senha:";
		}else{
		  document.getElementById("msgsenha").innerHTML =  msgini+"Senha:"+msgfim;
		  document.getElementById("msgconfirma").innerHTML =  msgini+"Senha não confere:"+msgfim;
		  lvai = false;
		}
		document.getElementById("msgsenha").innerHTML = "Senha";
	}
	
  	if(lvai===false){
		alert("Preencha os campos obrigatórios.");
        return false;
	}else{
		// PARAMETROS
		var empresa        = escape( theForm.empresa.value );
		var cnpj           = escape( theForm.cnpj2.value );
		var contato        = escape( theForm.contato.value );
		var email          = escape( theForm.email.value );
		var site           = escape( theForm.site.value );
		var telefone       = escape( theForm.telefone.value );
		var listEstados    = escape( theForm.listEstados.value );
		var listCidades    = escape( theForm.listCidades.value );
		var dtReqCad       = escape( theForm.dtReqCad.value );
		var senha          = escape( theForm.senha.value );
		var novaCat        = '';
		var termo          = '';
		var aceitatermo    = '';
		var logotipo       = escape( theForm.logotipo.value );
		var origemCadastro = escape( 'site' );
		
		var parametros  = '?empresa='+empresa+'&cnpj='+cnpj+'&contato='+contato+'&email='+email+
						  '&site='+site+'&telefone='+telefone+'&listEstados='+listEstados+'&listCidades='+listCidades+
						  '&dtReqCad='+dtReqCad+'&senha='+senha+'&novaCat='+novaCat+'&termo='+termo+'&aceitatermo='+aceitatermo+
						  '&logotipo='+logotipo+'&origemCadastro='+origemCadastro +
						  '&resposta_ajax=1';
		chamarAjax( 'ajaxCadastrarAnuncianteADS', '/__ads/anunciante/insere_anunciante.php', parametros, true );
		
	}
}


// função para excluir as despesas em bloco __user/despesas.php
function validar_form_excluir_despesas(tipo){
    var tipo = tipo;
	var achou=false;
	var selecionados = '';
	// verifica o tipo da ação que será feito
	if(tipo=='excluir'){
	  // verifica se foi selecionado algum registro para ser quitado  
	  for (var i=0;i<=document.fmModdespesas.elements.length-1;i++)   {
	    if (document.fmModdespesas.elements[i].type == "checkbox") {
		  if(document.fmModdespesas.elements[i].name == "selquita"){
		    if (document.fmModdespesas.elements[i].checked) {
		      // adiciona os registros selcionado para passar como parâmetro  
			  selecionados += 'selecionados'+i+'='+document.fmModdespesas.elements[i].value+'&';
			  achou=true;
			  //break;
		    }
		  }
	    }
	  }
	
	  if(achou==false){
		alert("Nenhuma despesa foi selecionada para ser excluída.");
	  }else{
	    if ( confirm( "Confirma a exclusão de toda(s) a(s) despesa(s) selecionada(s)?" ) ){
		
	      var selquita = escape( document.fmModdespesas.selquita.value );
	      var parametros = '?'+selecionados+'resposta_ajax=1';
	      // faz o update da receita passando como parâmetro dos os dados.
  	      chamarAjax( 'ajaxQuitarDespesas', '../../__user/despesa/mod_excluir.php', parametros, true );
	    }else{
		  alert("Operação cancelada.");
	    }
	  }
	}else{
		// rotina utilizada para a pesquisa.
		document.fmModdespesas.submit();
	}
}
// função para quitas as despesas em bloco __user/despesas.php
function validar_form_quitar_despesas(tipo){
    var tipo = tipo;
	var achou=false;
	var selecionados = '';
	// verifica o tipo da ação que será feito
	if(tipo=='quitar'){
	  // verifica se foi selecionado algum registro para ser quitado  
	  for (var i=0;i<=document.fmModdespesas.elements.length-1;i++)   {
	    if (document.fmModdespesas.elements[i].type == "checkbox") {
		  if(document.fmModdespesas.elements[i].name == "selquita"){
		    if (document.fmModdespesas.elements[i].checked) {
		      // adiciona os registros selcionado para passar como parâmetro  
			  selecionados += 'selecionados'+i+'='+document.fmModdespesas.elements[i].value+'&';
			  achou=true;
			  //break;
		    }
		  }
	    }
	  }
	
	  if(achou==false){
		alert("Nenhuma despesa foi selecionada para ser dado baixa.");
	  }else{
	    if ( confirm( "Confirma a quitação de toda(s) a(s) despesa(s) selecionada(s)?" ) ){
		
	      var selquita = escape( document.fmModdespesas.selquita.value );
	      var parametros = '?'+selecionados+'resposta_ajax=1';
	      // faz o update da receita passando como parâmetro dos os dados.
  	      chamarAjax( 'ajaxQuitarDespesas', '../../__user/despesa/mod_quitar.php', parametros, true );
	    }else{
		  alert("Operação cancelada.");
	    }
	  }
	}else{
		// rotina utilizada para a pesquisa.
		document.fmModdespesas.submit();
	}
}

// função para excluir as receitas em bloco __user/receitas.php
function validar_form_excluir_receita(tipo){
    var tipo = tipo;
	var achou=false;
	var selecionados = '';
	// verifica o tipo da ação que será feito
	if(tipo=='excluir'){
		
	  if ( confirm( "Confirma a exclusão de toda(s) a(s) cobrança(s) selecionada(s)?" ) ){
		// verifica se foi selecionado algum registro para ser quitado  
	    for (var i=0;i<=document.fmModReceitas.elements.length-1;i++)   {
	      if (document.fmModReceitas.elements[i].type == "checkbox") {
		    if(document.fmModReceitas.elements[i].name == "selquita"){
		      if (document.fmModReceitas.elements[i].checked) {
				// adiciona os registros selcionado para passar como parâmetro  
			    selecionados += 'selecionados'+i+'='+document.fmModReceitas.elements[i].value+'&';
			    achou=true;
			    //break;
		      }
		    }
	      }
	    }
	
	    if(achou==false){
		  alert("Nenhuma cobrança foi selecionada para ser excluída.");
	    }else{
		
	      var selquita = escape( document.fmModReceitas.selquita.value );
	      var parametros = '?'+selecionados+'resposta_ajax=1';
	      // faz o update da receita passando como parâmetro dos os dados.
  	      chamarAjax( 'ajaxQuitarReceitas', '../../__user/receita/mod_excluir.php', parametros, true );
	    }
	  }else{
		  alert("Operação cancelada.");
	  }
	}else{
		// rotina utilizada para a pesquisa.
		document.fmModReceitas.submit();
	}
}



// função para quitar as receitas em bloco __user/receitas.php
function validar_form_quitar_receita(tipo){
    var tipo = tipo;
	var achou=false;
	var selecionados = '';
	// verifica o tipo da ação que será feito
	if(tipo=='quitar'){
		
	  if ( confirm( "Confirma a quitação de toda(s) a(s) cobrança(s) selecionada(s)?" ) ){
		// verifica se foi selecionado algum registro para ser quitado  
	    for (var i=0;i<=document.fmModReceitas.elements.length-1;i++)   {
	      if (document.fmModReceitas.elements[i].type == "checkbox") {
		    if(document.fmModReceitas.elements[i].name == "selquita"){
		      if (document.fmModReceitas.elements[i].checked) {
				// adiciona os registros selcionado para passar como parâmetro  
			    selecionados += 'selecionados'+i+'='+document.fmModReceitas.elements[i].value+'&';
			    achou=true;
			    //break;
		      }
		    }
	      }
	    }
	
	    if(achou==false){
		  alert("Nenhuma cobrança foi selecionada para ser dado baixa.");
	    }else{
		
	      var selquita = escape( document.fmModReceitas.selquita.value );
	      var parametros = '?'+selecionados+'resposta_ajax=1';
	      // faz o update da receita passando como parâmetro dos os dados.
  	      chamarAjax( 'ajaxQuitarReceitas', '../../__user/receita/mod_quitar.php', parametros, true );
	    }
	  }else{
		  alert("Operação cancelada.");
	  }
	}else{
		// rotina utilizada para a pesquisa.
		document.fmModReceitas.submit();
	}
}

// função para atualizar anunciantes do ger_banners.
function AnunciantesGerBanners(theForm){
	theForm = document.getElementById( theForm );
alert('1')	;
	if ( theForm.cod_anun.value == 'nulo' ){
		alert("Selecione um anunciantes");
		jQuery("select#loginEmail").focus();
		return false;
	}
alert('2')	;
	
	var cod_anun = escape( theForm.cod_anun.value );
alert('3')	;

    var parametros  = '?cod_anun='+cod_anun+'&resposta_ajax=1';
alert('4')	;

    chamarAjax( 'idGerBanner', '../../mod_ger_banners.php', parametros, true );
}

// função para mudar o status do aluno no perfil.php
function perfil_status(st, idcadastro){
	if ( st.value == "T" )
	  msg = "Deseja reativar este aluno?";
	else if ( st.value == "D" )
	  msg = "Deseja desativar este aluno?"; 
	else if ( st.value == "F" )
	  msg = "Deseja aguardar a ativação da conta do aluno?";
	var idcadastro = escape( idcadastro );
    var parametros  = '?st='+st.value+'&idcadastro='+idcadastro+'&resposta_ajax=1';
	
	if ( confirm( msg ) )
	  chamarAjax( 'idNivelAcessoPerfil', '../../__user/classe/script_desativar_aluno.php', parametros , 'true' )   										
	else{
		window.location.reload();
		return false;
	}
}

// função para mudar o perfil do aluno no perfil.php
function perfil_aluno(st, funcao){

	if ( st == "C" )
	  msg = "Retirar aluno da comissão?"; 
	else 
	  msg = "Adicionar aluno para a comissão?";
																			
	funcao = urldecode(funcao);
	
	if ( confirm( msg ) )
		executar( funcao );
	else{
		window.location.reload();
		return false;
	}
}

// valida se a comissão removeu o campo para não ler mais o guia rápido.
function checkPrincipalGuiaRapido(theForm){
	theForm = document.getElementById( theForm );
	if ( theForm.remove_guia.checked == 1 )
		remove_guia = 'S';
	else
	{
		alert('Para não receber mais o comunicado será necessário marcar o campo "Não exibir esta janela novamente."');
		return false; 
	}
	var remove_guia = escape( theForm.remove_guia.value );
    var tabela      = escape( theForm.tabela.value ); // nome da tabela
    var chv         = escape( theForm.chv.value ); // campo que é chave da tabela
    var chvin       = escape( theForm.chvin.value ); // valor da chave
    var op          = escape( theForm.op.value ); // operação que está sendo executada, inclusão / alteração
    var naograva    = escape( theForm.naograva.value ); // campos que não é para ser gravado no banco

    var parametros  = '?remove_guia='+remove_guia+'&tabela=' + tabela +'&chv=' + chv +'&op=' + op +
					  '&naograva=' + naograva + '&chvin=' + chvin +
					  '&resposta_ajax=1';

	chamarAjax( 'ajaxGuia', '../../__user/principal/guia_rapido.php', parametros, true );
}
// VALIDA O LOGIN PARA USER
function validar_form_login_user( theForm )
{
	theForm = document.getElementById( theForm );
		
	if(!isBlank(theForm.loginEmail)) 
	{
		if(!isMail(theForm.loginEmail)) 
		{
			alert("Formato de e-Mail incorreto");
      		jQuery("input#loginEmail").focus();
			return false;
		} 
	}
	else
	{
		alert("Preencha o campo e-Mail");
		jQuery("input#loginEmail").focus();
		return false;
	}
	
	if (isBlank(theForm.loginSenha)) 
	{
		alert("Digite uma senha");
		jQuery("input#loginSenha").focus();
		return false;	
	}
	
	var email = escape( theForm.loginEmail.value );
	var senha = escape( theForm.loginSenha.value );
	var parametros = '?email='+email+'&senha='+senha
	//alert(parametros);

	chamarAjax( 'target', '../../__user/index/script_login_user.php', parametros, true );
}

// VALIDA CÓDIGO PARA CADASTRO DE FORMANDO - PÁGINA INDEX!
function validar_codigo_turma( theForm ) 
{
	theForm = document.getElementById( theForm );
	
	if(isBlank(theForm.codigo)) 
	{
		alert("É necessário informar o código de acesso. Para isso, entre em contato com a comissão da sua formatura.");
		jQuery("input#codigo").focus(); 
		return false;
	}
	
	// PARAMETROS
	var codigo = escape( theForm.codigo.value );
	var parametros = '?codigo='+codigo
	
	chamarAjax( 'target', 'cadastro_aluno/script_cadastro.php', parametros, true );
}

function validar_form_cadastro_aluno( theForm )
{	
	theForm = document.getElementById( theForm );
		
	if (isBlank(theForm.nome))
	{
		alert("Preencha o campo Nome");
		jQuery("input#nome").focus(); 
		return false; 
	}
	
	if(!isBlank(theForm.email)) 
	{
		if(!isMail(theForm.email)) 
		{
			alert("Formato de e-Mail incorreto");
      		jQuery("input#email").focus(); 
			return false;
		} 
	}
	else
	{
		alert("Preencha o campo e-Mail");
		jQuery("input#email").focus();
		return false;
	}
	
	if (isBlank(theForm.senha))
	{
		alert("Preencha o campo senha");
		jQuery("input#senha").focus(); 
		return false; 
	}
	
	if (theForm.listEstados.value == 0)
	{
		alert("Selecione um Estado");
		jQuery("select#listEstados").focus();
		return false; 
	}	
	
	if (theForm.listCidades.value == 0)
	{
		alert("Selecione uma Cidade");
		jQuery("select#listCidades").focus();
		return false; 
	}	
	
	// PREPARA STRING DE PARAMETROS
	var nome = escape( theForm.nome.value );
	var email = escape( theForm.email.value );
	var senha = escape( theForm.senha.value );
	var estado = escape( theForm.listEstados.value );
	var cidade = escape( theForm.listCidades.value );
	var parametros = '?nome='+nome+'&email='+email+'&senha='+senha+'&estado='+estado+'&cidade='+cidade; 

	
	return parametros;
	//chamarAjax( 'target', 'cadastro_aluno/script_insere.php', parametros, true );
}

function validar_form_cadastro_turma( theForm )
{	
	theForm = document.getElementById( theForm );
		
	if (isBlank(theForm.curso))
	{
		alert("Preencha o nome de seu curso");
		jQuery("input#curso").focus(); 
		return false; 
	}
		if (isBlank(theForm.inst))
	{
		alert("Preencha o nome da instituição");
		jQuery("input#inst").focus(); 
		return false; 
	}
	
    var today = new Date();
    var datenow = today.getFullYear();
	
	if (isBlank(theForm.ingresso))
	{
		alert("Preencha o ano de ingresso da sua turma");
		jQuery("input#ingresso").focus(); 
		return false; 
	}else if(theForm.ingresso.value > datenow){
		alert("O ano de ingresso da sua turma não pode ser maior que " + datenow);
		jQuery("input#ingresso").focus(); 
		return false; 
	}
	
	
	if (isBlank(theForm.regresso_mes))
	{
		alert("Preencha o mês de Conclusão da sua turma");
		jQuery("input#regresso_mes").focus(); 
		return false; 
	}else if(theForm.regresso_mes.value < 0 || theForm.regresso_mes.value > 12){
		alert("Preencha corretamente o mês de Conclusão da sua turma");
		jQuery("input#regresso_mes").focus(); 
		return false; 
	}

	if (isBlank(theForm.regresso_ano))
	{
		alert("Preencha o ano de Conclusão da sua turma");
		jQuery("input#regresso_ano").focus(); 
		return false; 
	}else if(theForm.regresso_ano.value < datenow ){
		alert("Preencha corretamente o ano de Conclusão da sua turma");
		jQuery("input#regresso_ano").focus(); 
		return false; 
	}
	
	if(theForm.ingresso.value > theForm.regresso_ano.value){
		alert("O ano de Conclusão não pode ser menor que o ano de ingresso da sua turma");
		jQuery("input#regresso_ano").focus(); 
		return false; 
	}
	
	if (isBlank(theForm.nome))
	{
		alert("Preencha seu nome");
		jQuery("input#nome").focus(); 
		return false; 
	}
	
	if(!isBlank(theForm.email)) 
	{
		if(!isMail(theForm.email)) 
		{
			alert("Formato de e-Mail incorreto");
      		jQuery("input#email").focus(); 
			return false;
		} 
	}
	else
	{
		alert("Preencha o campo e-Mail");
		jQuery("input#email").focus();
		return false;
	}
	
	if (isBlank(theForm.senha))
	{
		alert("Preencha o campo senha");
		jQuery("input#senha").focus(); 
		return false; 
	}
	
	if (theForm.listEstados.value == 0)
	{
		alert("Selecione um estado");
		jQuery("select#listEstados").focus();
		return false; 
	}	
	
	if (theForm.listCidades.value == 0)
	{
		alert("Selecione uma cidade");
		jQuery("select#listCidades").focus();
		return false; 
	}	
	
	// PREPARA STRING DE PARAMETROS
	var curso = escape( theForm.curso.value );
	var inst = escape( theForm.inst.value );
	var ingresso = escape( theForm.ingresso.value );
	var regresso_ano = escape( theForm.regresso_ano.value );
	var regresso_mes = escape( theForm.regresso_mes.value );
	var nome = escape( theForm.nome.value );
	var email = escape( theForm.email.value );
	var senha = escape( theForm.senha.value );
	var estado = escape( theForm.listEstados.value );
	var cidade = escape( theForm.listCidades.value );
	var parametros = '?curso=' + curso + '&inst=' + inst + '&ingresso=' + ingresso +
	                 '&regresso_ano=' + regresso_ano +'&regresso_mes=' + regresso_mes + '&nome=' + nome +
					 '&email=' + email + '&senha=' + senha + '&estado=' + estado + '&cidade=' + cidade; 
	chamarAjax( 'target', '../../__user/cadastro_turma/script_insere.php', parametros, true );
}
function validar_form_cadastro_turma_master( theForm )
{	
	theForm = document.getElementById( theForm );

	if (isBlank(theForm.curso))
	{
		alert("Preencha o nome de seu curso");
		jQuery("input#curso").focus(); 
		return false; 
	}

	
	
	if (isBlank(theForm.inst))
	{
		alert("Preencha o nome da instituição");
		jQuery("input#inst").focus(); 
		return false; 
	}
	
    var today = new Date();
    var datenow = today.getFullYear();
	
	if (isBlank(theForm.ingresso))
	{
		alert("Preencha o ano de ingresso da sua turma");
		jQuery("input#ingresso").focus(); 
		return false; 
	}else if(theForm.ingresso.value > datenow){
		alert("O ano de ingresso da sua turma não pode ser maior que " + datenow);
		jQuery("input#ingresso").focus(); 
		return false; 
	}
	
	
	if (isBlank(theForm.regresso_mes))
	{
		alert("Preencha o mês de Conclusão da sua turma");
		jQuery("input#regresso_mes").focus(); 
		return false; 
	}else if(theForm.regresso_mes.value < 0 || theForm.regresso_mes.value > 12){
		alert("Preencha corretamente o mês de Conclusão da sua turma");
		jQuery("input#regresso_mes").focus(); 
		return false; 
	}

	if (isBlank(theForm.regresso_ano))
	{
		alert("Preencha o ano de Conclusão da sua turma");
		jQuery("input#regresso_ano").focus(); 
		return false; 
	}else if(theForm.regresso_ano.value < datenow ){
		alert("Preencha corretamente o ano de Conclusão da sua turma");
		jQuery("input#regresso_ano").focus(); 
		return false; 
	}
	
	if(theForm.ingresso.value > theForm.regresso_ano.value){
		alert("O ano de Conclusão não pode ser menor que o ano de ingresso da sua turma");
		jQuery("input#regresso_ano").focus(); 
		return false; 
	}


	if (theForm.listEstados1.value == 0)
	{
		alert("Selecione um estado");
		jQuery("select#listEstados").focus();
		return false; 
	}	

	
	if (theForm.listCidades1.value == 0)
	{
		alert("Selecione uma cidade");
		jQuery("select#listCidades").focus();
		return false; 
	}	
	
	// PREPARA STRING DE PARAMETROS
	var curso = escape( theForm.curso.value );
	var inst = escape( theForm.inst.value );
	var ingresso = escape( theForm.ingresso.value );
	var regresso_ano = escape( theForm.regresso_ano.value );
	var regresso_mes = escape( theForm.regresso_mes.value );
	var ensino = escape( theForm.ensino.value );
	var estado = escape( theForm.listEstados1.value );
	var cidade = escape( theForm.listCidades1.value );
	var master_insert = escape( theForm.master_insert.value );  // usuário master que fez a inclusão do registro
	var parametros = '?curso=' + curso + '&inst=' + inst + '&ingresso=' + ingresso + '&regresso_mes=' + regresso_mes +
					 '&regresso_ano=' + regresso_ano + '&ensino=' + ensino + '&estado=' + estado + '&cidade=' + cidade+'&master_insert='+master_insert; 
	chamarAjax( 'target', '../../__user/classe/script_insere_master.php', parametros, true );
}

// HABILITA CADASTRO ALUNO
function abilita(val)
{
	if(val == 1)
		document.fm.Submit.disabled = 0;
	else 
		document.fm.Submit.disabled = 1;
}



function Dados(valor) {
  //verifica se o browser tem suporte a ajax
  try {
	 ajax = new ActiveXObject("Microsoft.XMLHTTP");
  } 
  catch(e) {
	 try {
		ajax = new ActiveXObject("Msxml2.XMLHTTP");
	 }
	 catch(ex) {
		try {
		   ajax = new XMLHttpRequest();
		}
		catch(exc) {
		   alert("Esse browser não tem recursos para uso do Ajax");
		   ajax = null;
		}
	 }
  }
  //se tiver suporte ajax
  if(ajax) {
	 //deixa apenas o elemento 1 no option, os outros são excluídos
	 document.fm.listCidades1.options.length = 1;
	 
	 idOpcao  = document.getElementById("opcoes");
	 
	 ajax.open("POST", "../../__user/comum/cidades.php", true);
	 ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	 
	 ajax.onreadystatechange = function() {
		//enquanto estiver processando...emite a msg de carregando
		if(ajax.readyState == 1) {
		   idOpcao.innerHTML = "Carregando...!";   
		}
		//após ser processado - chama função processXML que vai varrer os dados
		if(ajax.readyState == 4 ) {
		   if(ajax.responseXML) {
			  processXML(ajax.responseXML);
		   }
		   else {
			   //caso não seja um arquivo XML emite a mensagem abaixo
			   idOpcao.innerHTML = "--Primeiro selecione o estado--";
		   }
		}
	 }
	 //passa o código do estado escolhido
	 var params = "estado="+valor;
	 ajax.send(params);
  }
}

function processXML(obj){
  //pega a tag cidade
  var dataArray   = obj.getElementsByTagName("cidade");
  
  //total de elementos contidos na tag cidade
  if(dataArray.length > 0) {
	 //percorre o arquivo XML paara extrair os dados
	 for(var i = 0 ; i < dataArray.length ; i++) {
		var item = dataArray[i];
		//contéudo dos campos no arquivo XML
		var codigo    =  item.getElementsByTagName("codigo")[0].firstChild.nodeValue;
		var descricao =  item.getElementsByTagName("descricao")[0].firstChild.nodeValue;
		
		idOpcao.innerHTML = "--Selecione uma das op&ccedil;&otilde;es abaixo--";
		
		//cria um novo option dinamicamente  
		var novo = document.createElement("option");
			//atribui um ID a esse elemento
			novo.setAttribute("id", "opcoes");
			//atribui um valor
			novo.value = codigo;
			//atribui um texto
			novo.text  = descricao;
			//finalmente adiciona o novo elemento
			document.fm.listCidades1.options.add(novo);
	 }
  }
  else {
	//caso o XML volte vazio, printa a mensagem abaixo
	idOpcao.innerHTML = "--Primeiro selecione o estado--";
  }	  
}

function efetuarLogoff()
{
	if (confirm("Você tem certeza que deseja sair ?"))
		chamarAjax( 'menuVerticalSair', '../../__user/comum/script_efetuar_logoff.php', '', true );
}

// VALIDA O EMAIL PARA USER
function validarEmail( theForm )
{
	theForm = document.getElementById( theForm );
		
	if(!isBlank(theForm.email)) 
	{
		if(!isMail(theForm.email)) 
		{
			alert("Formato de e-Mail incorreto");
      		jQuery("input#loginEmail").focus();
			return false;
		} 
	}
	else
	{
		alert("Preencha o campo e-Mail");
		jQuery("input#loginEmail").focus();
		return false;
	}
	
	var email = escape( theForm.email.value );
	
	var parametros = '?email='+email;

	chamarAjax( 'targetReenvioEmail', '../../__user/reenviar_email/script_reenviar_email.php', parametros, true );
}

// VALIDA O EMAIL
function checkEmail( theForm, field )
{
	theForm = document.getElementById( theForm );
		
	if(!isBlank(theForm.email)) 
	{
		if(!isMail(theForm.email)) 
		{
			alert("Formato de e-Mail incorreto");
      		jQuery("input#email").focus();
			return false;
		} 
	}
	else
	{
		alert("Preencha o campo e-Mail");
		jQuery("input#email").focus();
		return false;
	}
	
	var email = escape( theForm.email.value );
	
	var parametros = '?email='+email;
	
	chamarAjax( 'target', '../../__user/senha/script_enviar_senha.php', parametros, true );
}

// VALIDA O EMAIL
function checkIndicarAmigo( theForm )
{
	theForm = document.getElementById( theForm );
		
	if (isBlank(theForm.indicador))
	{
		alert("Preencha seu nome");
		jQuery("input#indicador").focus(); 
		return false; 
	}
	
	if(!isBlank(theForm.email_indicador)) 
	{
		if(!isMail(theForm.email_indicador)) 
		{
			alert("Formato de seu e-Mail incorreto");
      		jQuery("input#email_indicador").focus();
			return false;
		} 
	}
	else
	{
		alert("Preencha o seu e-Mail");
		jQuery("input#email_indicador").focus();
		return false;
	}
	
	if (isBlank(theForm.indicado))
	{
		alert("Preencha o nome de seu amigo");
		jQuery("input#indicado").focus(); 
		return false; 
	}
	
	if(!isBlank(theForm.email_indicado)) 
	{
		if(!isMail(theForm.email_indicado)) 
		{
			alert("Formato do e-Mail de seu amigo incorreto");
      		jQuery("input#email_indicado").focus();
			return false;
		} 
	}
	else
	{
		alert("Preencha o e-Mail de seu amigo");
		jQuery("input#email_indicado").focus();
		return false;
	}
	
	var indicador = escape( theForm.indicador.value );
	var email_indicador = escape( theForm.email_indicador.value );
	var indicado = escape( theForm.indicado.value );
	var email_indicado = escape( theForm.email_indicado.value );
	
	var parametros = '?indicador='+indicador+'&email_indicador='+email_indicador+
					 '&indicado='+indicado+'&email_indicado='+email_indicado;
	
	chamarAjax( 'target', '../../__user/indicar/script_indicar.php', parametros, true );
}

// DATA: 	15-12-2009
// EMAIL: 	alfredo@ecliente.com.br
function checkEntrarContato( theForm )
{
	theForm = document.getElementById( theForm );
		
	if (isBlank(theForm.nome))
	{
		alert("Preencha seu nome");
		jQuery("input#nome").focus(); 
		return false; 
	}
	
	if(!isBlank(theForm.email)) 
	{
		if(!isMail(theForm.email)) 
		{
			alert("Formato de e-Mail incorreto");
      		jQuery("input#email").focus();
			return false;
		} 
	}
	else
	{
		alert("Preencha o seu e-Mail");
		jQuery("input#email").focus();
		return false;
	}
	
	if (isBlank(theForm.assunto))
	{
		alert("Preencha o assunto");
		jQuery("input#assunto").focus(); 
		return false; 
	}
	
	if (isBlank(theForm.mensagem))
	{
		alert("Preencha a mensagem");
		jQuery("textarea#mensagem").focus(); 
		return false; 
	}
	
	var nome = escape( theForm.nome.value );
	var email = escape( theForm.email.value );
	var assunto = escape( theForm.assunto.value );
	var mensagem = escape( theForm.mensagem.value );
	
	var parametros = '?nome='+nome+'&email='+email+
					 '&assunto='+assunto+'&mensagem='+mensagem;
	
	chamarAjax( 'target', '../../__user/contato/script_entrar_contato.php', parametros, true );
}

// DATA: 	17-12-2009
// EMAIL: 	alfredo@ecliente.com.br
function checkPerfil( theForm ){
	theForm = document.getElementById( theForm );
	
	if (isBlank(theForm.nome))
	{
		alert("Preencha seu nomeee");
		jQuery("input#nome").focus(); 
		return false; 
	}

	var sexo;
	if ( theForm.sexoM.checked == 1 )
		sexo = 'M';
	else if ( theForm.sexoF.checked == 1 )
		sexo = 'F';
	else
	{
		alert("Selecione um sexo");
		theForm.sexoM.focus();
		return false; 
	}
	
	if(!isBlank(theForm.email)) 
	{
		if(!isMail(theForm.email)) 
		{
			alert("Formato de e-Mail incorreto");
      		jQuery("input#email").focus();
			return false;
		} 
	}
	else
	{
		alert("Preencha o seu e-Mail");
		jQuery("input#email").focus();
		return false;
	}
	
	if ( theForm.senha.value != theForm.checkSenha.value )
	{
		alert("Confirme sua senha novamente!");
		jQuery("input#senha").focus();
		return false;      
	}
	
	if (theForm.idListaEstados.value == 0)
	{
		alert("Selecione um Estado");
		jQuery("select#idListaEstados").focus();
		return false; 
	}	
	
	if (theForm.idListaCidades.value == 0)
	{
		alert("Selecione uma Cidade");
		jQuery("select#idListaCidades").focus();
		return false; 
	}
	
	if (isBlank(theForm.fone))
	{
		alert("Preencha seu telefone");
		jQuery("input#fone").focus(); 
		return false; 
	}
	
	// PREPARA STRING DE PARAMETROS
	var nome = escape( theForm.nome.value );
	var email = escape( theForm.email.value );
	var senha = escape( theForm.senha.value );
	var estado = escape( theForm.idListaEstados.value );
	var cidade = escape( theForm.idListaCidades.value );
	
	var fone = escape( theForm.fone.value );
	var celular = escape( theForm.celular.value );
	var cep = escape( theForm.icep.value );
	var bairro = escape( theForm.bairro.value );
	var endereco = escape( theForm.endereco.value );	
	var complemento = escape( theForm.complemento.value );
	var indicacao = escape( theForm.idIndicacao.value );
	
	
	var cep2 = escape( theForm.icep2.value );
	var bairro2 = escape( theForm.bairro2.value );
	var endereco2 = escape( theForm.endereco2.value );	
	var complemento2 = escape( theForm.complemento2.value );	
	var estado2 = escape( theForm.idListaEstados2.value );
	var cidade2 = escape( theForm.idListaCidades2.value );
	var outra_indica = escape( theForm.outra_indica.value );
	
	
	
	
	var parametros = '?nome=' + nome + '&sexo=' + sexo + '&email=' + email + 
					 '&senha=' + senha + '&estado=' + estado + '&cidade=' + cidade + 
					 '&fone=' + fone + '&celular=' + celular + '&cep=' + cep + 
					 '&bairro=' + bairro + '&endereco=' + endereco + '&complemento=' + complemento + 
					 '&indicacao=' + indicacao + '&resposta_ajax=1' +
					 '&cep2=' + cep2 + '&bairro2=' + bairro2 + '&endereco2=' + endereco2 +
					 '&complemento2=' + complemento2 + '&estado2=' + estado2 + '&cidade2=' + cidade2 + '&outra_indica='+outra_indica; 
					   
	chamarAjax( 'ajaxDadosPerfil', '../../__user/perfil/dados.php', parametros, false );
	chamarAjax( 'idBarraPerfil', '../../__user/perfil/script_barra_perfil.php', parametros, false );
}

// DATA: 	18-12-2009
// EMAIL: 	alfredo@ecliente.com.br
function checkCEP( theForm )
{
	// PREPARA VALOR DE CEP
	var cep = theForm.icep.value;
	cep = cep.replace("-","");
	cep = cep.replace(".","");

	// NO MÍNIMO 5 NÚMEROS	
	if ( cep.lenght <= 5 )
	{
		alert("Preencha seu cep ou clique para buscar!");
		jQuery("input#icep").focus(); 
		return false; 
	}
	
	// PREPARA STRING DE PARAMETROS
	cep = escape( cep );	
	
	var parametros = '?cep=' + cep + '&resposta_ajax=1'; 
		   
	chamarAjax( 'ajaxDadosPerfil', '../../__user/perfil/alterar.php', parametros, true );	
}

// DATA: 	18-12-2009
// EMAIL: 	alfredo@ecliente.com.br
function alterarFotoPerfil( theForm )
{
	theForm = document.getElementById( theForm );
	
	// PREPARA VALOR DE CEP
	var foto = theForm.idUpFoto.value;

	// NO MÍNIMO 5 NÚMEROS	
	if ( foto == "" )
	{
		alert("Escolha uma foto!");
		jQuery("input#idUpFoto").focus(); 
		return false; 
	}
	
	// PREPARA STRING DE PARAMETROS
	foto = escape( foto );	
	
	var parametros = '?foto=' + foto;
	
	chamarAjax( 'idDivFotoPerfil', '../../__user/perfil/script_alterar_foto.php', parametros, true );
}

// ESCONDE OU MOSTRA UMA DIV
function mudarVisibilidade( id, check ) 
{
	if ( check == "S" )
	{
		document.getElementById(id).style.visibility = 'visible';
		document.getElementById( "txt" + id ).focus();
	}
	else
		document.getElementById(id).style.visibility = 'hidden';
}

function checkEnterAlbum( key, posicao, id, extra )
{
	var keycode;	

	if (window.event) 
		keycode = window.event.keyCode;	

	if ( keycode == 13 || extra == "S" )
	{
		var descricao = document.getElementById( "txtidDescricao" + posicao ).value;
		var parametros = "?idFoto=" + id + 
						 "&descricao=" + descricao +
						 "&posicao=" + posicao;	
		var div = "idFoto" + posicao;		
		chamarAjax( div, '../../__user/perfil/script_alterar_descricao.php', parametros, false );
	}
}

// ATRASA O SCRIPT DE EXECUTAR EM MILISEGUNDOS
function sleep(milliseconds) {
  var start = new Date().getTime();
  for (var i = 0; i < 1e7; i++) {
    if ((new Date().getTime() - start) > milliseconds){
      break;
    }
  }
}

// FAZ COM QUE O FOCO DA PÁGINA VÁ PARA O ELEMENTO ATRAVÉS DO ID
function ScrollToElement(theElement)
{	
	theElement = document.getElementById(theElement);	
	
	var selectedPosX = 0;
	var selectedPosY = 0;
	
	while(theElement != null)
	{
		selectedPosX += theElement.offsetLeft;
		selectedPosY += theElement.offsetTop;
		theElement = theElement.offsetParent;
	}
		  
	window.scrollTo(selectedPosX,selectedPosY);
}

// HABILITA BOTAO - PASSAR REFERENCIA DO FORM, NAME DO BOTÃO SUBMIT, TRUE OU FALSE
function abilitaBotao( theForm, theElement, status )
{	
	theElement = theForm.elements[theElement];
	
	if( status )
		theElement.disabled = 0;
	else 
		theElement.disabled = 1;	
}



// DATA: 	05-01-2010
// EMAIL: 	alfredo@ecliente.com.br
function checkTurma( theForm )
{	
	theForm = document.getElementById( theForm );
	
    var today = new Date();
    var datenow = today.getFullYear();

	if (isBlank(theForm.instituicao))
	{
		alert("Preencha o nome de sua instituição");
		jQuery("input#instituicao").focus(); 
		return false; 
	}
	
	if (isBlank(theForm.curso))
	{
		alert("Preencha o nome de seu curso");
		jQuery("input#curso").focus(); 
		return false; 
	}
	
	if (isBlank(theForm.ingresso))
	{
		alert("Preencha o ano de ingresso da sua turma");
		jQuery("input#ingresso").focus(); 
		return false; 
	}else if(theForm.ingresso.value > datenow){
		alert("O ano de ingresso da sua turma não pode ser maior que " + datenow);
		jQuery("input#ingresso").focus(); 
		return false; 
	}
	
	
	if (isBlank(theForm.regresso_mes))
	{
		alert("Preencha o mês de Conclusão da sua turma");
		jQuery("input#regresso_mes").focus(); 
		return false; 
	}else if(theForm.regresso_mes.value < 0 || theForm.regresso_mes.value > 12){
		alert("Preencha corretamente o mês de Conclusão da sua turma");
		jQuery("input#regresso_mes").focus(); 
		return false; 
	}

	if (isBlank(theForm.regresso_ano))
	{
		alert("Preencha o ano de Conclusão da sua turma");
		jQuery("input#regresso_ano").focus(); 
		return false; 
	}else if(theForm.regresso_ano.value < datenow ){
		alert("Preencha corretamente o ano de Conclusão da sua turma");
		jQuery("input#regresso_ano").focus(); 
		return false; 
	}
	
	if(theForm.ingresso.value > theForm.regresso_ano.value){
		alert("O ano de Conclusão não pode ser menor que o ano de ingresso da sua turma");
		jQuery("input#regresso_ano").focus(); 
		return false; 
	}	

	
	if (theForm.listEstados.value == 0)
	{
		alert("Selecione um Estado");
		jQuery("select#listEstados").focus();
		return false; 
	}	
	
	if (theForm.listCidades.value == 0)
	{
		alert("Selecione uma Cidade");
		jQuery("select#listCidades").focus();
		return false; 
	}
	
	
	// PREPARA STRING DE PARAMETROS
	var instituicao  = escape( theForm.instituicao.value );
	var curso        = escape( theForm.curso.value );
	var estado       = escape( theForm.listEstados.value );
	var cidade       = escape( theForm.listCidades.value );
	var ingresso     = escape( theForm.ingresso.value );
	var regresso_mes = escape( theForm.regresso_mes.value );
	var regresso_ano = escape( theForm.regresso_ano.value );
	
	//var valor = escape( theForm.valor.value );	
	
	var parametros = '?instituicao=' + instituicao + '&curso=' + curso + 
					 '&estado=' + estado + '&cidade=' + cidade + 
					 '&ingresso=' + ingresso + '&regresso_mes=' + regresso_mes + '&regresso_ano=' + regresso_ano + 
					 '&resposta_ajax=1'; //'&valor=' + valor + 
			   
	chamarAjax( 'ajaxDadosTurma', '../../__user/classe/info_turma.php', parametros, false );
}

function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
}

function checkEnterClasse( key, pagina, extra )
{
	var keycode;	

	if (window.event) 
		keycode = window.event.keyCode;	

	if ( keycode == 13 || extra == "S" )
	{
		// ITENS POR PÁGINA
		var pag_views = document.getElementById( "idTxtPageViews" ).value;		
		
		// VERIFICA SE EXIBE ALUNOS DESATIVADOS!
		var alunoDT = document.getElementById( "idAlunoDesativadoT" ).checked;
		var alunoDF = document.getElementById( "idAlunoDesativadoF" ).checked;
		if ( alunoDT == 1 )
			alunosD = 'T';
		else if ( alunoDF == 1 )
			alunosD = 'F';					
		
		// FILTRO POR SEXO
		var sexo = "";
		var sexoT = document.getElementById( "idSexoT" ).checked;
		var sexoM = document.getElementById( "idSexoM" ).checked;
		var sexoF = document.getElementById( "idSexoF" ).checked;
		if ( sexoT == 1 )
			sexo = 'T';
		else if ( sexoM == 1 )
			sexo = 'M';
		else if ( sexoF == 1 )
			sexo = 'F';
		
		var parametros = "?resposta_ajax=1" + "&pag_views=" + pag_views + "&pagina=" + pagina + 
						 "&alunosD=" + alunosD + "&sexo=" + sexo;	

		chamarAjax( 'ajaxDadosClasse', '../../__user/classe/info_classe.php', parametros, true );
	}
	
	
}

function confirmar( msg, funcao )
{
	funcao = urldecode(funcao);
	
	if ( confirm( msg ) )
		executar( funcao );
	else
		return false;
}

function executar( funcao )
{
	var Emular = document.createElement('script');
	Emular.setAttribute('language','Javascript');
	Emular.text = funcao;
	document.body.appendChild( Emular );
}

function urlencode(str) {
return escape(str).replace('+', '%2B').replace('%20', '+').replace('*', '%2A').replace('/', '%2F').replace('@', '%40');
}

function urldecode(str) {
return unescape(str.replace(/\053/g, ' '));
}



// DATA: 	11-01-2010
// EMAIL: 	alfredo@ecliente.com.br
function checkClasseCadastrarAluno( theForm )
{
	theForm = document.getElementById( theForm );
		
	if (isBlank(theForm.nome))
	{
		alert("Preencha o nome do aluno");
		jQuery("input#nome").focus(); 
		return false; 
	}
	
	if(!isBlank(theForm.email)) 
	{
		if(!isMail(theForm.email)) 
		{
			alert("Formato de e-Mail incorreto");
      		jQuery("input#email").focus();
			return false;
		} 
	}
	else
	{
		alert("Preencha o e-Mail do aluno");
		jQuery("input#email").focus();
		return false;
	}
	
	if ( isBlank( theForm.idTextoCadastro ) )
	{
		alert("Preencha um texto");
		jQuery("textarea#idTextoCadastro").focus(); 
		return false; 
	}
	
	var nome = escape( theForm.nome.value );
	var email = escape( theForm.email.value );
	var texto = escape( theForm.idTextoCadastro.value );
	
	var parametros = "?resposta_ajax=1" + "&nome=" + nome + "&email=" + email +
					 "&texto=" + texto;
	
	chamarAjax( 'ajaxCadastro', '../../__user/classe/cadastrar.php', parametros, false );
}

// DATA: 	05-05-2010
// EMAIL: 	eric@ecliente.com.br
function checkClasseCadastrarAlunoMaster( theForm )
{
	theForm = document.getElementById( theForm );

    var sexo;
	if ( theForm.sexoM.checked == 1 )
		sexo = 'M';
	else if ( theForm.sexoF.checked == 1 )
		sexo = 'F';
	else{
		alert("Selecione um sexo");
		theForm.sexoM.focus();
		return false; 
	}
	
	
	if (isBlank(theForm.nome)){
		alert("Preencha seu nome");
		jQuery("input#nome").focus(); 
		return false; 
	}

	if(!isBlank(theForm.email)) {
		if(!isMail(theForm.email)){
			alert("Formato de e-Mail incorreto");
      		jQuery("input#email").focus();
			return false;
		} 
	}else{
		alert("Preencha o seu e-Mail");
		jQuery("input#email").focus();
		return false;
	}
	
	if(theForm.nivel_ensino.value!='s' && theForm.nivel_ensino.value!=''){

	  // verifica se foi digitado o cpf, caso tenha, não é obrigatório, se for inserido valida o cadastro
	  if (!isBlank(theForm.cic)){
	    var checkCpfCnpjCedente = false;
	    if ( ValidarCPF2( theForm.cic ) )
		  checkCpfCnpjCedente = true;
 	    else{
		  alert('Por favor verifique o formato do CPF');
		  jQuery("input#cic").focus(); 
		  return false; 
	    }			
      }	

	  if (isBlank(theForm.nome_Resp)) {
		alert("Preencha o nome do Responsável");
		jQuery("input#nome_Resp").focus(); 
		return false; 
	  }
	  
	  if(!isBlank(theForm.email_Resp)) {
		if(!isMail(theForm.email_Resp)) {
			alert("Formato de e-Mail incorreto do Responsável");
      		jQuery("input#email_Resp").focus();
			return false;
		} 
	  }	  
	  
	  if (isBlank(theForm.rg_Resp)){
		alert("Preencha o RG do Responsável");
		jQuery("input#rg_Resp").focus(); 
		return false; 
	  }
	  	  
		
	  // curso médio e fundamental, precisa dos dados do responsável.
	  if (isBlank(theForm.cic_Resp)){
		alert("Preencha o número do CPF do Responsável");
		jQuery("input#cic_Resp").focus(); 
		return false; 
	  }else{
		var checkCpfCnpjCedente = false;
		if ( ValidarCPF2( theForm.cic_Resp ) )
			checkCpfCnpjCedente = true;
		else{
			alert('Por favor verifique o formato do CPF do Responsável');
			jQuery("input#cic_Resp").focus(); 
			return false; 
		}			
	  }	
	  
	  if (isBlank(theForm.fone_Resp)){
		alert("Preencha o telefone do Responsável");
		jQuery("input#fone_Resp").focus(); 
		return false; 
	  }	  

	}else{
	  // curso superior, precisa do rg e cpf do aluno	
      if (isBlank(theForm.rg)){
	    alert("Preencha o RG");
	    jQuery("input#rg").focus(); 
	    return false; 
      }		  
	  
      if (isBlank(theForm.cic)){
	    alert("Preencha o número do CPF");
	    jQuery("input#cic").focus(); 
	    return false; 
      }else{
	    var checkCpfCnpjCedente = false;
	    if ( ValidarCPF2( theForm.cic ) )
		  checkCpfCnpjCedente = true;
 	    else{
		  alert('Por favor verifique o formato do CPF');
		  jQuery("input#cic").focus(); 
		  return false; 
	    }			
      }	
	}	
	
	
	if (theForm.listEstados1.value == 0){
		alert("Selecione um Estado");
		jQuery("select#listEstados1").focus();
		return false; 
	}	
	
	if (theForm.listCidades1.value == 0){
		alert("Selecione uma Cidade");
		jQuery("select#listCidades1").focus();
		return false; 
	}
	
	if (isBlank(theForm.telefoneU)){
		alert("Preencha seu telefone");
		jQuery("input#telefoneU").focus(); 
		return false; 
	}
	// PREPARA STRING DE PARAMETROS
	var nome         = escape( theForm.nome.value );
	var email        = escape( theForm.email.value );
	var estado       = escape( theForm.listEstados1.value );
	var cidade       = escape( theForm.listCidades1.value );
	var telefoneU    = escape( theForm.telefoneU.value );
	var celular      = escape( theForm.celular.value );
	
	var cep_us       = escape( theForm.cep_us.value );
	var comi         = escape( theForm.comi.value );
	var bairroU      = escape( theForm.bairroU.value );
	var enderecoU    = escape( theForm.enderecoU.value );	
	var complemento  = escape( theForm.complemento.value );
	var cic          = escape( theForm.cic.value );	
	var rg           = escape( theForm.rg.value );
	var cep2         = escape( theForm.icep2.value );
	var bairro2      = escape( theForm.bairro2.value );
	var endereco2    = escape( theForm.endereco2.value );	
	var complemento2 = escape( theForm.complemento2.value );	
	var estado2      = escape( theForm.idListaEstados2.value );
	var cidade2      = escape( theForm.idListaCidades2.value );
	if(theForm.op.value=='INC')
	  var senha        = escape( theForm.senha.value );

    var codcurso     = escape( theForm.codcurso.value );
	var dt_cadastro  = escape( theForm.dtCadastro.value );
	var status       = escape( theForm.status.value );
	var navegador    = escape( theForm.navegador.value );
	// verifica o nível de ensino para validar os campos diferentes
	if(theForm.nivel_ensino.value!='s' && theForm.nivel_ensino.value!=''){
	  var cic_Resp   = escape( theForm.cic_Resp.value );	
	  var rg_Resp    = escape( theForm.rg_Resp.value );
	  var nome_Resp  = escape( theForm.nome_Resp.value );
	  var email_Resp = escape( theForm.email_Resp.value );
	  var fone_Resp  = escape( theForm.fone_Resp.value );
	  var cel_Resp   = escape( theForm.cel_Resp.value );
	}else{
	  var cic_Resp   = "";	
	  var rg_Resp    = "";
	  var nome_Resp  = "";
	  var email_Resp = "";
	  var fone_Resp  = "";
	  var cel_Resp   = "";
	}

	/*
	VARIAL VE DE CONTROLE DO SISTEMA
	*/
    var tabela   = escape( theForm.tabela.value ); // nome da tabela
    var chv      = escape( theForm.chv.value ); // campo que é chave da tabela
    var chvin    = escape( theForm.chvin.value ); // valor da chave
    var op       = escape( theForm.op.value ); // operação que está sendo executada, inclusão / alteração
    var naograva = escape( theForm.naograva.value ); // campos que não é para ser gravado no banco
	var parametros = '?nome=' + nome + '&sexo=' + sexo + '&email=' + email + 
					 '&estado=' + estado + '&cidade=' + cidade + 
					 '&telefone_us=' + telefoneU + '&celular=' + celular + '&cep=' + cep_us + '&comi=' + comi +
					 '&bairro_us=' + bairroU + '&endereco_us=' + enderecoU + '&complemento=' + complemento + 
					 '&cep2=' + cep2 + '&bairro2=' + bairro2 + '&endereco2=' + endereco2 +
					 '&complemento2=' + complemento2 + '&estado2=' + estado2 + '&cidade2=' + cidade2 + 
					 '&nome_Resp=' + nome_Resp +'&email_Resp=' + email_Resp +'&cic_Resp=' + cic_Resp + '&rg_Resp=' + rg_Resp +
					 '&fone_Resp=' + fone_Resp +'&cel_Resp=' + cel_Resp  +'&cic=' + cic +'&rg=' + rg +
					 '&codcurso=' + codcurso  +'&dt_cadastro=' + dt_cadastro +'&status=' + status +
					 '&navegador=' + navegador +
					 
					 '&tabela=' + tabela +'&chv=' + chv +'&op=' + op +'&naograva=' + naograva + '&chvin=' + chvin +
					 '&resposta_ajax=1';
					 
    if(theForm.op.value=='INC')
      parametros+= '&senha=' + senha;
	
	chamarAjax( 'ajaxCadastro', '../../__user/cadastro_aluno/cadastro_aluno_master.php', parametros, false );
}


function ativarFiltroCobrancas( key, pagina, extra )
{
	var keycode;	

	if (window.event) 
		keycode = window.event.keyCode;	

	if ( keycode == 13 || extra == "S" )
	{
		// ITENS POR PÁGINA
		var pag_views = document.getElementById( "idTxtPageViewsCob" ).value;		
		
		// FILTRO!
		var emAberto = document.getElementById( "idEmAberto" ).checked;	
		var todas = document.getElementById( "idTodas" ).checked;		
		var vencidas = document.getElementById( "idVencidas" ).checked;
		var aPagar = document.getElementById( "idAPagar" ).checked;
		var pagas = document.getElementById( "idPagas" ).checked;
		
		if ( emAberto == 1 )
			filtro = "emAberto";
		else if ( todas == 1 )
			filtro = "todas";
		else if ( vencidas == 1 )
			filtro = "vencidas";
		else if ( aPagar == 1 )
			filtro = "aPagar";
		else if ( pagas == 1 )
			filtro = "pagas";
			
		var parametros = "?resposta_ajax=1" + "&pag_views=" + pag_views + "&pagina=" + pagina + "&filtroCob=" + filtro;
	
		chamarAjax( 'ajaxCobrancas', '../../__user/classe/info_cobrancas.php', parametros, true );
	}	
}

// DATA: 	14-01-2010
// EMAIL: 	alfredo@ecliente.com.br
function checkClasseConvidarAluno( theForm )
{
	var emails_novos = "";
	theForm = document.getElementById( theForm );	
		
	if(!isBlank(theForm.emails)) 
	{
		var emails = theForm.emails.value;
		var emails = emails.split( "," );
	
		for (var i = 0; i < emails.length; i++)
		{			
			var email = trim( emails[i] )
			
			if( !isMail2( email ) )
			{
				var num = i + 1;
				alert("O " + num + "º email está com formato incorreto:" + email );
				jQuery("input#emails").focus();
				return false;
			} 

			if ( ( i + 1 ) < emails.length )
				emails_novos += email + ",";
			else	
				emails_novos += email;			
		}
	}
	else
	{
		alert("Preencha algum e-Mail para enviar o convite!");
		jQuery("input#emails").focus();
		return false;
	}
	
	if ( isBlank( theForm.idTextoConvite ) )
	{
		alert("Preencha um texto");
		jQuery("textarea#idTextoConvite").focus(); 
		return false; 
	}		

	var emails_novos = escape( emails_novos );
	var texto = escape( theForm.idTextoConvite.value );
	
	var parametros = "?resposta_ajax=1" + "&emails=" + emails_novos + "&texto=" + texto;
	
	chamarAjax( 'ajaxConvidar', '../../__user/classe/convidar.php', parametros, false );
}

//trim completo
function trim(str) {
return str.replace(/^\s+|\s+$/g,"");
}

// DATA: 	18-01-2010
// EMAIL: 	alfredo@ecliente.com.br
function checkClasseVisualizarCobranca( theForm )
{	
	theForm = document.getElementById( theForm );	
	
	if (isBlank(theForm.sel3))
	{
		alert("Preencha a data");
		jQuery("input#sel3").focus(); 
		return false; 
	}

	if (isBlank(theForm.idValor))
	{
		alert("Preencha um valor");
		jQuery("input#idValor").focus(); 
		return false; 
	}
	
	if ( theForm.idReceita.value == 0 )
	{
		alert("Selecione uma receita");
		jQuery("select#idReceita").focus();
		return false; 
	}	

	if ( theForm.idReceita.value == 'Outra' && isBlank(theForm.nova_categoria) )
	{
		alert("Preencha a Descrição da Nova Receita");
		jQuery("select#nova_categoria").focus();
		return false; 
	}	

	
	if (theForm.idAluno.value == 0)
	{
		alert("Selecione um aluno");
		jQuery("select#idAluno").focus();
		return false; 
	}	
	
	// PREPARA STRING DE PARAMETROS
	var dtPag          = escape( theForm.sel3.value );
	var valor          = escape( theForm.idValor.value );	
	var receita        = escape( theForm.idReceita.value );	
	var aluno          = escape( theForm.idAluno.value );	
	var voltar         = escape( theForm.idVoltar.value );		
	var id             = escape( theForm.idCobranca.value );
	var nova_categoria = escape (theForm.nova_categoria.value);
	
	if ( theForm.nmStatu.checked )
		var statu = "&statu=F";
	else	
		var statu = "&statu=A";
	
	if ( theForm.nmBoleto.checked || theForm.nmBoleto.value == '1'  )
		var boleto = "&boleto=1";
	else	
		var boleto = "&boleto=0";
		
	var parametros = '?dtPag=' + dtPag + '&valor=' + valor + '&receita=' + receita + 
					 '&aluno=' + aluno + '&id=' + id + '&resposta_ajax=1' + statu +
					 '&voltar=' + voltar + '&boleto=' + boleto + '&nova_categoria=' + nova_categoria + '&resposta_ajax=1'; 
	
	chamarAjax( 'ajaxDadosCobranca', '../../__user/classe/script_alterar_cobranca.php', parametros, false );
}

/* ENQUETES */
function ativarFiltroEnquete( key, pagina, extra )
{
	var keycode;	

	if (window.event) 
		keycode = window.event.keyCode;	

	if ( keycode == 13 || extra == "S" )
	{
		// ITENS POR PÁGINA
		var pag_views = document.getElementById( "idTxtPageViews" ).value;	 
		
		// DATA INICIAL
		var dataInicial = document.getElementById( "idTxtPeriodo" ).value;	    		
		
		// FILTRO!
		var ativas = document.getElementById( "idAtivas" ).checked;	
		var todas = document.getElementById( "idTodas" ).checked;		
		var encerradas = document.getElementById( "idEncerradas" ).checked;
		
		if ( ativas == 1 )
			filtro = "ativas";
		else if ( todas == 1 )
			filtro = "todas";
		else if ( encerradas == 1 )
			filtro = "encerradas";
						
		var parametros = "?resposta_ajax=1" + "&pag_views=" + pag_views + 
						 "&pagina=" + pagina + "&filtro=" + filtro + "&dataInicial=" + dataInicial;

		chamarAjax( 'ajaxEnquete', '../../__user/enquete/info_enquete.php', parametros, true );
	}	
}

// DATA: 	18-01-2010
// EMAIL: 	alfredo@ecliente.com.br
function checkEnqueteVisualizarEnquete( theForm )
{
	theForm = document.getElementById( theForm );	
	
	if (isBlank(theForm.idPergunta))
	{
		alert("Preencha uma pergunta");
		jQuery("input#idPergunta").focus(); 
		return false; 
	}

	if (isBlank(theForm.idDataFim))
	{
		alert("Preencha uma data para encerrar a enquete");
		jQuery("input#idDataFim").focus(); 
		return false; 
	}
	
	if ( ( isBlank( theForm.idAlternativa1 ) ) || ( isBlank( theForm.idAlternativa2 ) ) )
	{
		alert("Preencha a primeira e segunda alternativa no mínimo!");
		
		if (isBlank(theForm.idAlternativa1))
			jQuery("input#idAlternativa1").focus();
		else if (isBlank(theForm.idAlternativa2))
			jQuery("input#idAlternativa2").focus();	
			
		return false; 
	}	
	
	// PREPARA STRING DE PARAMETROS
	var pergunta = escape( theForm.idPergunta.value );
	var datafim = escape( theForm.idDataFim.value );
	var id = escape( theForm.idEnquete.value );
	
	var parametros = '?pergunta=' + pergunta + '&datafim=' + datafim + '&id=' + id + '&resposta_ajax=1'; 
	
	var alternativa1 = escape( theForm.idAlternativa1.value );	
	var alternativa2 = escape( theForm.idAlternativa2.value );	
	var alternativa3 = escape( theForm.idAlternativa3.value );	
	var alternativa4 = escape( theForm.idAlternativa4.value );	
	var alternativa5 = escape( theForm.idAlternativa5.value );

	parametros += "&alternativa1=" + alternativa1 + "&alternativa2=" + alternativa2 + 
				  "&alternativa3=" + alternativa3 + "&alternativa4=" + alternativa4 + 
				  "&alternativa5=" + alternativa5;
				  
	chamarAjax( 'ajaxDadosEnquete', '../../__user/enquete/script_alterar_enquete.php', parametros, true );
}

// DATA: 	18-01-2010
// EMAIL: 	alfredo@ecliente.com.br
function checkEnqueteCadastrarEnquete( theForm )
{
	theForm = document.getElementById( theForm );	
	
	if (isBlank(theForm.idPergunta))
	{
		alert("Preencha uma pergunta");
		jQuery("input#idPergunta").focus(); 
		return false; 
	}

	if (isBlank(theForm.idDataFim))
	{
		alert("Preencha uma data para encerrar a enquete");
		jQuery("input#idDataFim").focus(); 
		return false; 
	}	
	
	// PREPARA STRING DE PARAMETROS
	var pergunta = escape( theForm.idPergunta.value );
	var datafim = escape( theForm.idDataFim.value );
	var idEnqueteNova = theForm.idEnqueteNova.value;
	
	if( !compararData( datafim ) )
	{		
		alert('Data deve ser igual ou maior que hoje!');
		jQuery("input#idDataFim").focus(); 
		return false; 
	}
	
	var parametros = '?pergunta=' + pergunta + '&datafim=' + datafim + '&resposta_ajax=1';
	
	if ( idEnqueteNova )
		parametros += '&idEnqueteNova=' + idEnqueteNova;	
	else
		parametros += '&inserirPergunta=1'
		
	/*
	if ( theForm.nmStatus.checked )
		parametros += "&status=1";
	else	
		parametros += "&status=0";
	*/	
	chamarAjax( 'ajaxCadastrarEnquete', '../../__user/enquete/cadastrar_enquete.php', parametros, false );
	chamarAjax( 'ajax_Menu_Enquete', '../../__user/enquete/menu_principal.php', '?resposta_ajax=1', false );
}

// DATA: 	18-01-2010
// EMAIL: 	alfredo@ecliente.com.br
function checkVotarEnquete( theForm )
{
	theForm = document.getElementById( theForm );	
	
	var check = false;
	for ( var i = 0; i < theForm.enquete.length; i++) 
	{ 
		if ( theForm.enquete[i].checked ) 
		{ 
			var codAlt = theForm.enquete[i].value; 
			var check = true;
		} 
	}
	
	if ( check == false )
	{
		alert('Por favor selecione alguma alternativa!');
		jQuery("input#enviar").focus();	
		return false;
	}
	
	var parametros = '?resposta_ajax=1' + '&codAlt=' + codAlt + '&registrarVoto=1';	
	chamarAjax( 'ajax_Menu_Enquete', '../../__user/enquete/menu_principal.php', parametros, false );
}

// DATA: 	18-01-2010
// EMAIL: 	alfredo@ecliente.com.br
function checkEnqueteCadastrarAlternativa( theForm )
{
	theForm = document.getElementById( theForm );	
	
	if (isBlank(theForm.idAlternativa))
	{
		alert("Preencha a alternativa");
		jQuery("input#idAlternativa").focus(); 
		return false; 
	}	
	
	var alternativa = escape( theForm.idAlternativa.value );	
	var idPergunta = theForm.idPergunta.value 
	
	var parametros = '?resposta_ajax=1' + '&alternativa=' + alternativa + '&idPergunta=' + idPergunta;
		
	chamarAjax( 'ajaxCadastrarAlternativa', '../../__user/enquete/cadastrar_alternativa.php', parametros, false );
	chamarAjax( 'ajax_Menu_Enquete', '../../__user/enquete/menu_principal.php', '?resposta_ajax=1', false );
}

// DATA: 	27-01-2010
// EMAIL: 	alfredo@ecliente.com.br
function checkReceitaCadastrarCobranca( theForm )
{
	theForm = document.getElementById( theForm );	
	
	if (isBlank(theForm.sel3))
	{
		alert("Preencha a data");
		jQuery("input#sel3").focus(); 
		return false; 
	}

	if (isBlank(theForm.idValor))
	{
		alert("Preencha um valor");
		jQuery("input#idValor").focus(); 
		return false; 
	}
	
	if ( theForm.idReceita.value == 0 )
	{
		alert("Selecione uma receita");
		jQuery("select#idReceita").focus();
		return false; 
	}
	
	if ( theForm.idReceita.value == 'Outra' && isBlank(theForm.nova_categoria) )
	{
		alert("Preencha a Descrição da Nova Receita");
		jQuery("select#nova_categoria").focus();
		return false; 
	}	
	
	
	if (theForm.idAluno.value == 0)
	{
		alert("Selecione um aluno");
		jQuery("select#idAluno").focus();
		return false; 
	}
	
	// PREPARA STRING DE PARAMETROS
	var dtPag = escape( theForm.sel3.value );
	var valor = escape( theForm.idValor.value );	
	var receita = escape( theForm.idReceita.value );	
	var aluno = escape( theForm.idAluno.value );
	var nova_categoria = escape( theForm.nova_categoria.value );
	
	if ( theForm.nmBoleto.checked )
		var boleto = "&boleto=1";
	else	
		var boleto = "&boleto=0";
	
	var parametros = '?dtPag=' + dtPag + '&valor=' + valor + '&receita=' + receita + 
					 '&aluno=' + aluno + '&boleto=' + boleto + '&nova_categoria=' + nova_categoria + '&resposta_ajax=1';
	
	chamarAjax( 'ajaxCadastrarReceitas', '../../__user/receita/cobranca.php', parametros, false );
}

// protocolo 4357
function deletarReceita( id, tipo )
{
	if ( tipo == "aberta" )
	{
		var div = "ajaxReceitasAberto";
		var url = "../../__user/receita/receitasAberto.php";
	}
	else if ( tipo == "quitada" )
	{
		var div = "ajaxReceitasQuitadas";
		var url = "../../__user/receita/receitasQuitadas.php";
	}
	else if ( tipo == 'aluno' )
	{
		var div = "ajaxReceitasAluno";
		var url = "../../__user/classe/receitasAluno.php";
	}
	else if ( tipo == 'classe' )
	{
		var div = 'ajaxDadosCobranca';
		var url = "../../__user/receita/deletar.php";
		var retorno = "classe";
	}
	else if ( tipo == 'receita' )
	{
		var div = 'ajaxDadosCobranca';
		var url = "../../__user/receita/deletar.php";
		var retorno = "receita";
	}
	
	
	var parametros = "?deletar=1&retorno=" + retorno + "&id=" + id;
	
	chamarAjax( div, url, parametros, false );	
	chamarAjax( 'ajax_Menu_Financas', '../../__user/resumo_financeiro/script_menu_financas.php', '?resposta_ajax=1', false ); 
}

// DATA: 	27-01-2010
// EMAIL: 	alfredo@ecliente.com.br
function deletarDespesa( id, tipo )
{
	if ( tipo == "aberta" )
	{
		var div = "ajaxDespesasAberto";
		var url = "../../__user/despesa/script_abertas.php";
	}
	else if ( tipo == "quitada" )
	{
		var div = "ajaxDespesasQuitadas";
		var url = "../../__user/despesa/script_quitadas.php";
	}
	else if ( tipo == "classe" )
	{
		var div = "ajaxAlterarDespesas";
		var url = "../../__user/despesa/deletar.php";
	}
	
	
	var parametros = "?deletar=1&id=" + id;
	
	chamarAjax( div, url, parametros, false );	
	chamarAjax( 'ajax_Menu_Financas', '../../__user/resumo_financeiro/script_menu_financas.php', '?resposta_ajax=1', false ); 
}

// DATA: 	27-01-2010
// EMAIL: 	alfredo@ecliente.com.br
function checkDespesaCadastrarDespesa( theForm )
{
	theForm = document.getElementById( theForm );	
	
	if (isBlank(theForm.sel3))
	{
		alert("Preencha a data");
		jQuery("input#sel3").focus(); 
		return false; 
	}

	if (isBlank(theForm.idValor))
	{
		alert("Preencha um valor");
		jQuery("input#idValor").focus(); 
		return false; 
	}

	if ( theForm.idDespesa.value == 0 )
	{
		alert("Selecione uma despesa");
		jQuery("select#idDespesa").focus();
		return false; 
	}	
	
	if ( theForm.idDespesa.value == 'Outra' && isBlank(theForm.nova_categoria) )
	{
		alert("Preencha a Descrição da Nova Categoria");
		jQuery("select#nova_categoria").focus();
		return false; 
	}	
	
	var descricao = escape( theForm.idDescricao.value );
	
	if ( descricao == "" )
	{
		alert("Preencha uma descrição");
		jQuery("textarea#idDescricao").focus(); 
		return false; 
	}
	
	// PREPARA STRING DE PARAMETROS
	var vencimento = escape( theForm.sel3.value );
	var valor = theForm.idValor.value;	
	var despesa = escape( theForm.idDespesa.value );
	var descricao = escape( theForm.idDescricao.value );	
	var nova_categoria = escape( theForm.nova_categoria.value );	
	
	var parametros = '?vencimento=' + vencimento + '&valor=' + valor + '&despesa=' + despesa + 
					 '&nova_categoria=' + nova_categoria + '&descricao=' + descricao + '&resposta_ajax=1';
					 
	chamarAjax( 'ajaxCadastrarDespesas', '../../__user/despesa/script_cadastro.php', parametros, false );
}

// DATA: 	18-01-2010
// EMAIL: 	alfredo@ecliente.com.br
function checkDespesaAlterarDespesa( theForm )
{
	theForm = document.getElementById( theForm );	
	
	if (isBlank(theForm.sel3))
	{
		alert("Preencha a data");
		jQuery("input#sel3").focus(); 
		return false; 
	}

	if (isBlank(theForm.idValor))
	{
		alert("Preencha um valor");
		jQuery("input#idValor").focus(); 
		return false; 
	}	


	if ( theForm.idCatDespesa.value == '0' )
	{
		alert("Selecione uma categoria");
		jQuery("select#idDespesa").focus();
		return false; 
	}	


	if ( theForm.idCatDespesa.value == 'Outra' && isBlank(theForm.nova_categoria) )
	{
		alert("Preencha a Descrição da Nova Categoria");
		jQuery("select#nova_categoria").focus();
		return false; 
	}	
	
	
	var descricao = escape( theForm.idDescricao.value );
	
	if ( descricao == "" )
	{
		alert("Preencha uma descrição");
		jQuery("textarea#idDescricao").focus(); 
		return false; 
	}
	
	// PREPARA STRING DE PARAMETROS
	var id = escape( theForm.idDespesa.value );
	var vencimento = escape( theForm.sel3.value );
	var valor = theForm.idValor.value;	
	var categoria = escape( theForm.idCatDespesa.value );
	var descricao = escape( theForm.idDescricao.value );	
	var nova_categoria = escape( theForm.nova_categoria.value );	
	
	if ( theForm.nmStatu.checked )
		var statu = "&statu=F";
	else	
		var statu = "&statu=A";
		
	var parametros = '?id=' + id + '&vencimento=' + vencimento + '&valor=' + valor + 
					 '&categoria=' + categoria + '&nova_categoria='+ nova_categoria +'&descricao=' + descricao + statu + '&alterar=1';
	
	chamarAjax( 'ajaxAlterarDespesas', '../../__user/despesa/script_alterar.php', parametros, true );	
}

// DATA: 	18-01-2010
// EMAIL: 	alfredo@ecliente.com.br
function checkNoticiaCadastrarNoticia( theForm )
{
	theForm = document.getElementById( theForm );	
	
	if (isBlank(theForm.idTitulo))
	{
		alert("Preencha um título");
		jQuery("input#idTitulo").focus(); 
		return false; 
	}	
	
	if (isBlank(theForm.idDataIniDivulgacao))
	{
		alert("Preencha a data inicial");
		jQuery("input#idDataIniDivulgacao").focus(); 
		return false; 
	}
	
	if (isBlank(theForm.idDataFimDivulgacao))
	{
		alert("Preencha a data final");
		jQuery("input#idDataFimDivulgacao").focus(); 
		return false; 
	}
	
	if ( parseInt( theForm.idDataFimDivulgacao.value.split( "/" )[2].toString() + theForm.idDataFimDivulgacao.value.split( "/" )[1].toString() + theForm.idDataFimDivulgacao.value.split( "/" )[0].toString() ) < parseInt( theForm.idDataFimDivulgacao.value.split( "/" )[2].toString() + theForm.idDataFimDivulgacao.value.split( "/" )[1].toString() + theForm.idDataFimDivulgacao.value.split( "/" )[0].toString() ) )
	{
		alert('A Data final deve ser maior que a data inicial');
		jQuery("input#idDataFimDivulgacao").focus(); 
		return false; 
	}		
		
	if ( conteudo == "" )
	{
		alert("Preencha uma descrição");
		var oFCKeditor=FCKeditorAPI.GetInstance('conteudo') ;
		oFCKeditor.Focus();
		return false; 
	}
	
	// PREPARA STRING DE PARAMETROS
	var idNoticiaNova = escape( theForm.idNoticiaNova.value );
	var titulo = escape( theForm.idTitulo.value );
	var datainidivulgacao = escape( theForm.idDataIniDivulgacao.value );
	var datafimdivulgacao = escape( theForm.idDataFimDivulgacao.value );
	var conteudo = escape( theForm.conteudo.value );	
	
	/*
	if ( theForm.nmStatus.checked )
		var ativa = "&ativa=1";
	else	
		var ativa = "&ativa=0";
	*/	
	if ( idNoticiaNova )
		var modo = '&idNoticiaNova=' + idNoticiaNova;	
	else
		var modo = '&inserirNoticia=1'
		
	var parametros = '?resposta_ajax=1' + '&idNoticiaNova=' + idNoticiaNova + '&titulo=' + titulo + 
				     '&datainidivulgacao=' + datainidivulgacao + '&datafimdivulgacao=' + datafimdivulgacao + 
					 '&conteudo=' + conteudo + modo; //ativa + 
		
	if ( idNoticiaNova )
		var div = "ajaxDadosNoticia";
	else
		var div = "ajaxCadastrarNoticia";
	
	chamarAjax( div, '../../__user/noticia/cadastrar.php', parametros, false );	
}

// DATA: 	01-02-2010
// EMAIL: 	alfredo@ecliente.com.br
function deletarEnquete( id )
{	
	var parametros = "?deletar=1&id=" + id;	
	//alert(parametros);
	//chamarAjax( 'ajaxEnquete', '../../__user/enquete/info_enquete.php', parametros, false ); 
	chamarAjax( 'ajaxCadastrarEnquete', '../../__user/enquete/deletar.php', parametros, false ); 
}

// DATA: 	01-02-2010
// EMAIL: 	alfredo@ecliente.com.br
function deletarNoticia( id )
{	
	var parametros = "?deletar=1&id=" + id;	
	chamarAjax( 'ajaxDadosNoticia', '../../__user/noticia/info_noticia.php', parametros, false ); 
}

function Verifica() 
{
	rest	= limite - document.getElementById("texto").value.length;
	
	if( ( rest + 1 ) > 0) 
	{
		//rest	= limite - document.getElementById("texto").value.length;
		antes 	= document.getElementById("texto").value;
		
		document.getElementById("falta").innerHTML = rest;
		
		// HABILITA BOTÃO SUBMIT
		document.getElementById("enviar").disabled = false;		
	} 
	else
		document.getElementById("texto").innerHTML = antes;
}

// DATA: 	18-01-2010
// EMAIL: 	alfredo@ecliente.com.br
function checkMuralCadastrarRecado( theForm )
{
	theForm = document.getElementById( theForm );	
	
	if ( isBlank( theForm.texto ) )
	{
		alert("Preencha um texto");
		jQuery("textarea#texto").focus(); 
		return false; 
	}		
	
	var texto = escape( theForm.texto.value );
	var idTipo = escape( theForm.idTipo.value );
	
	var parametros = '?inserir=1' + '&texto=' + texto;
	if ( idTipo == 'principal' )
		chamarAjax( 'ajaxMural', '../../__user/principal/mural.php', parametros, false );	
	else
		chamarAjax( 'ajaxMural', '../../__user/mural/info_mural.php', parametros, false );	
}

// DATA: 	01-02-2010
// EMAIL: 	alfredo@ecliente.com.br
function deletarRecado( id, tipo )
{	
	var parametros = "?deletar=1&id=" + id;
	if ( tipo == 'principal' )
		chamarAjax( 'ajaxMural', '../../__user/principal/mural.php', parametros, false );	
	else
		chamarAjax( 'ajaxMural', '../../__user/mural/info_mural.php', parametros, false );	
}

function gerarListaCidades(valor) {
  //verifica se o browser tem suporte a ajax
  try {
	 ajax = new ActiveXObject("Microsoft.XMLHTTP");
  } 
  catch(e) {
	 try {
		ajax = new ActiveXObject("Msxml2.XMLHTTP");
	 }
	 catch(ex) {
		try {
		   ajax = new XMLHttpRequest();
		}
		catch(exc) {
		   alert("Esse browser não tem recursos para uso do Ajax");
		   ajax = null;
		}
	 }
  }
  //se tiver suporte ajax
  if(ajax) {
	 //deixa apenas o elemento 1 no option, os outros são excluídos
	 var cidades = document.getElementById( 'idListaCidades' );	
	 cidades.options.length = 1;
	 
	 idOpcao  = document.getElementById("opcoes");
	 
	 ajax.open("POST", "../../__user/comum/cidades.php", true);
	 ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	 
	 ajax.onreadystatechange = function() {
		//enquanto estiver processando...emite a msg de carregando
		if(ajax.readyState == 1) {
		   idOpcao.innerHTML = "Carregando...!";   
		}
		//após ser processado - chama função processXML que vai varrer os dados
		if(ajax.readyState == 4 ) {
		   if(ajax.responseXML) {
			  processXMLCidades(ajax.responseXML);
		   }
		   else {
			   //caso não seja um arquivo XML emite a mensagem abaixo
			   idOpcao.innerHTML = "--Primeiro selecione o estado--";
		   }
		}
	 }
	 //passa o código do estado escolhido
	 var params = "estado="+valor;
	 ajax.send(params);
  }
}

function processXMLCidades(obj){
	var cidades = document.getElementById( 'idListaCidades' );	
  //pega a tag cidade
  var dataArray   = obj.getElementsByTagName("cidade");
  
  //total de elementos contidos na tag cidade
  if(dataArray.length > 0) {
	 //percorre o arquivo XML paara extrair os dados
	 for(var i = 0 ; i < dataArray.length ; i++) {
		var item = dataArray[i];
		//contéudo dos campos no arquivo XML
		var codigo    =  item.getElementsByTagName("codigo")[0].firstChild.nodeValue;
		var descricao =  item.getElementsByTagName("descricao")[0].firstChild.nodeValue;
		
		idOpcao.innerHTML = "--Selecione uma das op&ccedil;&otilde;es abaixo--";
		
		//cria um novo option dinamicamente  
		var novo = document.createElement("option");
			//atribui um ID a esse elemento
			novo.setAttribute("id", "opcoes");
			//atribui um valor
			novo.value = codigo;
			//atribui um texto
			novo.text  = descricao;
			//finalmente adiciona o novo elemento
			cidades.options.add(novo);
	 }
  }
  else {
	//caso o XML volte vazio, printa a mensagem abaixo
	idOpcao.innerHTML = "--Primeiro selecione o estado--";
  }	  
}

// DATA: 	01-02-2010
// EMAIL: 	alfredo@ecliente.com.br
function checkMasterCadastrar( theForm )
{
	theForm = document.getElementById( theForm );	
	
	if (theForm.idAlunos.value == 0)
	{
		alert("Selecione um aluno");
		jQuery("select#idAlunos").focus();
		return false; 
	}	

	if (theForm.idTurma.value == 0)
	{
		alert("Selecione uma turma");
		jQuery("select#idTurma").focus();
		return false; 
	}	
	
	var codturma = escape( theForm.idTurma.value );
	var idcadastro = escape( theForm.idAlunos.value );
	
	var parametros = '?inserir=1' + '&codturma=' + codturma + '&idcadastro=' + idcadastro;

	chamarAjax( 'ajaxMasterInc', '../../__user/master/cadastrar.php', parametros, false );	
}

// DATA: 	01-02-2010
// EMAIL: 	alfredo@ecliente.com.br
function alterarSessaoTurma( turma )
{		
	if ( turma != 0 )
	{
		var parametros = '?resposta_ajax=1' + '&turma=' + turma;
		chamarAjax( 'ajaxMaster', '../../__user/master/gerenciar_turmas.php', parametros, false );	
		chamarAjax( 'ajax_Menu_Financas', '../../__user/resumo_financeiro/script_menu_financas.php', '?resposta_ajax=1', false );
		chamarAjax( 'ajax_Menu_Enquete', '../../__user/enquete/menu_principal.php', '?resposta_ajax=1', false );
		chamarAjax( 'ajaxCbUserMaster', '../../__user/master/alterarCbUser.php', '?resposta_ajax=1', false );	
	}
}

// DATA: 	01-02-2010
// EMAIL: 	alfredo@ecliente.com.br
function checkAlterarContaBancaria( theForm )
{
	theForm = document.getElementById( theForm );	
	
	if (isBlank(theForm.idCedente))
	{
		alert("Preencha o nome do cedente");
		jQuery("input#idCedente").focus(); 
		return false; 
	}
	
	if (isBlank(theForm.idCpfCnpjCedente))
	{
		alert("Preencha o número do CPF e CNPJ");
		jQuery("input#idCpfCnpjCedente").focus(); 
		return false; 
	}
	else
	{
		var checkCpfCnpjCedente = false;
		if ( ValidarCPF2( theForm.idCpfCnpjCedente ) )
			checkCpfCnpjCedente = true;
		else if ( ValidarCNPJ2( theForm.idCpfCnpjCedente ) )
			checkCpfCnpjCedente = true;
		else
		{
			alert('Por favor verifique o formato de seu CPF/CNPJ');
			jQuery("input#idCpfCnpjCedente").focus(); 
			return false; 
		}			
	}
	
	/*
	if (isBlank(theForm.idEndereco))
	{
		alert("Preencha o endereço do cedente");
		jQuery("input#idEndereco").focus(); 
		return false; 
	}
	*/
	
	if (theForm.idListaBanco.value == 0)
	{
		alert("Selecione um banco");
		jQuery("select#idListaBanco").focus();
		return false; 
	}
	
	if (isBlank(theForm.idAgencia))
	{
		alert("Preencha o campo agência");
		jQuery("input#idAgencia").focus(); 
		return false; 
	}
	
	if (isBlank(theForm.idConta))
	{
		alert("Preencha o campo conta");
		jQuery("input#idConta").focus(); 
		return false; 
	}
	
	if (isBlank(theForm.idCarteira))
	{
		alert("Preencha o campo carteira");
		jQuery("input#idCarteira").focus(); 
		return false; 
	}		
	
	var cedente = escape( theForm.idCedente.value );
	var cpfCnpjCedente = escape( theForm.idCpfCnpjCedente.value );
	//var endereco = escape( theForm.idEndereco.value );
	var banco = escape( theForm.idListaBanco.value );
	var agencia = escape( theForm.idAgencia.value );
	var dgAgencia = escape( theForm.idDgAgencia.value );
	var conta = escape( theForm.idConta.value );
	var dgConta = escape( theForm.idDgConta.value );
	var carteira = escape( theForm.idCarteira.value );
	var convenio = escape( theForm.idConvenio.value );
 
	var parametros = '?cadastrar=1' + '&cedente=' + cedente + '&cpfCnpjCedente=' + cpfCnpjCedente +
					 /*'&endereco=' + endereco +*/ '&banco=' + banco + '&agencia=' + agencia + 
					 '&dgAgencia=' + dgAgencia + '&conta=' + conta + '&dgConta=' + dgConta +
					 '&carteira=' + carteira + '&convenio=' + convenio + '&resposta_ajax=1';
	
	chamarAjax( 'ajaxContaBancaria', '../../__user/conta/info.inc.php', parametros, false );	
}

/******************************************************************** 	
FUNÇÃO:		IMPRIMIR BOLETO
PARÂMETROS:	ID DO BOLETO!
RETORNO:
*********************************************************************/
function imprimirBoleto( url )
{
	window.open( url, "IMPRIMIR", "height = 600, width = 600,resizable=yes,scrollbars=yes");	
}



// DATA: 	01-02-2010
// EMAIL: 	alfredo@ecliente.com.br
function gerarBoleto( idPacote )
{
	idPacote = document.getElementById( idPacote );	

	if ( idPacote.value == 0)
	{
		alert("Selecione um pacote");
		jQuery("select#idPacote").focus();
		return false; 
	}
	
	var quantidade = idPacote.value;
	
	if ( quantidade == 50 )
		var valor = 10;
	else if ( quantidade == 250 )
		var valor = 45;
	else if ( quantidade == 500 )
		var valor = 80;
	else return false;	
	
	var parametros = '?resposta_ajax=1&gerarBoleto=1' + 
					 '&quantidade=' + quantidade + '&valor=' + valor;
					 
	chamarAjax( 'ajaxCreditoBoleto', '../../__user/conta/infoCreditoBoleto.inc.php', parametros, false );	
}

// DATA: 	01-02-2010
// EMAIL: 	alfredo@ecliente.com.br
function checkFmLoginAdm( theForm )
{
	theForm = document.getElementById( theForm );	

	if (isBlank(theForm.idLogin))
	{
		alert("Preencha o campo login");
		jQuery("input#idLogin").focus(); 
		return false; 
	}
	
	if (isBlank(theForm.idSenha))
	{
		alert("Preencha o campo senha");
		jQuery("input#idSenha").focus(); 
		return false; 
	}
	
	
	var loginAdm = escape( theForm.idLogin.value );
	var senhaAdm = escape( theForm.idSenha.value );
	
	var parametros = '?resposta_ajax=1' + 
					 '&loginAdm=' + loginAdm + '&senhaAdm=' + senhaAdm;
					 
	chamarAjax( 'idDivLoginAdm', '../../__adm/index/verificaLoginAdm.php', parametros, false );	
}


// FUNÇÃO DINÂMICA PARA GERAÇÃO DE CIDADES/ESTADOS!
function gerarListaCidadesDinamico(valor) {
  //verifica se o browser tem suporte a ajax
  try {
	 ajax = new ActiveXObject("Microsoft.XMLHTTP");
  } 
  catch(e) {
	 try {
		ajax = new ActiveXObject("Msxml2.XMLHTTP");
	 }
	 catch(ex) {
		try {
		   ajax = new XMLHttpRequest();
		}
		catch(exc) {
		   alert("Esse browser não tem recursos para uso do Ajax");
		   ajax = null;
		}
	 }
  }
  //se tiver suporte ajax
  if(ajax) {
	 //deixa apenas o elemento 1 no option, os outros são excluídos
	 var cidades = document.getElementById( 'idListaCidades2' );	
	 cidades.options.length = 1;
	 
	 idOpcao  = document.getElementById("opcoes2");
	 
	 ajax.open("POST", "../../__user/comum/cidades.php", true);
	 ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	 
	 ajax.onreadystatechange = function() {
		//enquanto estiver processando...emite a msg de carregando
		if(ajax.readyState == 1) {
		   idOpcao.innerHTML = "Carregando...!";   
		}
		//após ser processado - chama função processXML que vai varrer os dados
		if(ajax.readyState == 4 ) {
		   if(ajax.responseXML) {
			  processXMLCidadesDinamico(ajax.responseXML);
		   }
		   else {
			   //caso não seja um arquivo XML emite a mensagem abaixo
			   idOpcao.innerHTML = "--Primeiro selecione o estado--";
		   }
		}
	 }
	 //passa o código do estado escolhido
	 var params = "estado="+valor;
	 ajax.send(params);
  }
}

function processXMLCidadesDinamico(obj){
	var cidades = document.getElementById( 'idListaCidades2' );	
  //pega a tag cidade
  var dataArray   = obj.getElementsByTagName("cidade");
  
  //total de elementos contidos na tag cidade
  if(dataArray.length > 0) {
	 //percorre o arquivo XML paara extrair os dados
	 for(var i = 0 ; i < dataArray.length ; i++) {
		var item = dataArray[i];
		//contéudo dos campos no arquivo XML
		var codigo    =  item.getElementsByTagName("codigo")[0].firstChild.nodeValue;
		var descricao =  item.getElementsByTagName("descricao")[0].firstChild.nodeValue;
		
		idOpcao.innerHTML = "--Selecione uma das op&ccedil;&otilde;es abaixo--";
		
		//cria um novo option dinamicamente  
		var novo = document.createElement("option");
			//atribui um ID a esse elemento
			novo.setAttribute("id", "opcoes");
			//atribui um valor
			novo.value = codigo;
			//atribui um texto
			novo.text  = descricao;
			//finalmente adiciona o novo elemento
			cidades.options.add(novo);
	 }
  }
  else {
	//caso o XML volte vazio, printa a mensagem abaixo
	idOpcao.innerHTML = "--Primeiro selecione o estado--";
  }	  
}

// DATA: 	24-02-2010
// EMAIL: 	alfredo@ecliente.com.br
function abrirPopUp( url )
{
	window.open( url, "IMPRIMIR", "height = 600, width = 800,resizable=yes,scrollbars=yes");	
}

// DATA: 	24-02-2010
// EMAIL: 	alfredo@ecliente.com.br
function visualizarEmailCadastro( theForm )
{
	theForm = document.getElementById( theForm );
		
	if (isBlank(theForm.nome))
	{
		alert("Preencha o nome do aluno");
		jQuery("input#nome").focus(); 
		return false; 
	}
	
	if(!isBlank(theForm.email)) 
	{
		if(!isMail(theForm.email)) 
		{
			alert("Formato de e-Mail incorreto");
      		jQuery("input#email").focus();
			return false;
		} 
	}
	else
	{
		alert("Preencha o e-Mail do aluno");
		jQuery("input#email").focus();
		return false;
	}
	
	if ( isBlank( theForm.idTextoCadastro ) )
	{
		alert("Preencha um texto");
		jQuery("textarea#idTextoCadastro").focus(); 
		return false; 
	}
	
	var nome = escape( theForm.nome.value );
	var email = escape( theForm.email.value );
	var texto = escape( theForm.idTextoCadastro.value );
	
	var parametros = "?resposta_ajax=1" + "&nome=" + nome + "&email=" + email +
					 "&texto=" + texto;
					 
	var url = '../../__user/classe/visualizarEmailCadastro.php' + parametros;
	
	abrirPopUp( url );
}

// DATA: 	24-02-2010
// EMAIL: 	alfredo@ecliente.com.br
function visualizarEmailConvite( theForm )
{
	var emails_novos = "";
	theForm = document.getElementById( theForm );	
		
	if(!isBlank(theForm.emails)) 
	{
		var emails = theForm.emails.value;
		var emails = emails.split( "," );
	
		for (var i = 0; i < emails.length; i++)
		{			
			var email = trim( emails[i] )
			
			if( !isMail2( email ) )
			{
				var num = i + 1;
				alert("O " + num + "º email está com formato incorreto:" + email );
				jQuery("input#emails").focus();
				return false;
			} 

			if ( ( i + 1 ) < emails.length )
				emails_novos += email + ",";
			else	
				emails_novos += email;			
		}
	}
	else
	{
		alert("Preencha algum e-Mail para enviar o convite!");
		jQuery("input#emails").focus();
		return false;
	}
	
	if ( isBlank( theForm.idTextoConvite ) )
	{
		alert("Preencha um texto");
		jQuery("textarea#idTextoConvite").focus(); 
		return false; 
	}		

	var emails_novos = escape( emails_novos );
	var texto = escape( theForm.idTextoConvite.value );
	
	var parametros = "?resposta_ajax=1" + "&emails=" + emails_novos + "&texto=" + texto;
	var url = '../../__user/classe/visualizarEmailConvite.php' + parametros;
	
	abrirPopUp( url );
}

// DATA: 	18-01-2010
// EMAIL: 	alfredo@ecliente.com.br
function ativarEnqueteMenuPrincipal( id, status )
{		
	var parametros = '?resposta_ajax=1' + '&ativar=1' +'&idPergunta=' +  id;
	
	if ( status == 'ativar' )
		parametros += "&status=1";
	else if ( status == 'desativar' )
		parametros += "&status=0";
	
	chamarAjax( 'ajaxCadastrarAlternativa', '../../__user/enquete/cadastrar_alternativa.php', parametros, false );
	chamarAjax( 'ajax_Menu_Enquete', '../../__user/enquete/menu_principal.php', '?resposta_ajax=1', false );
}


// DATA: 	24-02-2010
// EMAIL: 	alfredo@ecliente.com.br
function checkEnqueteAlterarAlternativa( theForm )
{
	
	theForm = document.getElementById( theForm );	
	
	if (isBlank(theForm.alternativa))
	{
		alert("Preencha a alternativa");
		jQuery("input#alternativa").focus(); 
		return false; 
	}	
	
	var alternativa = escape( theForm.alternativa.value );	
	var idAlternativa = theForm.idAlternativa.value 
	
	var parametros = '?resposta_ajax=1' + '&alternativa=' + alternativa + '&id=' + idAlternativa;
	
	chamarAjax( 'ajaxVisualizarVotos', '../../__user/enquete/visualizarVotos.php', parametros, false );
	chamarAjax( 'ajax_Menu_Enquete', '../../__user/enquete/menu_principal.php', '?resposta_ajax=1', false );
}



