	  
	  // placeholder for the ID of the currently visible dialog window
      var activeDlgID;
      
      // due to bugs in Mozilla which prevent the window.onscroll event
      // from firing properly (on a mousewheel), it was necessary to use
      // a timeout to keep the dialog centered on the screen. This variable
      // stores the ID of the timeout call.
      var timeoutID;
      
      function activateImanDialog(id)
      {
      	if(id == null || id.length == 0)
      	{
      		return false;
      	}
      	activeDlgID = id;
      	dlgObject = document.getElementById(id);
        centerImanDialog();
      	dlgObject.style.display = "block";
      	if(document.getElementById(id+"_greyout") != null)
      	{
      		document.getElementById(id+"_greyout").style.display = "block";
      	}
      }
      
      function deactivateImanDialog(id)
      {
        if(id == null || id.length == 0)
      	{
      		return false;
      	}
        document.getElementById(id).style.display = "none";
        if(document.getElementById(id+"_greyout") != null)
      	{
      		document.getElementById(id+"_greyout").style.display = "none";
      	}
      	activeDlgID = "";
      	window.clearTimeout(timeoutID);
      }
      
      function centerImanDialog()
      {
      	var id = activeDlgID;
      	var center = eval(id+"_center");
      	if(id == null || id.length == 0 || !center)
      	{
      		return false;
      	}
        var dlg = document.getElementById(id);
        var dlgBody = document.getElementById(id+"_body");
        setImanDialogScreenVars();
        yPos = document.scrollTop+(document.screenHeight - parseInt(dlgBody.style.height,10))/2;
        if(yPos < 0)
        {
           yPos = 0;
        }
        xPos = document.scrollLeft+(document.screenWidth - parseInt(dlgBody.style.width,10))/2;
        if(xPos < 0)
        {
           xPos = 0;
        }
        dlg.style.top = yPos+"px";
        dlg.style.left = xPos+"px";
        if(document.getElementById(id+"_greyout") != null)
        {
        	document.getElementById(id+"_greyout").style.top = document.scrollTop+"px";
        	document.getElementById(id+"_greyout").style.left = document.scrollLeft+"px";
        }
        timeoutID = window.setTimeout(centerImanDialog, 10);
      }
      
      function setImanDialogScreenVars()
      {
        //get the height and width
        if(window.innerHeight)
        {
        	document.screenHeight = window.innerHeight;
        	document.screenWidth = window.innerWidth;
        }
        else if(document.documentElement && document.documentElement.clientHeight) 
        {
        	document.screenHeight = window.innerHeight;
        	document.screenWidth = window.innerWidth;
        }	
        else if(document.body && document.body.clientHeight)
        {
        	document.screenHeight = document.body.clientHeight;
        	document.screenWidth = document.body.clientWidth;
        }
        else
        {
        	document.screenHeight = 0;
        	document.screenWidth = 0;
        }
        
        //get the scrolling X and Y offsets	
        if(document.documentElement && document.documentElement.scrollTop)
        {
        	document.scrollTop = document.documentElement.scrollTop;
        	document.scrollLeft = document.documentElement.scrollLeft;
        }
        else
        {
        	document.scrollTop = document.body.scrollTop;
        	document.scrollLeft = document.body.scrollLeft;
        }
      }
      
      