<!--
/*
+----------------------------------------------------------------------------------------------
| gotopage 3.0 - Content Management by Rosman
| Copyright (c) 2003 - 2005 Rosman (http://www.rosman.co.at)
|
| Author(s): Johan Rosman <johan@rosman.co.at>
| Credits:   Peter-Paul Koch (http://www.quirksmode.org)
+----------------------------------------------------------------------------------------------
| Purpose
| dhtml support: browser independant finding of objects and their positions on the screen
+----------------------------------------------------------------------------------------------
| Version   Date         Comment
| 3.03      2005/10/13   issue 136: height & width function added
| 3.02      2005/06/10   procedural->object
| 3.01      2004/11/19   initial version
+----------------------------------------------------------------------------------------------
*/

if ( !window._dhtml ) {
/*
+----------------------------------------------------------------------------------------------
| public part
+----------------------------------------------------------------------------------------------
*/
    // constructor initialises the properties:
    // name, dhtml, obj and style
    var _dhtml = function ( _name ) {
        this.name = _name;
        this.dhtml = ( document.getElementById || document.all || document.layers);
        if ( document.getElementById ) {
            this.obj = document.getElementById ( _name );
        } else if ( document.all ) {
            this.obj = document.all[_name];
        } else if ( document.layers ) {
            this.obj = this.getobj_NN4 (document, _name);
        }
        if ( this.obj ) {
            this.style = this.obj.style;
        }
    } // _dhtml (constructor)

    // returns the x position on the screen
    _dhtml.prototype.x = function () {
        // calculate position only once on request
        if ( !this.pos_x ) this.position();
        return this.pos_x;
    } // x

    // returns the y position on the screen
    _dhtml.prototype.y = function () {
        // calculate position only once on request
        if ( !this.pos_y ) this.position();
        return this.pos_y;
    } // y

    // returns the height in pixels of an object
    _dhtml.prototype.height = function() {
        if ( this.obj.offsetHeight )      return this.obj.offsetHeight;
        else if ( this.obj.pixelHeight )  return this.obj.pixelHeight;
        else                              return 0;
    }

    // returns the width in pixels of an object
    _dhtml.prototype.width = function() {
        if ( this.obj.offsetWidth )      return this.obj.offsetWidth;
        else if ( this.obj.pixelWidth )  return this.obj.pixelWidth;
        else                             return 0;
    }

    // returns the object (for cross window scripting)
    _dhtml.getobj = function ( _name ) {
        var _obj = new _dhtml ( _name );
        return _obj;
    } // getobj

/*
+----------------------------------------------------------------------------------------------
| private part
+----------------------------------------------------------------------------------------------
*/
    // browser independand position calculation
    _dhtml.prototype.position = function () {
        this.pos_x = 0;
        this.pos_y = 0;
        if (this.obj.offsetParent) {
            var _tmpobj = this.obj
            while (_tmpobj.offsetParent) {
                this.pos_y += _tmpobj.offsetTop;
                _tmpobj = _tmpobj.offsetParent;
            }
            var _tmpobj = this.obj
            while (_tmpobj.offsetParent) {
                this.pos_x += _tmpobj.offsetLeft;
                _tmpobj = _tmpobj.offsetParent;
            }
        } else {
            if (this.obj.x) this.pos_x += this.obj.x;
            if (this.obj.y) this.pos_y += this.obj.y;
        }
    } // position

    // internal helper function for constructor
    _dhtml.prototype.getobj_NN4 = function ( _obj, _name ) {
        var _x = _obj.layers;
        var _found_layer;
        for (var _i=0; _i<_x.length; _i++) {
            if (_x[_i].id == _name)
                _found_layer = _x[_i];
            else if (_x[_i].layers.length)
                var _tmp =
                       this.getobj_NN4(_x[_i],_name);
            if (_tmp) _found_layer = _tmp;
        }
        return _found_layer;
    } // getobj_NN4

}
-->
