function activaTab (id) {

	var activa = document.querySelector('#activa-' + id).checked ? 1 : 0;

	jQuery.ajax({

		url: smat_reordena.ajax_url,
		type : 'POST',
		data : {
			action : 'smat_activa_tab',
			cache : false,
			id : id,
			activar : activa,
			nonce : smat_reordena.nonce_activa,
			},

		success : function (data) {},
		error : function (html) {},
		});
	}

jQuery(document).ready(function() {

	jQuery('table.posts #the-list').sortable({

		'items' : 'tr',
		'axis' : 'y',
		'update' : function(e, ui) {

			var cpt   = getQueryVariable('post_type');
			var orden = jQuery('#the-list').sortable('serialize');
			var paged = getQueryVariable('paged');

			if ('undefined' == typeof paged)
				paged = 1;

			jQuery.ajax({

				url : smat_reordena.ajax_url,
				type : 'POST',
				cache : false,
				dataType : 'html',
				data : {
					action : 'smat_actualiza_orden_cpt',
					cpt : cpt,
					orden : orden,
					paged : paged,
					nonce : smat_reordena.nonce_reordena,
					},

				'success' : function(data) {},
				'error' : function(html) {},
				});
			},
		});
	});

function getQueryVariable (variable) {

	var query = window.location.search.substring(1);
	var vars  = query.split('&');

	for (var i = 0; i < vars.length; i++) {

		var pair = vars[i].split('=');

		if (pair[0] == variable)
			return pair[1];
		}

	return false;
	}