/*
$(document).bind('cbox_load', function(){
	$("html, body").animate({scrollTop:0}, 1);
});
*/
$(document).bind("keydown.cbox_close", function (e) {
	if (e.keyCode === 27) {
			e.preventDefault();
	}
	if (e.keyCode === 37) {
			e.preventDefault();
	}
	if (e.keyCode === 39) {
			e.preventDefault();
	}
});


$(document).ready(function(){

	$('input[placeholder], textarea[placeholder]').placeholder(); 

///////////////////////////////////////////////////////////////////
//// topmenu
///////////////////////////////////////////////////////////////////
	$('#header li img').css({ opacity: 0 });
	$('#header li').hover(function(){
			$(this).find('img').animate({ opacity: 1 }, 500);
		},function(){
			$(this).find('img').animate({ opacity: 0 }, 300);
	});


///////////////////////////////////////////////////////////////////
//// vyjížděcí boxy na HP
///////////////////////////////////////////////////////////////////
	$('.box:not(.show) img.icon').css({ opacity: 0.7 });
	$('.box:not(.show) h3').hover(function(){
			$(this).parent().find('.icon').animate({ opacity: 1 }, 500);
		},function(){
			$(this).parent().find('.icon').animate({ opacity: 0.7 }, 300);
	});

	$('.box:not(.show) h3').click(function() {
		var otevreny = $(this).parent().hasClass('boxOpen');
		$('.box h3').animate({ opacity: 1 }, 500);
		
		if (!otevreny) {
			$(this).animate({ opacity: 0 }, 1500);
			$('.box').removeClass('boxOpen');
			$('.box:not(.show)').animate({ height: 57 }, 300);
			$(this).parent().animate({ height: 200 }, 1500);
			$(this).parent().addClass('boxOpen');
		} else {
			$(this).parent().animate({ height: 57 }, 300);
			$(this).parent().removeClass('boxOpen');
		}
	});
	
///////////////////////////////////////////////////////////////////
//// colorbox
///////////////////////////////////////////////////////////////////
	$('#header ul li a, #footer ul#footmenu li a, .more').click(function() {
		$("#cboxContent").removeClass("slideshow").addClass("html"); 
		//var text = $("html").scrollTop();

		$(this).colorbox({
			innerWidth: 976,
			scrolling: false,
			top: 109,
			opacity: 0.8,
			rel:'nofollow'
		});
	});

	$('a[rel="celnice"], a[rel="vaclavak"], a[rel="kremencova"]').click(function() {
		$("#cboxContent").removeClass("html").addClass("slideshow"); 
		$('a[rel="celnice"], a[rel="vaclavak"], a[rel="kremencova"]').colorbox({
			scrolling: false,
			top: 109,
			opacity: 1,
			photo: true,
			previous: "",
			next: ""
		});
	});

///////////////////////////////////////////////////////////////////
//// slidery s fotkama na HP
///////////////////////////////////////////////////////////////////
	$(function(){
		$('#slider-celnice ul').bxSlider({
			mode: 'fade',
			infiniteLoop: true,
			auto: true,
			pause: 5000,
			pager: true,
			displaySlideQty: 1,
			moveSlideQty: 1,
			prevText: '',
			nextText: '',
			autoHover: true,
			buildPager: function(){
				return '<a href=""><img src="img/bg/green-pager.png" /></a>';
			}
		});	
	});	
	$(function(){
		$('#slider-vaclavske-namesti ul').bxSlider({
			mode: 'fade',
			infiniteLoop: true,
			auto: true,
			pause: 5000,
			pager: true,
			displaySlideQty: 1,
			moveSlideQty: 1,
			prevText: '',
			nextText: '',
			autoHover: true,
			buildPager: function(){
				return '<a href=""><img src="img/bg/red-pager.png" /></a>';
			}
		});	
	});	
	$(function(){
		$('#slider-kremencova ul').bxSlider({
			mode: 'fade',
			infiniteLoop: true,
			auto: true,
			pause: 5000,
			pager: true,
			displaySlideQty: 1,
			moveSlideQty: 1,
			prevText: '',
			nextText: '',
			autoHover: true,
			buildPager: function(){
				return '<a href=""><img src="img/bg/yellow-pager.png" /></a>';
			}
		});	
	});	

});


