function OnToolbarButtonPropertyChange(EventObject){
	var Button = EventObject.srcElement;
	switch(EventObject.propertyName){
		case "Enabled":
			Button.SetButtonState();
			break;
	}
}

function InitButton(Button){
	Button.SetEnabled = SetEnabled;
	Button.SetButtonState = SetButtonState;
	Button.Restore = Restore;
	if(typeof(Button.Enabled) != 'undefined') 
		Button.SetEnabled(Button.Enabled);
}

///////////////////////////////////////////////////////////////////////////////////////////////////
function SetEnabled(vValue){
	if(typeof(vValue) == 'string'){
		this.Enabled = (vValue == 'false') ? false : true;
	}else if(typeof(vValue) == 'boolean'){
		this.Enabled = vValue;
	}else{
		alert("Invalid property value!");
	}
	this.SetButtonState();
}
///////////////////////////////////////////////////////////////////////////////////////////////////
function SetButtonState(){
	
	this.disabled = !this.Enabled;
	if(this.firstChild && this.firstChild.tagName == "TABLE" && this.firstChild.rows[0].cells[0].firstChild.tagName == 'IMG'){
		this.firstChild.rows[0].cells[0].firstChild.style.filter = (this.Enabled) ? "" : "progid:DXImageTransform.Microsoft.Alpha(Opacity=50, FinishOpacity=0, Style=3, StartX=0,  FinishX=100, StartY=0, FinishY=100)";
	}
	if(this.Enabled == false) 
		this.Restore();
}
///////////////////////////////////////////////////////////////////////////////////////////////////
function Restore(){
	// restore original values
	//element.blur();
	//alert('restore');
	try{
//		this.runtimeStyle.border = sNormalBorder;
//		this.firstChild.runtimeStyle.color = sNormalColor;
//		this.runtimeStyle.filter = sNormalFilter;
		//runtimeStyle.padding = sNormalPadding;
	}catch(e){
		
	}
}
