$(document).ready(function() {

	var nowDate = new Date();

	if ($('table.calendar').length) {
		$(this).find('tr').click(function() {
			window.location.href = $(this).find('a').attr('href');
		})/*.hide()*/.each(function(index) {			
			var a = $(this).attr('id').split('-');			
			var trDate = new Date(a[1], a[2]-1, parseInt(a[3]) + 1);
			if (trDate.getTime() < nowDate.getTime())
			{
				$(this).hide()
			}
			$(this).animate({'opacity':0},1).delay(index*50).animate({'opacity':1},300);			
		});
		hideDates();		
	}
	
	$('img').load(function() { $(this).hide().fadeIn(); })
	
	$('#banner').hide().delay(250).fadeIn(500);
	
	$("a.group").fancybox({
		'speedIn':		300,
		'speedOut':	300,
		'overlayColor':	'#000',
		'overlayOpacity':	0.7
	});
	
	$('.boxes .wernisaz').each(function() {
		$(this).find('img.maska').attr('src', '/uploads/images/box-maska-black.png');
	});
	
});

function hideDates() {
	var a = $('#mDate').text().split('-');
	var currentMonthDate = new Date(a[2], a[1]-1, a[0]);
	var nowDate = new Date();
	if (currentMonthDate.getTime() < nowDate.getTime())
	{
		$('.next_prev .prev').hide();
	}
}


