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

pushButtonControl_Update = function(jsonParameters)
{
	var P = parseParameters(jsonParameters);
	//alert(JSON.stringify(P));
	var c = getControl(P.fullControlName);
	pushButtonControl_setText(c, P.text);
	pushButtonControl_updateAttributes(c, P);
};

pushButtonControl_updateAttributes = function(cell, jsonParameters)
{
	var P = parseParameters(jsonParameters);
	//alert(JSON.stringify(P));
	var visible = true;
	var enabled = true;

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

	if (typeof P.enabled != "undefined")
	{
		cell.disabled = parseIntEx(P.enabled) == 0;
	}
};

function pushButtonControl_setup(cell, txt)
{
	cell.setAttribute("type", "button");
	addControlEvent(cell, "click", function(event) { pushButtonControl_onClick(cell, event); });
	pushButtonControl_setText(cell, txt);
}

function pushButtonControl_setText(cell, txt)
{
	cell.value = txt;
	cell.title = txt;
}

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

