// JavaScript Document

// FUNCTION THAT CHECKS THE DOM 
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];}
}

// GENERIC //

function doHide(theObject,theAction) {
	var thisHiding = new getObj(theObject);
	if (theAction == "hidden") {
	thisHiding.obj.className = "make_hidden";	
	}
	else {
	thisHiding.obj.className = "make_none";	
	}
}

function doShow(theObject, theAction) {
	var thisShowing = new getObj(theObject);
	if (theAction == "block") {
	thisShowing.obj.className = "make_block";	
	}
	else {
	thisShowing.obj.className = "make_visible";	
	}
}

function doAddClass(theObject, theAction) {
	var thisDiv = new getObj(theObject);
	thisDiv.obj.className = theAction;
}

function getRandomNum(thenum) {
	var rndm = Math.floor(Math.random()*thenum);
	return rndm;
}

// FUNCTION TO HIGHLIGHT CURRENT FOLIO LINK
function  doHighlight(thisNavItem, thisNavSection) {
var z = new getObj(thisNavSection);
if (!z) return;
var theseTags  = (z.obj.getElementsByTagName('a'));
var y = (theseTags.length);
for (var i=0;i<y;i++) {
theseTags[i].className = "";
}
if (thisNavItem != 0) {
theseTags[thisNavItem-1].className = "selected";
}
}

function goHome() {
	//doHide('sorry','none');
	//doHide('full_image','none');
	//doHide('thumb_content','none');	
	//doHide('folio_nav_area','none');
	doShow('page_content','block');	
	doHide('image_area','none');
	getPage('Home');
	doHighlight(1,"menu_bar");
}

function goPortfolio() {
	//getPage('Skills')	
//var thisPage = new getObj("content_area");
	//var thisHTML = getFolioMenu();
	//var thisImage = "<img src='core\/S80801_02.jpg' alt='' \/>";
	//thisHTML = "<div id='theImage'>" + thisImage + "<\/div><div id='folio_nav'>" + thisHTML + "<\/div>";
	doHide('page_content','none');	
	doShow('image_area','block');
	getFolioMenu();
	//thisMenuNum = 1;
	setFolio(thisOrder[1][1],1);
	doHighlight(2,"menu_bar");
	}

function goSkills() {
	doHide('image_area','none');	
	doShow('page_content','block');
	getPage('Skills')
	doHighlight(3,"menu_bar");
	}
	
function goClients() {
	doHide('image_area','none');	
	doShow('page_content','block');
getPage('Clients')
doHighlight(5,"menu_bar");
}

function goContacts() {
	doHide('image_area','none');	
	doShow('page_content','block');
getPage('Contacts')
doHighlight(6,"menu_bar");
}

function goPrint() {
	doHide('image_area','none');	
	doShow('page_content','block');
getPage('Print')
doHighlight(4,"menu_bar");
}

function getPage(reqPage) {
	//alert(reqPage);
var thisPage = new getObj("page_content");
if (reqPage != "Home") {
var thisHTML = eval("page" + reqPage);
if (reqPage == "Clients") {
thisHTML = thisHTML + "<dl id=\"content_clients_quote\">" + getQuote(getRandomNum(thisQuote.length-1)+1) + "<\/dl>";
}
	}
	else {
	var thisLogoNum = getRandomNum(8);
var thisHTML = "<div id='home_logo'><img src='logos\/" + thisLogo[thisLogoNum][0] + "' id='logo_big' height='504' width='504' alt='Standard 8 design and produce 3D installations, exhibitions and special projects' \/>";
//thisHTML = thisHTML + "<img src='gifs\/logo_tag.gif' id='logo_tag' height='34' width='103' alt='Standard 8 design and produce 3D installations, exhibitions and special projects' \/>";
thisHTML = thisHTML + "<div id='logo_tag'>" + thisLogo[thisLogoNum][1] + "<\/div>";
thisHTML = thisHTML + "<\/div>";	
		}

if (document.getElementById || document.all) {
thisPage.obj.innerHTML = thisHTML; 
}
else {
thisPage.obj.document.open();
thisPage.obj.document.write(thisHTML);
thisPage.obj.document.close();
}
doShow('content_area','block');
}

function getQuote(reqnum) {
// var thisHTML = "<dl id=\"content_clients_quote\"><dd>" + thisQuote[reqnum][0] + "<img src='gifs\/quote_close.gif' id='quote_close' alt='#' \/><\/dd><dt>" + thisQuote[reqnum][1] + "<\/dt><\/dl>";
		var thisHTML = "<dd>" + thisQuote[reqnum][0] + "<img src='gifs\/quote_close.gif' id='quote_close' alt='#' \/><\/dd><dt>" + thisQuote[reqnum][1] + "<\/dt>";
	return thisHTML;	
	}
	
function changeQuote(reqnum) {
	var thisQuote = new getObj("content_clients_quote");
	var thisHTML = getQuote(reqnum); 
	if (document.getElementById || document.all) {
thisQuote.obj.innerHTML = thisHTML; 
}
else {
thisQuote.obj.document.open();
thisQuote.obj.document.write(thisHTML);
thisQuote.obj.document.close();
}
	}

