//////////////////////////////////////////////////////////////////////////////
// Requires   http://www.bildarchiv-ostpreussen.de/js/base.js
//////////////////////////////////////////////////////////////////////////////

// absLeft(el)
// absRight(el)
// absTop(el)
// absBottom(el)
// getHeight(el)
// getWidth(el)
// getScrollbarsVisible()



//var ie  = !!document.all;
//var nc  = !!(document.captureEvents && !document.getElementById);
//var nc6 = !!(document.captureEvents && document.documentElement);


// Liefert die absolute linke Position eines Elementes zurueck:
function absLeft(el) {
        if (!el) { return 0; }
	var t = typeof el;
	if (t.toLowerCase() == 'string') {
		el = getEl(el);
	}
        return _absLeft(el);
}
function _absLeft(el) {
        if (el == null) { return 0; }
        return (el.offsetParent)? el.offsetLeft+_absLeft(el.offsetParent) : el.offsetLeft;
}
function absRight(el) {
        if (!el) { return _getWidth(); }
	var t = typeof el;
	if (t.toLowerCase() == 'string') {
		el = getEl(el);
	}
        return _absLeft(el) + _getWidth(el);
}

// Liefert die absolute obere Position eines Elementes zurueck:
function absTop(el) {
        if (!el) { return 0; }
	var t = typeof el;
	if (t.toLowerCase() == 'string') {
		el = getEl(el);
	}
        return _absTop(el);
}
function _absTop(el) {
        if (el == null) { return 0; }
        return (el.offsetParent)? el.offsetTop+_absTop(el.offsetParent) : el.offsetTop;
}
function absBottom(el) {
        if (!el) { return _getHeight(); }
	var t = typeof el;
	if (t.toLowerCase() == 'string') {
		el = getEl(el);
	}
        return _absTop(el) + _getHeight(el);
}


// Use getHeight() without parameter, if you want the viewport height of the browser:
function getHeight(el) {
	var t = typeof el;
	if (t.toLowerCase() == 'string') {
		el = getEl(el);
	}
        return _getHeight(el);
}
function _getHeight(el) {
        if (!el) {
                if( typeof( window.innerHeight ) == 'number' ) {
                        //Non-IE
                        return window.innerHeight;
                } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
                        //IE 6+ in 'standards compliant mode'
                        return document.documentElement.clientHeight;
                } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
                        //IE 4 compatible
                        return document.body.clientHeight;
                }
                return 0;
        }

        if( typeof( el.offsetHeight ) == 'number' ) {
                //Non-IE
                return el.offsetHeight;
        } else if( el.clientHeight ) {
                return el.clientHeight;
        }
        return 0;
}

// Use getWidth() without parameter, if you want the viewport width of the browser:
function getWidth(el) {
	var t = typeof el;
	if (t.toLowerCase() == 'string') {
		el = getEl(el);
	}
        return _getWidth(el);
}
function _getWidth(el) {
        if (!el) {
                if( typeof( window.innerWidth ) == 'number' ) {
                        //Non-IE
                        return window.innerWidth;
                } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
                        //IE 6+ in 'standards compliant mode'
                        return document.documentElement.clientWidth;
                } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
                        //IE 4 compatible
                        return document.body.clientWidth;
                }
                return 0;
        }

        if( typeof( el.offsetWidth ) == 'number' ) {
                //Non-IE
                return el.offsetWidth;
        } else if( document.documentElement.clientWidth || document.documentElement.clientHeight ) {
                return el.clientWidth;
        }
        return 0;
}

// Does not really work:
function getScrollbarsVisible() {
        if (window.innerHeight && window.document.height) {
                return window.innerHeight != window.document.height;
        }
        if(document.body && document.body.clientHeight) {
                return document.body.clientHeight != document.body.scrollHeight;
        }
        return self.innerHeight != self.document.height;
}

