$(document).ready(function() {
$("#masthead ul").imageSwap();
});
$.fn.imageSwap = function() {
var $parentElement = this;
var cache = [];
//preload the active images before use.
var imageSrc = $parentElement.find("img").get();
for (var i = imageSrc.length; i--; ) {
var cacheImage = document.createElement('img');
cacheImage.src = imageSrc[i].src.replace("_off", "_on");
cache.push(cacheImage);
}
//Events for mouseover mouseout on the images within the parentElement that was passed in.
$parentElement.find("img").bind("mouseover", function() {
var $img = $(this);
$img.attr("src", $img.attr("src").replace("_off", "_on"));
}).bind("mouseout", function() {
var $img = $(this);
$img.attr("src", $img.attr("src").replace("_on", "_off"));
});
};