﻿var AjaxNotFound = "O Servidor ajax não foi encontrado!";
var ComponentNotFound = 'Componente não encontrado!';
var ContainerNotFound = 'Componente container não encontrado!';
var trmEmAtualizacao = null;
var EmAtualizacaoBloqueado = false;
var IWEmAtualizacaoBloq = false

//** Load Inner Html ***************************************************************************************************************************
function LoadInnerHtml(strSender, Url, FormName, AutoAjuste)
{                            
 if ((HideLayer) && (strSender.toLowerCase() == "tdmenu"))
 {
  return true;
 }

 var Sender = document.getElementById(strSender);

 if (Sender == null)
 {
  alert(ComponentNotFound);
  return;
 }
 
 if (FormName == null)
 {
  FormName = '';
 }
 
 if (AutoAjuste == null)
 {
  AutoAjuste = false;
 }
 
 try
 {
  var LoadInnerIndex = AddLoadHtml(strSender, Sender.style.backgroundImage,Sender.style.backgroundPosition,
                                   Sender.style.backgroundRepeat,Sender.innerHTML,FormName,AutoAjuste,Url);
                                   
  if (LoadInnerIndex < 0)
   return false;
  
  if (Sender.style.backgroundImage.toString().indexOf("loading.gif") >= 0) 
   return false;        
   
  Url = GetPageSession(Url);
  Height = parseInt(Sender.offsetHeight);
  Height = (Height < 24) ? 24 : Height;
 
  Sender.innerHTML               = "<img src='imagens/branco.gif' width='1' height='" + Height + "'>";
  Sender.style.backgroundImage    = "url(imagens/loading.gif)";
  Sender.style.backgroundPosition = "center center";
  Sender.style.backgroundRepeat   = "no-repeat";

  jQuery.ajax({
      type: "POST",
      url: "Index.aspx/NovoLoadInnerHtml", // URL da página/Nome do método
      contentType: "application/json; charset=utf-8",
      dataType: "json",
      data: "{ID: '" + ID + "', DBIndex: '" + self.DBIndex + "', SessionID: '" + SessionID + "', strSender: '" + strSender + "', Url: '" + Url + "', LoadInnerIndex: '" + LoadInnerIndex + "'}", // Parâmetros da função
      beforeSend: function ()
      {
          ShowAguarde(true);
      },
      success: function (data)
      {
          var seguro;
          var JSONObject = data.d;

          // Retorno o valor do seguro
          if (JSONObject.length > 0)
              cbk_LoadInnerHtml(JSONObject)
      },
      complete: function ()
      {
          ShowAguarde(false);
      },
      error: function (XMLHttpRequest, textStatus, errorThrown)
      {
          alert(XMLHttpRequest.responseText);
      }
  });

  //JRAjax.LoadInnerHtml(ID,self.DBIndex,SessionID,strSender,Url,LoadInnerIndex,FormName, cbk_LoadInnerHtml);
  return true;
 }
 catch(e) 
 {
  Sender.innerHTML                = innerHTML;
  Sender.style.backgroundImage    = backgroundImage;
  Sender.style.backgroundPosition = backgroundPosition;
  Sender.style.backgroundRepeat   = backgroundRepeat;
  alert(AjaxNotFound);
  return false;
 }
}

function cbk_LoadInnerHtml(Request)
{
 try
 {
  var LoadInnerIndex = parseInt("0" + Request[5].toString());
  var LoadInner      = GetLoadHtml(LoadInnerIndex);
  var Sender         = document.getElementById(Request[4]);
  
  if (Sender == null)
  {
   return false;
  }
  
  try
  {                                                      
   if (LoadInner == null)
   {
    alert(ContainerNotFound);
    return false;
   }
   
   Sender.style.backgroundImage    = LoadInner.BgImg;
   Sender.style.backgroundPosition = LoadInner.BgPos;
   Sender.style.backgroundRepeat   = LoadInner.BgRep;

   if (!Request[0])
   {                    
    if ((Request[1] == null) || (Request[1] == ""))
    {
     alert('Erro ao carregar o conteúdo!');
    }
    else 
    {
     alert(Request[1]);
    } 
    
    Sender.innerHTML = LoadInner.InnerHtml;
    return false;
   }
   
    Sender.innerHTML = Request[2];

   try
   {
    if ((Request[3] != null) && (Request[3].length > 0))
    {
     new Function(Request[3])();
    }
   }
   catch(e)
   {
    // faz nada
   }
   
   if (LoadInner.FormName != "")
   {
    ShowDinamicForm(LoadInner.FormName);
   }
   
   var ParentNode = Request[4].toString();
   if (BackHomeUrl[ParentNode] != LoadInner.Url)
   {
    AddUrlList(ParentNode,BackHomeUrl[ParentNode]);
    BackHomeUrl[ParentNode] = LoadInner.Url;
   }
  
   return true;
  }
  catch(e)
  {
   alert(ComponentNotFound+"\n"+e.Message);
   Sender.innerHTML = LoadInner.InnerHtml;
  }
  return false;
 }
 finally
 {
  FreeLoadHtml(LoadInnerIndex);
  
  if (LoadInner != null)
  {
   LoadInner.InnerHtml  = "";
   LoadInner.BgImg      = "";
   LoadInner.BgPos      = "";
   LoadInner.BgRep      = "";
   LoadInner.Name       = "";
   LoadInner.FormName   = "";
   LoadInner.AutoAjuste = "";
   LoadInner.Url        = "";
  }  
 }
}

