var _killTimer;
var _DDMenuList = [["#menu258", [25, 93]], ["#menu259", [138, 93]], ["#menu276", [313, 93]], ["#menu267", [418, 93]]];

function hideMenus() {
    var obj = null;
    
    for(var i = 0; i < _DDMenuList.length; i ++) {
        obj = $(_DDMenuList[i][0]);
        
        if(obj.css("visibility") != "hidden") {
            //obj.hide("slide", {direction:"up"}, 300, function() { obj.css("visibility", "hidden"); obj.hide = null; });
            obj.css("visibility", "hidden");
        }
    }
}

function menuParentOver(id) {
    hideMenus();
    
    clearTimeout(_killTimer);
    $(id).css("visibility", "visible");
    $(id).show("slide", {direction:"up"}, 500);
}

function menuOver(id) {
    clearTimeout(_killTimer);
    $(id).css("visibility", "visible");
}

function menuOut() { 
    _killTimer = setTimeout(hideMenus, 100);
}   

//call to reposition all absolutely positioned menus
function reposition() {
    var intLayoutW = 920;                     //width of main layout not counting variable widths
    var intPageW = $(window).width();         //current width of viewport
    var menu = null;
    var menuX = 0;
    var menuY = 0;

    for(var i = 0; i < _DDMenuList.length; i ++) {
        menu = $(_DDMenuList[i][0]);
        menuX = _DDMenuList[i][1][0];
        menuY = _DDMenuList[i][1][1];   
        
        if(intPageW <= intLayoutW) {    		//body width smaller then layout width
            menu.css("left", menuX + "px");
            menu.css("top", menuY + "px");
        }else {                                	//body width bigger then layout width
            var left = menuX + ((intPageW / 2) - (intLayoutW / 2));
            if(window.navigator.userAgent.match(/Firefox/i)) { left += 1; }
            
            menu.css("left", left + "px");
            menu.css("top", menuY + "px");
        }
    }
}

$(document).ready(function() {
    $(window).bind("load", reposition);
    $(window).bind("resize", reposition);
});