/*
    This script-routines handles the MessageBox show and hide functions.
*/

  var intBodyHeight;

  function ShowMessageBox(messageBoxID)
  {
      var objParentPanel;
      var objMessageBox;
      var objCurtain;
      
      var intWidth;
      var intHeight;

      // The message box has a curtain div and in the curtain the client div, the message box
      if(typeof messageBoxID == 'string')
          objParentPanel = document.getElementById(messageBoxID);
      else if(typeof messageBoxID == 'object')
          objParentPanel = messageBoxID;
      else
          return true;

      objParentPanel.style.display = 'block';

      // The curtain box div is always the first element
      objCurtain = objParentPanel.getElementsByTagName('div')[0];
      // The message box div is always the second element
      objMessageBox = objParentPanel.getElementsByTagName('div')[1];
      
	  if (document.documentElement.clientHeight > document.body.clientHeight)
	      intHeight = document.documentElement.clientHeight;
	  else
		  intHeight = document.body.clientHeight;
		
	  if (document.documentElement.scrollWidth > document.body.clientWidth)
		  intWidth = document.documentElement.scrollWidth;
	  else
		  intWidth = document.body.clientWidth;
		           
      objCurtain.style.display = 'block';
      objCurtain.style.position = 'absolute';
      objCurtain.style.top = '0px';
      objCurtain.style.left = '0px';
      objCurtain.style.width = Math.round(intWidth) + 'px';
      objCurtain.style.height = Math.round(intHeight) + 'px';
      
      objMessageBox.style.display = 'block';
      objMessageBox.style.top = Math.round((document.documentElement.clientHeight - objMessageBox.offsetHeight) / 2 + document.documentElement.scrollTop) + 'px';
      objMessageBox.style.left = Math.round((document.documentElement.clientWidth - objMessageBox.clientWidth) / 2 + document.documentElement.scrollLeft) + 'px';

      return false;
  }

  function HideMessageBox(messageBoxID)
  {
      var objParentPanel;
      var objMessageBox;
      var objCurtain;

      if(typeof messageBoxID == 'string')
          objParentPanel = document.getElementById(messageBoxID);
      else if(typeof messageBoxID == 'object')
          objParentPanel = messageBoxID
      else
          return true;

      // The message box div is always the first element
      objCurtain = objParentPanel.getElementsByTagName('div')[0];
      // The message box div is always the second element
      objMessageBox = objParentPanel.getElementsByTagName('div')[1];

      objMessageBox.style.display = 'none';
      objCurtain.style.display = 'none';
      objParentPanel.style.display = 'none';
      document.body.style.overflow = 'auto';

      return false;
  }

    function RaiseTargetControlClickEvent(strTargetControlID)
    {
        var objTargetControl;

        if(typeof strTargetControlID == 'string')
          objTargetControl = document.getElementById(strTargetControlID);
        else if(typeof strTargetControlID == 'object')
          objTargetControl = strTargetControlID
        else
          return;

        if(typeof objTargetControl.href != null)
            eval(objTargetControl.href);
        else if(objTargetControl.getAttribute('onclick') != null)
            eval(objTargetControl.getAttribute('onclick'));
            
        return false;
    }