function dialog(elm) {
    var x, y;
    var w, h;
    var parent;
    
    parent = elm.parentNode;
    w = parseInt(elm.clientWidth);
    h = parseInt(elm.clientHeight);
    x = (parseInt(parent.clientWidth) - w) / 2;
    y = (parseInt(parent.clientHeight) - h) / 2;
    pageOffset(parent);
    x = x + parent.pageOffsetLeft;
    y = y + parent.pageOffsetTop;
    
    elm.style.left = x + "px";
    elm.style.top = y + "px";
    elm.style.visibility = "visible";
}

function dialog_close(elm) {
    elm.style.visibility = "hidden";
    elm.style.top = "0px";
    elm.style.left = "0px";
}

function get_elm(name) {
    return document.getElementById(name);
}

function pageOffset(o) {
    var x, y;
    var p;
    
    x = y = 0;
    p = o;
    while(p.offsetParent) {
        x = x + p.offsetLeft;
	y = y + p.offsetTop;
	p = p.offsetParent;
    }
    
    o.pageOffsetLeft = x;
    o.pageOffsetTop = y;
}

