// JavaScript Document

function getWindowHeight() {
var windowHeight=0;
if (typeof(window.innerHeight) == 'number') {
windowHeight = window.innerHeight;
}
else {
if (document.documentElement && document.documentElement.clientHeight) {
windowHeight = document.documentElement.clientHeight;
}
else {
if (document.body&&document.body.clientHeight) {
windowHeight = document.body.clientHeight;
}
}
}
return windowHeight;
}

function setSpacing() {
if (document.getElementById) {
var windowHeight = getWindowHeight();
if (windowHeight > 0) {
var footerElement = document.getElementById('footer');
var footerHeight = footerElement.offsetHeight;
var contentElement = document.getElementById('content');
//var contentHeight = contentElement.offsetHeight;
var contentHeight = 650;
var headerHeight = document.getElementById('header').offsetHeight;
var availHeight = (windowHeight-(headerHeight+footerHeight));
if (availHeight - contentHeight > 0) {	
contentElement.style.height = contentHeight + 'px';
contentElement.style.position = 'relative';
contentElement.style.top = ((availHeight / 2) - (contentHeight / 2)) + 'px';
}
else {
//contentElement.style.position = 'static';
contentHeight = availHeight;
contentElement.style.height = availHeight + 'px';
contentElement.style.position = 'relative';
contentElement.style.top = "0px";
}
footerElement.style.position='relative';
footerElement.style.top=(windowHeight-(headerHeight+contentHeight+footerHeight))+'px';
}
}
}

window.onload = function() {
  setSpacing();
  goHome();
}
window.onresize = function() {
  setSpacing();
}

// FUNCTION TO SWITCH TO IMAGE MODE
function goImages(thisitemnum) {
	//doHide('title_box','hidden');
	doHide('homecontent','none');
	doHide('infohere','none');
	//doHide('About','none');
	//doHide('Contact','none');
	//doHide('Copyright','none');
	doHighlight(thisitemnum+1);
	myMode = startMode;
	if (myMode == "full") {
	doHide('thumbshere','none');
	doShow('imagecontent','block');
	doShow('nav_butts','block');
}
else {
	doHide('imagecontent','none');
	doHide('nav_butts','none');
	doShow('thumbshere','block');
}
	thisnum = 0;
	switchContent(thisitemnum);
}

function goHome() {
	doHide('sorry','none');
	doHide('imagecontent','none');
	doHide('nav_butts','none');
	doHide('thumbshere','none');
	doHide('infohere','none');
	doShow('homecontent','block');
	doHighlight(1);
}

function goInfo() {
	doHide('imagecontent','none');
	doHide('nav_butts','none');
	doHide('thumbshere','none');
	doHide('homecontent','none');
	doShow('infohere','block');
	doHighlight(7);
}


function doGetFull(fullNum) {
	//doHide('group','none');
	//doHide('contact','none');
	//doHide('clients','none');
	doHide('homecontent','none');
	doHide('infohere','none');
	doHide('thumbshere','none');
	doShow('imagecontent','block');
	doShow('nav_butts','block');
	myMode='full';
	thisnum=fullNum;
//doFullBG('full');
switchContent(thisItemNum);
}


function doGetThumbs(thumbsNum) {
	//doHide('group','none');
	//doHide('contact','none');
	//doHide('clients','none');
	doHide('homecontent','none');
	doHide('infohere','none');
	doHide('imagecontent','none');
	doHide('nav_butts','none');
	doShow('thumbshere','block');
myMode='thumbs';
//if (thisnum==0) {
	//var thisDiv = new getObj('thumbshere');
	//thisDiv.obj.scrollLeft = 0;
	//}
switchContent(thisItemNum);
}

// FUNCTION TO HIGHLIGHT CURRENT FOLIO LINK
function  doHighlight(thisNavItem) {
var z = new getObj("footer_links");
if (!z) return;
var y = (z.obj.getElementsByTagName('a').length);
for (var i=1;i<=y;i++) {
navLink = new getObj("nav" + i + "hi");
navLink.obj.className="";
}
if (thisNavItem != 0) {
navLink = new getObj("nav" + thisNavItem + "hi");
navLink.obj.className = "hilite";
return true;
}
}

function showthisimage(showwhat) {
if (showwhat == "prev") {
if (thisnum >= 1) {
	thisnum = thisnum-1;}
	else {
	if (imageLoop){thisnum = lastnum-1;} 
	else {thisnum = 0;}
	}
}
else if (showwhat == "next" || showwhat == "nextslide") {
if (showwhat == "next") {
}
	if (thisnum < lastnum-1) {thisnum = thisnum + 1;}
	else {
	if (imageLoop) {thisnum = 0;} 
	else {thisnum = lastnum-1;}
	}
}
shownum = thisnum;
getimagefile(shownum);
}	

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 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 TO SWITCH TO REQUIRED FOLIO
function switchContent(thisitemnum) {
thisItemNum = thisitemnum;
thisfolio = eval("thisfolio" + thisItemNum);
allnum = thisfolio.length;
if (myMode == "full") {
thisImageDir = fullImageDir;
showthisimage('current');
}
else {
thisImageDir = thumbsImageDir;
showThumbs(0);
}
}

