var currIMG
arImages = new Array();
arCount = 0;

function imageData(thumb, image, caption) {
arImages[arCount] = new Array(thumb, image, caption);
arCount ++;
}

function buildViewer(imgNo){

//Adjust imgNo down by one, as array starts at 0;
imgNo--;

//document.write("<textarea>");

document.write("<div id='projectViewer'>");

/*main image*/
document.write("<img src='" + arImages[imgNo][0] +  "' width='307' height='188' alt='' border='0' id='mainIMG'>");

/*navigation*/
document.write("<img src='images/projects/forwards.gif' width='9' height='10' alt='' border='0' onmouseover='mOver(this)' onmouseout='mOver()' onClick='moveForwards()' id='forwardsArrow'>");
document.write("<div id='biegeBar'>&nbsp;</div>");
document.write("<img src='images/projects/back.gif' width='9' height='10' alt='' border='0' onmouseover='mOver(this)' onmouseout='mOver()' onClick='moveBack()' id='backArrow'>");

/* thumb grid */
//document.write("<table id='thumbGrid' cellpadding='0' cellspacing='0' border='0'>");
document.write("<div id='thumbGrid'>");
var count  = 0;

//rows...
for (y=0; y<4; y++) {
//document.write("<tr>");
//cols...
for (x=0; x<3; x++) {
	if (count < arImages.length) {
		if (count==imgNo) {
			document.write("<img src='" + arImages[count][1] + "' width='60' height='43' alt='" + arImages[count][2] + "' border='0' id='thumb" + count + "' onClick='jumpTo(" + count + ")' class='selected'>");
		} else {
			document.write("<img src='" + arImages[count][1] + "' width='60' height='43' alt='" + arImages[count][2] + "' border='0' id='thumb" + count + "' onClick='jumpTo(" + count + ")'>");
		}
	} else {
		document.write("<img src='images/projects/blank.gif' width='60' height='43' alt='' border='0' class='empty'>");
	}
	count++;
}
//document.write("</tr>");
}

//document.write("</table>");



document.write("</div></div>");
currIMG = imgNo;

/*caption*/
document.write("<div id='caption'>" + arImages[imgNo][2] + "</div>");



}

function jumpTo(imgNo) {
document.getElementById("mainIMG").src = arImages[imgNo][0];
document.getElementById("caption").innerHTML = arImages[imgNo][2];
document.getElementById("thumb" + currIMG).className ="";
document.getElementById("thumb" + imgNo).className ="selected";
currIMG = imgNo;
}

function moveForwards() {
if (currIMG == (arImages.length -1)) {
jumpTo(0);
} else {
jumpTo(currIMG + 1)
}

}

function moveBack() {
if (currIMG == 0) {
jumpTo(arImages.length - 1);
} else {
jumpTo(currIMG - 1)
}
}


//document.write("</textarea>");

