<form action="index.php?ToDo=saveUpdatedAnalyticsSettings" name="frmAnalyticsSettings" id="frmAnalyticsSettings" method="post" onsubmit="return ValidateForm(CheckAnalyticsSettingsForm)">
	<div class="row">
		<div class="col-sm-12">
			<h4 class="page-title">{% lang 'AnalyticsSettings' %}</h4>
			<p>{% lang 'AnalyticsSettingsIntro' %}</p>
			{{ Message|safe }}
		</div>
	</div>

	<div class="row">
		<div class="col-sm-12">
			<input class="FormButton SaveButton btn btn-primary" type="submit" value="{% lang 'Save' %}">
			<input type="reset" value="{% lang 'Cancel' %}" class="FormButton CancelButton btn btn-default" onclick="ConfirmCancel()" />
		</div>
	</div>
	<br />
	<div class="row">
		<div class="col-sm-12">
			<ul id="tabnav" class="nav nav-tabs tabs" style="margin-bottom: 20px;">
				<li class="tab"><a href="#" class="active" id="tab0" onclick="ShowTab(0)">{% lang 'GeneralSettings' %}</a></li>
				<li style="display:none"><a href="#" id="tab1" onclick="ShowTab(1)"></a></li>
				{{ AnalyticsTabs|safe }}
			</ul>
		</div>
	</div>

	<input id="currentTab" name="currentTab" value="0" type="hidden">
	<div id="div0">
		<div class="panel panel-default form-horizontal">
			<div class="panel-heading"> 
				<h3 class="panel-title">Configurações Gerais</h3> 
			</div> 

			<div class="panel-body"> 
				<div class="form-group">
					<label class="col-md-2 control-label">{% lang 'AnalyticsMethods' %}:</label>
					<div class="col-md-10">
						<select size="5" multiple name="analyticsproviders[]" id="analyticsproviders" class="form-control ISSelectReplacement">
							{{ AnalyticsProviders|safe }}
						</select>
			        </div>
			    </div>
			</div>
		</div>
	</div>
	<div id="div1"></div>
	{{ AnalyticsDivs|safe }}

	<div class="row">
		<div class="col-sm-12">
			<input class="FormButton SaveButton btn btn-primary" type="submit" value="{% lang 'Save' %}">
			<input type="reset" value="{% lang 'Cancel' %}" class="FormButton CancelButton btn btn-default" onclick="ConfirmCancel()" />
		</div>
	</div>
</form>

<script type="text/javascript">
	function package_selected(package_id) {
		var ap = document.getElementById("analyticsproviders_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;
	}

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

	function CheckAnalyticsSettingsForm() {
		{{ AnalyticsJavaScript|safe }}
	}

	// Load the main analytics settings tab by default
	ShowTab({{ CurrentTab|safe }});
</script>