
$(document).ready( function() {

	$('.details').bind( 'mouseenter', function(event, slide) {
		var tool = $(this).attr('id');
		$(this).removeClass('slideUp').addClass('slideDown').addClass('hover');
		$('.details:not(#'+tool+')').trigger( 'mouseleave', [0] );
		setTimeout( function() {
			if ( $('#'+tool).hasClass('slideDown') ) {
				$('#'+tool).find('.tool_details').slideDown(300, function() {
					if ( slide == true ) {
						$(this).trigger('mouseleave', [4000] );
					}
				});
			}
		}, 100);
	}).bind( 'mouseleave', { time: 800 }, function(event, time) {
		var tool = $(this).attr('id');
		var timeout = ( typeof time == 'number' ? time : 800 );
		$(this).removeClass('slideDown').addClass('slideUp');
		setTimeout( function() {
			if ( $('#'+tool).hasClass('slideUp') ) {
				if ( $('#'+tool+' .tool_details').length > 0 ) {
					$('#'+tool).find('.tool_details').slideUp(300, function(){
						$('#'+tool).removeClass('hover');
					});
				} else {
					$('#'+tool).removeClass('hover');
				}
			}
		}, timeout);
	});
	
	$('#hide_cart_details').live( 'click', function() {
		$("#cart_details").trigger( 'mouseleave', [0] );
		return false;
	});

	//
	$("a.fancyimage").fancybox({
		'hideOnContentClick': true,
		'zoomSpeedIn': 300,
		'zoomSpeedOut':	300,
		'overlayOpacity':0.7,
		'overlayColor':'#000'
	});


	
	$("a.fancycontent").fancybox({
		'width'				: 700,
		'height'			: 500,
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});
		

	$('#nav > li').hover( function() {
		$(this).find( 'div.ulborder > ul > li > ul.szpalting').equalHeights();
		$(this).find( 'div.ulborder > ul > li').equalHeights();
	});

});


function printWindow( url ) {
	okno = window.open( url,'Diverse','toolbar=no,scrollbars=yes,status=no,top=50,left=50,width=700,height=600');
}


$.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;
};
