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

PEPS = {};

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

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