document.observe("dom:loaded", function() {
    $$('.b-scale a').each(function(noteLink) {
        var noteOptions = noteLink.onclick instanceof Function ? noteLink.onclick() : {};

        // Заметаем следы - обнуляем onclick
        noteLink.onclick = null;
        noteLink.removeAttribute('onclick');

        noteLink.observe('click', function() {  
            // Навешиваем обработчик onclick для показа попапа
            showChart(noteOptions.chart);
        });
    });
});

    function showChart(chart) { //e.g. F# for whistle: xxxxoo
        var chart = chart;
        var i = 0;
        $$('.note').each(function(e) {
            e.removeClassName('active');
        });
        $$('#instrumentScheme .hole').each(function(e) {
            $w('closed open half-open').each(function(s) {
                e.removeClassName(s);
            });
            switch ($A(chart)[i]) {
                case 'x':
                    e.addClassName('closed');
                    break;
                case 'o':
                    e.addClassName('open');
                    break;
                case '/':
                    e.addClassName('half-open');
                    break;
                default:
            }
            i++;
        });
        //document.cookie = this.type + "Scheme=" + chart + ";max-age=" + (60 * 60 * 24 * 365);
        //alert(document.cookie);
    }


/*

var element = document.getElementById('test');

// Забираем параметры
var options = element.onclick instanceof Function ? element.onclick() : {};

// Заметаем следы - обнуляем onclick
element.onclick = null;
element.removeAttribute('onclick');

// Навешиваем обработчик onclick для показа попапа
element.onclick = function () {
    showPopup(options);
};
*/
