$(function(){
	
	var k = false;
	
	$('ul.fck')
		.live('mouseenter', function(){
			k = true;
		})
		.live('mouseleave', function(){
			k = false;
			
			setTimeout(function() {
				if ( !k ) { 
					$('.fck').remove(); 
					$('.menu_hor li').attr('class', 'normal');
				}
			}, 500);
		});
		
	$('.menu_hor li')
		.live('mouseenter', function(){
			k = true;
		
			$('.fck').remove();
			
			$('<ul></ul>')
				.addClass('fck')
				.html($(this).find('ul:first').html())
				.appendTo('body')
				.show()
				.css({
					top: $(this).offset().top + $(this).height() - ( $.browser.opera ? 20 : 0 ) ,
					left: $(this).offset().left
				});
		})
		.live('mouseleave', function(){
			k = false;

			$(this).attr('class', 'normal');

			setTimeout(function() {
				if ( !k ) { $('.fck').remove(); }
			}, 500);
		});


	/*$('.menu_hor ul').parent().each(function() {
		var o = $(this);
		var s = o.find('>ul');
		var l = o.parents('ul').length;
		var k = false;

		o.hover(
			function() {
				o.find('>a').attr('class','active');
				for (i=$('.menu_hor 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;
				if (l == 1) {
					ts =  p.top + o.height();
					ls = p.left;
				} else {
					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);
			}
		);
	});*/
});
