/**
 * @author juanlopez4691@gmail.com
 */

var $jQ = jQuery.noConflict();

function switchStylestyle(styleName)
{
	$jQ('link[@rel="stylesheet"][@title]').each(function(i)
	{
		this.disabled = true;
		if (this.getAttribute('title') == styleName) this.disabled = false;
	});
}

$jQ(document).ready(function(){
	//Adapta la configuración de la página al ancho de pantalla en función de la resolución
	if (screen.width > 1024) {
		switchStylestyle('layout_res1200')
	} else {
		switchStylestyle('layout_res1024')
	}
	
	//Escoge un fondo para la cabecera al azar
	$jQ('#logo').css({backgroundImage: 'url(wp/wp-content/themes/massa/images/imagenCabecera_'+Math.floor(Math.random()*2+1)+'.jpg)'})
	
	//Prepara la leyenda de código de colores
	var e = '#leyenda > .colorKey';
	$jQ(e).hide();
	
	$jQ("#btnLeyenda").click(function () {
		if ($jQ(e).css('display')=='none') {
			$jQ(e).show("slow");
		} else {
			$jQ(e).hide("slow");
		}
	});
});

$jQ(window).resize(function() {
	if ($jQ(this).width() > 1024) {
		switchStylestyle('layout_res1200')
	} else {
		switchStylestyle('layout_res1024')
	}
})
