$(document).ready( function() {
	
	$('ul#myRoundabout li').focus( function(e) {
		$(this).find('div').slideDown();
	}).blur( function(e) {
		$(this).find('div').hide();
	});
	

	$('ul#myRoundabout').roundabout({
		minOpacity: 1,
		btnNext: '#carousel_next',
		btnPrev: '#carousel_prev'
	});

	
	
	$("#lang").mouseenter( function() {
		$("#lang ul").removeClass('slideUp').addClass('slideDown')
		setTimeout( function() {
			if ( $('#lang ul').hasClass('slideDown') ) {
				$('#lang ul').slideDown(200);
			}
		}, 100)
	}).mouseleave( function() {
		$('#lang ul').removeClass('slideDown').addClass('slideUp');
		setTimeout( function() {
			if ( $('#lang ul').hasClass('slideUp') ) {
				$('#lang ul').slideUp(200)
			}
		}, 800);
	});
	
	var tsm = null;
	var tz = null;
	$("#nav > ul").hover( 
		function () { 
			clearTimeout(tz); 
			$("#cover").fadeIn('fast'); 
		}, 
		function () { 
			tz = setTimeout("ukryj_zaslone()", 400); 
		}
	);
	$("#nav > ul > li").hover( 
		function () { 
			clearTimeout(tsm); 
			$("#nav > ul ul").hide().removeClass("hover");  
			$(this).find("ul").show().addClass('hover'); 
			$("#nav > ul > li").removeClass("lihover"); 
			$(this).addClass('lihover'); 
		}, 
		function () { 
			var t_this = this; 
			tsm = setTimeout( function(){ 
				if ( $(t_this).find("ul").hasClass('hover') ) {
					$(t_this).find("ul").fadeOut('slow').removeClass("hover"); 
				}
				$(t_this).removeClass("lihover"); 
			}, 400); 
		} 
	);
	
	$("a.fancyimage").fancybox({
		'hideOnContentClick': true,
		'zoomSpeedIn': 300,
		'zoomSpeedOut':	300,
		'overlayOpacity':0.7,
		'overlayColor':'#000',
		'autoScale':false
	});
		
	$("a.fancypanorama").fancybox({
		'hideOnContentClick': false,
		'zoomSpeedIn': 300,
		'zoomSpeedOut':	300,
		'overlayOpacity':0.7,
		'overlayColor':'#000'
	});
	$("a.fancypanorama2").fancybox({
		'hideOnContentClick': false,
		'type':'iframe',
		'width':800,
		'height':600,
		'zoomSpeedIn': 300,
		'zoomSpeedOut':	300,
		'overlayOpacity':0.7,
		'overlayColor':'#000'
	});	
});



function ukryj_zaslone() {
	$("#cover").fadeOut('fast');
}

$.fn.equalHeights = function(px) {
	var currentTallest = 0;
	$(this).each(function() {
		var currentHeight = $(this).height();
		if ( currentHeight > currentTallest) {
			currentTallest = currentHeight;
		}
	});
	currentTallest += 'px';
	// for ie6, set height since min-height isn't supported
	if ($.browser.msie && $.browser.version == 6.0) {
		$(this).css({'height': currentTallest});
	}
	$(this).css({'min-height': currentTallest}); 
	
	return this;
};

function wyswietlDetal( photo, width, height, src_dir ) {
	var win = window.open(src_dir+'/'+photo,'FOTO','menubar=no,toolbar=no,scrollbars=yes,resizable=no,status=no,top=50,left=100,width='+width+',height='+height);
}


