/* $Id: javascripts.js 3 2009-07-22 19:39:50Z esmith $ */
/**
* A simple two state (on/off) rollover effect.
*
* This will create a simple rollover effect by replacing
* image_off.ext with image_on.ext on mouseover. Images are
* swapped back on mouseout.
*
* @param onIdentifier
*   Change the on identifier from the default "_on" to a custom value.
*
* @param offIdentifier
*   Change the off identifier from the default "_off" to a custom value.
*
* @dependency JQuery 1.3
*
  Usage Example:

  $(function(){
    $.twoStateRollover('_on', '_off');
  });

*/
jQuery.twoStateRollover = function(onIdentifier, offIdentifier) {

  // Set defaults
  if ( onIdentifier == null ) {
    onIdentifier = '_on';
  }
  if ( offIdentifier == null ) {
    offIdentifier = '_off';
  }

  // Preload rollover images
  $('img.rollover').each(
    function(){
      jQuery(
        "<img>").attr("src",
        $(this).attr('src').replace(offIdentifier, onIdentifier)
      );
  });

  $('img.rollover').hover(
    function(){
      if (!$(this).hasClass('active')) {
        $(this).attr('src', $(this).attr('src').replace(offIdentifier, onIdentifier));
      }
    },
    function() {
      if (!$(this).hasClass('active')) {
        $(this).attr('src', $(this).attr('src').replace(onIdentifier, offIdentifier));
      }
    }
  );
} // jQuery.twoStateRollover()

