
    function initPopup(popupDiv, popupTitle) {
        // --- Initialize DOM drag ---
        // get the root (element) that will move when the handle is dragged
        var oRoot = document.getElementById(popupDiv);
        // get the handle (element) which will make the entire root move when dragged
        var oHandle = document.getElementById(popupTitle);

        // make sure both the root and the handle (popup_div and popup_handle) could be found
        if(oRoot && oHandle) {
            // specifies the handle (only area that permits drag for the root) and the root of the drag
            Drag.init(oHandle, oRoot);
            
            // NOTE : to drag an entire container without specifying a handle :
            // Drag.init(myPopupDiv);
            // NOTE : the element must have a relative or absolute position set in its style attributes
        }
    }
    
    function showPopup(popupId) {
        var popup = $(popupId);
        
        // make sure the given popup exists
        if(popup) {
            popup.style.display = '';
            centerPopup(popupId);             
        }
    }
    
    function closePopup(popupId) {
        var popup = $(popupId);
        
        // make sure the given popup exists
        if(popup) {
            popup.style.display = 'none';
        }
    }

function centerPopup(popupId) {
        if(oPopup = document.getElementById(popupId))
        {
            popupWidth = oPopup.clientWidth;
            popupHeight = oPopup.clientHeight;
            
            if(document.all)
            {
                parentWidth = document.body.clientWidth;
                //parentWidth = screen.width;
                parentHeight = document.body.clientHeight;
                //parentHeight = screen.height;
                
                pTop = document.documentElement.scrollTop;
                pLeft = document.documentElement.scrollLeft;
            }
            else
            {
                parentWidth = window.innerWidth;
                parentHeight = window.innerHeight;
                
                pTop = window.pageYOffset;
                pLeft = window.pageXOffset;
            }
            
            if(oPage = document.getElementById('laPage'))
            {
                parentWidth = oPage.offsetWidth;
            }
            
            if(parentWidth > 0)
            {
                var myLeft = (pLeft/2)+(parentWidth-popupWidth)/2;
                if(myLeft < 0)
                {
                    myLeft = 0;    
                }
                oPopup.style.left = myLeft+"px";
            }
            if(parentHeight > 0)
            {
                var myTop = (pTop/2)+(parentHeight-popupHeight)/2;
                if(myTop < 0)
                {
                    myTop = 0;    
                }
                oPopup.style.top = myTop+"px";
            }
        }
    }

    
    function centerPopup_old(popupId) {
        if(oPopup = document.getElementById(popupId))
        {
            popupWidth = oPopup.clientWidth;
            popupHeight = oPopup.clientHeight;
            
            var parentWidth  = 0;
            var parentHeight = 0;
            var pTop         = 0;
            var pLeft        = 0;
            
            if(document.all)
            {
                parentWidth = document.documentElement.scrollWidth;
                parentHeight = document.documentElement.scrollHeight;
                
                pTop = document.documentElement.scrollTop;
                pLeft = document.documentElement.scrollLeft;
            }
            else
            {
                parentWidth = window.innerWidth;
                parentHeight = window.innerHeight;
                
                pTop = window.pageYOffset;
                pLeft = window.pageXOffset;
            }
            
            if(oPage = document.getElementById('laPage'))
            {
                parentWidth = oPage.offsetWidth;
            }
            
            oPopup.style.left = (pLeft/2)+(parentWidth-popupWidth)/2+"px";
            oPopup.style.top = (pTop/2)+(parentHeight-popupHeight)/2+"px";
        }
    }

