(function($)
{
    $.fn.menu = function(o)
    {
        o = $.extend({
        active: null			// previous button customization
        }, o || {});
        $('#transparentLayer').hide();
        return this.each(function()
        {
            var ul = $(this);
            $("div", ul).each(function()
            {
                if($(this).attr('id') &&  $(this).attr('id').indexOf('m_') != -1)
                {
                    $(this).bind('click', function()
                    {
                        var branchId = $(this).attr('id').replace(/m_/g, '');
                        var branch = $(this).attr('name');
                        if(o.active != branchId)
                        {
                          get_activity(branchId, branch);

                        }
                        
                    });
                }

            });

        });


function get_activity(Id, branch)
{
        $('#PopUp').load('/branchenbuch/inc/ajax/get_activity.php',
        {ajaxpost: {routing: 'get_activity',
                    branchId: Id}},
        function (responseText, textStatus, XMLHttpRequest)
        {
            if(responseText != '')
            {
                          $('#m_'+o.active).removeClass('active')
                          $('#m_'+Id).addClass('active')
                          o.active = Id;
              $('#transparentLayer').show();
              $('#close_layer').bind('click', function()
              {
                $('#transparentLayer').hide();
                $('#leistungen').hide();
                $('#m_'+o.active).removeClass('active')
                o.active = null;
              });
          }
          else
          {
                document.location.href = '/'+branch+'/';
          }
        }
    );

}


    }



})(jQuery);