function BackHistory(ParentNode, ParamName, ParamValue)
{
  
 if (ParentNode == null)
  ParentNode = 'tdHome';
  
 if ((BackUrl != null) && (BackUrl[ParentNode] != null) && (BackUrl[ParentNode] != "")) 
 {
  var Url = GetLastUrlList(ParentNode);
  
  if ((Url != null) && (Url != ""))
  {
   if ((ParamName != null) && (ParamValue != null))
   {
    var Index = Url.replace("?","&").toLowerCase().indexOf("&"+ParamName.toString().toLowerCase()+'=');
     
    if (Index >= 0)
    {
     var Str1 = Url.substring(0,Index);
     var Str2 = Url.substring(Index+("&"+ParamName).length+1,Url.length);
     
     Index = (Str2+"&").indexOf("&");
     
     Str2 = Str2.substring(Index,Str2.length);
     Url = Str1 + Str2;
    }
    
    Url += ((Url.toString().indexOf("?") >= 0) ? "&" : "?") + ParamName + "=" + ParamValue;
   }
  
   LoadInnerHtml(ParentNode,Url);
   BackHomeUrl[ParentNode] = "";
  }
 }
}

function AddUrlList(ParentNode, Url)
{
 if (BackUrl[ParentNode] == null)
 {
  BackUrl[ParentNode] = new Array();
 }
 
 var List = BackUrl[ParentNode];
 var i    = List.length;
 
 while ((i > 0) && ((List[i-1] == null) || (List[i-1] == "")))
  i--;
  
 List[i] = Url;
}

function GetLastUrlList(ParentNode)
{
 if (BackUrl[ParentNode] == null)
 {
  BackUrl[ParentNode] = new Array();
 }
 
 var List = BackUrl[ParentNode];
 var i = List.length;

 while ((i > 0) && (List[i] == null))
  i--;
 
 if ((i >= 0) && (List[i] != null))
 {
  var Url = List[i];
  List[i] = null;
  List.length = List.length-1;
  return Url;
 }
 return null;
}

//** Show Forms ******************************************************************************************************************************
function ShowForm(Caption, Url)
{
 try
 { 
  Url = GetPageSession(Url);
  ShowAguarde(true);
  JRAjax.ShowForm(ID, self.DBIndex, SessionID, Caption, Url, FormCount, cbk_ShowForm);
 }
 catch(e) 
 {
  ShowAguarde(false);
  alert(AjaxNotFound);
 }
}

