  // #############################################################
  
  function ismail( oMail ) {
    // Valida oMail como um e-mail, retorna true/false
  
    MyRegExp = new RegExp("^(([A-Za-z0-9])([_\.a-zA-Z0-9\-]*)(@)([A-Za-z0-9]+)(([\.\-]{1}[a-zA-Z0-9]+)*))$");
    return MyRegExp.test(oMail)

  }
  
  // #############################################################
  
  function validamail ( oform) { 
    oMail = oform.mail.value;
    if ( ismail ( oMail ) ) {
       return true;
    } else {
       alert("Endereço de E-mail inválido!");
       return false;
    }
  }
     
  // #############################################################
  
  function togglediv(divname, para) {
    if (document.getElementById) {
      document.getElementById(divname).style.display  = (para) ? 'block' : 'none';
    } else if (document.all) {
      document.all[divname].style.display = (para) ? 'block' : 'none';
    } else if(document.layers) {
      document[divname].style.display = (para) ? 'block' : 'none';
    }
  }
  
  // #############################################################
  function menudiv(divname) {
    if (document.getElementById) {
      document.getElementById(divname).style.display  = (document.getElementById(divname).style.display == 'none') ? 'block' : 'none';
    } else if (document.all) {
      document.all[divname].style.display = (document.all[divname].style.display == 'none') ? 'block' : 'none';
    } else if(document.layers) {
      document[divname].style.display = (document[divname].style.display == 'none') ? 'block' : 'none';
    }
  }
   
  // #############################################################
  
  function apenasNumeros(k) { 
    if(!(k >= 48 && k <= 57)) { 
        return false;
    }
  }
  
  // #############################################################

  function limpaString(S){
	// Deixa so' os digitos no numero
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";

	for (var i=0; i<S.length; i++)	{
		digito = S.charAt(i);
		if (Digitos.indexOf(digito) >= 0)	{
			temp=temp+digito
        }
	} //for

	return temp
  }
  
  // #############################################################
  function ereg(arquivo,mascara) {
    MyRegExp = new RegExp(mascara);
    return MyRegExp.test(arquivo);
  }
  
  // #############################################################
  function checkbusca(oform) {
     if (oform.code.value.length != 6) {
      alert("Por favor digite o código de segurança apresentado na imagem");
      return false;
    } else if (oform.fb_estado.value == "") {
      alert("Por favor selecione um Estado");
      return false;
    //} else if (oform.fb_cidade.value == "" && oform.fb_bairro.value != "") {
//      alert("Para buscar por bairro, por favor preencha a cidade");
      //return false;
    } else if (oform.fb_atividade.value == "") {
      alert("Preencha uma atividade");
      return false;
    } else {      
      return true;
    }
  }
  
  // #############################################################
  function mygetElement(id) {
    if (document.getElementById) {
      return document.getElementById(id);
    } else if (document.all) {
      return document.all[id];
    } else if(document.layers) {
      return document[id];
    }
  }

  // ## Cidades ######################################################################
  // #################################################################################

  function buscaCidades(campo, campo_cidade, largura) {
  
    nome_div = 'div_' + campo_cidade
     
    mygetElement(nome_div).innerHTML = '<select style="width:" + largura + "px"><option>Carregando...</option></select>';
  
    eval("parent.escondido.location='_funcs/escondido.php?campo_cidade="+campo_cidade+"&id_estado="+campo.options[campo.selectedIndex].value+"&largura="+largura+"'");
  }
  
  function buscaCidadesDireto(estado, cidade,  campo_cidade, largura) {
    
    nome_div = 'div_' + campo_cidade
      
    mygetElement(nome_div).innerHTML = '<select style="width:" + largura + "px"><option>Carregando...</option></select>';
      
    eval("parent.escondido.location='_funcs/escondido.php?campo_cidade="+campo_cidade+"&id_estado="+estado+"&cidade="+cidade+"&largura="+largura+"'");
  }
  
  function carregaCidades(div) { 
      var novo_select;
      
      novo_select  = eval("parent.escondido.retornaCidades()");
      
      mygetElement(div).innerHTML = novo_select;
  }
  
  // #################################################################################