
function Page() {
}


Page.isIE = document.all;
Page.isNN =! document.all && document.getElementById;
Page.isN4 = document.layers;


Page.writeAddr = function(user, host) {
    document.write(user);
    document.write('&#64;');
    document.write(host);
}

Page.isFlashInstalled = function(v) {
    if (v) {
    } else {
        v = 8;
    }
    return Page.isIE && isWindows && flashInstalled == 2 && flashVersion >= v;
}

Page.w = function(s) {
    document.write(s);
}

Page.getById = function(id) {
    var elem = null;
    if (document.getElementById) {
        elem = document.getElementById(id);
    } else if (document.all) {
        elem = document.all[id];
        if (!elem) {
            elem = eval('document.all.' + id);
        }
    } else if (document.layers) {
        elem = Page.getObjNN4(document, id);
    }

    if (!elem) {
        elem = document.getElementById(id);
    }                   
    return elem;  
}

Page.getObjNN4 = function(obj,name) {
    var x = obj.layers;
    var foundLayer;
    for (var i=0;i<x.length;i++) {
        if (x[i].id == name) {
            foundLayer = x[i];
        } else if (x[i].layers.length) {
            var tmp = getObjNN4(x[i],name);
            if (tmp) {
                foundLayer = tmp;
            }
        }
    }
    return foundLayer;
}


Page.getInnerHtml = function(element) {
    if (element.innerHTML != null) {
        return element.innerHTML;
    } else if (document.layers) {
        return element.document.read();
    }
}

Page.setInnerHtml = function(element, html) {
    if (element.innerHTML != null) {
        element.innerHTML = '';
        element.innerHTML = html;
    } else if (document.layers) {
        element.document.open();
        element.document.write(html);
        element.document.close();
    } else {
        element.innerHtml = '';
        element.innerHtml = html;
    }

    if (element.refresh) {
        element.refresh();
    }
    if (element.document && element.document.refresh) {
        element.document.refresh();
    }
}

Page.setVisible = function(element, vis) {
    if (Page.isIE || Page.isNN) {
        if (vis) {
            element.style.visibility = "visible";
        } else {
            element.style.visibility = "hidden";
        }
    } else if (Page.isN4) {
        if (vis) {
            element.style.visibility = "show";
        } else {
            element.style.visibility = "hide";
        }
    } else {
        if (vis) {
            element.style.visibility = "visible";
        } else {
            element.style.visibility = "hidden";
        }
    }
}

Page.isVisible = function(element) {
    if (Page.isIE || Page.isNN) {
        return element.style.visibility == "visible";
    } else if (Page.isN4) {
        return element.style.visibility == "show";
    } else {
        return element.style.visibility == "visible";
    }
}


Page.show = function(id) {
    var o = Page.getById(id);
    if (o) {
        Page.setVisible(o, true);
    }
}

Page.hide = function(id) {
    var o = Page.getById(id);
    if (o) {
        Page.setVisible(o, false);
    }
}








Page.getX = function(obj) {
    var curleft = 0;
    if (obj.offsetParent) {
        while (obj.offsetParent) {
            curleft += obj.offsetLeft
            obj = obj.offsetParent;
        }
    } else if (obj.x) {
        curleft += obj.x;
    }
    return curleft;
}



Page.getY = function(obj) {
    var curtop = 0;
    if (obj.offsetParent) {
        while (obj.offsetParent) {
            curtop += obj.offsetTop
            obj = obj.offsetParent;
        }
/*
        while (obj.parent && obj.parent != top) {
            curtop += obj.parent.offsetTop;
            obj = obj.parent;
        }
*/
    } else if (obj.y) {
        curtop += obj.y;
    }
    return curtop;
}



Page.setX = function(obj, x) {
    if (obj.style) {
        obj.style.left = x + 'px';
    } else if (obj.left) {
        obj.left = x + 'px';
    } else if (obj.x) {
        obj.x = x;
    }
}


Page.setY = function(obj, y) {
    if (obj.style) {
        obj.style.top = y + 'px';
    } else if (obj.top) {
        obj.top = y + 'px';
    } else if (obj.y) {
        obj.y = y;
    }
}


Page.getWidth = function(obj) {
    if (obj.clip && obj.clip.width) {
        return obj.clip.width;
    }
    if (obj.offsetWidth) {
        return obj.offsetWidth;
    }
    if (obj.width) {
        return obj.width;
    }
    if (obj.w) {
        return obj.w;
    }
    if (obj.style && obj.style.width) {
        return obj.style.width;
    }
    if (obj.style && obj.style.pixelWidth) {
        return obj.style.pixelWidth;
    }
    return -1;
}

Page.getHeight = function(obj) {
    if (obj.clip && obj.clip.height) {
        return obj.clip.height;
    }
    if (obj.offsetHeight) {
        return obj.offsetHeight;
    }
    if (obj.height) {
        return obj.height;
    }
    if (obj.h) {
        return obj.h;
    }
    if (obj.style && obj.style.height) {
        return obj.style.height;
    }
    if (obj.style && obj.style.pixelHeight) {
        return obj.style.pixelHeight;
    }
    return -1;
}





Page.setHeight = function(obj, h) {
    if (obj.clip && obj.clip.height) {
        obj.clip.height = h + "px";
        return;
    }
    if (obj.style && obj.style.height) {
        obj.style.height = h + "px";
        return;
    }
    if (obj.style && obj.style.pixelHeight) {
        obj.style.pixelHeight = h + "px";
        return;
    }
    if (obj.offsetHeight) {
        obj.offsetHeight = h;
        return;
    }
    if (obj.height) {
        obj.height = h;
        return;
    }
    if (obj.h) {
        obj.h = h;
        return;
    }
}


Page.setWidth = function(obj, w) {
    if (obj.clip && obj.clip.width) {
        obj.clip.width = w + "px";
        return;
    }
    if (obj.style && obj.style.width) {
        obj.style.width = w + "px";
        return;
    }
    if (obj.style && obj.style.pixelWidth) {
        obj.style.pixelWidth = w + "px";
        return;
    }
    if (obj.offsetWidth) {
        obj.offsetWidth = w;
        return;
    }
    if (obj.width) {
        obj.width = w;
        return;
    }
    if (obj.w) {
        obj.w = w;
        return;
    }
}
