/*
This script exists in pods/login.cfm but only when the user is signed in. I'm extracting it so that it can be used in other places. However, to prevent conflict with
the script in login.cfm I'm renaming the "bt" object to "bt2". Also, we'll make this script work on the "flip" img class instead of "png" class
*/


//$j = jQuery.noConflict();

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

bt2 = {};

bt2.rollover =
{
   init: function()
   {
	  this.preload();

	  $(".flip").hover(
		 function () { $(this).attr( 'src', bt2.rollover.newimage($(this).attr('src')) ); },
		 function () { $(this).attr( 'src', bt2.rollover.oldimage($(this).attr('src')) ); }

	  );
   },

   preload: function()
   {
	  $(window).bind('load', function() {
		 $('.flip').each( function( key, elm ) { $('<img>').attr( 'src', bt2.rollover.newimage( $(this).attr('src') ) ); });
	  });
   },

   newimage: function( src )
   {
	  return src.substring( 0, src.search(/(\.[a-z]+)/) ) + '_hover' + src.match(/(\.[a-z]+)/)[0];
   },

   oldimage: function( src )
   {
	  return src.replace(/_hover/, '');
   }
};
