// JavaScript Document

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 doScrollTop(thisDiv) {
	var y = new getObj(thisDiv);
	y.obj.scrollTop = 0;
}

function getRandomNum() {
	var rndm = Math.floor(Math.random()*allnum);
	return rndm;
}

function goRandom() {
	doHide('text_area','none');
	doHide('About','none');
	//doHide('Contact','none');
	//doHide('ArtPhotos','none');
	//doHide('folio_nav','none');
	doShow('image_content','block');
	myMode = "full";	
	switchContent(0);
	thisnum = getRandomNum();
	showthisimage("current");
}

/*function goForward() {
	doHighlight(0);
	hideGallery();
	hideContact();
	hideFolioNav();
	hideTitle();
	showImageArea();
	showLogo2();
	if (document.images) {
	var thisHTML = "<img src='fi/MH_00002.jpg' alt='&copy; artistName' />";
	x = new getObj("content");
	if (document.getElementById || document.all) { x.obj.innerHTML = thisHTML; }
else {
x.obj.document.open();
x.obj.document.write(thisHTML);
x.obj.document.close();
	}
	}
}*/

// FUNCTION TO SWITCH TO IMAGE MODE
/*function goImages(thisitemnum) {
	//doHide('title_box','hidden');
	doHide('text_area','none');
	doHide('About','none');
	doHide('Prices','none');		
	doHide('Specials','none');
	doHide('Letters','none');
	doHide('WeddingGallery','none');
	doHide('ArtPhotos','none');
	doHide('Contact','none');
	//doHide('Copyright','none');
	doShow('image_content','block');
	doShow('folio_nav','block');
	myMode = startMode;
	thisnum = 0;
	switchContent(thisitemnum);
}*/


// FUNCTION TO SWITCH TO ABOUT PAGE
function goAbout(){
	doHide('image_content','none');
	//doHide('folio_nav','none');
	//doHide('ArtPhotos','none');
	//doHide('Contact','none');
	doShow('text_area','block');	
	doScrollTop('text_area');	
	doShow('About','block');
	doHighlight(4,"nav");
}


/*// FUNCTION TO SWITCH TO ART PHOTOS PAGE
function goArtPhotos(){
	doHide('image_content','none');
	//doHide('folio_nav','none');
	doHide('About','none');
	doShow('ArtPhotos','block');
	//doHide('Contact','none');		
	doShow('text_area','block');
	doScrollTop('text_area');	
	doHighlight(9,"nav");
}*/

/*// FUNCTION TO SWITCH TO CONTACT PAGE
function goContact(){
	doHide('image_content','none');
	//doHide('folio_nav','none');
	doHide('About','none');
	doHide('ArtPhotos','none');	
	doShow('text_area','block');
	doScrollTop('text_area');	
	doShow('Contact','block');	
	doHighlight(10,"nav");
}*/

// 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 TO SWITCH TO REQUIRED FOLIO
function switchContent(thisitemnum) {
thisItemNum = thisitemnum;
// now show the right folio
thisfolio = eval("thisfolio" + thisItemNum);
// and the right image titles
if (imageTitles) {
thistitle = eval("thistitle" + thisItemNum);
}
thisimage = thisfolio;
allnum = thisimage.length;
lastnum = allnum;
if (thisitemnum!=0) {
if (myMode == "full") {
thisImageDir = fullImageDir;
showthisimage('current');
}
else {
thisImageDir = thumbsImageDir;
showThumbs();
}
doHighlight(thisItemNum, "nav");
}
else {
thisImageDir = fullImageDir;
}
}

// Function used?
function getValue(stringtoparse) {
return stringtoparse.substring(2,stringtoparse.length);
}

// 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];}
}

