var theMenu = new Array;
        var mainMenuH = new Array;
        var theTipH = new Array;

function start() {
        theMenu[0] = new menuSetup(0,55);
        theMenu[1] = new menuSetup(1,55);
        theMenu[2] = new menuSetup(2,55);
        theMenu[3] = new menuSetup(3,55);
        theMenu[4] = new menuSetup(4,55);
        theMenu[5] = new menuSetup(5,55);
        theMenu[6] = new menuSetup(6,55);

        for (var i=0;i<theMenu.length;i++) {
        theMenu[i].measure();
        theMenu[i].showMenu();
        }
}
function layerSetup(id) {
        theObj = document.getElementById(id);
        return theObj;
}
function getHeight(id) {
        theHeight = layerSetup(id).offsetHeight;
        return theHeight;
}
function showDiv(id,posX,posY) {
        layerSetup(id).style.visibility = 'visible';
        layerSetup(id).style.left = parseInt(posX);
        layerSetup(id).style.top = parseInt(posY);
}

function hideDiv(id) {
        layerSetup(id).style.visibility = 'hidden';
}
function menuSetup(id,Ytop) {
        this.space = 10;
        this.posX = 0;
        this.id = id;
        this.mainId = "mainMenu" + id;
        this.tipId = "theTip" + id;
        this.Ytop = Ytop;
        this.posY=0;
        this.delay = 50;
        this.timer;
        this.measure =  measure;
        this.showMenu = showMenu;
        this.newPosition = newPosition;
        this.layerMove = layerMove;
        this.slideMenu = slideMenu;
        this.showTip = showTip;
}
function measure() {
        mainMenuH[this.id] = getHeight(this.mainId);
        theTipH[this.id] = getHeight(this.tipId);
}
function showMenu() {
        posY=this.Ytop;
        for (var i=0;i<=this.id-1;i++) {
        posY += parseInt(mainMenuH[i]) + this.space;
        }
        this.posY = posY;
        showDiv(this.mainId,this.posX,posY);
}
function newPosition(id) {
        hideDiv(this.tipId);
        posY=this.Ytop;
        for (var i=0;i<=this.id-1;i++) {
        posY += parseInt(mainMenuH[i]) + this.space;
        }
        if (this.id == mainMenuH.length-1) {
                var  f="openTip(" + id + ")";
        }
        this.finish = new Function(f);
        this.layerMove(posY,-5)
}

function layerMove(posY,moveY) {
        if (moveY>0) {
        var a=posY-this.posY;
        } else {
        var a=this.posY-posY;
        }
        if (a>0) {
        this.posY = this.posY + moveY;
        showDiv(this.mainId,this.posX,this.posY);
        if(this.timer) {
        clearTimeout(this.timer);
        }
        eval("theMenu[" + this.id + "].timer = setTimeout(\"theMenu[" + this.id + "].layerMove("+posY+","+moveY+","+this.delay+")\"," + this.delay + ")");
        } else {
        this.finish();
        }
}

function openTip(id) {
        for (var i=0;i<theMenu.length-1;i++) {
        if (id <= theMenu[i].id) {
        theMenu[i+1].slideMenu(id);
                }
        }
        if (id == theMenu.length-1) {
        theMenu[theMenu.length-1].showTip();
        }
}

function slideMenu(id) {
        posY = this.Ytop;
        posY+=theTipH[id]+this.space;
        for (var i=0;i<=this.id-1;i++) {
        posY += parseInt(mainMenuH[i]) + this.space;
        }
        var  f="theMenu[" + id + "].showTip()";
        this.finish = new Function(f);
        this.layerMove(posY,5)
}

function showTip() {
        posY = this.Ytop;
        for (var i=0;i<=this.id;i++) {
        posY += parseInt(mainMenuH[i]) + this.space;
        }
        showDiv(this.tipId,this.posX,posY);
}

function openMenu(id){
        for (var i=0;i<theMenu.length;i++) {
        theMenu[i].newPosition(id);
        }
}