/**
 * コンストラクタ
 */
function RollOverImage( id ){
	this.img = document.getElementById( id );
	this.originalPath = this.img.src;
}

/**
 * 画像のsrcプロパティを変更する関数クロージャを作成
 */
RollOverImage.prototype.getClosure = function( filepath ){
	return function(){
		 this.src = filepath;
	}
}

// マウスオーバー・マウスアウト時処理
RollOverImage.prototype.setMouseOverImage = function( filepath ){
	this.mouseoverImg = new Image();
	this.mouseoverImg.src = filepath;
	
	this.img.onmouseover = this.getClosure( filepath );
	this.img.onmouseout = this.getClosure(this.originalPath );

	/* DOM Level2 Event API */
	//this.img.addEventListener( "mouseover" , this.getClosure( filepath ) , true );
	//this.img.addEventListener( "mouseout" , this.getClosure( this.originalPath ) , true );

}

// マウスダウン・マウスアップ時処理
RollOverImage.prototype.setMouseDownImage = function( filepath ){
	this.mousedownImg = new Image();
	this.mousedownImg.src = filepath;

	this.img.onmousedown = this.getClosure( filepath );
	this.img.onmouseup = this.getClosure( this.originalPath );
}

