
var currentImage = ""; 
function galleryLoad()
{
	currentImage = document.getElementById("showImage");
	if(currentImage)
		galleryLoadImage(0);
}

function galleryLoadImage(shift)
{
	gotoImage = "";
	if(shift == -1)
		gotoImage = currentImage.previousSibling;
	else if(shift == 1)
		gotoImage = currentImage.nextSibling;
	if(gotoImage && (gotoImage.tagName == "INPUT"))
		currentImage = gotoImage;
	
	galleryUpdateArrows();

	img = document.getElementById("showImg");
	txt = document.getElementById("showImgTitle");
	strs = currentImage.value.split(";", 2);
	
	img.src = "getimage.php?size=big&file="+strs[0];
	img.style.visibility = "visible";
	txt.innerHTML = strs[1];
}

function galleryUpdateArrows()
{
	if(currentImage.previousSibling && currentImage.previousSibling.tagName == "INPUT")
		document.getElementById("leftArrow").style.visibility = "visible";
	else
		document.getElementById("leftArrow").style.visibility = "hidden";
	if(currentImage.nextSibling && currentImage.nextSibling.tagName == "INPUT")
		document.getElementById("rightArrow").style.visibility = "visible";
	else
		document.getElementById("rightArrow").style.visibility = "hidden";
}

function galleryLoadImageSet(index)
{
	var gallery = document.getElementById("showGallery");
	if(gallery)
	{
		inputs = gallery.getElementsByTagName("INPUT");
		currentImage = inputs[index-1];
		galleryUpdateArrows();
		
		img = document.getElementById("showImg");
		txt = document.getElementById("showImgTitle");
		strs = inputs[index-1].value.split(";", 2);
		
		img.src = "getimage.php?size=big&file="+strs[0];
		img.style.visibility = "visible";
		txt.innerHTML = strs[1];
	}
}

// popup
function windowPopup(src,x,y)
{
	newwindow=window.open(src,'image','height='+y+',width='+x+',resizable=yes');
	if(window.focus)
		newwindow.focus();
	return false;
}

