/* JavaScript Document * Set the appropriate image container or use #gallery * Set your over images to have the same name with _h (or whatever) as suffix */ $(document).ready(function() { $('#navbar img').each(function() { var imgFile = $(this).attr('src'); var preloadImage = new Image(); var imgExt = /(\.\w{3,4}$)/; preloadImage.src = imgFile.replace(imgExt,'_f2$1'); $(this).hover( function() { $(this).attr('src', preloadImage.src); }, function () { $(this).attr('src', imgFile); } ); // end hover }); // end each }); // end ready $(function() { var currentPage = window.location.pathname; if(currentPage == "/"){currentPage = '/index.html'} currentPage = currentPage.replace(/\//,''); $('#navbar a').each(function(){ if(currentPage == $(this).attr('href')){ var imgTxt = $(this).html(); imgTxt = imgTxt.replace(/.\gif/,'_f2.gif') $(this).replaceWith(imgTxt); } }); // end each }); //end ready