$(document).ready( function() {

	var heightMin = 34
	var heightMax = 250
	
	var menuheight = $('#top_menu').height();
	
	var heightsOfMenuItems = $('.category').map(function (index, item) {
		return parseInt($(item).css('height'))
	})
	
	var maxListItemHeight = Math.max.apply(null, heightsOfMenuItems.get())
	
	$($('.category*').get().concat($('.category_current').get())).find("ul").css('height', maxListItemHeight)
	
	$('#top_menu').css('height', heightMin);
	$('#top_menu').css('visibility', 'visible');

	//100% height processor
	var height = $('.fullHeight').parent().css('height');
	$('.fullHeight').css('height', height);

	// $("#top_menu").hoverIntent( 
	// 	function() {
	// 		$(this).animate({ height: menuheight}, heightMax);
	// 	}, 
	// 	function() {
	// 		$(this).animate({ height: heightMin}, heightMax);
	// 	}
	// );

	var sendFancyBoxToFront = function () {
		$('#fancybox-overlay').css('z-index', 99999);
		$('#fancybox-wrap').css('z-index', 100000);
	}

	$(".fancybox").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600,
		'speedOut'		:	200,
		'onComplete'	: 	sendFancyBoxToFront
	});

	$(".fancyYoutube").fancybox({
		'transitionIn' 	: 'elastic',
		'padding' 		: 0,
		'autoScale' 	: false,
		'transitionOut' : 'fade',
		'width' 		: 680,
		'height' 		: 495,
		'type' 			: 'swf',
		'onComplete'	: 	sendFancyBoxToFront 
	});
});
