﻿    // JScript File

    //*********************************************************************************************
    //Displays a div and centers it in the client window
    //*********************************************************************************************
    function ShowDivCentered(pDivID)
    {
        var _elem = document.getElementById(pDivID);
        
        if (_elem != null)
        {
            _elem.style.left = '25%';
            _elem.style.top = '10%';
            _elem.style.display = "block";        
        }        
        
        return false;
    }
    
    function ShowDivAtCurrentPos(pDivID, pShow)
    {
        var _elem = document.getElementById(pDivID);
        
        if (pShow == 'true')
        {
            _elem.style.left = event.clientX;
            _elem.style.top = event.clientY;
            _elem.style.display = "block";        
        }
        else
        {
            _elem.style.display = "none";        
        }
    }
    
    
    function getWindowHeight() 
    {
      var windowHeight = 0;
      if (typeof(window.innerHeight) == 'number') 
      {
        windowHeight = window.innerHeight;
      }
      else 
      {
        if (document.documentElement && document.documentElement.clientHeight) 
        {
          windowHeight = document.documentElement.clientHeight;
        }
        else 
        {
          if (document.body && document.body.clientHeight) 
          {
            windowHeight = document.body.clientHeight;
          }
        }
      }
      
      return windowHeight;
    }

    function setContent(pDiv) 
    {
      if (document.getElementById) 
      {
        var windowHeight = getWindowHeight();
        if (windowHeight > 0) 
        {
          var contentElement = document.getElementById(pDiv);
          var contentHeight = contentElement.offsetHeight;
          if (windowHeight - contentHeight > 0) 
          {
            contentElement.style.top = ((windowHeight / 2) - (contentHeight / 2)) + 'px';
          }
        }
      }
    }
    
    function toggleShowDiv(pCheckBox, pDivID, pClassHide, pClassShow, pClassFont)
    {
        var _elem = document.getElementById(pDivID);
        var _cb = document.getElementById(pCheckBox);
        
        if (_elem == null || _cb == null)
            return;
            
        if (_cb.checked)
        {
            _elem.className = pClassShow + " " + pClassFont;        
        }
        else
        {
            
            _elem.className = pClassHide;        
        }
    }
