function HTMLStyleButton(objRef, id, altText, normalStyle, overStyle, downStyle, beenThereStyle){
	var retVal = null;
	if (typeof(objRef) == "string"){
		objRef = document.getElementById(objRef);
	}
	if (objRef && typeof(objRef) == "object"){
		this.objRef = objRef;
		this.htmlButton = new HTMLButton(objRef, id, altText);
		
		this.styleArray = new Array();
		if (normalStyle){
			this.styleArray[0] = normalStyle;
			this.applyStyle(0);
		}
		if (overStyle){
			this.styleArray[1] = overStyle;
		}
		if (downStyle){
			this.styleArray[2] = downStyle;
		}
		if (beenThereStyle){
			this.styleArray[3] = beenThereStyle;
		}
		
		this.htmlButton.parentObject = this;
		this.htmlButton.setClickHandler(this.btnClick);
		this.htmlButton.setOverHandler(this.btnOver);
		this.htmlButton.setDownHandler(this.btnDown);
		this.htmlButton.setUpHandler(this.btnUp);
		this.htmlButton.setOutHandler(this.btnOut);
		retVal = this;
	}	
	
	return retVal;
}
HTMLStyleButton.prototype.setNormalStyle = function(normalStyle){
	this.styleArray[0] = normalStyle;
	if (this.styleArray[0]){
		this.applyStyle(0);
	}
}
HTMLStyleButton.prototype.setOverStyle = function(overStyle){
	this.styleArray[1] = overStyle;
}
HTMLStyleButton.prototype.setDownStyle = function(downStyle){
	this.styleArray[2] = downStyle;
}
HTMLStyleButton.prototype.setBeenThereStyle = function(beenThereStyle){
	this.styleArray[3] = beenThereStyle;
}
HTMLStyleButton.prototype.show = function(){
	this.htmlButton.show();
}
HTMLStyleButton.prototype.hide = function(){
	this.htmlButton.hide();
}
HTMLStyleButton.prototype.isVisible = function(){
	return this.htmlButton.isVisible();
}
HTMLStyleButton.prototype.isEnabled = function(){
	return this.htmlButton.isEnabled();
}
HTMLStyleButton.prototype.enable = function(){
	this.htmlButton.enable();

	if (this.htmlButton.objRef.beenThere == true){
		this.applyStyle(3);
	}
	else{
		this.applyStyle(0);
	}
}
HTMLStyleButton.prototype.disable = function(){
	this.htmlButton.disable();

	this.applyStyle(3);
}
HTMLStyleButton.prototype.setBeenThere = function(flag){
	this.htmlButton.setBeenThere(flag);
	this.showBeenThereState();
}

HTMLStyleButton.prototype.getBeenThere = function(){
	return this.htmlButton.getBeenThere();
}

HTMLStyleButton.prototype.btnClick = function(id, instObj, imgRef){
	if (imgRef.parentObject.parentObject.userHandleClick){
		imgRef.parentObject.parentObject.userHandleClick(id, instObj, imgRef);
	}
}

HTMLStyleButton.prototype.btnOver = function(id, instObj, imgRef){
	imgRef.parentObject.parentObject.applyStyle(1);
	if (imgRef.parentObject.parentObject.userHandleOver){
		imgRef.parentObject.parentObject.userHandleOver(id, instObj, imgRef);
	}
}

HTMLStyleButton.prototype.btnDown = function(id, instObj, imgRef){
	imgRef.parentObject.parentObject.applyStyle(2);
	if (imgRef.parentObject.parentObject.userHandleDown){
		imgRef.parentObject.parentObject.userHandleDown(id, instObj, imgRef);
	}
}

HTMLStyleButton.prototype.btnUp = function(id, instObj, imgRef){
	imgRef.parentObject.parentObject.applyStyle(1);
	if (imgRef.parentObject.parentObject.userHandleUp){
		imgRef.parentObject.parentObject.userHandleUp(id, instObj, imgRef);
	}
}

HTMLStyleButton.prototype.btnOut = function(id, instObj, imgRef){
	imgRef.parentObject.parentObject.showBeenThereState();
	if (imgRef.parentObject.parentObject.userHandleOut){
		imgRef.parentObject.parentObject.userHandleOut(id, instObj, imgRef);
	}
}
HTMLStyleButton.prototype.showBeenThereState = function(){
	if (this.getBeenThere()){
		this.applyStyle(3);
	}
	else{
		this.applyStyle(0);
	}
}
HTMLStyleButton.prototype.setClickHandler = function(func){
	this.userHandleClick = func;
}
HTMLStyleButton.prototype.setOverHandler = function(func){
	this.userHandleOver = func;
}
HTMLStyleButton.prototype.setDownHandler = function(func){
	this.userHandleDown = func;
}
HTMLStyleButton.prototype.setUpHandler = function(func){
	this.userHandleUp = func;
}
HTMLStyleButton.prototype.setOutHandler = function(func){
	this.userHandleOut = func;
}

HTMLStyleButton.prototype.applyStyle = function(styleIndex){
	if (this.styleArray[styleIndex]){
		var styleArr = this.styleArray[styleIndex].split(";");
		for (var i=0;i<styleArr.length;i++){
			var re = new RegExp("\\s*([^\\:\\s]+)\\s*\\:\\s*([^\\:\\s]+)\\s*","");
			var retVal = re.exec(styleArr[i]);
			if (retVal){
				if (this.htmlButton.objRef.style.setAttribute){
					this.htmlButton.objRef.style.setAttribute(retVal[1],retVal[2]);
				}
				else{
					eval("this.htmlButton.objRef.style." + retVal[1] + " = '" + retVal[2] + "';");
				}
			}
		}
	}
}


