$(function() {
    $('.comments-container .comments').each(function() {
        id = this.title;
        if (id) {
            var _this = this;
            $.get('/video_comments.json', { music_id: id }, function(data, textStatus) {
                var comments = null;
                try {
                    comments = eval('(' + data + ')');
                } catch (e) {
                    comments = [];
                }
                _this.title = '';
                _this.innerHTML = '';
                if (comments.length) {
                    var ul = $('<ul></ul>');
                    for (var i = 0; i < comments.length; i++) {
                        var e = $('<li></li>');
                        e.text(comments[i]);
                        if (i >= 3) {
                            e.addClass('older');
                        }
                        e.appendTo(ul);
                        ul.appendTo(_this);
                    }
                } else {
                    var e = $('<p></p>').text('コメントがみつかりませんでした。');
                    e.appendTo(_this);
                }
            });
        } else {
            this.innerHTML = '';
            var e = $('<p></p>').text('コメントがみつかりませんでした。');
            e.appendTo(this);
        }
    });
    //$('.cd .product .image img').reflect();
    //$('.thumbnail-container .thumbnail img').reflect();
});
