/////////////////
/* GRAYSCREEEN */
/////////////////

var garyScreenIsOn = false;

function getMultiWinWidth()
{
  var viewportwidth;
 
  // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
  if (typeof window.innerWidth != 'undefined')
  {
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
  }
 
  // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
  else if (typeof document.documentElement != 'undefined'
      && typeof document.documentElement.clientWidth !=
      'undefined' && document.documentElement.clientWidth != 0)
  {
       viewportwidth = document.documentElement.clientWidth,
       viewportheight = document.documentElement.clientHeight
  }
 
  // older versions of IE 
  else
  {
       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
       viewportheight = document.getElementsByTagName('body')[0].clientHeight
  }
    
  return(parseInt(viewportwidth)); 
}//getMultiWinWidth

function getMultiWinHeight()
{
  var viewportwidth;
  var viewportheight;
 
  // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
  if (typeof window.innerWidth != 'undefined')
  {
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
  }
 
  // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
  else if (typeof document.documentElement != 'undefined'
      && typeof document.documentElement.clientWidth !=
      'undefined' && document.documentElement.clientWidth != 0)
  {
       viewportwidth = document.documentElement.clientWidth,
       viewportheight = document.documentElement.clientHeight
  }
 
  // older versions of IE 
  else
  {
       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
       viewportheight = document.getElementsByTagName('body')[0].clientHeight
  }
    
  return(parseInt(viewportheight));  
}//getWinHeight
/**/
  
function GrayScreenOff()
{
  garyScreenIsOn = false;
  document.getElementById('loadingbox').style.display = 'none';
  document.getElementById('grayscreen').style.width = '0px';
  document.getElementById('grayscreen').style.height = '0px';
}

var tLoadingTextPosTimer = false;
function GrayScreen_LoadingPosition()
{
  //var myScrollLeft = parseInt( (document.all)?document.body.scrollLeft:window.pageXOffset );
  //var myScrollTop = parseInt( (document.all)?document.body.scrollTop:window.pageYOffset );
  
  document.getElementById('loadingbox').style.display = '';
  document.getElementById('loadingbox').style.zIndex = 2;
  
  document.getElementById('loadingbox').style.top = parseInt(  (getMultiWinHeight()/2) - (parseInt(document.getElementById('loadingbox').offsetHeight)/2)  )+'px';
  document.getElementById('loadingbox').style.left = parseInt(  (parseInt(document.getElementById('grayscreen').style.width)/2) - (parseInt(document.getElementById('loadingbox').offsetWidth)/2)  )+'px';
  
  //alert( document.getElementById('loadingbox').style.top + " / " + getMultiWinHeight() )
  
  document.getElementById('loadingbox').style.position = 'fixed';  
  //tLoadingTextPosTimer = setTimeout("GrayScreen_LoadingPosition()",30);
}

function GrayScreenOn()
{
  garyScreenIsOn = true;

  // gray div
  if ( document.body.offsetHeight > document.body.scrollHeight)
    document.getElementById('grayscreen').style.height = parseInt(document.body.offsetHeight)+'px';
  else
    document.getElementById('grayscreen').style.height = parseInt(document.body.scrollHeight)+'px';
    
  if ( document.body.offsetWidth > document.body.scrollWidth)
    document.getElementById('grayscreen').style.width = parseInt(document.body.offsetWidth)+'px';
  else
    document.getElementById('grayscreen').style.width = parseInt(document.body.scrollWidth)+'px';

  document.getElementById('grayscreen').style.zIndex = 1;
  
  //loading div
  GrayScreen_LoadingPosition();
}

window.onresize = function() 
{
  if (garyScreenIsOn)
    GrayScreenOn();
}

//document.observe('dom:loaded', function () { GrayScreenOn(); });
