jQuery.fn.collapse = function () {
	this.each(function() {
		$(this).children('li').children('a').click(
			function (event) {
				var submenu = $(this).siblings('ul:first');
				//only apply event if the submenu exists
				if (submenu.length) {				
					//show or hide menu
					if (submenu.css('display') == 'none')
						submenu.show('slow');
					else
						submenu.hide('slow');
	
					//stop event and prevent propagation
					event.preventDefault();
					event.stopPropagation();
				}
		});
	});
}; 
