/* ===================================================================================================
 * iconButtonControl
 * ===================================================================================================
 */
 
/// jsonParameters
/// { fullControlName: <string>,
///   text: <string>,
///   visible: "0" | "1"
///   enabled: "0" | "1"
///   tabstop: "0" | "1"
///   description: <columnDescriptor>
/// }
iconButtonControl_Initialize = function(jsonParameters)
{
	var P = parseParameters(jsonParameters);
	//alert(JSON.stringify(P));
	var c = getControl(P.fullControlName);
	c.description = P.description;
	iconButtonControl_setup(c, P.text);
	iconButtonControl_updateAttributes(c, P);
};

iconButtonControl_Update = function(jsonParameters)
{
	var P = parseParameters(jsonParameters);
	//alert(JSON.stringify(P));
	var c = getControl(P.fullControlName);
	iconButtonControl_setText(c, P.text);
	iconButtonControl_updateAttributes(c, P);
};

iconButtonControl_updateAttributes = function(cell, jsonParameters)
{
	var P = parseParameters(jsonParameters);
	//alert(JSON.stringify(P));

	if (typeof P.visible != "undefined")
	{
		var visible = parseIntEx(P.visible);
		cell.style.visibility = visible ? "inherit" : "hidden";
	}

	if (typeof P.enabled != "undefined")
	{
		if (parseIntEx(P.enabled))
			cell.removeAttribute("disabled");
		else
			cell.setAttribute("disabled", "true");
	}
};

iconButtonControl_setup = function(cell, txt)
{
	//cell.setAttribute("type", "button");
	addControlEvent(cell, "click", function(event) { iconButtonControl_onClick(cell, event); });
	iconButtonControl_setText(cell, txt);
};

iconButtonControl_setText = function(cell, txt)
{
	//cell.innerText = txt;
	cell.src = txt;
	cell.title = txt;
};

iconButtonControl_onClick = function(cell, event)
{
	raiseControlEvent({ msg: "onClick", control: cell.id });
};

