
// bloque activo
var bloqueActivo = 'bloque1';

function jQueryId(id)
{
    return "#" + id;
}

function jQueryLiId(bloqueId)
{
    return "#li_" + bloqueId;
}

function ver(bloqueId)
{
    // le cambio el estilo al li antiguo
    jQuery(jQueryLiId(bloqueActivo)).attr('class', null);

    // le cambio el estilo al li nuevo
    jQuery(jQueryLiId(bloqueId)).attr('class', 'pulsado');

    // oculto el bloque activo
    jQuery(jQueryId(bloqueActivo)).fadeOut('fast', function(){
        mostrar(bloqueId);
    });
}

function mostrar(bloqueId)
{
    // muestro el bloque nuevo
    bloqueActivo = bloqueId;
    jQuery(jQueryId(bloqueId)).fadeIn('fast');
}

// muestro el primero
jQuery(document).ready(function() {
    ver('bloque1');
});

function ver_pie(bloqueId)
{
    // muestro el bloque nuevo
    jQuery(jQueryId(bloqueId)).slideToggle(750, function(){
        // oculto los demás
        ocultar_pie(bloqueId);
    });
    
}

function ocultar_pie(bloqueId)
{
    var bloques = new Array("pie_mariscopedia_contenido", "pie_rias_contenido", "pie_donacigala_contenido");
    for(var i=0; i<bloques.length; i++)
    {
        if(bloques[i] != bloqueId)
        {
            // si es visible, lo oculto
            if(jQuery(jQueryId(bloques[i])).css('display') != 'none')
            {
                jQuery(jQueryId(bloques[i])).slideToggle('fast');
            }
        }
    }
}

jQuery(document).ready(function () {
    jQuery(jQueryId("pie_mariscopedia")).bind("mouseover", function(evento){
        jQuery(jQueryId("pie_mariscopedia_imagen")).attr('src', '/img/mariscopedia-on.jpg');
    });
    jQuery(jQueryId("pie_mariscopedia")).bind("mouseout", function(evento){
        jQuery(jQueryId("pie_mariscopedia_imagen")).attr('src', '/img/mariscopedia.jpg');
    });
    jQuery(jQueryId("pie_riasbaixas")).bind("mouseover", function(evento){
        jQuery(jQueryId("pie_riasbaixas_imagen")).attr('src', '/img/rias-on.jpg');
    });
    jQuery(jQueryId("pie_riasbaixas")).bind("mouseout", function(evento){
        jQuery(jQueryId("pie_riasbaixas_imagen")).attr('src', '/img/rias.jpg');
    });
    jQuery(jQueryId("pie_donacigala")).bind("mouseover", function(evento){
        jQuery(jQueryId("pie_donacigala_imagen")).attr('src', '/img/donacigala-on.jpg');
    });
    jQuery(jQueryId("pie_donacigala")).bind("mouseout", function(evento){
        jQuery(jQueryId("pie_donacigala_imagen")).attr('src', '/img/donacigala.jpg');
    });
});

function tienda()
{
    var capaId = jQueryId('menu_tienda');
    jQuery(capaId).slideToggle('fast', function() {
        createCookie('menuDisplay', jQuery(capaId).css('display'));
    });
}

jQuery(document).ready(function () {
    var menuDisplay = readCookie('menuDisplay');
    if(menuDisplay == 'block') tienda();
});

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function ventanuca(url, ancho, alto)
{
    window.open(url, 'popup', 'width='+ancho+',height='+alto+',location=no,toolbar=no,scrollbars=yes,top=200,left=200');
}

function __asdf(domObj, partes)
{
    var asdf = partes[0] + unescape("&#64") + 'doncamaro' + 'n.c' + 'om';
    jQuery(jQueryId(domObj.id)).html('<a href="'+ 'ma' + 'ilt' + 'o' + ':' + asdf + '">' + asdf + '</span></a>');
}

function recetas()
{
    jQuery("li[class$='submenu-recetas']").show("slow");
}

function recetasBloque(bloque)
{
    jQuery("[class^='submenu-recetas']").each(function (i) {
       if(this.id == bloque) jQuery(this).addClass("pulsado");
       else if(jQuery(this).hasClass("pulsado")) jQuery(this).removeClass("pulsado");
    });

    jQuery("[class^='submenu-recetas-receta']").each(function (i) {
        if(this.id.indexOf(bloque) != -1) jQuery(this).show("slow");
        else jQuery(this).hide("slow");
    });
}

function artes()
{
    jQuery("li[class$='submenu-artes']").show("slow");
}

function artesBloque(bloque)
{
    jQuery("[class^='submenu-artes']").each(function (i) {
       if(this.id == bloque) jQuery(this).addClass("pulsado");
       else if(jQuery(this).hasClass("pulsado")) jQuery(this).removeClass("pulsado");
    });

    jQuery("[class^='submenu-artes-arte']").each(function (i) {
        if(this.id.indexOf(bloque) != -1) jQuery(this).show("slow");
        else jQuery(this).hide("slow");
    });
}
