jQuery(document).ready(function ($){
    $('.categories').click(function (e) {
        var target = e.target, $target = $(target);
        var parent = $target.parent();
        var catid = parent.attr('data-id');
        if (target.tagName == 'SPAN' && catid !== undefined) {
            var child = parent.find('ul.child');
            if(child[0])
                child.slideDown('fast');
            if(!$target.hasClass('active'))
            {
                $('.categories .active').removeClass('active');
                $target.addClass('active');
                if(catid != undefined && catid != '')
                    window.location = '/directory/?catid=' + catid;
                else
                    window.location = '/directory/';
            }
        }
    });
    
});