// FUNCTION THAT GETS THE FULL IMAGES, INCLUDING GO BACK AND GO ON, AND THE TITLE 
function getimagefile(thisreqnum) {
if (document.images) {
thisHTML = '<img src="' + thisImageDir + thisimage[thisreqnum] + '" alt="&copy ' + artistName + '" id="content_image"'
if (imageTitles) {
thisHTML = 	thisHTML + ' onLoad="doShow(\'title_box\',\'visible\');"';
}
thisHTML = 	thisHTML + '>';
if (hasThumbsLink) {
thisHTML = '<a href="Javascript:doGetThumbs();" onMouseOver="status=\'Click here to view thumbnails\'; return true;" onMouseOut="status=\'\'; return true;">' + thisHTML + '</a>'; 
}
if ((thisreqnum<(thisimage.length)) && thisreqnum>=0) {
x = new getObj("image_content");
// image numbers
if (imageNumbers) {var numberseq = new getObj("numberSeq");}
// image title
if (imageTitles) {var newtitle = new getObj("title_box");}
// thumbs link
if (hasThumbsLink) { var thumbsLink = new getObj("thumbsLink");
var thumbsHTML = '<a href="Javascript:doGetThumbs();" onMouseOver="status=\'Click here to view thumbnails\'; return true;" onMouseOut="status=\'\'; return true;"></a>'; 
}
if (document.getElementById || document.all) {
x.obj.innerHTML = thisHTML;
// set image numbers
if (imageNumbers) {numberseq.obj.innerHTML = (thisnum+1) + " / " + allnum ;}
// set title
if (imageTitles) {newtitle.obj.innerHTML = thistitle[thisreqnum];}
// set thumbs link
if (hasThumbsLink) { 
thumbsLink.obj.innerHTML = thumbsHTML; 
}
}

else {
x.obj.document.open();
x.obj.document.write(thisHTML);
x.obj.document.close();
// set image numbers
if (imageNumbers) {
numberseq.obj.document.open();
numberseq.obj.document.write(thisnum + " / " + allnum);
numberseq.obj.document.close();}
// set image title
if (imageTitles) {
newtitle.obj.document.open();
newtitle.obj.document.write('<p>' + thistitle[thisreqnum] + '</p>');
newtitle.obj.document.close(); }
// set thumbs link
if (hasThumbsLink) {
thumbsLink.obj.document.open();
thumbsLink.obj.document.write(thumbsHTML);
thumbsLink.obj.document.close();
}
}
}
// Go Back & Go On links
var thisnext = new getObj("butt_next");
var thisprev = new getObj("butt_prev");
if (thisreqnum < (lastnum-1) || imageLoop) 
	{
	thisnextHTML = "<a href='Javascript:showthisimage(\"next\");' onMouseOver=\"status='Click here for the next image'; return true;\" onMouseOut=\"status=''; return true;\"><img src='gifs/butt_next.gif' height='19' width='19' alt='Click here for the next image'></a>";
	
	}
else {
thisnextHTML = "<img src='gifs/spacer.gif' height='19' width='19' alt='#'>";   
}
if (thisreqnum > 0 || imageLoop)
	{
	thisprevHTML = "<a href='Javascript:showthisimage(\"prev\");' onMouseOver=\"status='Click here for the previous image'; return true;\" onMouseOut=\"status=''; return true;\"><img src='gifs/butt_prev.gif' height='19' width='19' alt='Click here for the previous image'></a>";
	}
else {
thisprevHTML = "<img src='gifs/spacer.gif' height='19' width='19' alt='#'>";
}
}
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();
}

//newtitle.obj.firstChild.nodeValue=thistitle[thisreqnum];
}


// FUNCTION TO WRITE THUMBNAILS
function showThumbs() {
var thisHTML = "<div id='thumbsArea'><ul id='thumbslist'>";
for (y=thisnum; y<(thisnum+thumbsGrid); y++) {
if (y < allnum) {
thisHTML = thisHTML + '<li><table cellpadding="0" cellspacing="0" border="0"><tr><td width="' + thumbwidth + '" height="' + thumbheight + '" align="center" valign="middle"><a href="Javascript:doGetFull(' + y + ');" onMouseOver="status=\'Click here to view the full image\';return true;" onMouseOut="status=\'\';return true;"><img src="' + thumbsImageDir + thisimage[y] + '" alt="&copy; ' + artistName + '" border="0"></a>';
if (thumbTitles) {
var thumbTitleContent = thistitle[y];
thisHTML = thisHTML + '<br /><span class="thumbslabel">' + thumbTitleContent.toUpperCase() + '</span>';
}
thisHTML = thisHTML + '</td></tr></table></li>';	
}
else {
thisHTML = thisHTML + '<li><img src="gifs/spacer.gif" width="' + thumbwidth + '"  height="' + thumbheight + '" alt="#" border="0"></li>';
}
}
thisHTML = thisHTML + "</ul>";
if (folioTitle) {
thisHTML = thisHTML + "<div id='folio_title'>" + eval("folio_title" + thisItemNum) + "</div>";
}
thisHTML = thisHTML + "</div>";
x = new getObj("image_content");
// image numbers
if (imageNumbers) {
var thumbsnumberseq = new getObj("numberseq");
var currentThumbsPageNum = getThumbsStartNum(thisnum)/thumbsGrid;
var totalThumbsPageNum = getThumbsStartNum(allnum)/thumbsGrid;
if (totalThumbsPageNum > 0) {
var thisThumbsPageNum = (currentThumbsPageNum+1) + " / " + (totalThumbsPageNum+1);
}
else {var thisThumbsPageNum = "&nbsp;&nbsp;&nbsp;&nbsp;";}
}
// thumbs link
if (hasThumbsLink) {
//var thumbsLink = new getObj("thumbsLink");
var thumbsHTML = ''; 
}
if (document.getElementById || document.all) {
x.obj.innerHTML = thisHTML;
// set image numbers
if (imageNumbers) {
//thumbsnumberseq.obj.innerHTML = thisThumbsPageNum;
}
// set thumb link
if (hasThumbsLink) {
//thumbsLink.obj.innerHTML = thumbsHTML;
}
}
else {
x.obj.document.open();
x.obj.document.write(thisHTML);
x.obj.document.close();
// show image numbers
if (imageNumbers) {
thumbsnumberseq.obj.document.open();
thumbsnumberseq.obj.document.write(thisThumbsPageNum);
thumbsnumberseq.obj.document.close();
}
if (hasThumbsLink) {
thumbsLink.obj.document.open();
thumbsLink.obj.document.write(thumbsHTML);
thumbsLink.obj.document.close();
}
}
// GO BACK & GO ON LINKS
/*var thisnext = new getObj("butt_next");
var thisprev = new getObj("butt_prev");
if (currentThumbsPageNum < totalThumbsPageNum) 
	{
	thisnextHTML = "<a href='Javascript:doGetThumbs(\"next\");' onMouseOver=\"status='Click here for the next page'; return true;\" onMouseOut=\"status=''; return true;\"><img src='gifs/butt_next.gif' alt='Click here for the next page' width='20' height='13' border='0' /></a>";		
	}
else {
//thisnextHTML = "<img src='gifs/spacer.gif' alt='#' width='20' height='13' border='0' />";   
thisnextHTML = ""; 
}
if (currentThumbsPageNum > 0)
	{
	thisprevHTML = "<a href='Javascript:doGetThumbs(\"prev\");' onMouseOver=\"status='Click here for the previous page'; return true;\" onMouseOut=\"status=''; return true;\"><img src='gifs/butt_prev.gif' alt='Click here for the previous page' width='20' height='13' border='0' /></a>";
	}
else {
//thisprevHTML = "<img src='gifs/spacer.gif' alt='#' width='20' height='13' border='0' />";
thisprevHTML = "";
}

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();
}*/
}