function cbk_ShowForm(Request)
{
 if (!Request.value[0])
 {                    
  ShowAguarde(false);
  if ((Request.value[1] == null) || (Request.value[1] == ""))
  {
   alert('Erro ao carregar o cadastro!');
  }
  else 
  {
   alert(Request.value[1]);
  } 
  return ;
 }
 
 try
 {
  var Func = new Function(Request.value[2]);
  
  if (!Func())
  {
   return false;
  }
  
  var Form   = document.getElementById('Form'+Request.value[4]);
  var Filtro = document.getElementById('Filtro'+Request.value[4]);
  
  try
  {
   Filtro.style.position        = 'absolute';
   Filtro.style.visibility      = 'hidden';
   Filtro.style.width           = '1px';
   Filtro.style.height          = '1px';
   Filtro.style.left            = '0px';
   Filtro.style.top             = '0px';
   Filtro.style.backgroundColor = '#000000';
   Filtro.style.opacity         = '0.7';
   Filtro.style.filter          = 'alpha(opacity=70)';
   
   Form.style.position        = 'absolute';
   Form.style.left            = '0px';
   Form.style.top             = '0px';
   Form.style.width           = '1px';
   Form.style.height          = '1px';
   Form.style.cursor          = 'default';
   Form.style.visibility      = 'hidden';
   Form.border                = '0';
   Form.cellpadding           = '0';
   Form.cellspacing           = '0';

  }
  catch(e)
  {
   alert('PropertyErro: '+e.Message);
  }

  ShowDinamicForm(Request.value[4]);
  
  try
  {
   var ActiveInput = Form.getElementsByTagName('input');
   var ActiveSelect = Form.getElementsByTagName('select');
   var ActiveTextArea = Form.getElementsByTagName('textarea');
   
   ActiveInput    = (ActiveInput.length >= 0) ? ActiveInput[0] : null;
   ActiveSelect   = (ActiveSelect.length >= 0) ? ActiveSelect[0] : null;
   ActiveTextArea = (ActiveTextArea.length >= 0) ? ActiveTextArea[0] : null;
      
   var frm = (ActiveInput || ActiveSelect || ActiveTextArea);
   
   if (frm != null)
   {
     frm = frm.form;
     
     for (i = 0; i < frm.length; i++)
     {
      if ((frm.elements[i] == ActiveInput) || (frm.elements[i] == ActiveSelect) || (frm.elements[i] == ActiveTextArea))
      {
       frm.elements[i].focus();
       break;
      }
     }
   }

  }
  catch(e)
  {
   //faz nada
  }

  try
  {
   new Function(Request.value[3])();
  }
  catch(e)
  {
   //faz nada
  }

  BringToFront('btnAguarde');
 }
 catch(e)
 {
  alert(ComponentNotFound+"\n"+e.Message);
 }
 finally
 {
  ShowAguarde(false);
 }
}  

//** Show Ballons ******************************************************************************************************************************
function ShowBallon(Sender, Caption, Url)
{
 if (!BallonInProcess)
 try
 { 
  ShowAguarde(false);
  BallonInProcess = true;
  Url = (Url.indexOf("?",0) < 0) ? Url+"?ID="+ID+"&SessionID=" + SessionID + "&Matricula="+Matricula : Url;
      
  if (Url.indexOf("ID=",0) < 0)
  {
   Url += "&ID="+ID;
  }
  if (Url.indexOf("SessionID=",0) < 0)
  {
   Url += "&SessionID="+SessionID;
  }
  if (Url.indexOf("Matricula=",0) < 0)
  {
   Url += "&Matricula="+Matricula;
  }
 
 
  var P = getElementPosition(Sender);
  P.left = parseInt(P.left + (Sender.offsetWidth / 2));
  
  JRAjax.ShowBallon(ID, self.DBIndex, SessionID, Caption, Url, BallonCount, P.left, P.top,cbk_ShowBallon);
 }
 catch(e) 
 {
  BallonInProcess = false;
  alert(AjaxNotFound);
 }
}

function cbk_ShowBallon(Request)
{
 if (!Request.value[0])
 {                    
  if ((Request.value[1] == null) || (Request.value[1] == ""))
  {
   alert('Erro ao carregar o balão!');
  }
  else 
  {
   alert(Request.value[1]);
  } 
  BallonInProcess = false;
  return ;
 }
 
 try
 {
  var Func = new Function(Request.value[2]);
  
  if (!Func())
  {
   return false;
  }
  
  var Ballon   = document.getElementById(Request.value[4]);
  
  try
  {
   var Left = parseInt(Request.value[5]);
   var Top  = parseInt(Request.value[6]) - (Ballon.offsetHeight) + 2;
   
   Ballon.style.opacity         = '1'; 
   Ballon.style.position        = 'absolute';
   Ballon.style.left            = Left+'px';
   Ballon.style.top             = Top+'px';
   Ballon.style.width           = '1px';
   Ballon.style.height          = '1px';
   Ballon.style.cursor          = 'default';
   Ballon.style.visibility      = 'visible';
   Ballon.border                = '0';
   Ballon.cellpadding           = '0';
   Ballon.cellspacing           = '0';
  }
  catch(e)
  {
   alert('PropertyErro: '+e.Message);
  }

  try
  {
   var ActiveControl = Ballon.getElementsByTagName('input')[0];
   if (ActiveControl)
    ActiveControl.focus();
  }
  catch(e)
  {
   //faz nada
  }

  try
  {
   new Function(Request.value[3])();
  }
  catch(e)
  {
   //faz nada
  }

  BringToFront('btnAguarde');
 }
 catch(e)
 {
  alert(ComponentNotFound+"\n"+e.Message);
 }
 finally
 {
  BallonInProcess = false;
 }
}  


