﻿jQuery(document).ready(function () {

    // Apertura / chiusura della propria tab per ciascun pulsante
    jQuery('.head-tab A.open').click(function () {
        //alert('open');
        jQuery(this).parent().parent().children('.toggle').toggle('blind',400, checkVisibleItems);
        return false;
    });


    // Funzione per pulsante apri / chiudi tabs
    jQuery('A.open-all').click(function () {
        if (jQuery(this).hasClass('close')) {
            jQuery('.toggle').hide(); //Rimosso "blind" se no flickera
            jQuery('A.open-all SPAN').html(openAllTabsLabel);
        } else {
            jQuery('.toggle').show('blind');
            jQuery('A.open-all SPAN').html(closeAllTabsLabel);
        }
        jQuery('A.open-all').toggleClass('close');
        return false;
    });


});

//Cambia pulsante open all/close all
function checkVisibleItems() {
    var currentVisible = jQuery('.toggle:visible').length;
    var total = jQuery('.toggle').length;

    if (currentVisible == 0) {
        jQuery('A.open-all SPAN').html(openAllTabsLabel);
    }
    else if (currentVisible == total) {
        jQuery('A.open-all SPAN').html(closeAllTabsLabel);
    }
}



