function swapImage (elId, newState) {
	document.getElementById (elId).src = preloadedImages[elId+"_"+newState].src;
}

var preloadedImages = [];

function initMenuImages(menuId)
{
    var im = document.getElementById(menuId).getElementsByTagName('img');

    for(var i = 0; i < im.length; ++i)
    {
        if(!im[i].src.match(/(_on|_off)\./))
            continue;

        if(im[i].src.match(/_on\./))
            continue;

        var tmp = new Image();
        tmp.src = im[i].src.replace(/_off\./, '_on.');

        preloadedImages.push(tmp);

        im[i].onmouseover = function()
        {
            this.src = this.src.replace(/_off\./, '_on.');
        }

        im[i].onmouseout = function()
        {
            this.src = this.src.replace(/_on\./, '_off.');
        }

    }

}