
// Redimensionamos coverAll porque no coje todo el tamaño del documento en altura
jQuery(document).ready(function () {
	jQuery("#coverAll").height(jQuery(document).height());
});

/* 
	CoverAll alpha
	Se cargará la capa de COVER si hay imagen de fondo para la Web
 */
if (jQuery("img.maximage").html() != null) {
	jQuery("#coverAll").fadeTo("slow", 0.3);
}

function hideCoverAll ()
{
	// Ocultamos la capa que cubre todo y precarga
	jQuery("#coverAll").fadeOut("slow", function (){
		// Si estamos en la página inicial, habrá logotipo grande: lo mostramos con FADE
		if (jQuery("#logotype").html() != null) {
			jQuery("#logotype").fadeIn("slow");	
		}
	});
}



/* Hack para que los enlaces con la clase EXTERNAL carguen en ventana nueva */
jQuery(document).ready(function () {
	jQuery("a.external").click(function(){
		this.target = "_blank";
	});
});


// Hack para reemplazar la dirección de correo escrita (cuenta [AT] dominio [dot] ext) por la dirección real
jQuery.fn.mailto = function() {
	return this.each(function(){
		if (jQuery(this).attr("href").indexOf("(at)") != -1)
		{
			var email = jQuery(this).attr("href").replace(/\s*\(.+\)\s*/, "@");
			var email = email.replace("mailto:", ""); // Delete mailto: if exists
			var text = jQuery(this).html().replace(/\s*\(.+\)\s*/, "@"); // Replace (at) on text if exists
			jQuery(this).before('<a href="mailto:' + email + '" rel="nofollow" class="email" title="Email ' + email + '">' + text + '</a>').remove();
		}
	});
};

jQuery(document).ready(function () {
	jQuery(".email").mailto();
});
