$(function(){
		$('#curren').find('ul:first').show();
		$('#current').parents('#lm>li>ul').show();
			
		$('#lm ul ul').parent().each(function() {
				var o = $(this);
				var s = o.find('>ul');
				var k = false;
				o.hover(
					function() {
						o.find('>a').attr('class','over');
						for (i=$('#menu_b ul').length; i>=0; i--){
						o.parent().find('>li').not(o).find('ul').eq(i).hide();
						}
						k = true;
						var p = o.position();
						var ts, ls;
							ts =  p.top;
							ls = p.left + o.width();
						s.css({
							top: ts,
							left: ls
						}).show();
					},
					function() {
						o.find('>a').attr('class','normal');
						k = false;
						window.setTimeout(function() {
							if (!k) s.hide(); 						   
						}, 500);
					}
				);
			});			
			
			
			
		$('#lm div').each(function(){
			var div = $(this);
			var m = div.parents('li:first').find('ul:first');
			if(m.get(0)){
				if(div.parents('li').find('ul:first').is(':visible')){
						div.attr('class','mminus');						
				}
				else{
						div.attr('class','mplus');						
				}
			}
			else div.removeAttr('class');
		})
		
		$('#lm a').each(function(){
			var a = $(this);
			var m = a.parents('li:first').find('ul:first');
			if(m.get(0)){
				if(a.parents('li:first').find('ul:first').is(':visible')){
						a.attr('class','lover');						
				}
				else{
						a.removeAttr('class');						
				}
			}
			else a.removeAttr('class');
			
		})
		
		 $('#lm div').click(function() {
					var a = $(this);
					var ul = a.parents('li:first').find('ul:first');
					if (ul.get(0)) {
							ul.toggle();
							if(a.parents('li:first').find('ul:first').is(':visible')){
								a.attr('class','mminus');
								a.parents('li:first').find('a:first').attr('class','lover');
															}
							else{
								a.attr('class','mplus');
								a.parents('li:first').find('a:first').removeAttr('class');
							}return true;
							
					}
					
		});
})
