if (document && document.documentElement){
    document.documentElement.className = 'js';
}

// Navegación
$(function() {
    $('#s')
        .each(function() {
            this._value = $(this).val();
        })
        .click(function(e) {
            if ($(this).val() == this._value) {
                $(this).val('');
            }
        })
        .blur(function() {
            if (!$(this).val()) {
                $(this).val(this._value);
            }
            
        });
});

$(function() {
    $('.tabs:not(.nojs)')
        .find('.marcado a')
            .each(function() {
                var href = $(this).attr('href');
                if (href.match(/^#.?/)){
                    $(href).show().trigger('visible');
                }
            })
        .end()
        .find('a')
            .each(function() {
                var href = $(this).attr('href');
                if (!href.match(/^#.?/)){
                    return;
                }
                $(this).click(function(e) {
                    e.preventDefault();
                    var li = $(this).parent();
                    if (!li.hasClass('marcado')) {
                        var marcado = li.parent().find('.marcado');
                        $(marcado.find('a').attr('href')).hide();
                        marcado.removeClass('marcado');

                        li.addClass('marcado');
                        $($(this).attr('href')).show().trigger('visible');
                    }
                });

            });
});

$(function() {
    $('.lnk-desplegable a').toggle(
        function() {
            $(this).parent().addClass('abierto');
            var txt = $(this).text().replace('más','menos');
            $(this).text(txt);
            $($(this).attr('href')).slideDown();
        },
        function() {
            $(this).parent().removeClass('abierto');
            var txt = $(this).text().replace('menos','más');
            $(this).text(txt);
            $($(this).attr('href')).slideUp();
        });
});

