﻿$(function () {
    var imgType = '.png';
    if ($.browser.msie && $.browser.version.substr(0, 1) < 7) {
        imgType = '.gif';
        $('#menu img').each(function() {
            $(this).attr('src', $(this).attr('src').replace('.png', '.gif'));
        });
    }

    var cache = [];
    // Arguments are image paths relative to the current page.
    $.preLoadImages = function () {
        var args_len = arguments.length;
        for (var i = args_len; i--; ) {
            var cacheImage = document.createElement('img');
            cacheImage.src = arguments[i];
            cache.push(cacheImage);
        }
    }

    imgs = [];
    for (var i = 1; i <= 6; i++) {
        imgs[i - 1] = 'assets/images/menu/menu_on_0' + i + imgType;
    }
    $.preLoadImages(imgs);

    $('#menu img').hover(function () {
        $(this).attr('src', $(this).attr('src').replace('off', 'on'));
    }, function () {
        $(this).attr('src', $(this).attr('src').replace('on', 'off'));
    });
});
