$(document).ready(function() {
    // 親カテゴリ
    var categories = $('#side ul.category>li');
    // 前に乗っていたオブジェクト
    var thisObj;
    // タイマー
    var sideTimer;
    // 孫カテゴリ
    var dCat = $('ul.d_cat');

    // 孫カテゴリを非表示に
        /*
    dCat.each(function() {
        $(this).hide();
    });
            */

    categories.each(function() {
    	$(this).find('dt').hover(function() {
            // ふきだし
            var balloon = $(this).find('span.cat_num');
            // オブジェクトのポジション
            var objLeft = $(this).parent().position().left;
            var objTop  = $(this).parent().position().top;

            if (balloon.css('display') == 'none') {
                balloon.show();

                // マウスポインタの10px上に配置
                $(this).mousemove(function(e) {
                    balloon.css({
                        'left': e.pageX - objLeft - Math.floor(balloon.width() / 2) + 'px',
                        'top': e.pageY - objTop - balloon.height() - 10 + 'px',
                        'z-index': 1
                    });
                });
            }
        }, function() {
            var balloon = $(this).find('span.cat_num');
                
            if (balloon.css('display') != 'none') {
                balloon.hide();
            }
        });
    
        // クラスがあるオブジェクトのみ
        /*if (!!$(this).attr('class')) {
            $(this).find('dt a').click(function() {
                var child = $(this).parent()
                                   .parent()
                                   .find('dd');

                if (child.css('display') != 'none') {
                    child.hide();
                } else {
                    categories.each(function() {
                        $(this).find('dd').hide();
            });
                    child.show();
                }

                return false;
                    });
        }*/
    });
});