function getimagefile(thisreqnum) {
if (document.images) {
lastnum = thisfolio.length;
	if ((thisreqnum<lastnum) && thisreqnum>=0) {	
thisHTML = '<img src="' + thisImageDir + thisfolio[thisreqnum] + '" alt="&copy ' + artistName + '">'
if (hasThumbsLink) {
thisHTML = '<a href="Javascript:doGetThumbs();" onMouseOver="status=\'Click here to view thumbnails\'; return true;" onMouseOut="status=\'\'; return true;">' + thisHTML + '</a>'; 
}
thisHTML = '<table class="imagetable"><tr><td>' + thisHTML + '<\/td><\/tr><\/table>';
x = new getObj("imagecontent");
if (hasThumbsLink) { 
var thumbsLink = new getObj("thumbsLink");
var thumbsHTML = '<a href="Javascript:doGetThumbs();" onMouseOver="MM_swapImage(\'thumbs_MM\',\'\',\'graphics\/thumbs_f2.gif\',1);status=\'Click here to view thumbnails\'; return true;" onMouseOut="MM_swapImgRestore();status=\'\'; return true;"><img src="graphics/thumbs.gif" alt="Click here to view thumbnails" id="thumbs_MM" width="30" height="30" \/></a>'; 
}
if (document.getElementById || document.all) {
x.obj.innerHTML = thisHTML;
if (hasThumbsLink) {	thumbsLink.obj.innerHTML = thumbsHTML; }
}

else {
x.obj.document.open();
x.obj.document.write(thisHTML);
x.obj.document.close();
if (hasThumbsLink) {
thumbsLink.obj.document.open();
thumbsLink.obj.document.write(thumbsHTML);
thumbsLink.obj.document.close();
}
}
}
// IMAGE TITLES
if (imageTitles) {
thistitle = eval("thistitle" + thisItemNum);
var titleContent = "<table><tr><td>" + thistitle[thisreqnum] + "</td></tr></table>";
//var titleContent = "<p>" + thistitle[thisreqnum] + "</p>";
y = new getObj("image_title");
if (document.getElementById || document.all) {
y.obj.innerHTML = titleContent;
}
else {
y.obj.document.open();
y.obj.document.write(titleContent);
y.obj.document.close();
}
}
// IMAGE NUMBERS
if (imageNumbers) {
var z = new getObj("numberseq");
var numberContent =  "<p>" + (thisnum+1) + "&nbsp;/&nbsp;" + allnum + "</p>" ;
//var numberContent = " / " + allnum ;
if (document.getElementById || document.all) {
z.obj.innerHTML = numberContent;
}
else {
z.obj.document.open();
z.obj.document.write(numberContent);
z.obj.document.close();
}
}
// Go Back & Go On links
var thisnext = new getObj("butt_next");
var thisprev = new getObj("butt_prev");
if (thisreqnum < (lastnum-1)) 
	{
	thisnextHTML = "<a href='Javascript:showthisimage(\"next\");' onMouseOver=\"MM_swapImage('butt_next_MM','','graphics\/butt_next_f2.gif',1);status='Click here for the next image'; return true;\" onMouseOut=\"MM_swapImgRestore();status=''; return true;\"><img src='graphics\/butt_next.gif' id='butt_next_MM' alt='Click here for the next image' width='40' height='30' \/></span><\/a>";	
	}
else {
thisnextHTML = "<span class='nav_null'>&nbsp;</span>"; 
}

if (thisreqnum > 0)
	{
	thisprevHTML = "<a href='Javascript:showthisimage(\"prev\");' onMouseOver=\"MM_swapImage('butt_prev_MM','','graphics\/butt_prev_f2.gif',1);status='Click here for the previous image'; return true;\" onMouseOut=\"MM_swapImgRestore();status=''; return true;\"><img src='graphics\/butt_prev.gif' alt='Click here for the previous image' id='butt_prev_MM' width='40' height='30' \/><\/a>";
	}
else {
thisprevHTML = "<span class='nav_null'>&nbsp;<\/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();
}
}

function showThumbs(thisNumCalled) {
if (document.images) {
var thisHTML ="<table><tr>";
for (i=0;i<allnum;i++) {
thisHTML = thisHTML + '<td><table class="thumbcell"><tr><td><a href="Javascript:doGetFull(' + i + ')" onMouseOver="status=\'Click here to view full image\'; return true;" onMouseOut="status=\'\'; return true;"><img src="' + thisImageDir + thisfolio[i] + '" border="0" alt="&copy ' + artistName + ', 2007" \/><\/a><\/td><\/tr><\/table><\/td>';
}
thisHTML = thisHTML + "<\/tr><\/table>";
thisthumbstitle = eval("thisthumbstitle" + thisItemNum);
thisHTML = thisHTML + "<p>" + thisthumbstitle + "<\/p>";
x = new getObj("thumbshere");
if (document.getElementById || document.all) {x.obj.innerHTML = thisHTML;}
else { x.obj.document.open();
x.obj.document.write(thisHTML);
x.obj.document.close();
}
if (thisnum==0) {
	x.obj.scrollLeft = 0;
	}
}
}
