window.onload = function() {
    var menu = document.getElementById('menu');
    var points = menu.getElementsByTagName('li');
    var height = 0;
    points[0].style.background = 'none';
    points[points.length - 1].style.marginRight = '-1px'; // for ie 6
    for (var i = 0; i < points.length; i++) {
        width = 100 / points.length + '%';
        points[i].style.width = width;
        if(points[i].offsetHeight > height) {
            height = points[i].offsetHeight;
        }
    }
    for (var i = 0; i < points.length; i++) {
        points[i].style.height = height + 'px';
        a = points[i].getElementsByTagName('a')[0];
        a.style.height = height + 'px';
        var span = points[i].getElementsByTagName('span')[0];
        span.style.marginTop = - span.offsetHeight / 2 + 'px';
        points[i].onmouseover = function() {
            currentSpan = this.getElementsByTagName('a')[0];
            currentSpan.className = 'hovered';
        }
        points[i].onmouseout = function() {
            currentSpan = this.getElementsByTagName('a')[0];
            currentSpan.className = '';
        }
    }
}