﻿var MensajeUsuario = document.getElementById("MensajeUsuario");
function AbrirPopup(pagina) {
	var opciones = "toolbar=no, location=no, left=0, top=0, width=270, height=200,  directories=no, status=no, menubar=no, scrollbars=no, resizable=no ";
	window.open(pagina, "ppBora", opciones);
}

function EMailInvalido(EMail) {
	return !/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$/.test(EMail);
}

function esNumero(e) {
	var ie = document.all;
	if ((ie && e.keyCode == 8) || (!ie && (e.which == 8 || e.which == 0)))
		return true;
	else
		return /\d/.test(String.fromCharCode(ie ? e.keyCode : e.which));
}
jQuery(document).ready(function() {

	//busqueda rapida con enter
	jQuery('body').keypress(function(e) { if (e.which == 13) { e.preventDefault(); validar(); } });

	// Tooltip de anexos.
	jQuery('#ingresar a').each(function() {
		//obtener url
		var content = '<iframe src="';
		content += jQuery(this).attr('url');
		content += '" alt="Cargando ingreso..." height="185" width="270" frameborder="0" scrolling="no" />';

		// Configurar tooltip
		jQuery(this).qtip(
		{
			content: {
				once: true,
				text: content,
				title: {
					text: 'Ingresar',
					button: true
				}
			},
			position: {
				my: 'top center',
				at: 'bottom center',
				target: jQuery('#ingresar a'),
				adjust: {
					x: -92
				}
			},
			style: {
				tip: true,
				classes: 'ui-tooltip-blue'
			},
			show: {
				solo: true, // And hide all other tooltips
				delay: 200,
				event: 'click'
			},
			hide: {
				event: 'click'
			}
		});
	});


});

function CargarPopUpBienvenida(primeraVez) {

	if (primeraVez != 'True') return;

	jQuery(document).ready(function() //crear tooltip una vez cargado el documento
	{
		// Configurar tooltip
		jQuery(document.body).qtip(
		{
			content:
			{
				once: true,
				text:'<img src="/Content/Images/PopUpBienvenida/pop-up_principal.jpg" alt="Bienvenidos"/>',
				title: {
					text: '¡Bienvenido!',
					button: true
				}
			},
			position:
			{
				my: 'top center',
				at: 'top center',
				target: jQuery(document.body),
				adjust:
				{
					y: 100
				}
			},
			style:
			{
				tip: false,
				classes: 'ui-tooltip-blue',
				width: { min: 650 }

			},
			show: { when: false, ready: true },
			hide: {
				event: 'click'
			},
			events: {
				hide: function(event, api) {
					jQuery(document.body).qtip('destroy');
				}
			}
		});
	});
}

function getInternetExplorerVersion() {
	var rv = -1;
	if (navigator.appName == 'Microsoft Internet Explorer') {
		var ua = navigator.userAgent;
		var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
		if (re.exec(ua) != null)
			rv = parseFloat(RegExp.$1);
	}
	return rv;
}
