/*
「img/hoge.gif」「img/hoge_on.gif」を用意
同フォルダにイメージを格納
img要素にclass「.rollover」を指定

例）
<img src="http://point.ecnavi.jp.eimg.jp/campaign/cerevo/img/hoge.gif" class="rollover">
*/

function initRollOverImages() {
  var image_cache = new Object();
  $("img.rollover").each(function(i) {
    var imgsrc = this.src;
    var dot = this.src.lastIndexOf('.');
    var imgsrc_on = this.src.substr(0, dot) + '_on' + this.src.substr(dot, 4);
    image_cache[this.src] = new Image();
    image_cache[this.src].src = imgsrc_on;
    $(this).hover(
      function() { this.src = imgsrc_on; },
      function() { this.src = imgsrc; });
  });
}

$(document).ready(initRollOverImages);

