
var gotImages = false;

topMenuLeftHilite = new Image(20, 22);
topMenuMiddleHilite = new Image(22, 22);
topMenuRightHilite = new Image(33, 22);

var menuImagesDirRelativePath = null;
var menuImagesOverMenuId = null;


function preLoadComplete(imageArray, numLoaded) {
    topMenuLeftHilite = imageArray[0];
    topMenuMiddleHilite = imageArray[1];
    topMenuRightHilite = imageArray[2];
    gotImages = true;
    if (menuImagesOverMenuId) {
        hiliteMenu(menuImagesOverMenuId, true);
    }
}

function preLoadImages(p) {
    if (!p) {
        p = '/img/';
    }
    menuImagesDirRelativePath = p;
    urls = new Array();
    urls.push(p + 'top/top_menu_left_hilite.png');
    urls.push(p + 'top/top_menu_middle_hilite.png');
    urls.push(p + 'top/top_menu_right_hilite.png');
    new ImageLoader(urls, preLoadComplete);
}



function hiliteMenu(id, hilite) {

    if (!gotImages) {
        return;
    }

    if (hilite) {
        menuImagesOverMenuId = id;
    } else {
        menuImagesOverMenuId = null;
    }

    var ltd = getById(id + "left");
    var mtd = getById(id + "middle");
    var rtd = getById(id + "right");

    if (ltd == null || mtd == null || rtd == null) {
        return;
    }

    if (hilite) {
        mtd.style.backgroundImage = "url('" + menuImagesDirRelativePath + "top/top_menu_middle_hilite.png')";
        ltd.style.backgroundImage = "url('" + menuImagesDirRelativePath + "top/top_menu_left_hilite.png')";
        rtd.style.backgroundImage = "url('" + menuImagesDirRelativePath + "top/top_menu_right_hilite.png')";
    } else {
        mtd.style.backgroundImage = "url('" + menuImagesDirRelativePath + "top/top_menu_middle_normal.png')";
        ltd.style.backgroundImage = "url('" + menuImagesDirRelativePath + "top/top_menu_left_normal.png')";
        rtd.style.backgroundImage = "url('" + menuImagesDirRelativePath + "top/top_menu_right_normal.png')";
    }
}

