// 画像のロールオーバー

(function() {
  if (!document.getElementsByTagName) return;

  var addEvent, switchImage, init;
  addEvent = function(obj, type, func) {
    if (obj.addEventListener) {
      obj.addEventListener(type, func, false);
    }
    else if (obj.attachEvent) {
      obj.attachEvent('on' + type, func);
    }
  };
  switchImage = function(event) {
    var img = event.target || event.srcElement;
    img.src = (img.src == img.srcOff) ? img.srcOn : img.srcOff;
  };
  init = function() {
    var imgs = document.getElementsByTagName('img');
    var loaded = {}, img;
    for (var i = 0, len = imgs.length; i < len; i++) {
      img = imgs[i];
      if ( !img.src.match(/^(.*_)off(\..*)$/) ) continue;
      img.srcOff = img.src;
      img.srcOn = RegExp.$1 + 'on' + RegExp.$2;
      addEvent(img, 'mouseover', switchImage);
      addEvent(img, 'mouseout', switchImage);
      if (loaded[img.srcOn]) continue;
      loaded[img.srcOn] = true;
      (new Image).src = img.srcOn;
    }
  };

  addEvent(window, 'load', init);
})();

this.imagePreview = function(){	
	/* CONFIG */
		
		xOffset = 10;
		yOffset = 30;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.preview").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='preview'><img src='"+ this.href +"' alt='Image preview' />"+ c +"</p>");								 
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#preview").remove();
    });	
	$("a.preview").mousemove(function(e){
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};


// starting the script on page load
$(document).ready(function(){
	imagePreview();
});

<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->

