<form action="index.php?ToDo=saveUpdatedLiveChatSettings" method="post" id="frmLiveChatSettings" onsubmit="return ValidateForm(CheckLiveChatSettingsForm)">
	<input type="hidden" name="currentTab" id="currentTab" value="0" />
	<div class="row">
		<div class="col-sm-12">
			<h4 class="page-title">{% lang 'LiveChatSettings' %}</h4>
			<p>{% lang 'LiveChatSettingsIntro' %}</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>
				{{ LiveChatTabs|safe }}
			</ul>
		</div>
	</div>

	<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 'LiveChatServices' %}:</label>
					<div class="col-md-10">
						<select multiple name="livechatservices[]" id="livechatservices" class="form-control ISSelectReplacement" style="width: 100%">
							{{ LiveChatServices|safe }}
						</select>
			        </div>
			    </div>
			</div>
		</div>
	</div>

	<div id="div1" style="padding-top: 10px;"></div>
	{{ LiveChatDivs|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) {
		if(g('livechatservices_old')) {
			f = 'livechatservices_old';
		}
		else {
			f = 'livechatservices';
		}
		var ap = document.getElementById(field);
		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 'ConfirmCancelLiveChatSettings' %}"))
			document.location.href = "index.php?ToDo=viewLiveChatSettings";
	}

	function CheckLiveChatSettingsForm() {
		{{ LiveChatJavaScript|safe }}
	}

	// Load the main tab by default
	ShowTab({{ CurrentTab|safe }});

</script>
