<form action="index.php?ToDo=saveUpdatedAddonSettings" name="frmAddonSettings" id="frmAddonSettings" method="post" onsubmit="return ValidateForm(CheckAddonSettingsForm)">
	<div class="row">
		<h4 class="page-title">{% lang 'AddonSettings' %}</h4>
		<p>{% lang 'AddonSettingsIntro' %}</p>
		{{ Message|safe }}
	</div>

	<div class="row">
		<input type="submit" value="{% lang 'Save' %}" class="btn btn-primary" />
		<input type="reset" value="{% lang 'Cancel' %}" class="btn btn-default" onclick="ConfirmCancel()" />
		<br><br>
	</div>

	<div class="row">
		<ul id="tabnav" class="nav nav-tabs tabs ui-tabs ui-widget ui-widget-content ui-corner-all" style="margin-bottom: 20px;">
			<li class="tab"><a href="#" class="active" id="tab0" onclick="ShowTab(0)">{% lang 'GeneralSettings' %}</a></li>
			{{ AddonTabs|safe }}
			<br class="Clear">
		</ul>
	</div>

	<div class="row">
		<input id="currentTab" name="currentTab" value="0" type="hidden">
		<div id="div0" style="padding-top: 10px;">
			<div class="panel panel-default">
				<div class="panel-heading" style=""> 
					<h3 class="panel-title">{% lang 'AddonPackages' %}</h3> 
				</div> 

				<div class="panel-body">
					<select size="{{ AddonSelectBoxSize|safe }}" multiple name="addonpackages[]" id="addonpackages" class="form-control ISSelectReplacement">
						{{ AddonProviders|safe }}
					</select>
				</div>
			</div>
		</div>

		{{ AddonDivs|safe }}
	</div>
	<div class="row">
		<input type="submit" value="{% lang 'Save' %}" class="btn btn-primary" />
		<input type="reset" value="{% lang 'Cancel' %}" class="btn btn-default" onclick="ConfirmCancel()" />
	</div>
</form>
<script type="text/javascript">
	var hide_buttons_on_tabs = '{{ TabIdsToHideButtonsFrom|safe }}';
	function package_selected(package_id) {
		var ap = document.getElementById("addonpackages_old");

		for(i = 0; i < ap.options.length; i++) {
			if(ap.options[i].value == package_id && ap.options[i].selected)
				return true;
		}

		return false;
	}

	function ShowTab(T) {
		i = 0;
		while (document.getElementById("tab" + i) != null) {
			document.getElementById("div" + i).style.display = "none";
			document.getElementById("tab" + i).className = "";
			i++;
		}

		document.getElementById("div" + T).style.display = "";
		document.getElementById("tab" + T).className = "active";
		document.getElementById("currentTab").value = T;

		// Is this a tab on which we have to hide the save/cancel buttons
		if(hide_buttons_on_tabs.indexOf(T + '|') > -1) {
			$('#SaveCancelBottom').hide();
		} else {
			$('#SaveCancelBottom').show();
		}
	}

	function ConfirmCancel() {
		if(confirm("{% lang 'ConfirmCancelAddonsSettings' %}"))
			document.location.href = "index.php?ToDo=viewAddonSettings";
	}

	function CheckAddonSettingsForm() {
		{{ AddonJavaScript|safe }}
	}

	$(document).ready(function() {
		// Load the main addons settings tab by default
		ShowTab({{ CurrentTab|safe }});
	});
</script>