/*function getFolioMenu() {
	var thisDiv = new getObj("folio_nav");
var thisLength = thisInfo.length;
	var thisHTML = "<ul>";
	for (var i=1;i<thisLength;i++) {
	thisHTML = thisHTML + "<li><a href='#' onClick='setFolio(" + i + ");'>" + thisInfo[i][0] + "<\/a><\/li>";
	}
	thisHTML = thisHTML + "<\/ul>";	
	if (document.getElementById || document.all) {
	thisDiv.obj.innerHTML = thisHTML; 
	}
	else {
	thisDiv.obj.document.open();
	thisDiv.obj.document.write(thisHTML);
	thisDiv.obj.document.close();
	}
	}*/
	
	function getFolioMenu() {
	var thisDiv = new getObj("folio_nav");
var thisLength = thisOrder.length;
	var thisHTML = "<ul>";
	for (var i=1;i<thisLength;i++) {
	thisHTML = thisHTML + "<li><a href='#' onClick='setFolio(" + thisOrder[i][1] + "," + i + ");'>" + thisOrder[i][0] + "<\/a><\/li>";
	}
	thisHTML = thisHTML + "<\/ul>";	
	if (document.getElementById || document.all) {
	thisDiv.obj.innerHTML = thisHTML; 
	}
	else {
	thisDiv.obj.document.open();
	thisDiv.obj.document.write(thisHTML);
	thisDiv.obj.document.close();
	}/**/
	}
	
function setFolio(folioNum,menuNum) {
thisFolio = eval("thisFolio" + folioNum);
//thisMenuNum = menuNum;
//thisTitle = eval("thistitles" + folioNum);
allnum = thisFolio.length;
var countHTML = "<ul>";
for (i=1;i<=allnum;i++) {
countHTML += '<li><a href="Javascript:showImage(' + i + ');">' + i + '<\/a>&nbsp;<\/li>';
}
countHTML += "<\/ul>";
x = new getObj("nav_images");
if (document.getElementById || document.all) {
x.obj.innerHTML = countHTML;
}
else {
x.obj.document.open();
x.obj.document.write(countHTML);
x.obj.document.close();
}
doHighlight(menuNum, "folio_nav");
//doClearFolios();/**/
getTitles(folioNum);
showImage(1);
}

function getTitles(folioNum) {
//Project - Location - Client	
//var thisInfo = eval("thisInfo" + thisnum);
var thisProject = "<dl><dt><strong>Project:<\/strong><\/dt><dd>" + thisInfo[folioNum][0] + "<\/dd><\/dl>";
var thisLocation = "<dl><dt><strong>Venue: <\/strong><\/dt><dd>" + thisInfo[folioNum][1] + "<\/dd><\/dl>";
var thisClient = "<dl><dt><strong>Client: <\/strong><\/dt><dd>" + thisInfo[folioNum][2] + "<\/dd><\/dl>";
//var thisHTML = "<p>" + thisProject + "<\/p><p>" + thisClient + "<\/p><p>" + thisLocation + "<\/p>"
var thisHTML = "<div id='imageAttrib'>" + thisProject + thisClient + thisLocation + "<\/div>"

var imageTitle  = new getObj("image_title");
if (document.getElementById || document.all) {
imageTitle.obj.innerHTML = thisHTML;
}
else {
imageTitle.obj.document.open();
imageTitle.obj.document.write(thisHTML);
imageTitle.obj.document.close();
}
	}

function showImage(thisnum) {
if (document.images) {
thisreqnum = thisnum-1;
var thisHTML = '<img src="' + thisImageDir + thisFolio[thisreqnum] + '" border="0" alt="&copy\; ' + artistName + ', 2005" \/>';
//var thisTitleHTML = thisTitle[thisreqnum];
var x = new getObj("theImage");
/*var image_text = new getObj("image_text");*/
if (document.getElementById || document.all) {
x.obj.innerHTML = thisHTML;
// SET TITLE
/*if (imageTitles) {
image_text.obj.innerHTML = thisTitleHTML;
}*/
}
else {
x.obj.document.open();
x.obj.document.write(thisHTML);
x.obj.document.close();
// SHOW IMAGE TITLE
/*if (imageTitles) {
image_text.obj.document.open();
image_text.obj.document.write(thisTitleHTML);
image_text.obj.document.close(); }*/
}

// Go Back & Go On links
var thisnext = new getObj("butt_next");
var thisprev = new getObj("butt_prev");
if (thisreqnum < allnum-1) 
	{
	thisnextHTML = "<a href='Javascript:showthisimage(\"next\");' onMouseOver=\"status='Click here for the next image'; return true;\" onMouseOut=\"status=''; return true;\">next ></a>";	
	}
else {
thisnextHTML = "<span class='black'>next ><\/span>";   
}
if (thisreqnum > 0)
	{
	thisprevHTML = "<a href='Javascript:showthisimage(\"prev\");' onMouseOver=\"status='Click here for the previous image'; return true;\" onMouseOut=\"status=''; return true;\">< prev</a>";
	}
else {
thisprevHTML = "<span class='black'>< prev<\/span>";
}
if (document.getElementById || document.all) {
thisnext.obj.innerHTML = thisnextHTML;
thisprev.obj.innerHTML = thisprevHTML;
}
else {
thisnext.obj.document.open();
thisnext.obj.document.write(thisnextHTML);
thisnext.obj.document.close();
thisprev.obj.document.open();
thisprev.obj.document.write(thisprevHTML);
thisprev.obj.document.close();
}
}
doHighlight(thisnum,"nav_images");
}

/* Function that sorts out the numbering for go back and go on */
function showthisimage(showwhat) {
		var thisnum = thisreqnum+1;
if (showwhat == "prev") {
if (thisnum >= 1) {thisnum = thisnum-1;}
	else {thisnum = 0;}
}
else if (showwhat == "next") {
	if (thisnum < allnum) {thisnum = thisnum + 1;}
	else {thisnum = allnum;}
}	
showImage(thisnum);
}
