/************************************************************
Example 4-4
"Dynamic HTML:The Definitive Reference"
2nd Edition
by Danny Goodman
Published by O'Reilly & Associates  ISBN 0-596-00316-1
http://www.oreilly.com
Copyright 2002 Danny Goodman.  All Rights Reserved.
************************************************************/

// Global 'corrector' for IE/Mac et al., but doesn't hurt others
var fudgeFactor = {top:-1, left:-1};

// Center a positionable element whose name is passed as 
// a parameter in the current window/frame, and show it
function centerIt(layerName) {
    // 'obj' is the positionable object
    var obj = getRawObject(layerName);
    // set fudgeFactor values only first time
    if (fudgeFactor.top == -1) {
        if ((typeof obj.offsetTop == "number") && obj.offsetTop > 0) {
            fudgeFactor.top = obj.offsetTop;
            fudgeFactor.left = obj.offsetLeft;
        } else {
            fudgeFactor.top = 0;
            fudgeFactor.left = 0;
        }
        if (obj.offsetWidth && obj.scrollWidth) {
            if (obj.offsetWidth != obj.scrollWidth) {
                obj.style.width = obj.scrollWidth;    
            }
        }
    }
    var x = Math.round((getInsideWindowWidth()/2) - (getObjectWidth(obj)/2));
    var y = Math.round((getInsideWindowHeight()/2) - (getObjectHeight(obj)/2));
    shiftTo(obj, x - fudgeFactor.left, y - fudgeFactor.top);
    show(obj);
}

// Special handling for CSS-P redraw bug in Navigator 4
function handleResize() {
    if (isNN4) {
        // causes extra re-draw, but gotta do it to get banner object color drawn
        location.reload();
    } else {
        centerIt("page");
    }
}
//window.onresize = handleResize;
