var HiddenMenus = new Array();

function HiddenMenu(id, objectID) {
    this.id = id;
    this.objectID = objectID;
    this.addSelf = false;
    HiddenMenus[HiddenMenus.length] = this;
    this.off = 6;
    if (navigator != null && navigator.userAgent != null)
        if (navigator.userAgent.indexOf('MSIE') > -1 && navigator.userAgent.indexOf('MSIE 7.') == -1) {
        this.off = 2;
    }
    return this;
}

HiddenMenu.prototype.Display = function() {
    this.visible = true;
    this.evt = (window.event ? window.event : arguments.callee.caller.arguments[0]);
    this.src = (this.evt.srcElement ? this.evt.srcElement : this.evt.target)
    var p = this.src.parentNode;

    this.src.parentNode.parentNode.parentNode.childNodes[0].src = '/images/LeftNavArrowRightOver.gif'
    for (i = 0; i < HiddenMenus.length; i++) {
        if (HiddenMenus[i] != this) {
            HiddenMenus[i].visible = false;
            HiddenMenus[i].DoHide();
        }
    }
    setTimeout(this.id + '.DoDisplay()', 500);
}
HiddenMenu.prototype.DoDisplay = function(e) {
    var top, height;

    if (this.visible && (!this.obj || this.obj.style.display != 'inline')) {
        var evt = this.evt;
        var win = GetWindowInfo();
        var objInfo, srcInfo;

        if (evt) {
            this.obj = document.getElementById(this.objectID);
            srcInfo = GetObjectInfo(this.src);
            this.obj.style.top = (srcInfo.top + 1) + 'px';
            this.obj.style.left = (srcInfo.left + 200) + 'px';
            this.obj.style.width = '0px';
            this.Expand();
            this.obj.style.display = 'inline';
            objInfo = GetObjectInfo(this.obj);

            if (objInfo.top + objInfo.height > win.top + win.height)
                this.obj.style.top = (srcInfo.top + srcInfo.height - objInfo.height - this.off) + 'px';

            if (this.off == 2) {
                if (this.obj.insertAdjacentHTML) {
                    this.iframe = document.getElementById(this.objectID + '_iframe');
                    if (this.iframe == null) {
                        this.obj.insertAdjacentHTML("afterEnd", '<IFRAME style="position: absolute;height:0;width:0;z-index:4;" src="javascript:false;" frameBorder="0" scrolling="no" id="' + this.objectID + '_iframe" />');
                        this.iframe = document.getElementById(this.objectID + '_iframe');
                    }
                    this.iframe.style.top = this.obj.style.top;
                    this.iframe.style.left = this.obj.style.left
                    this.iframe.style.width = this.obj.offsetWidth;
                    this.iframe.style.height = this.obj.offsetHeight;
                }
            }
        }
    }
}
HiddenMenu.prototype.Show = function() {
    this.visible = true;
    return true;
}
HiddenMenu.prototype.Hide = function() {
    this.visible = false;
    setTimeout(this.id + '.DoHide()', 150);
}
HiddenMenu.prototype.DoHide = function() {
    if (!this.visible) {
        if (this.src)
            this.src.parentNode.parentNode.parentNode.childNodes[0].src = '/images/LeftNavArrowRight.gif'
        if (this.off == 2) {
            var iframe = document.getElementById(this.objectID + '_iframe');
            if (iframe != null)
                document.getElementById(this.objectID).parentNode.removeChild(iframe);
        }
        document.getElementById(this.objectID).style.display = 'none';
    }
}
HiddenMenu.prototype.Expand = function() {
    if (parseInt(this.obj.style.width, 10) < 200) {
        this.obj.style.width = (parseInt(this.obj.style.width, 10) + 40) + 'px';
        if (this.off == 2) {
            if (this.iframe != null) {
                this.iframe.style.width = this.obj.offsetWidth;
                this.iframe.style.height = this.obj.offsetHeight;
            }
        }
        setTimeout(this.id + '.Expand()', 5);
    }
}

function GetPosition(object, offset) {
    var totaloffset = ((offset == 'top') ? object.offsetTop : object.offsetLeft);
    var parent = object.offsetParent;
    if (parent != null)
        totaloffset += GetPosition(parent, offset);

    return totaloffset;
}
function GetWindowInfo() {
    var top, left, width, height;

    if (typeof (window.pageYOffset) == 'number') {
        top = window.pageYOffset;
        left = window.pageXOffset;
    } else if (document.documentElement) {
        top = document.documentElement.scrollTop;
        left = document.documentElement.scrollLeft;
    } else if (document.body) {
        top = document.body.scrollTop;
        left = document.body.scrollLeft;
    }

    if (typeof (window.innerWidth) == 'number') {
        width = window.innerWidth;
        height = window.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        width = document.documentElement.clientWidth;
        height = document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        width = document.body.clientWidth;
        height = document.body.clientHeight;
    }

    return { top: top, left: left, width: width, height: height };
}
function GetObjectInfo(o) {
    var top, left, width, height;
    if (typeof (o.innerWidth) == 'number') {
        width = o.innerWidth;
        height = o.innerHeight;
    } else if (o && (o.clientWidth || o.clientHeight)) {
        width = o.clientWidth;
        height = o.clientHeight;
    } else if (o.style.width) {
        width = parseInt(o.style.width, 10)
        height = parseInt(o.style.height, 10)
    }
    top = GetPosition(o, 'top');
    left = GetPosition(o, 'left');

    return { top: top, left: left, width: width, height: height };
}