/*$(document.body).dblclick(function(){
	modalGalleryShow(
		new Array(
			"preview.php?id=b21d228cec7bb9cbb86aef85cbcdd68d",
			"preview.php?id=1e9f0a93a63105ebe1eb91ab0536f5a8",
			"preview.php?id=2f096e8e51c721a7679a092f20a0b3af",
			"preview.php?id=6e613ff7d6348fe9509d5e8f770852bd",
			"preview.php?id=289f0ad1529d180ac641e3a8d3b7774d",
			"preview.php?id=fa27e362ce712b9fc9f9e0fedcbd802d",
			"preview.php?id=30d0d411b9db6fc901d8b74ae36c2f4e"
		),
		new Array(
			"Ako išlo {vajce na vandrovku}",
			"No comment",
			"Ide vláčik ši ši ši",
			"Ako sa {tekvica} na dach škrabala",
			"Čo má veverička v ruke? {Kŕŕŕŕŕŕč.}",
			"Šme še pobaviľi",
			"{Ťavy} do chlieva nepatria {štyri}, a {brav} do púšte - razdvatrištyri!"
		),
		0
	);
});*/

var modalGalleryImages = new Array();
var modalGalleryImageNames = new Array();
var modalGalleryCurrentIndex = 0;

function modalGalleryShow(images, names, currentIndex)
{
	modalGalleryImages = images;
	modalGalleryImageNames = names;
	for (var i = 0; i < modalGalleryImageNames.length; i++)
		modalGalleryImageNames[i] = modalGalleryImageNames[i].replace(/{/g, "<em>").replace(/}/g, "</em>");
	$("#modal_gallery_show_previous")
		.unbind()
		.click(modalGalleryShowPrevoius);
	$("#modal_gallery_show_next")
		.unbind()
		.click(modalGalleryShowNext);
	$("#modal_gallery_close")
		.unbind()
		.click(modalGalleryClose);
	$("#modal_gallery").modal({
		opacity: 25,
		close: false
	});
	modalGalleryShowImage(currentIndex);
}

function modalGalleryShowImage(imageIndex)
{
	modalGalleryCurrentIndex = imageIndex;
	$("#modal_gallery_image").attr("src", "./" + modalGalleryImages[modalGalleryCurrentIndex] + "&mw=800&mh=600");
	$("#modal_gallery_name").html(modalGalleryImageNames[imageIndex]);
	$("#modal_gallery_description").html((imageIndex + 1) + " / " + modalGalleryImages.length);
	$("#modal_gallery_show_previous").attr("class", imageIndex <= 0 ? "disabled" : "");
	$("#modal_gallery_show_next").attr("class", imageIndex >= modalGalleryImages.length - 1 ? "disabled" : "");
}

function modalGalleryShowPrevoius()
{
	if (modalGalleryCurrentIndex <= 0)
		return;
	modalGalleryShowImage(modalGalleryCurrentIndex - 1);
	return false;
}

function modalGalleryShowNext()
{
	if (modalGalleryCurrentIndex >= modalGalleryImages.length - 1)
		return;
	modalGalleryShowImage(modalGalleryCurrentIndex + 1);
	return false;
}

function modalGalleryClose()
{
	$.modal.close();
}

