﻿function custom_WindowHeight()
{
  var windowHeight;
  
  if(window.innerHeight)
  {
    windowHeight = windowHeight = window.innerHeight;
  }
  else if (document.documentElement.clientHeight) 
  {
    windowHeight = document.documentElement.clientHeight;
  }
  else
  {
    windowHeight = document.body.clientHeight;
  }
  
  //document.getElementById("txtWindowHeight").value = windowHeight;
  return windowHeight;
  
}
  
function custom_WindowWidth()
{
var windowWidth;
  
  if(window.innerWidth)
  {
    windowHeight = windowWidth = window.innerWidth;
  }
  else if (document.documentElement.clientWidth) 
  {
    windowWidth = document.documentElement.clientWidth;
  }
  else
  {
    windowWidth = document.body.clientWidth;
  }
  //document.getElementById("txtWindowWidth").value = windowWidth;
  return windowWidth;
}

function custom_ScrollLeft() 
{
  var scrollLeft = 0;
  if (document.documentElement && document.documentElement.scrollLeft) 
  {
      scrollLeft = document.documentElement.scrollLeft;
  }
  else if (document.body) 
  {
      scrollLeft = document.body.scrollLeft;
  }
  //document.getElementById("txtScrollX").value = scrollLeft;
  return scrollLeft;
}

function custom_ScrollTop() 
{
  var scrollTop = 0;
    if (document.documentElement && document.documentElement.scrollTop) 
    {
        scrollTop = document.documentElement.scrollTop;
    }
    else if (document.body) 
    {
        scrollTop = document.body.scrollTop;
    }
    //document.getElementById("txtScrollY").value = scrollTop;
    return scrollTop;
}

function PositionPopup()
{
 
  var background = document.getElementById("pnlBackground");
  if(!background)
  {
    background = document.getElementById("ctl00_pnlBackground");
  }
  if(background)
  { 
    background.style.left = custom_ScrollLeft() + "px";
    background.style.top = custom_ScrollTop() + "px";
    background.style.height = custom_WindowHeight() + "px"; 
    background.style.width = custom_WindowWidth() + "px";
  }
  
  var popup = document.getElementById("pnlPopup");
  if(!popup)
  {
    popup = document.getElementById("ctl00_pnlPopup");
  }
  if(popup)
  {
    popup.style.left = custom_ScrollLeft() + (custom_WindowWidth() - parseFloat(popup.style.width)) / 2 + 'px';
    popup.style.top = custom_ScrollTop() + (custom_WindowHeight() - parseFloat(popup.style.height)) / 2 + 'px';
  }
}

