
$(document).ready(function() {
	$("img[zoomsrc]").each(function() {
		//$(this).css('position', 'absolute');
		
		var src = $(this).attr("zoomsrc");

		/* vytvoreni obrazku zvetseniny */
		$(this).parent().append("<img src='" + src + "' class='fullsize' alt='' style='"
						+ "position: absolute; display: none; border: 1px solid;"
						+ "padding: 5px; background-color: #fff; z-index: auto;'>")
						.css('position', 'relative')
						.css('display', 'block');

		var fullsize = $(".fullsize", $(this).parent());

		var disp;
		$(this).hover(function() {
			/* po najeti na obrazek a uplynuti urciteho casu zobrazit zvetseninu */
			disp = true;

			/* vycentrovani zvetseniny */                             
			//fullsize.css('left', ($(this).width() - fullsize.width()) / 4 );
			fullsize.css('left', '50%');
			fullsize.css('margin-left', - fullsize.width() / 2 );
			fullsize.css('top', ($(this).height() - fullsize.height()) / 4 - 30);

			$("img.fullsize").fadeOut();

			setTimeout(function() {
				if (disp)
					fullsize.fadeIn();
			}, 500);
		}, function() {
			/* odjeti mysi z obrazku, nezobrazovat zvetseninu */
			disp = false;
			fullsize.hide();
		});

		fullsize.hover(function() {
			$(this).show();
		}, function() {
			$(this).fadeOut();
		});

		fullsize.click(function() {
			$(this).hide();
			return true;
		});

		/* kvuli priznaku, ktery nekdy prekryvaji obrazek */
		$(".priznak", $(this).parent().parent()).mouseover(function() {
			disp = true;

			setTimeout(function() {
				if (disp)
					fullsize.fadeIn();
			}, 500);
		});
	});
});
