﻿jQuery(document).ready(function() {
    osf.masterInit();
});

osf = {
    masterInit: function() {
        //main menu
        jQuery(".publicnavbar a>img").mouseover(function() {
            jQuery(this).attr("src", "images/" + jQuery(this).attr("id") + "_MO.gif");
        }).mouseout(function() {
            jQuery(this).attr("src", "images/" + jQuery(this).attr("id") + ".gif");
        }).each(function() {
            osf.newImage("images/" + jQuery(this).attr("id") + "_MO.gif");
        });

        //preload splat mouseovers
        jQuery(".splat a>img").each(function() {
            osf.newImage("images/" + jQuery(this).attr("id") + "_MO.png");
        });

        osf.setMenuHighlight();
    },
    newImage: function(arg) {
        if (document.images) {
            rslt = new Image();
            rslt.src = arg;
            return rslt;
        }
    },
    setMenuHighlight: function() {
        // highlight menu
        var href = location.href;
        jQuery(".publicnavbar a").each(function() {
            if (href.indexOf(jQuery(this).attr("href")) > -1) {
                jQuery("img", this).attr("src", "images/" + jQuery("img", this).attr("id") + "_MO.gif").unbind("mouseout");
            }
        });
    }
};

function changeImage(id, image) {
    var element = document.getElementById(id);
    element.src = image;
    //ie6 hack needed for .png with transparency
    if (jQuery.browser.msie && jQuery.browser.version < 7 && image.match('.png') != null) {
        element.src = "Images/spacer.gif";
        element.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + image + "', sizingMethod='scale')";
    }
}