(function($){
$.fn.initMenu = function() {  
return this.each(function(){
						  
	//var theMenu = $.get(0);
		$('.n2', this).hide();
		
		// asc activeMenu	
		var urlPath = location.pathname;
		var pathArray = urlPath.split("/", 4);
		var activeMenu = pathArray[2];
		
		$('#'+activeMenu).addClass('expand');
		
		
		
       	$('li.expand > .n2', this).show();
        $('li.expand > .n2', this).prev().addClass('active');
		//$('li.expand > .n2', this).prev().addClass('collapsible');
		
        $('li a', this).click(function(e) {				   
                e.stopImmediatePropagation();
                var theElement = $(this).next();
                var parent = this.parentNode.parentNode;
				nactive = String(this.parentNode.id);
				
				
				
				if(theElement.hasClass('n2') && theElement.is(':visible') ){
						$('.n2:visible', parent).first().slideUp('normal', function() {
							$(this).prev().removeClass('active');
						}
					);
					return false;
                }		
				
                if(theElement.hasClass('n2') && !theElement.is(':visible')) {         
                    $('.n2:visible', parent).first().slideUp('normal', function() {
                        $(this).prev().removeClass('active');
                    });
                    theElement.slideDown('normal', function() {
                        $(this).prev().addClass('active');
                    });
                    return false;
                }
    	});
		


});
};
})( jQuery );

jQuery(document).ready(function() {jQuery('.menu').initMenu();});


