// JavaScript Document
function setWidth(thisWidth) {
var theDiv = new getObj('thumbsholder');
var allDivs = theDiv.obj.getElementsByTagName('div');
var len = allDivs.length;
for (var i = 0; i < len ; i++) {
var thisDiv = allDivs[i].style;
thisDiv.width = thisWidth;
}
}

function getSectionArray() {
var thisfolio = eval("thisfolio" + thisNumCalled);
var thisTitles = eval("thisTitles" + thisNumCalled);
thisimage = thisfolio;
imageTitles = thisTitles;
allnum = thisimage.length;
// Especially for Castrol because of extra image!
//alert(specialLength + " / " + normalLengthValue);
typeof specialLength != 'undefined' ? specialLength == true ? thisNumCalled == specialLengthIndex ? setWidth(specialLengthValue) : setWidth(normalLengthValue) : setWidth(normalLengthValue) : setWidth(normalLengthValue) ;
}

/* function that checks the DOM and prepares the title stuff */
function getObj(name){
if (document.getElementById)
  {this.obj = document.getElementById(name);}
else if (document.all)
  {this.obj = document.all[name];}
else if (document.layers)
  {this.obj = document.layers[name];}
}

function IsValidObject(objToTest) {
if (null == objToTest) {return false;}
if ("undefined" == typeof(objToTest) ) {return false;}
return true;
}


function showDiv(nextDiv) {
var theDiv = new getObj('projectimages');
var allDivs = theDiv.obj.getElementsByTagName('div');
//var allDivs = document.getElementById('projectimages').getElementsByTagName('div');
var len = allDivs.length;
for (var i = 0; i < len ; i++) {
var thisDiv = allDivs[i].style;
thisDiv.display = 'none';
}
document.getElementById(nextDiv).style.display = "block";
}

function getThumbs() {
if (document.images) {
var thumbsHTML ="<ul><li id='first'><a href='Javascript:nada();' onClick=\"showDiv('showText');\" onMouseover=\"showDiv('helpText');\" onMouseout=\"showDiv('showText');\"><img src='gifs/start.GIF' width='100' height='70' border='0'></a></li>";
for (var i=0;i<allnum;i++) {
thumbsHTML = thumbsHTML + "<li><a href=\"Javascript:chooseImage(" + i + ");showDiv('showImages');\"><img src='" + thumbsImageDir + thisimage[i] + "' width='100' height='70' border='0'></a></li>";
}
var endGif;
thisNumCalled < 3 ? endGif = "gifs/next.GIF" : endGif = "gifs/again.GIF" ;

thumbsHTML = thumbsHTML + "<li id=\"last\"><img src=\"" + endGif + "\" width=\"100\" height=\"35\"><br><a href=\"JavaScript:newSection(" + thisNumCalled + ");\"><img src=\"gifs/yes.GIF\" width=\"50\" height=\"35\" border=\"0\"></a><a href=\"projects.htm\"><img src=\"gifs/no.GIF\" width=\"50\" height=\"35\" border=\"0\"></a></li></ul>";
//thumbsHTML = thumbsHTML + "</ul>";
t = new getObj("thumbsrow");
if (document.getElementById || document.all) {t.obj.innerHTML = thumbsHTML;}
else {t.obj.document.open();
t.obj.document.write(thumbsHTML);
t.obj.document.close();
}
}
}

function chooseImage(thisreqnum) {
if (document.images) {
// get the image
x = new getObj("showImages");
// get the title
if (imageTitles) {
var thisImageTitle = "<br /><p class='titletext'>" + imageTitles[thisreqnum] + "</p>"; 
}
var nextImageNum = (thisreqnum+1);
if (nextImageNum < allnum) {
var fullHTML = "<a href=\"Javascript:chooseImage(" + (thisreqnum+1) + ");\" onMouseOver=\"status='Click here to view next image'; return true;\" onMouseOut=\"status=''; return true;\"><img src=\"" + fullImageDir + thisimage[thisreqnum] + "\" border=\"0\" alt=\"&copy " + artistName + ", 2005\"></a><br />" + thisImageTitle;}
else {
var fullHTML = "<a href=\"Javascript:newSection(" + thisNumCalled + ");\" onMouseOver=\"status='Click here to view next roll'; return true;\" onMouseOut=\"status=''; return true;\"><img src='" + fullImageDir + thisimage[thisreqnum] + "' border='0' alt='&copy; " + artistName + ", 2005'></a><br />" + thisImageTitle;
}
// write them in
if (document.getElementById || document.all) {
x.obj.innerHTML = fullHTML;
}
else {x.obj.document.open();
x.obj.document.write(fullHTML);
x.obj.document.close();
}
}
}

function newSection(thissection)  {
thissection < 3 ? thisNumCalled = thissection + 1 : thisNumCalled = 1;
getSectionArray();
getThumbs();
chooseImage(0);
thisNumCalled > 1 ? showDiv('showImages') : showDiv('showText');
var w = new getObj("thumbsholder");
w.obj.scrollLeft = 0;
}

function nada() {
}