//** Carrega Teclado Digital *******************************************************************************************************************
function IW_LoadDigitalKeyBord(ShowError)
{
 if (ShowError == null)
  ShowError = true;

 try
 {
  JRAjax.IW_LoadDigitalKeyBord(ShowError,cbk_IW_LoadDigitalKeyBord);
 }
 catch(e)
 {
  alert(AjaxNotFound);
 } 
}


function cbk_IW_LoadDigitalKeyBord(Request)
{
 if (!Request.value[0])
 {
  alert('Falha ao carregar o teclado digital!');
  return ;
 }

 var Img = null;
 for (i = 0; i < 10; i++)
 {
  Img = document.getElementById("btn0" + i.toString());
  
  if (Img != null)
  {
   Img.src = Request.value[2][i];
  }
 }
 
 var lbSenha    = document.getElementById("lbSenha");
 var SenhaIndex = document.getElementById("SenhaIndex");
 var Senha      = document.getElementById("Senha");
 
 if ((Request.value[4]) && (lbSenha != null))
 {
  lbSenha.innerHTML = "";
  lbSenha.style.color = "navy";
 }

 if (SenhaIndex != null)
 {
  SenhaIndex.value = Request.value[3];
 }

 if (Senha != null)
 {
  Senha.value = "";
 }
}

//** Verifica Se o User já está na sessão *******************************************************************************************************

function isInSession()
{
 if (trmEmAtualizacao != null)
 {
  clearTimeout(trmEmAtualizacao);
  trmEmAtualizacao = null;
 }
 
 self.trmEmAtualizacao = setTimeout("AppEmAtualizacao()",10000);
 AppEmAtualizacao();

 try
 {
  ShowAguarde(true); 
  JRAjax.GetSessionInfJS(ID,self.DBIndex,SessionID,cbk_isInSession);
 }
 catch(e)
 {
  ShowAguarde(false); 
  SetDefaultPath();
 }
}

function cbk_isInSession(Request)
{
 ShowAguarde(false); 
 try
 {
  if (AntiPopUpEnabled)
  {
   LoadInnerHtml('tdMenu','includes/v_menuReload.aspx');
   LoadInnerHtml('tdHome','AntPopUp.aspx');
   return true;
  }
 
  if ((Request.value[0]) && (Request.value[1]) && (Request.value[3] != "") && (Request.value[4] != ""))
  {
   Matricula = Request.value[2];
   if (!HideLayer)
    LoadInnerHtml('tdMenu',Request.value[4]);
   LoadInnerHtml('tdHome',Request.value[3]);
   
   if (Request.value[5] != null)
   try
   {
    new Function(Request.value[5])();
   }
   catch(e)
   {
    //faz nada   
   }
  } 
  else
  {
   SetDefaultPath();
  }
 }
 catch(e)
 {
  IW_LogOff();
 }
 
}

function AppEmAtualizacao()
{
 try
 {
  JRAjax.AppEmAtualizacao(ID,SessionID, self.EmAtualizacaoBloqueado, self.IWEmAtualizacaoBloq, cbk_GenericCallBack);
 }
 catch(E)
 {
  self.trmEmAtualizacao = setTimeout("AppEmAtualizacao()",10000); 
 }
 
}

//** Efetuar LogOff *****************************************************************************************************************************
function IW_LogOff()
{  
 try
 {
  JRAjax.LogOff(ID,SessionID,cbk_IW_LogOff);
 }
 catch(e)
 {
 }
}

function cbk_IW_LogOff(Request)
{
 if (Request.value)
 {
  self.Matricula = "";
  self.JRPWK     = "";

  SetDefaultPath();

  clearTimeout(trmHelpDesk);
  trmHelpDesk    = null;
 }
 
}

function SetDefaultPath()
{
 try
 {
  JRAjax.SetDefaultPath(ID,SessionID,cbk_SetDefaultPath)
 }
 catch(E)
 {
  return alert(AjaxNotFound);
 }
}

