﻿// JScript File

// Move an element directly on top of another element (and optionally
// make it the same size)
function Cover(bottom, top, ignoreSize) {
    var location = Sys.UI.DomElement.getLocation(bottom);
    top.style.position = 'absolute';
    top.style.top = location.y + 'px';
    top.style.left = location.x + 'px';
    if (!ignoreSize) {
        top.style.height = bottom.offsetHeight + 'px';
        top.style.width = bottom.offsetWidth + 'px';
    }
}



 function ExecutaEnter(code, campo){

   if (code == 13) {

      document.getElementById(campo).focus();
   
   }
    
}

function Loga()
{
   var keynum;
   keynum = window.event.keyCode;
   if (keynum == 13)
   {
      document.getElementById("ctl00_Cabecalho1_WebPartManager1_gwpLoginRX_LoginRX_LoginImageButton").focus();
      //WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$Cabecalho1$WebPartManager1$gwpLoginRX$LoginRX$LoginImageButton&quot;, &quot;&quot;, true, &quot;ctl00$Cabecalho1$WebPartManager1$gwpLoginRX$LoginRX&quot;, &quot;&quot;, false, false));
   }
}


function IncrementaDecrementa(campo, valor)
{
   valorCampo = document.getElementById(campo).value;
   if(valorCampo == "")
   {
      valorCampo = "0";
   }
   numero = parseInt(valorCampo);
   numero = numero + valor;
   if(numero > 0)
   {
      document.getElementById(campo).value = numero;
   }
}

function SetUniqueRadioButton(nameregex, current)
{
   re = new RegExp(nameregex);
   for(i = 0; i < document.forms[0].elements.length; i++)
   {
      elm = document.forms[0].elements[i]
      if (elm.type == 'radio')
      {
         if (re.test(elm.name))
         {
            elm.checked = false;
         }
      }
   }
   current.checked = true;
}

var prm = Sys.WebForms.PageRequestManager.getInstance();
function CancelAsyncPostBack() 
{
    if (prm.get_isInAsyncPostBack()) 
    {
      prm.abortPostBack();
    }
}

if(prm != null)
{
   prm.add_initializeRequest(InitializeRequest);
   prm.add_endRequest(EndRequest);
}

var postBackElement;
function InitializeRequest(sender, args) 
{
    if (prm.get_isInAsyncPostBack()) 
    {
        args.set_cancel(true);
    }
    postBackElement = args.get_postBackElement();
    $get('upProgress').style.display = 'block';                
}
function EndRequest(sender, args) 
{
    $get('upProgress').style.display = 'none';
}