////
//// support code for Future of Nuclear Power site
////

//
// required:
//   jquery.js (version 1.3.2+) (see jquery.com)
//   jquery.ifixpng-3.1.2.js
//   jquery.preloadImg.js
//

$(document).ready(function(){

  //
  // fix png images for IE6
  //
  $.ifixpng('/nuclearpower/img/spacer.gif');
  $('img[src$=.png]').ifixpng();


  // function gets the mouseover version of the specified image src
  //
  var getMouseoverSrc = function(src) {
    return src.replace(/_off/, '_ro');
  }
  //
  // navigation mouseovers and preloads
  //
  $("img[src*='_off']")
    .each( function(i) {
      // set up two versions of image, and save both values in the image itself
      this.src1 = this.src;
      this.src2 = getMouseoverSrc(this.src1);
      // preload mouseover version
      $.preloadImg.add(this.src2);
      // respond to mouseover/mouseout
      $(this).hover(
        function () { // mouseover function
          this.src = this.src2;
        },
        function () { // mouseout function
          this.src = this.src1;
        }
      );
    });
  // start preload
  $.preloadImg.start();


  //
  // execute back to top with scrollTo
  //
  $('p.backtotop a').click( function() {
    window.scrollTo(0,0);
    return false;
  });

});
