var arrMenus = new Array(5);
var intCurrentMenu = 0;
var stepSize = 10;
var animationTimeStep = 10; //in milli seconds.
var boolMenusActive = false;
var currentMenu = 0;

arrMenus[0] = new VertexMenu('MenuDevelopment01','MenuDevelopment02',22,-6,200,315,45,100,210,315,100,171);
arrMenus[1] = new VertexMenu('MenuHosting01','MenuHosting02',22,-6,316,393,45,100,295,393,100,143);
arrMenus[2] = new VertexMenu('MenuListrak01','MenuListrak02',22,-6,394,576,45,100,405,576,100,171);
arrMenus[3] = new VertexMenu('MenuAboutus01','MenuAboutus02',22,-6,708,797,45,100,580,797,100,157);
arrMenus[4] = new VertexMenu('MenuHE01','MenuHE02',22,-6,577,707,45,100,580,707,100,212);

var intCurrentMenu = 0;
var stepSize = 5;
var animationTimeStep = 10; //in milli seconds.

function VertexMenu(strBGMenu,strMenu,intSteps,intOffset,intxMin,intxMax,intyMin,intyMax,intxMin2,intxMax2,intyMin2,intyMax2){
        this.boolMenuOn = false;
        this.BGMenu = strBGMenu;
        this.Menu = strMenu;
        this.Offset = intOffset;
        this.Steps = intSteps;
        this.xMax = intxMax; //if the mouse moves from this rect. bound and the rect. bound below, hide the menu.
        this.yMax = intyMax;
        this.xMin = intxMin;
        this.yMin = intyMin;
        this.xMax2 = intxMax2;
        this.yMax2 = intyMax2;
        this.xMin2 = intxMin2;
        this.yMin2 = intyMin2;
}


function moveIT(menuNumber){
//yOffset is the number of pixels the menu is offset on start
//iSteps is the number of global var stepSize moves the menu makes
        if(boolMenusActive){
        if(!arrMenus[menuNumber].boolMenuOn){
                var strMenuBG = arrMenus[menuNumber].BGMenu;
                var strMenu = arrMenus[menuNumber].Menu;
                var yOffset = arrMenus[menuNumber].Offset;
                var iSteps = arrMenus[menuNumber].Steps;
                //move the menu above the event horizon before we drop them down...
                eval("document.all." + strMenuBG + ".style['top'] = '" + (yOffset) + "px';");
                eval("document.all." + strMenu + ".style['top'] = '" + (yOffset) + "px';");
                //make menus visible
                eval("document.all." + strMenuBG + ".style['visibility'] = 'visible';");
                eval("document.all." + strMenu + ".style['visibility'] = 'visible';");
                //drop the menu down
                for(i=0;i<iSteps;i++){
                        setTimeout("document.all." + strMenuBG + ".style['top'] = '" + ((i* stepSize) + yOffset) + "px';",i*animationTimeStep);
                        setTimeout("document.all." + strMenu + ".style['top'] = '" + ((i* stepSize) + yOffset) + "px';",i*animationTimeStep);
                }
                setTimeout("arrMenus[" + menuNumber + "].boolMenuOn = true;",(i*animationTimeStep));
                setTimeout("setCurrentMenu(" + menuNumber + ");",(i*animationTimeStep));
        }
        }
}

function hideIT(menuNumber){
        if(boolMenusActive){
        if (arrMenus[menuNumber].boolMenuOn){
			var strMenuBG = arrMenus[menuNumber].BGMenu;
			var strMenu = arrMenus[menuNumber].Menu;
			var yOffset = arrMenus[menuNumber].Offset;
			var iSteps = arrMenus[menuNumber].Steps;
            var j = 0;
            for(i=iSteps;i>0;i--){
                    setTimeout("document.all." + strMenuBG + ".style['top'] = '" + ((i* stepSize) + yOffset) + "px';",(j*animationTimeStep));
                    setTimeout("document.all." + strMenu + ".style['top'] = '" + ((i* stepSize) + yOffset) + "px';",(j*animationTimeStep));
                    j++;
            }
            setTimeout("document.all." + strMenuBG + ".style['visibility'] = 'hidden';",((j + 1)*animationTimeStep));
            setTimeout("document.all." + strMenu + ".style['visibility'] = 'hidden';",((j + 1)*animationTimeStep));
			arrMenus[menuNumber].boolMenuOn = false;
        }
        }
}

function setEvents(){
        //add NS event listener
        document.onmousemove = mouseMoveHandler;
        boolMenusActive = true;
}

function mouseMoveHandler(evt){        
        var x = document.all ? event.clientX : document.layers ? evt.x : evt.clientX;
        var y = document.all ? event.clientY : document.layers ? evt.y : evt.clientY;
        x = x + document.body.scrollLeft; //offset scrolling...
		y = y + document.body.scrollTop; //offset scrolling...
        cursorCheck(x,y);
}

function setCurrentMenu(menuNumber){
	currentMenu = menuNumber;
	//shut off all other menus
	for(i=0;i<arrMenus.length;i++){
		if((i != currentMenu) && (arrMenus[i].boolMenuOn)){
			hideIT(i);
		}
	}
}

function cursorCheck(x,y){
	for(i=0;i<arrMenus.length;i++){
				if(arrMenus[i].boolMenuOn){
                if (((x < arrMenus[i].xMin) || (x > arrMenus[i].xMax) || (y < arrMenus[i].yMin) || (y > arrMenus[i].yMax)) && ((x < arrMenus[i].xMin2) || (x > arrMenus[i].xMax2) || (y < arrMenus[i].yMin2) || (y > arrMenus[i].yMax2))){
                        hideIT(i);
                }
                }
            }
}