 jQuery(function() {
 var currHeight = 0;
	/*
	jQuery('#menu').hover(
		function() {
		var bcg = jQuery(this).find('#menu_bcg');
		if(!bcg.hasClass('open')) {
			bcg.addClass('open');
			bcg.stop(true,true).slideDown('slow',function() {
				
			});
			
		}
	}, function() {
		var bcg = jQuery(this).find('#menu_bcg');
		if(bcg.hasClass('open')) {
			bcg.removeClass('open');
			bcg.delay(500).slideUp('slow');
		}
	});
	*/
	jQuery('.sf-menu').hover(
		function() {
		var bcg = jQuery('#menu_bcg');
		if(!bcg.hasClass('open')) {
			bcg.addClass('open');
			bcg.stop(true,true).slideDown('slow',function() {
				
			});
			
		}
	}, function() {
		var bcg = jQuery('#menu_bcg');
		if(bcg.hasClass('open')) {
			bcg.removeClass('open');
			bcg.delay(500).slideUp('slow');
		}
	});
	
	jQuery("#wrapper").children("#menu").children().children().hover(function(){
		var counter = 0;
		jQuery('#menu_bcg').css('height', 300).css('padding-bottom', 20).css('border', 1);
		var liHeight = parseInt(jQuery(this).children('ul').children().children('a').css('lineHeight')) + 1;
		jQuery(this).children('ul').children('li').each(function(index){
			counter = counter + 1;
		});
	
			var bcgHeight = 0;
			if(counter*liHeight < 280)
			{
				bcgHeight = 300;
			}
			else
			{
				bcgHeight = counter*liHeight;
			}
			jQuery('#menu_bcg').css('height', bcgHeight).css('padding-bottom', 20).css('border', 1);

	})
	
});