function cbk_SetDefaultPath(Request)
{
 LoadInnerHtml("tdHome",Request.value[2]);
 if (!HideLayer)
  LoadInnerHtml("tdMenu",Request.value[3]);
}


function IW_DestroySession()
{
 try
 {
  JRAjax.IW_DestroySession(ID,DBIndex,SessionID,cbk_IW_DestroySession);
 }
 catch(E)
 {
  //faz nada
 }

}

function cbk_IW_DestroySession()
{
 //faz Nada
}
//* Função Calendário **************************************************************************************************************
function GetCalendario(StrControl)
{
 Control = document.getElementById(StrControl);
 
 if (!Control)
  return alert(ComponentNotFound);
  
                     
 if ((!Control.disabled) && (Control.style.visibility.toLowerCase() != 'hidden'))
 {
  ShowForm('Calendário','Calendario.aspx?Control=' + StrControl + '&Data='+Control.value);
 } 
}

function SetCalendario(StrControl,StrData,FormName)
{
 Control = document.getElementById(StrControl);
 
 if (!Control)
  return alert(ComponentNotFound);
  
 Control.value = StrData;
 CloseForm(FormName);
 JRAjax.SetEdicao(ID,SessionID,Matricula + ".LastDate",StrData,cbk_NoCallBack);
}

function GetCalendarioFunction(StrFunction)
{
 var StrArgs = "";
 for (i = 1; i < arguments.length; i++)
 {
  StrArgs += "&Args_" + i + "=" + arguments[i];
 }
 ShowForm('Calendário','Calendario.aspx?Function=' + StrFunction + '&Data=' + StrArgs);
}

function SetCalendarioFunction(StrFunction,StrData,FormName)
{
 var StrArgs = "";
 for (i = 3; i < arguments.length; i++)
 {
  StrArgs += ",'" + arguments[i] + "'";
 }

 try
 {
  new Function(StrFunction + "('" + StrData + "'" + StrArgs + ");")();
  CloseForm(FormName);
  JRAjax.SetEdicao(ID,SessionID, Matricula + ".LastDate",StrData,cbk_NoCallBack);
 } 
 catch(e)
 {
  return alert('Falha ao Acessar a função "'+StrFunction+'"!');
 }
}

function cbk_GenericCallBack(Request)
{
 ShowAguarde(false);

 if (!Request.value[0])
 {
  alert(Request.value[1]);
  var Control = document.getElementById(Request.value[2]);
  
  if (Control)
  {
   Control.focus();
   Control.style.backgroundColor = 'red';
  }
  
  return false;
 }
 
 try
 {
  new Function(Request.value[3])();
 }
 catch(e)
 {
  return alert("Falha ao executar a função!");
 }
}

function cbk_NoCallBack(Request)
{
 ShowAguarde(false);
}

function SetAlertHint(StrSender, intTime)
{
 var Sender = document.getElementById(StrSender);
 
 if (!Sender)
  return false;
  
 intTime--;
 if (intTime > 0)
 {    
  if ((Sender.style.backgroundColor == '#FFFFE1') || (Sender.style.backgroundColor == 'rgb(255, 255, 225)'))
  {
   Sender.style.backgroundColor = '#E1E1E1';
  }
  else
  {
   Sender.style.backgroundColor = '#FFFFE1';
  }
  setTimeout("SetAlertHint('" + StrSender + "'," + intTime +")",500);
 }
 else
 {
  Sender.style.backgroundColor = '#FFFFE1';
 }
}

function CloseHint(StrSender, Hint)
{
 if (confirm("Deseja fechar a mensagem?\nCaso sim, ela não irá aparecer novamente."))
 {
  try
  {
   JRAjax.CloseHint(ID,SessionID,StrSender,Hint,cbk_GenericCallBack);
  }
  catch(e)
  {
  
  }
  finally
  {
  
  }
 }
}

function OnLoadHttp(frmHorarios, InnerHtml)
{

 while (InnerHtml.toString().indexOf("#39") >= 0)
 {
  InnerHtml = InnerHtml.toString().replace("#39","'");
 }
 
 if ((frmHorarios) && (frmHorarios.contentWindow) && (frmHorarios.contentWindow))
 {
  Doc = frmHorarios.contentWindow.document;

  if (isIE)
  {
   Doc.write(InnerHtml);
  }
  else
  {
   Doc.body.innerHTML = InnerHtml;
  }
 }
}


