#include "../../../lib/std.mi"

Global Text textBox;
Global Togglebutton buttonCheckBox;
Global String strItem = "";
Global String strSection = "";
Global int intDefaultValue = 999;

System.onScriptLoaded() {
	textBox = System.getScriptGroup().getObject("checkbox.text");
	buttonCheckBox = System.getScriptGroup().getObject("checkbox.toggle");
}

System.onSetXuiParam(String strParam, String strValue) {
	if (strUpper(strParam) == "USETEXT") textBox.setText(strValue);
	if (strUpper(strParam) == "PRIVATEINTITEM") strItem = strValue;
	if (strUpper(strParam) == "DEFAULT") intDefaultValue = System.stringToInteger(strValue);
	if (strItem != "" && strSection != "" && intDefaultValue != 999) {
		buttonCheckBox.setActivated(System.getPrivateInt(getSkinName(), strItem, intDefaultValue));
	}
}

buttonCheckBox.onLeftClick() {
	buttonCheckBox.setActivated(!buttonCheckBox.getActivated());
}

textBox.onLeftButtonUp(Int intPosX, Int intPosY) {
	buttonCheckBox.setActivated(!buttonCheckBox.getActivated());
}

buttonCheckBox.onActivate(Int intActivated) {
	System.setPrivateInt(getSkinName(), strItem, intActivated);
}