function preload(thumbContainerId) {
	/*
	if (typeof(thumbContainerId) != "undefined")
		alert(document.getElementById(thumbContainerId).tagName);
	else
		alert("blaat");
	*/
	for (var t = 0; t < arrImagesObjects.length; t++) {
		imgLookup["p" + arrImagesObjects[t].id] = t;
		mimg[t] = new Image();
		mimg[t].src = folder + arrImagesObjects[t].file;
	}
}

function getImage(file) {
	currentImage = file;
	var currentIndex = imgLookup["p" + file];
	var elmBigImage = document.getElementById("bigimage");
	if (elmBigImage && elmBigImage != null)
		elmBigImage.src = folder + arrImagesObjects[currentIndex].file;

	var voteBlock = document.getElementById("voteblock");
	var voteResult = document.getElementById("voteResult");
	var elmVotePid = document.getElementById("pid");
	if (!(voteBlock == null || voteResult == null)) {
		if (arrImagesObjects[currentIndex].vote == -1) {
			voteBlock.style.display = "";
			voteResult.style.display = "none";
		}
		else {
			voteBlock.style.display = "none";
			voteResult.style.display = "";
			voteResult.innerHTML = "Visitors votes: " + arrImagesObjects[currentIndex].vote;
		}
		if (elmVotePid != null)
			elmVotePid.value = file;
	}
	var btnNextPicture = document.getElementById("btnNextPicture");
	if (currentIndex >= (arrImagesObjects.length - 1) && nextPageLink == "-1")
		btnNextPicture.src = "/media/buttons/knopblauwrechts_d.gif"
	else
		btnNextPicture.src = "/media/buttons/knopblauwrechts.gif";
	var btnPrevPicture = document.getElementById("btnPrevPicture");
	if (currentIndex == 0 && prevPageLink == "-1")
		btnPrevPicture.src = "/media/buttons/knopblauwlinks_d.gif"
	else
		btnPrevPicture.src = "/media/buttons/knopblauwlinks.gif";
}

function skipImage(direction) {
	var currentIndex = imgLookup["p" + currentImage];
	if (direction == -1) {
		if (currentIndex > 0)
			getImage(arrImagesObjects[currentIndex - 1].id)
		else {
			if (prevPageLink != "-1")
				document.location = prevPageLink;
		}
	}
	else if (direction == 1) {
		if (currentIndex < (arrImagesObjects.length - 1))
			getImage(arrImagesObjects[currentIndex + 1].id)
		else {
			if (nextPageLink != "-1")
				document.location = nextPageLink;
		}
	}
}

function sendImage() { window.open("mailpic.asp?picture=" + currentImage, "mailpic", "height=500,width=400,status=yes,toolbar=no,menubar=no,location=no"); }

function printImage() { window.open("printpic.asp?picture=" + currentImage, "printpic", "height=240,width=320,status=yes,toolbar=no,menubar=no,location=no"); }

function imageAction(action) {
	var action = new String(action);
	action = action.toLowerCase();
	switch (action) {
		case "mobile":
			window.open("/app/mobilepic/wallpaper.asp?picture=" + currentImage, "shirt_popup", "height=296,width=496,status=yes,toolbar=no,menubar=no,location=no");
			break;
		default:
			break;
	}
}

function submitVote(elmValue) {
	if (elmValue.Value * 1 != -1)
		elmValue.form.submit();
	return false;
}

