var imgIndex = 0;
var qu = String.fromCharCode(32);

function fillThumbs(subfolder) {
	content = "<nobr>";
	for (i=0; i<titleArray.length; i++) {
		content += "<a href=" + qu + "javascript:changeImg('" + subfolder + "','" + i + "')" + qu + ">";
		content += "<img src='" + subfolder + "/" + imgArray[i].substr(0,imgArray[i].indexOf(".jpg")) + "_t.jpg'";
		content += " width='100' height='100' border='0'></a>";
		content += "<img src='spacer.gif' width='10' height='30'>";
	}
	content += "</nobr>";
	document.getElementById("thumbs").innerHTML = content;
//	document.getElementById("thumbs").style.width = (titleArray.length * 110).toString(10) + "px";
}

function changeImg(subfolder,value) {
	if (value.charAt(0)=="+" || value.charAt(0)=="-") {
		imgIndex += parseInt(value);
	} else {
		imgIndex = parseInt(value);
	}
	if (imgIndex+1 > imgArray.length) {
		imgIndex = 0;
	}
	if (imgIndex < 0) {
		imgIndex = imgArray.length-1;
	}
	document.images["galleryImg"].src = subfolder + "/" + imgArray[imgIndex];
	fillInfo(imgIndex);
	document.getElementById("outerFrame").scrollLeft = imgIndex * 110;
	if (subfolder == "gallery") {
		document.cookie = "gallery=" + imgIndex + "g*"
	} else {
		document.cookie = "installs=" + imgIndex + "i*"
	}
}

function fillInfo(indx) {
	content = "<p class='text'><b>"+titleArray[indx]+"</b></p>";
	content += "<p class='text'>"+descArray[indx]+"</p>";
	content += "<p class='text'><br><br><i>image " + (indx+1) + " of " + titleArray.length;
	document.getElementById("imgInfo").innerHTML = content;
}

function getIndx(subfolder) {
	c=document.cookie;
	if ((c.lastIndexOf("gallery") == -1) || (c.lastIndexOf("installs") == -1)) {	// gallery & install cookies do not exist
		document.cookie = "gallery=0g*";
		document.cookie = "installs=0i*";
		c=document.cookie;
	}
	start = c.lastIndexOf(subfolder) + subfolder.length + 1;
	end = c.lastIndexOf(subfolder.slice(0,1) + "*");
	imgIndex = parseInt(c.slice(start,end));
	changeImg(subfolder,imgIndex.toString(10));
	}