//** Gerar PDF ***********************************************************************************************************************

function IW_GerarPDF(Url, Width, Height, Paisagem)
{
 if ((Width == null) || (Width == NaN))
  Width = '';
 if ((Height == null)  || (Height == NaN) )
  Height = '';
 if ((Paisagem == null)  || (Paisagem == NaN) )
  Paisagem = false;
 
 try
 {
  ShowAguarde(true);
  JRAjax.IW_GerarPDF(ID,SessionID,Url,Width,Height,Paisagem,cbk_IW_OpenPDF);
 }
 catch(e)
 {
  ShowAguarde(false);
  alert(AjaxNotFound);
 }
}

//** Abrir PDF Gerado ****************************************************************************************************************
function cbk_IW_OpenPDF(Request)
{
 ShowAguarde(false);
 
 if (!Request.value[0])
 {
  return alert(Request.value[1]);
 }

 self.open(Request.value[3],"_blank");
}


function PistarControl(StrControl)
{
 var Control = document.getElementById(StrControl);
 
 if (Control)
 {
  Control.style.visibility = (Control.style.visibility.toLowerCase() == "visible") ? "hidden" : "visible";
  setTimeout("PistarControl('" + StrControl + "')",500);
 }
}


//** Bloquear Tela *********************************************************************************************************

function BloquearTela(isBloq, isIWBloq)
{
 if (self.IWEmAtualizacaoBloq != isIWBloq)
 {
  self.IWEmAtualizacaoBloq = isIWBloq;
  
  if (!self.IWEmAtualizacaoBloq)
  {
   self.window.location = self.window.location;
   return false;
  }
 }

 if (self.EmAtualizacaoBloqueado != isBloq)
 {
  self.EmAtualizacaoBloqueado = isBloq;

  var Filtro = document.getElementById("FiltroBloqTela");
  var Form = document.getElementById("FormBloqTela");

  if (Filtro == null)
  {
   Filtro     = document.createElement("div");
   Filtro.id  = "FiltroBloqTela";
   document.body.appendChild(Filtro);
   
   var Form  = document.createElement("div");
   Form.id   = "FormBloqTela";
   document.body.appendChild(Form);
   
   
   Filtro.style.position        = 'absolute';
   Filtro.style.width           = '500px';
   Filtro.style.height          = '500px';
   Filtro.style.left            = '0px';
   Filtro.style.top             = '0px';
   Filtro.style.backgroundColor = '#000000';
   Filtro.style.opacity         = '0.7';
   Filtro.style.filter          = 'alpha(opacity=70)';
   Filtro.style.zIndex          = 0;
   Filtro.align                 = "center";
   Filtro.valign                = "middle";
   
   Form.style.position        = 'absolute';
   Form.style.width           = '494px';
   Form.style.height          = '272px';
   Form.style.left            = '100px';
   Form.style.top             = '100px';
   Form.style.zIndex          = 0;
   Form.align                 = "center";
   Form.valign                = "middle";
   
   LoadInnerHtml("FormBloqTela","TelaBloqueada.aspx");
  } 
  
  Filtro.style.visibility = (isBloq) ? 'visible' : 'hidden';
  Form.style.visibility = (isBloq) ? 'visible' : 'hidden';
  PositionTelaBloqueada();
  setTimeout("PositionTelaBloqueada();",500);
 }
}

function PositionTelaBloqueada()
{
 
 var Filtro = document.getElementById("FiltroBloqTela");
 var frmPrincipal  = document.getElementById("tblPrincipal") || document.getElementById("tdHome") || document.body;
 
 if (Filtro && frmPrincipal && (Filtro.style.visibility.toLowerCase() == 'visible'))
 {
  var window_width    = frmPrincipal.offsetWidth;
  var window_height   = frmPrincipal.offsetHeight;
  
  if (document.body.clientWidth > window_width)
   window_width = document.body.clientWidth;
  if (document.body.clientHeight > window_height)
   window_height = document.body.clientHeight;
  if (document.body.offsetHeight > window_height)
   window_height = document.body.offsetHeight;
  
  Filtro.style.left        = 0+'px';
  Filtro.style.top         = 0+'px';
  Filtro.style.width       = window_width+'px';
  Filtro.style.height      = window_height+'px';
  setTimeout("PositionTelaBloqueada();",500);
  PositionForm('BloqTela');
 } 
}
