$(document).ready(function() {
	$('a[rel^=PrettyPhoto]').prettyPhoto({
		padding: 40, 
		theme: 'dark_rounded', 
		language_: 'cs',
		opacity: .4
	});	
	
	posHolder();
	$(window)
		.resize(function() {
		posHolder();
	})
		.scroll(function() {
		posHolder();
	});
	
});

function posHolder() {
	$("#page .diary").stop().animate({'marginTop': $(window).scrollTop() + 17 + "px"}, 100);
	$("#page .skrin").stop().animate({'marginTop': $(window).scrollTop() + 26 + "px"}, 200);
}

$(function(){

	var imageButtons = new Array();

	$('.buttons a img').add('.spocitejte-si a img').each(function(){
		var imageFilename = $(this).attr('src').substr(0,$(this).attr('src').indexOf('_s.jpg')) + '.jpg';
		var bigImg = new Image();
		bigImg.src = imageFilename;

		//preload kvůli tomu, aby byly obrázky načtené a měly správnou šířku a výšku - nefunguje v IE
		if (!$.browser.msie)
			$('body').append($(bigImg).css({position: 'absolute', top:0, left: 0, width: 'auto', height: 'auto', visibility: 'hidden'}));

		var smallImg = new Image();
		smallImg.src = $(this).attr('src');

		var i = $(this).attr('alt');
		imageButtons[i] = {big: bigImg, small: smallImg};

		//$(this).attr('src', imageButtons[i].small.src);
		//$(this).parents('a').css({width: imageButtons[i].small.width, height: imageButtons[i].small.height, position: 'relative'});
		//$(this).css({width: $(this).width(), height: $(this).height(), position : 'absolute'})
		//alert(bigImg.width+'x'+bigImg.height);
	});

	$('.buttons a img').add('.spocitejte-si a img').hover(function(e){
		var i = $(this).attr('alt');
		$(this).parents('a').css({display: 'block', width: imageButtons[i].small.width, height: imageButtons[i].small.height, position: 'relative'});
		$(this).css({width: $(this).width(), height: $(this).height(), position : 'absolute'})
			.attr('src', imageButtons[i].big.src).stop()
			.animate({
				width: imageButtons[i].big.width,
				height: imageButtons[i].big.height,
				top: -(imageButtons[i].big.height-imageButtons[i].small.height)/2,
				left: -(imageButtons[i].big.width-imageButtons[i].small.width)/2
			});
	},function(e){
		var i = $(this).attr('alt');
		$(this).stop()
			.animate({
				width: imageButtons[i].small.width,
				height: imageButtons[i].small.height,
				top: 0,
				left: 0
			}, function() {
				$(this).attr('src', imageButtons[i].small.src);
			});
			
	});
});

