var noAlbum = false;

function initPics() {
	// Put html code in all thumbnails
	var tmbnl_divs = document.getElementById("contents").getElementsByTagName("div");

	var i;
	for (i = tmbnl_divs.length - 1; i >= 0; i--) {

		var tmbnl_class = tmbnl_divs[i].className;
		if (tmbnl_class) tmbnl_class = tmbnl_class.toString().substr(0, 9);

		var img_name = tmbnl_divs[i].id;

		if (tmbnl_class == "tmbnl_box") {
			var newHTML = "<div class=\"tmbnl_links\">";
			if (!noAlbum) {
				newHTML += "<a href=\"album.php?img=" + img_name + "\" title=\"" + txtGallery + "\">";
				newHTML += "<img class=\"tmbnl_links_img\" alt=\"Gallery\" src=\"" + topPath + "res/slideshow.png\" width=\"16\" height=\"16\" />";
				newHTML += "</a>";
			}
			newHTML += "<a href=\"javascript:expandImg('" + img_name + "')\" title=\"" + txtExpandPic + "\">";
			newHTML += "<img class=\"tmbnl_links_img\" alt=\"Expand\" src=\"" + topPath + "res/expand.png\" width=\"16\" height=\"16\" />";
			newHTML += "</a>";
			newHTML += "</div>";

			tmbnl_divs[i].innerHTML = newHTML + tmbnl_divs[i].innerHTML;

			tmbnl_divs[i].onmouseover = function() {
				showTmbnlLinks(this);
			}

			tmbnl_divs[i].onmouseout = function() {
				hideTmbnlLinks(this);
			}
		}
	}
}

function showTmbnlLinks(div_id) {
	var divEls = div_id.getElementsByTagName("div");
	if (divEls.length > 0) divEls[0].style.visibility = "visible"
}

function hideTmbnlLinks(div_id) {
	var divEls = div_id.getElementsByTagName("div");
	if (divEls.length > 0) divEls[0].style.visibility = "hidden"
}

function expandImg(imgName) {
	var imgBoxEl = document.getElementById(imgName);

	imgBoxEl.className = "large_img_box";
	imgBoxEl.style.width = "auto";
	imgBoxEl.onmouseover = null;
	imgBoxEl.onmouseout = null;

	var bigImgSrc = imgBoxEl.getElementsByTagName("a")[noAlbum ? 1 : 2].href;
	bigImgSrc = bigImgSrc.replace("/sm/", "/");

	imgBoxEl.parentNode.className = "img_box";

	// Get img description
	var index = imgBoxEl.innerHTML.lastIndexOf(">");
	var desc = imgBoxEl.innerHTML.substr(index + 1);

	imgBoxEl.innerHTML = "<img src=\"" + bigImgSrc + "\" /><br />" + desc;
}


