function HTMLButton(objRef, id, altText){
	var retVal = null;
	if (typeof(objRef) == "string"){
		objRef = document.getElementById(objRef);
	}
	if (objRef && typeof(objRef) == "object"){
		this.objRef = objRef;
		this.id = id;
		this.objRef.parentObject = this;
		this.beenThere = false;
		this.objRef.beenThere = false;
		
		if (altText){
			this.objRef.alt = altText;
		}
						
		this.userHandleClick = null;
		this.userHandleOver = null;
		this.userHandleDown = null;
		this.userHandleUp = null;
		this.userHandleOut = null;
		this.userHandleEnabled = null;
		this.userHandleDisabled = null;
		
		this.enable();
		
		this.objRef.getInstanceObject = this.getInstanceObject;
		
		retVal = this;
	}	
	
	return retVal;
}
HTMLButton.prototype.getInstanceObject = function(){
	var retVal = this.parentObject;
	while (retVal.parentObject){
		retVal = retVal.parentObject;
	}
	return retVal;
}
HTMLButton.prototype.isEnabled = function(){
	return (this.objRef.onmouseover != null);
}
HTMLButton.prototype.show = function(){
	this.objRef.style.display = "block";
}
HTMLButton.prototype.hide = function(){
	this.objRef.style.display = "none";
}
HTMLButton.prototype.isVisible = function(){
	return (this.objRef.style.display != "none");
}
HTMLButton.prototype.enable = function(){
	this.objRef.onmouseover = this.btnOver;
	this.objRef.onmousedown = this.btnDown;
	this.objRef.onmouseup = this.btnUp;
	this.objRef.onmouseout = this.btnOut;
	this.objRef.onclick = this.btnClick;
	this.objRef.style.cursor = "pointer";
	
	if (this.userHandleEnabled){
		this.userHandleEnabled(this.id, this.objRef.getInstanceObject(), this.objRef);
	}
}
HTMLButton.prototype.disable = function(){
	this.objRef.onmouseover = null;
	this.objRef.onmousedown = null;
	this.objRef.onmouseup = null;
	this.objRef.onmouseout = null;
	this.objRef.onclick = null;
	this.objRef.style.cursor = "";

	if (this.userHandleDisabled){
		this.userHandleDisabled(this.id, this.objRef.getInstanceObject(), this.objRef);
	}
}

HTMLButton.prototype.setBeenThere = function(flag){
	this.beenThere = flag;
	if (this.objRef){
		this.objRef.beenThere = flag;
	}
}

HTMLButton.prototype.getBeenThere = function(){
	return this.beenThere;
}

HTMLButton.prototype.btnClick = function(){
	if (this.parentObject){
		this.beenThere = true;
		this.parentObject.beenThere = true;
		if (this.parentObject.userHandleClick){
			this.parentObject.userHandleClick(this.parentObject.id, this.getInstanceObject(), this);
		}
	}
}

HTMLButton.prototype.btnOver = function(){
	if (this.parentObject){
		if (this.parentObject.userHandleOver){
			this.parentObject.userHandleOver(this.parentObject.id, this.getInstanceObject(), this);
		}
	}
}

HTMLButton.prototype.btnDown = function(){
	if (this.parentObject){
		if (this.parentObject.userHandleDown){
			this.parentObject.userHandleDown(this.parentObject.id, this.getInstanceObject(), this);
		}
	}
}

HTMLButton.prototype.btnUp = function(){
	if (this.parentObject){
		if (this.parentObject.userHandleUp){
			this.parentObject.userHandleUp(this.parentObject.id, this.getInstanceObject(), this);
		}
	}
}

HTMLButton.prototype.btnOut = function(){
	if (this.parentObject){
		if (this.parentObject.userHandleOut){
			this.parentObject.userHandleOut(this.parentObject.id, this.getInstanceObject(), this);
		}
	}
}
HTMLButton.prototype.setClickHandler = function(func){
	this.userHandleClick = func;
}
HTMLButton.prototype.setOverHandler = function(func){
	this.userHandleOver = func;
}
HTMLButton.prototype.setDownHandler = function(func){
	this.userHandleDown = func;
}
HTMLButton.prototype.setUpHandler = function(func){
	this.userHandleUp = func;
}
HTMLButton.prototype.setOutHandler = function(func){
	this.userHandleOut = func;
}
HTMLButton.prototype.setEnabledHandler = function(func){
	this.userHandleEnabled = func;
}
HTMLButton.prototype.setDisabledHandler = function(func){
	this.userHandleDisabled = func;
}

