function CoreGetID(module, subelement)
{
	return "core_advanced_" + module + "_" + subelement;
}

function CoreOnAdvancedTitleClick(module)
{
	if (ToggleShowElement(CoreGetID(module, "settings")))
	{
		document.getElementById(CoreGetID(module, "icon")).style.backgroundImage = "url(\"themes/icon/collapse.png\")";
		IncludeURL("ajax/core/showsettings?values_module=" + module, CoreGetID(module, "settings"));
	}
	else
		document.getElementById(CoreGetID(module, "icon")).style.backgroundImage = "url(\"themes/icon/expand.png\")";
}

function CoreOnAdvancedSettingAdd(module)
{
	HideElement("hint_core_setting_add");
	onLightBoxPrompt_CallBack = function (setting)
	{
		return CoreOnAdvancedSettingEdit(module, setting, "");
	}
  LightBoxPrompt(modastrings.get("core", "advanced_setting"), "");
	return false;
}

function CoreOnAdvancedSettingEdit(module, setting, defaultValue)
{
	onLightBoxPrompt_CallBack = function (value)
	{
		url = "ajax/core/editsetting?values_module=" + module;
		url += "&values_setting=" + URLEncode(setting);
		url += "&values_value=" + URLEncode(value);

		id = CoreGetID(module, "settings");
		IncludeURL(url, id);
		ShowElement(id);
	}
	LightBoxPrompt(modastrings.get("core", "advanced_value"), defaultValue);
	return true;
}

function CoreOnAdvancedSettingDelete(module, setting)
{
	if (confirm("Are you sure?"))
	{
		url = "ajax/core/deletesetting?values_module=" + module;
		url += "&values_setting=" + URLEncode(setting);

		id = CoreGetID(module, "settings");
		IncludeURL(url, id);
		ShowElement(id);
	}
}

function CoreOnAdvancedSettingChanged(module)
{
	HideElement(CoreGetID(module, "settings"));
	CoreOnAdvancedTitleClick(module);
}
