$(document).ready(function() {
	// Remove normal links, to use jquery switching instead
	$("#thumbnailList a.refLink").removeAttr("href");
	// Set initial lightbox and show link
	$("a[@rel*=lightbox-group" + currId + "]:not(:eq(1))").slimbox({counterText:imageTexts});
	$("a[@rel*=lightbox-group" + currId + "]:eq(0)").show();
	// Set click handler for links
	$("#thumbnailList a.refLink").click(function() {
		var id = this.id;
		// Handle data div text
		$("#pictureData").fadeOut(300, function() {
			$(this).html($("#refText-" + id).html());
			if ($("#refLightBoxImgs-" + id).html() != "") {
				$("#pictureData")
						.html($("#pictureData").html()
								+ '<br /><a href="'
								+ $("#refLightBoxImgs-" + id + " a:first-child").attr("href")
								+ '" rel="lightbox-group' + id + '" title="' 
								+ $("#refLightBoxImgs-" + id + " a:first-child").attr("title")
								+ '"><span class="redArrow">'
								+ morePicsText
								+ ' &gt;</span></a>');
				$("a[@rel*=lightbox-group" + id + "]:not(:eq(1))").slimbox({ counterText: imageTexts });
			}
			$(this).fadeIn(300);
		});
		// Handle description div text
		$("#pictureDescription").fadeOut(300, function() {
			$(this).html($("#refDescription-" + id).html());
			$(this).fadeIn(300);
		});
		// Handle case pictures
		$("#refPictureFrame").fadeOut(300, function() {
			$(this).html($("#refPictures-" + id).html());
			$(this).fadeIn(300);
		});
	});
});

