function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

function pageWidth() {
  return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?       document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
}
function pageHeight() {
 return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;
}



////////////////////////////////////////////////////
//  Atualizar refresh na area da página sendo mostrada
/////////////////////////////////////////////////////
function refreshArea(areaID,areaPanel,serverPage){
//  WebtoolWaitingMessage (areaID,"");
  closePanel(areaPanel)
  WebtoolAjax ("GET",serverPage,areaID,"");
}


////////////////////////////////////////////////////
//  Controle do Painel
/////////////////////////////////////////////////////
function openAlertaWin(panelWidth,nlinhas,areaAlert){
  //25 = header, 18=cada linha
  var panelHeight =(nlinhas*19)+30;
  openPanel (panelWidth,panelHeight,areaAlert);

}

//  Reduzir Window Panel
function zoonInPanel (areaID,width,height){
 var theObject = document.getElementById(areaID);
 theObject.style.height = height + "px";
 theObject.style.width = width + "px";
}
// Panel de edição
function openPanel2 (panelWidth,panelHeight,areaID){
 var theObject = document.getElementById(areaID);
 theObject.style.visibility = "visible";
 theObject.style.height = panelHeight + "px";
 theObject.style.width = panelWidth + "px";
 posx = 1;posy=1;
 theObject.style.left = posx + "px";
 theObject.style.top = posy + "px";
}
function openPanel(panelWidth,panelHeight,areaID) {
 var theObject = document.getElementById(areaID);
 //////////// calcula posicionamento /////////////
 var xyscroll = getScrollXY();
 var offsetX = xyscroll[0];
 var offsetY = xyscroll[1];
 var posx = 0;
 var posy = 0;
 var larguraPagina = pageWidth();
 var alturaPagina = pageHeight();
 if (larguraPagina <= panelWidth) {
	posx = 0;
 }else {
    posx = larguraPagina - panelWidth;
    posx = ((posx/2) + offsetX);
 }
 posy = offsetY + 50;
 //////////////////////////////////////

 theObject.style.visibility = "visible";
 theObject.style.height = panelHeight + "px";
 theObject.style.width = panelWidth + "px";
 theObject.style.left = posx + "px";
 theObject.style.top = posy + "px";
}

// Fechar painel
function closeAlertPanel(){
  closePanel('pnlalert');
}
function closePanel(areaID) {
 var theObject = document.getElementById(areaID);
  theObject.innerHTML = "";
 theObject.style.visibility = "hidden";
 theObject.style.height = "0px";
 theObject.style.width = "0px";
}


//-----------------------------------------------------
//  Tratamento de Configuração
//------------------------------------------------------
function accesslogin(){
  var login = Trim(document.formlogin.login.value);
  var pass = Trim(document.formlogin.logpss.value);
  var obj = document.getElementById('acessomsgerr');
  if ((login == "")||(pass == "")){
  }else {
      if (!(email_valido = is_email(login))) {
         obj.innerHTML = ">> Campo Login incorreto.";
      }else {
        document.formlogin.submit();
      }
  }

}


