
/* GENERAL
============================================================== */
$(document).ready(function() {
	/* Detección de javascript */
	$('html').removeClass('js-off');
	
	var anchoPantalla = $(window).width();
	if(anchoPantalla < 980){
		insertDataTitle();
	}
	
});


/* Titulos de las tablas (ready y resize) */
var setContent = false;

function insertDataTitle(){
	if(!setContent){
		$('table td').each(function() {
			if($(this).attr( "data-title" )){
				var dataTitle = $(this).attr( "data-title" );
				$(this).prepend( '<span class="content-before">' + dataTitle + '</span>' );
			}
		});

		setContent = true;
	}
}

function deleteDataTitle(){
	$('table td').each(function() {
		if($(this).attr( "data-title" )){
			$('.content-before').remove();
		}
	});

	setContent = false;
}

$(window).resize(function() {
	anchoPantalla = $(window).width();

	if(anchoPantalla <= 980){
  	insertDataTitle();
	}
	if((anchoPantalla > 980) & (setContent)){
		deleteDataTitle();
	}
});

/* Popups */
if(typeof fancybox == 'function'){
$('.popup-sm').fancybox({
	minWidth: '35%',
	padding: 0,
	closeBtn: true,
	title: null,
	helpers: {
		overlay: {
			closeClick: false,
			locked: true
		}
	}
});
$('.popup-md').fancybox({
	minWidth: '45%',
	padding: 0,
	closeBtn: true,
	title: null,
	helpers: {
		overlay: {
			closeClick: false,
			locked: true
		}
	}
});
$('.popup-lg').fancybox({
	minWidth: '65%',
	padding: 0,
	closeBtn: true,
	title: null,
	helpers: {
		overlay: {
			closeClick: false,
			locked: true
		}
	}
});
}


/* Para el login con Cédula Electrónica */
$(function() {
    $(".selector").click(function (event) {
        $(".selector").toggleClass('seleccionado');
        $("#tab1, #tab2").toggleClass('hide');
    })
});
