(function ($) {
    
$(document).ready(function() { 

  
  $('#global li.expand').click(function () {
    var $this = $(this).toggleClass('active');
    if ($this.hasClass('active')) {
      //$(document).bind('test');
    }
    //return false;
  });
    
  $('#header li.expand > a').click(function () {
	hidePopups();
    $(this).parent().addClass('active');
    return false;
  });
  
  $('body').click(function() {
	hidePopups();
  });
  
  $('#menu-browse .popup').click(function(e){
  	e.stopPropagation();
  });
  
});

})(jQuery);

function hidePopups() {
  	$('#header li.expand > a').each(function() {
  		$(this).parent().removeClass('active');
  	});
}
