Button = function(id){
	this.button = document.getElementById(id);
	this.images = {};
	this.initial = this.button.src;
}
Button.prototype.over = null;
Button.prototype.out = null;
Button.prototype.click = null;
Button.prototype.release = null;
Button.prototype.checkImage = function(img){
	return ((img.fileSize == -1) || img.width == 0) ? false : true;
}
Button.prototype.init = function(){
	var o = this;
	if(o.out) (this.images.out = new Image()).src = o.out;
	this._out = this.button.onmouseout;
	this.button.onmouseout = function(){
		if(typeof(o._out) == "function") o._out();
		if(!o.out) this.src = o.initial;
		else if(o.checkImage(o.images.out)) this.src = o.out;
	}
	if(this.over){
		this._over = this.button.onmouseover;
		(this.images.over = new Image()).src = o.over;
		this.button.onmouseover = function(){
			if(typeof(o._over) == "function") o._over();
			if(o.checkImage(o.images.over))
				this.src = o.over;
		}
	}
	if(this.click){
		this._click = this.button.onmousedown;
		(this.images.click = new Image()).src = o.click;
		this.button.onmousedown = function(){
			if(typeof(o._click) == "function") o._click();
			if(o.checkImage(o.images.click))
				this.src = o.click;
		}
	}
	if(this.release || this.click){
		this._release = this.button.onmouseup;
		(this.images.release = new Image()).src = o.release;
		this.button.onmouseup = function(){
			if(typeof(o._release) == "function") o._release();
			var check = o.images.release || o.images.over || o.images.initial;
			if(o.checkImage(check))
				this.src = o.release || o.over || o.initial;
		}
	}
}