﻿
//http://forums.asp.net/t/1086380.aspx
//http://www.softcomplex.com/docs/get_window_size_and_scrollbar_position.html
function getBrowserHeight()
{
  var intH = 0;
  var intW = 0;
  var intScrollLeft = 0;
  var intScrollTop = 0;

  if (typeof window.innerWidth == 'number')
  {
    intH = window.innerHeight;
    intW = window.innerWidth;
    intScrollLeft = window.pageXOffset;
    intScrollTop = window.pageYOffset; 
  }
  else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
  {
    intH = document.documentElement.clientHeight;
    intW = document.documentElement.clientWidth;
    intScrollLeft = document.documentElement.scrollLeft;
    intScrollTop = document.documentElement.scrollTop;
  }
  else if (document.body && (document.body.clientWidth || document.body.clientHeight))
  {
    intH = document.body.clientHeight;
    intW = document.body.clientWidth;
    intScrollLeft = document.body.scrollLeft;
    intScrollTop = document.body.scrollTop; 
  }

  return { width: parseInt(intW), height: parseInt(intH), scrollLeft: parseInt(intScrollLeft), scrollTop: parseInt(intScrollTop) };
}


function DisplayModalMessage(backgroundDiv, contentDiv)
{
  var bws = getBrowserHeight();

  if (document.getElementById(backgroundDiv) != null)
  {
    document.getElementById(backgroundDiv).style.height = document.body.offsetHeight + 'px';
    document.getElementById(backgroundDiv).style.display = 'block';
  }
  
  document.getElementById(contentDiv).style.display = 'block';

  var _left = (bws.scrollLeft + (parseInt(bws.width) - document.getElementById(contentDiv).offsetWidth) / 2) + 'px';
  var _top = (bws.scrollTop + (parseInt(bws.height) - document.getElementById(contentDiv).offsetHeight) / 2) + 'px';

  document.getElementById(contentDiv).style.left = _left;
  document.getElementById(contentDiv).style.top = _top;
  document.getElementById(contentDiv).style.display = 'block';

}

function HideModalMessage(backgroundDiv, contentDiv)
{
  if (document.getElementById(backgroundDiv) != null)
  {
    document.getElementById(backgroundDiv).style.display = 'none';
  }
  document.getElementById(contentDiv).style.display = 'none';  
}


