﻿// Funciones para masters.
var DHTML = (document.getElementById || document.all || document.layers);
 
function ap_getObj(name) {
   if (document.getElementById)
      { return document.getElementById(name).style; }
   else if (document.all)
      { return document.all[name].style; }
   else if (document.layers)
      { return document.layers[name]; }
}

function ap_showWaitMessage(div,flag) {
   if (!DHTML) return;
   var x = ap_getObj(div);
   x.visibility = (flag) ? 'visible':'hidden'
   if(! document.getElementById) if(document.layers) x.left=280/2;
   //obtenemos info del navegador
   var navegador = new Browser();
   //si el navegador es el 6.0 cambiamos estilos de la capaContenido
   if (navegador.version==6)
   {
        //posicionamos el coche fantástico para IE6.0
        var lCapa=document.getElementById(div);
        lCapa.style.marginLeft=eval(window.screen.availWidth/2)-100;
        lCapa.style.marginTop=eval(window.screen.availHeight/2)-50;
   }
   return true; 
} 
ap_showWaitMessage('waitDiv', 3);
 
function calculoCapaContenido() {
   var lSumatorio=0;
   var lCabecera=document.getElementById("CabeceraLogo");
   if (lCabecera != null)
   {
      lSumatorio=lCabecera.clientHeight;
   }
   //Calculamos altura menu
   var lMenu=document.getElementById("ctl00_tablaMenu");
   if (lMenu != null)
   {
      lSumatorio=lSumatorio + lMenu.clientHeight;
   }
   //Calculamos altura titulo
   var lTitulo=document.getElementById("tituloCabecera");
   if (lTitulo != null)
   {
      lSumatorio = lSumatorio + lTitulo.clientHeight;
   }  
   
   var lMenuCal=document.getElementById("menuCal");
   if (lMenuCal != null)
   {
      lSumatorio = lSumatorio + lMenuCal.clientHeight;
   }
   
   //Obtenemos capa
   var lContenido=document.getElementById("capaContenido");
   if (lContenido != null)
   {
      //en el caso de programa por defecto se hace uso de alert al grabar datos
      //en lugar del texto de umbral provocando que el parentnode.clientheight
      //sea 0 dando lugar a un lcontenido.style.height negativo provocando el
      //respectivo error de js.
      if (document.body.parentNode.clientHeight<lSumatorio )
      {
         lContenido.style.height=document.body.clientHeight-lSumatorio;
      }
      else
      {
         lContenido.style.height=document.body.parentNode.clientHeight-lSumatorio +'px';
      }
      
      //obtenemos info del navegador
      var navegador = new Browser();
      //si el navegador es el 6.0 cambiamos estilos de la capaContenido
      if (navegador.version==6 || navegador.isFirefox==true)
      {
         lContenido.style.width='100%';
         lContenido.style.overflowY='auto';
      }
   }
   
   var lCalendarios=document.getElementById("jmc");
   if (lCalendarios != null)
   {
      if (document.body.parentNode.clientHeight<lSumatorio )
      {
         lCalendarios.style.height=document.body.clientHeight-lSumatorio;
      }
      else
      {
         lCalendarios.style.height=document.body.parentNode.clientHeight-lSumatorio +'px';
      }
      //obtenemos info del navegador
      var navegador = new Browser();
      //si el navegador es el 6.0 cambiamos estilos de la capaContenido
      //if (navegador.version==6 || navegador.isFirefox==true)
      //{
      lCalendarios.style.width='100%';
      lCalendarios.style.overflowY='auto';
      //}
   }
}

 
function CerrarVentana()
{
   var win = window.self;
   win.opener=window.self;
   win.close();
}
 
