function verifCampoPreemchido(sObj, sMsgNaoPreenchido)
{
  if(strEstaVazia(sObj.value))
  {
    alert(sMsgNaoPreenchido);
    sObj.focus();
    return false;
  }
  return true;
}

function verifCampoPreenchido(sObj, sMsgNaoPreenchido){
  return verifCampoPreemchido(sObj, sMsgNaoPreenchido);
}

function setarFocusTxtObj(objTxt)
{
  objTxt.focus();
  objTxt.value = objTxt.value;
}

function validarSenha(str)
{
  var sValid = '1234567890';
  var bValidSenha = false;
  for(var i = 0; i < sValid.length; i++)
  {
    if(str.indexOf(sValid.charAt(i)) > -1)
      bValidSenha = true;
  }
  if(!bValidSenha)
    alert('A senha deverá conter pelo menos um número.');
  
  return bValidSenha;
}

//** DESENVOLVER VERIF. CPF
function validarCPF(sCPF)
{
  return true;
}

function validarData(sData)
{
  return true;
}

//** seta um objeto div, montado como se fosse uma combo, visível.
function setObjCboVisibilidade(strIdObjCbo, strIdObjRef, bIndVisivel)
{
  //var frm = document.formCadPsv;
  var divCbo = document.getElementById(strIdObjCbo); 
  //var divMain = document.getElementById(strIdObjRef); 
  
  if(bIndVisivel)
  {
    //divCbo.style.top = pegarPosicaoY(divMain) + 28;
    //divCbo.style.left = pegarPosicaoX(divMain);//270;
    divCbo.style.visibility = 'visible';
  }
  else
  {
    divCbo.style.visibility = 'hidden';
  }
}

//** Retorna a posição X de um objeto.
function pegarPosicaoX(objeto)
{
    var atual_left = 0;
    if (objeto.offsetParent) {
        while (objeto.offsetParent) {
            atual_left += objeto.offsetLeft
            objeto = objeto.offsetParent;
        }
    }
    return atual_left;
}

//** Retorna a posição Y de um objeto.
function pegarPosicaoY(objeto)
{
    var atual_top = 0;
    if (objeto.offsetParent) {
        while (objeto.offsetParent) {
            atual_top += objeto.offsetTop
            objeto = objeto.offsetParent;
        }
    }
    return atual_top;
} 


//** Exemplo:
//** var aryPosition = ObjectPosition(document.getElementById('MyElementId'));
//** document.write('MyElementId left offset is ' + aryPosition[0] + '<br />');
//** document.write('MyElementId top offset is ' + aryPosition[1] + '<br />');
function ObjectPosition(obj) {
    var curleft = 0;
      var curtop = 0;
      if (obj.offsetParent) {
            do {
                  curleft += obj.offsetLeft;
                  curtop += obj.offsetTop;
            } while (obj = obj.offsetParent);
      }
      return [curleft,curtop];
}

function exibirDiv(sIdDiv, saIdObjsParaFechar)
{
  var divCbo = document.getElementById(sIdDiv);
  divCbo.style.visibility = 'visible';
}

function esconderDiv(sIdDiv)
{
  var divCbo = document.getElementById(sIdDiv);
  divCbo.style.visibility = 'hidden';
}

function exibeEscondeDiv(sIdDiv, saIdDivRef)
{
  var div = document.getElementById(sIdDiv);
  if(div.style.visibility != 'visible')
  {
    div.style.visibility = 'visible';
  }
  else
  {
    div.style.visibility = 'hidden';
  }
}

//** Cria container opaco.
var sCurrentContainer = '';
createContainer = function(objDiv, iHeight){
  indConteiner = true;
  sCurrentContainer = objDiv.id;
  if(document.getElementById('divContainer')){
    var objDivContainer = document.getElementById('divContainer')
    objDivContainer.style.top = f_scrollTop();
    objDivContainer.style.display = 'block';
    objDivContainer.style.height = f_clientHeight();
  }
  else{
    var objDivContainer = document.createElement('div');
    objDivContainer.id = 'divContainer';
    objDivContainer.className = 'container';
    objDivContainer.style.top = f_scrollTop();
    objDivContainer.style.display = 'block';
    objDivContainer.style.height = f_clientHeight();
    document.body.appendChild(objDivContainer);
    
  }
  
  window.onscroll = function(){
    if(indConteiner){
      objDivContainer.style.top = f_scrollTop();
      objDivContainer.style.height = f_clientHeight();
      if(objDiv){
        objDiv.style.top = f_scrollTop() + eval(f_clientHeight()  / 2) - eval(iHeight / 2);
      }
    }
  };
  
  if(objDiv){
    objDiv.style.top = f_scrollTop() + eval(f_clientHeight()  / 2) - eval(iHeight / 2);
    objDiv.style.zIndex = '101';
    objDiv.style.display = 'block';
  }
};

//** Destroi container.
destroyContainer = function(objDiv){
  indConteiner = false;
  sCurrentContainer = '';
  if(objDiv)objDiv.style.display = 'none';
  document.getElementById('divContainer').style.display = 'none';
};

//** retorna a largura da janela.
function f_clientWidth() {
  return f_filterResults (
    window.innerWidth ? window.innerWidth : 0,
    document.documentElement ? document.documentElement.clientWidth : 0,
    document.body ? document.body.clientWidth : 0
  );
}

//** retorna a altura da janela.
function f_clientHeight() {
  return f_filterResults (
    window.innerHeight ? window.innerHeight : 0,
    document.documentElement ? document.documentElement.clientHeight : 0,
    document.body ? document.body.clientHeight : 0
  );
}

//** retorna a posição do scroll lateral.
function f_scrollLeft() {
  return f_filterResults (
    window.pageXOffset ? window.pageXOffset : 0,
    document.documentElement ? document.documentElement.scrollLeft : 0,
    document.body ? document.body.scrollLeft : 0
  );
}

//** reotna a posição do scroll que fica na base.
function f_scrollTop() {
  return f_filterResults (
    window.pageYOffset ? window.pageYOffset : 0,
    document.documentElement ? document.documentElement.scrollTop : 0,
    document.body ? document.body.scrollTop : 0
  );
}

//** filtra o resultado conforme o tipo do browser.
function f_filterResults(n_win, n_docel, n_body) {
  var n_result = n_win ? n_win : 0;
  if (n_docel && (!n_result || (n_result > n_docel)))
    n_result = n_docel;
  return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}