(function() {
	
	$("a.tab_panel_tab_link").click(
			function(event) {
				var tab = this.id.split("__")[1];
				$("td.tab_panel_tab_compare_active").removeClass("tab_panel_tab_compare_active").addClass("tab_panel_tab_inactive");
				$(this).parent().removeClass("tab_panel_tab_inactive").addClass("tab_panel_tab_compare_active");
				$("div.targets_tab").hide();
				$("div#tab__"+tab).show();
				event.stopPropagation();
				event.preventDefault();
			}
	);
	
	console.log('engaging manipulators');
	$('button.server_manipulator_delete').click(
			function(event) {
				var serverid = $(this).data()['serverid'];
				if (confirm('Точно удалить?')) {
					$(this).parent().append('<span id="krutilka_'+serverid+'" style="clolor: red; padding-left: 0.4em;"><i class="krutilka fa fa-circle-o-notch fa-spin" aria-hidden="true"></i><span>');
					$.getJSON("/openstack/delete_server?server_id=" + serverid).done(function(data) {
						if (data[0]['success']){
							window.location.reload()
						}
						else {
							$("#krutilka_"+serverid).html(data[0]['error'])
						}
					})
				}
 				event.stopPropagation();
				event.preventDefault();
			}
		)
})();