function IsValidObject(objToTest) {
if (null == objToTest) {return false;}
if ("undefined" == typeof(objToTest) ) {return false;}
return true;
}

/* Function that sorts out the numbering for go back and go on */
function showthisimage(showwhat) {
	if (imageTitles) {
//hideTitle();
doHide('title_box','hidden');
	}
// ACTION FOR 'GO BACK' BUTTON
if (showwhat == "prev") {
if (thisnum >= 1) {
	thisnum = thisnum-1;}
	// what to do going < back from first page?
	else {
	if (imageLoop){thisnum = lastnum-1;} 
	//thisnum = lastnum-2 makes it loop round to last page - show button with 'hide button' feature 
	else {thisnum = 0;}
	//thisnum = 0 makes it stop at 1st page - hide button with 'hide button' feature
	}
}
// Function that creates action for Full Image 'go next' button
else if (showwhat == "next" || showwhat == "nextslide") {
if (showwhat == "next") {
}
/*if (showwhat == "nextslide") {showSSStop();}*/
	if (thisnum < lastnum-1) {thisnum = thisnum + 1;}
	// what to do going < on from last page?
	else {
	if (imageLoop) {thisnum = 0;} 
	// thisnum = 0 makes it loop round to 1st page - show button with 'hide button' feature 
	else {thisnum = lastnum-1;}
	// thisnum = lastnum-2 makes it stop at last page - hide button with 'hide button' feature
	}
}	

// DEFAULT ACTION
shownum = thisnum;
getimagefile(shownum);
}

// Function that gets Thumbnails page Start Number
function getThumbsStartNum(currentnum) {
var basenum = Math.floor(currentnum/thumbsGrid);
returnnum = basenum*thumbsGrid;
return returnnum;
}

// Function that creates action for Thumbnails 'go next' button
function doGetThumbs(thisDirection) {
	doHide('folio_nav','none');
	//doHide('title_box','hidden');
	//doShow('Copyright','block');
if (thisDirection == "next") 
{
thisnum = (thisnum + thumbsGrid);
}
else if (thisDirection == "prev") 
{
thisnum = (thisnum - thumbsGrid);
}
if (thisnum > allnum) {
thisnum = allnum;
}
if (thisnum <= 0) {
thisnum = 0;
} 
myMode='thumbs';
thisnum = getThumbsStartNum(thisnum);
//switchNav('thumbs');
switchContent(thisItemNum);
}

// Image change functions end
//+++++++++++++++++++++++++++++++++++++


function doGetFull(fullNum) {
	//doHide('Copyright','none');
	doShow('folio_nav','block');
myMode='full';
thisnum=fullNum;
switchContent(thisItemNum);
}



function nada() {
}
