// from http://peps.ca/blog/easy-image-rollover-script-with-jquery/

/*It looks through the document for any “img” or “input” tags with a class of “ro”. The rollover image needs to be named the same as the normal image but with “_o” at the end. For example, the rollover image for “image.gif” will be “image_o.gif”. After finding all the image tags, the script preloads all of the rollover images and ads the “mouseover” and “mouseout” events.*/


$(document).ready( function()
{
   PEPS.rollover.init();
});

PEPS = {};

PEPS.rollover =
{
   init: function()
   {
      this.preload();
     
      $(".ro").hover(
         function () { $(this).attr( 'src', PEPS.rollover.newimage($(this).attr('src')) ); },
         function () { $(this).attr( 'src', PEPS.rollover.oldimage($(this).attr('src')) ); }
      );
   },

   preload: function()
   {
      $(window).bind('load', function() {
         $('.ro').each( function( key, elm ) { $('<img>').attr( 'src', PEPS.rollover.newimage( $(this).attr('src') ) ); });
      });
   },
   
   newimage: function( src )
   {
      return src.substring( 0, src.search(/(\.[a-z]+)$/) ) + '_o' + src.match(/(\.[a-z]+)$/)[0];
   },

   oldimage: function( src )
   {
      return src.replace(/_o\./, '.');
   }
};// JavaScript Document
