// JavaScript Document

function nada() {}

// 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];}
}

// CENTER WINDOW //
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 contentElement = new getObj('holder');
var contentHeight = contentElement.obj.offsetHeight;
if (windowHeight - contentHeight > 0) {	
contentElement.obj.style.position = 'relative';
contentElement.obj.style.top = ((windowHeight / 2) - (contentHeight / 2)) + 'px';
}
else {
contentElement.obj.style.position = 'relative';
contentElement.obj.style.top = "0px";
}
}
}
}

// START SITE //

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

window.onload = function() {
  setSpacing();
if (window.location.search == "?new") {
	thisSection = "Section6";
	  thisFolioNum = 306;
	  goFull(0);
	  } 
	  else {
		  goHome();
	}
	} 

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

// 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;
}


// SECTION FUNCTIONS 

function goHome() {
	//doHide('sorry','none');
	doHide('full_image','none');
	doHide('thumb_content','none');	
	doHide('folio_nav_area','none');
	getPage('Section0','index');
	doShow('page_content','block');
	writeNavLink(0);
}

function goIndex(reqPage) {
	doHide('full_image','none');
	doHide('thumb_content','none');	
	doHide('folio_nav_area','none');
	getPage(reqPage,'index');
	doShow('page_content','block');
	}

function goContact() {
	//doHide('sorry','none');
	doHide('full_image','none');
	doHide('thumb_content','none');	
	doHide('folio_nav_area','none');
	getPage('Contact','text');
	doShow('page_content','block');
	writeNavLink(0);
}

function goGallery() {
	//doHide('sorry','none');
	doHide('full_image','none');
	doHide('thumb_content','none');	
	doHide('folio_nav_area','none');
	getPage('Gallery','text');
	doShow('page_content','block');
	writeNavLink(0);
}

function goProfile() {
	//doHide('sorry','none');
	doHide('full_image','none');
	doHide('thumb_content','none');	
	doHide('folio_nav_area','none');
	getPage('Profile','text');
	doShow('page_content','block');
	writeNavLink(0);
}

function goFull(reqImageNumber) {
	doHide('page_content','none');
	doHide('thumb_content','none');
	doShow('full_image','block');	
	//doShow('image_title','block');
	doShow('folio_nav_area','block');
	myMode='full';
	thisImageNumber = reqImageNumber;
	switchContent(thisFolioNum);
}

function goThumbs(thisFolioNum) {
	doHide('page_content','none');
	doHide('full_image','none');
	doHide('folio_nav_area','none');	
	//doHide('image_title','none');
	doShow('thumb_content','block');	
	myMode='thumbs';
//thisnum=thumbsNum;
	//thisImageNumber = 0;
	switchContent(thisFolioNum);
}

function writeNavLink(navLevel) {
	//alert(navLevel);
	var navLinkFin = navLink;
    //alert(navLinkFin);
	var thisAddLink = "";
	if (navLevel.length > 7) {
		// It's a Section call
		thisSection = navLevel;
		// Which section?
		var thisSectionNum = thisSection.substr(7);
		if (thisSectionNum == 0) {
			//It's the Home page for Folios
			navLevel = 0;
			}
			else {
			// It's another - Show the Section name
			thisAddLink = Section0[(parseInt(thisSectionNum)-1)][2];
			}
		}
		else {
			// It's a Folio call
			if (navLevel > 5) {
			// Within a section?
			if (thisSection.length > 7) {
			var thisSectionNum = thisSection.substr(7);
			thisAddLink = "<a href=\"Javascript:goIndex('" + thisSection + "');\">" + Section0[(parseInt(thisSectionNum)-1)][2] + "<\/a>" + navLinkSep + navLinkFront;
			}
			}
			else {
				// Not in a Section, probably Gallery
				thisSection = "";
				}
	if (navLevel > 0) {
		// Not Gallery Front Page
		// Check if a Section Level Title has been requested
		var thisSelectFolioTitle = "";
		if (navLevel > 2) {	
		// Excludes Print Sales
		var thisSelectArray = eval(thisSection);
		for (var i in thisSelectArray) {
			if (thisSelectArray[i][0] == navLevel) { 
			thisSelectFolioTitle = thisSelectArray[i][2];
			 }
			}
		}		
		if (thisSelectFolioTitle.length > 1) {
			// Yes, add it to top nav
			thisAddLink = thisAddLink + thisSelectFolioTitle;		
		}
		else {
			// No, use Folio Level Title
			thisAddLink = thisAddLink + eval("thisNavLink" + navLevel);
		}
		}
			}
	switch (navLevel) {
	// Start menu
	case 0:
	navLinkFin = navLinkFin + navLinkPrint;
	break;
	// Gallery menus
	case 1:
	case 2:
    case 3:
    case 4:
    case 5:
	navLinkFin = navLinkFin + navLinkPrint + navLinkSep + navLinkFront + thisAddLink;
	break;
	// Folio menus
	default:
	navLinkFin = navLinkFin + navLinkFront + thisAddLink + navLinkSep + navLinkPrint;
	}
	navLinkFin = navLinkFin + navLinkBack;
	//alert(navLinkFin);
	var x = new getObj("main_nav");
	if (document.getElementById || document.all) {
x.obj.innerHTML = navLinkFin; 
}
else {
	x.obj.document.open();
x.obj.document.write(navLinkFin);
x.obj.document.close();
}
	}
	
// TEXT PAGE OR INDEX PAGE?

function getPage(reqPage,reqType) {
	//alert(reqPage);
	var thisPage = new getObj("page_content");
	switch (reqType) {
		case "text":
		var thisHTML = eval("page" + reqPage);
		break;
		
		case "index":
		var thisHTML = getIndex(reqPage);
		//alert(reqPage);
		writeNavLink(reqPage);
		break;
		
		}
if (document.getElementById || document.all) {
thisPage.obj.innerHTML = thisHTML; 
}
else {
thisPage.obj.document.open();
thisPage.obj.document.write(thisHTML);
thisPage.obj.document.close();
}
	}
	
// MAKES THE INDEX PAGES
	
function getIndex(reqPage) {
	var thisArray = eval(reqPage);
	var thisIndexWidth = thisArray.length * 206;
	var thisIndexOffset = 155;
	if (thisIndexWidth > 824) {thisIndexWidth = 824;thisIndexOffset = 55;}
	var thisHTML = "<ul class=\"indexThumbs\" style=\"width:" + thisIndexWidth + "px;padding-top:" + thisIndexOffset + "px;\">";
	for (var y=0; y<thisArray.length; y++) {
thisHTML = thisHTML + "<li>"
switch (reqPage) {
	case "Section0":
//if(reqPage == "Section0") {
	if (y == 7) {
		thisHTML = thisHTML + "<a href=\"http://www.animal-library.com\" target=\"_blank\">";
			}
	else {
	thisHTML = thisHTML + "<a href=\"Javascript:getPage('" + thisArray[y][0] + "','index');\">";
		}
	break;
	
	case "Section5":
	if (thisArray[y][0].length > 0) {
		var thisWindowWidth = thisArray[y][3] + 20;
		var thisWindowHeight = thisArray[y][4] + 40;
	thisHTML = thisHTML + "<a href=\"Javascript:nada();\" onClick=\"Javascript:window.open('movies\/" + thisArray[y][0] + "','animation','width=" + thisWindowWidth + ",height=" + thisWindowHeight + ", toolbar=no');\">";
	}
	break;
	//}
//else {
	default:
	thisHTML = thisHTML + "<a href=\"Javascript:goThumbs(" + thisArray[y][0] + ");\">";
	}
if (thisArray[y][1].length > 0) {
thisHTML = thisHTML + "<img src=\"../~stevehos/gifs/" + thisArray[y][1] + "\" width=\"150\" height=\"150\" alt=\"#\"><\/a><br \/>" + thisArray[y][2] + "<\/li>"; 
}
else 
{thisHTML = thisHTML + "<\/li>";}
	}
	thisHTML = thisHTML + "<\/ul>";
	return thisHTML;
	}

// FUNCTION TO SWITCH TO IMAGE MODE
function goImages(thisitemnum) {
	myMode = startMode;
	thisFolioNum = thisitemnum
	if (myMode == "full") {
		goFull(0);
}
else {goThumbs(thisFolioNum); }
}

// FUNCTION TO SWITCH TO REQUIRED FOLIO
function switchContent(reqFolioNum) {
thisFolioNum = reqFolioNum;
// Only Gallery images have titles
	imageTitles = false
//if (thisFolioNum == 1 || thisFolioNum == 2) {
if (thisFolioNum < 6 ) {
	imageTitles = true
	}
/*switch (thisFolioNum) {
	case 101:
	case 102:
	case 103:
	case 104:
	case 201:
	case 202:
	case 203:
	case 204:
	case 501:
	case 502:
	case 503:
	case 504:
	case 601:
	case 306:
    case 602:
	fullImageDir = "yfi/";
	thumbsImageDir = "yti/";
	break;
	
	default:
	fullImageDir = "fi/";
	thumbsImageDir = "ti/";
	break;
	}  */
	
writeNavLink(thisFolioNum);
thisFolio = eval("thisfolio" + thisFolioNum);
thisFolioLength = thisFolio.length;
if (myMode == "full") {
thisImageDir = fullImageDir;
//showthisimage('current');
getimagefile(thisImageNumber);
}
else {
thisImageDir = thumbsImageDir;
thisImageNumber = 0;
if (reqFolioNum < 6) {
showThumbs(0);
}
else {
showScrollThumbs(0);	
	}
}
}

// 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;
}
}*/

// GET CORRECT FULL IMAGE NUMBER	
function showthisimage(showwhat) {
if (showwhat == "prev") {
if (thisImageNumber >= 1) {
	thisImageNumber = thisImageNumber-1;
	}
	else {
	if (imageLoop){thisImageNumber = thisFolioLength-1;} 
	else {thisImageNumber = 0;}
	}
}
else if (showwhat == "next" || showwhat == "nextslide") {
if (showwhat == "next") {
}
	if (thisImageNumber < thisFolioLength-1) {thisImageNumber = thisImageNumber + 1;}
	else {
	if (imageLoop) {thisImageNumber = 0;} 
	else {thisImageNumber = thisFolioLength-1;}
	}
}
//var shownum = thisnum;

getimagefile(thisImageNumber);
}

// GET FULL IMAGE
function getimagefile(thisreqnum) {
if (document.images) {
	if ((thisreqnum < thisFolioLength) && thisreqnum >= 0) {
var thisHTML = '<img src="' + thisImageDir + thisFolio[thisreqnum] + '" alt="&copy ' + artistName + '">';
if (hasThumbsLink) {
thisHTML = '<a href="Javascript:goThumbs(' + thisFolioNum + ');" onMouseOver="status=\'Click here to view thumbnails\'; return true;" onMouseOut="status=\'\'; return true;">' + thisHTML + '</a>'; 
}
thisHTML = '<table><tr><td>' + thisHTML + '<\/td><\/tr><\/table>';
var x = new getObj("full_image");
if (folioTitle) {
var q = new getObj("foliotitle");
var thisTitle = eval("thisfoliotitle" + thisFolioNum);
}
if (hasThumbsLink) { 
var thumbsLink = new getObj("thumbsLink");
var thumbsHTML = '<a href="Javascript:goThumbs(' + thisFolioNum + ');" onMouseOver="status=\'Click here to view thumbnails\'; return true;" onMouseOut="status=\'\'; return true;"><img src="~stevehos/gifs/thumbs.gif" alt="Click here to view thumbnails" id="thumbs_MM" width="30" height="30" \/></a>';
//var thumbsHTML = '<a href="Javascript:doGetThumbs(0);" onMouseOver="MM_swapImage(\'thumbs_MM\',\'\',\'gifs\/thumbs_f2.gif\',1);status=\'Click here to view thumbnails\'; return true;" onMouseOut="MM_swapImgRestore();status=\'\'; return true;"><img src="gifs/thumbs.gif" alt="Click here to view thumbnails" id="thumbs_MM" width="43" height="15" \/></a>'; 
}
if (document.getElementById || document.all) {
x.obj.innerHTML = thisHTML;
if (folioTitle) {
q.obj.innerHTML = thisTitle;
}
if (hasThumbsLink) {	
thumbsLink.obj.innerHTML = thumbsHTML; 
}
}
else 
{
x.obj.document.open();
x.obj.document.write(thisHTML);
x.obj.document.close();
if (folioTitle) {
q.obj.document.open();
q.obj.document.write(thisTitle);
q.obj.document.close();
}
if (hasThumbsLink) {
thumbsLink.obj.document.open();
thumbsLink.obj.document.write(thumbsHTML);
thumbsLink.obj.document.close();
}
}
// IMAGE TITLES
var titleContent = "";
if (imageTitles) {
var thistitle = eval("thistitle" + thisFolioNum);
//var titleContent = "<br \/>" + thistitle[thisImageNumber];
titleContent = "<p>" + thistitle[thisImageNumber] + "</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>" + (thisImageNumber + 1) + "/" + thisFolioLength + "</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
if (hasNavLinks) {
var thisnext = new getObj("butt_next");
var thisprev = new getObj("butt_prev");

if (thisreqnum < (thisFolioLength-1)) 
	{
		//var thisnextHTML = "<a href='Javascript:showthisimage(\"next\");'>&gt;<span class='full_nav'><\/span><\/a>";
		var thisnextHTML = "<a href='Javascript:showthisimage(\"next\");' onMouseOver=\"status='Click here for the next image'; return true;\" onMouseOut=\"status=''; return true;\"><img src='~stevehos/gifs\/butt_next.gif' id='butt_next_MM' alt='Click here for the next image' width='30' height='30' \/></span><\/a>";
	//var thisnextHTML = "<a href='Javascript:showthisimage(\"next\");' onMouseOver=\"MM_swapImage('butt_next_MM','','gifs\/butt_next_f2.gif',1);status='Click here for the next image'; return true;\" onMouseOut=\"MM_swapImgRestore();status=''; return true;\"><img src='gifs\/butt_next.gif' id='butt_next_MM' alt='Click here for the next image' width='12' height='20' \/></span><\/a>";	
	}
else {
thisnextHTML = "<span class='nav_null'>&nbsp;</span>"; 
}

if (thisreqnum > 0)
	{
		//var thisprevHTML = "<a href='Javascript:showthisimage(\"prev\");'>&lt;<span class='full_nav'><\/span><\/a>"; 
		var thisprevHTML = "<a href='Javascript:showthisimage(\"prev\");' onMouseOver=\"status='Click here for the previous image'; return true;\" onMouseOut=\"status=''; return true;\"><img src='~stevehos/gifs\/butt_prev.gif' alt='Click here for the previous image' id='butt_prev_MM' width='40' height='30' \/><\/a>";
	//var 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 showScrollThumbs(thisImageNumber) {
if (document.images) {
//var thisHTML = "<div id=\"thumbsscrolllist\"><div id=\"thumbsscrolllistholder\"><img src=\"gifs/frameleft08.gif\" alt=\"#\" id=\"frameleft\" \/><table id='thumbsscrolllist'><tr>";	
var numCells = thisFolioLength+2;
var thisHTML = "<div id=\"thumbsscrolllist\"><div id=\"thumbsscrolllistholder\"><table><tr><td rowspan='3' width='18'><img src='~stevehos/gifs/frameleft.gif' width='18' height='149' alt='#' border='0'></td><td colspan='" + numCells + "' background='~stevehos/gifs/frameline.gif'><img src='~stevehos/gifs/frameline.gif' width='12' height='12' alt='' border='0'></td><td rowspan='3' width='18'><img src='~stevehos/gifs/frameright.gif' width='18' height='149' alt='' border='0'></td></tr><tr>";
for (var y=thisImageNumber; y<thisFolioLength; y++) {	
//if (y == 0 || y == thisFolioLength) {thisHTML = thisHTML + "<td>";} else {thisHTML = thisHTML + "<td class='imagecell'>";}
switch(y) {
	case 0:
	thisHTML = thisHTML + "<td class='imagecellfirst'>";
	break;
	
	case thisFolioLength-1:
	thisHTML = thisHTML + "<td class='imagecelllast'>";
	break;
	
	default:
	thisHTML = thisHTML + "<td class='imagecell'>";
	}
//thisHTML = thisHTML + "<td class='imagecell'>";
thisHTML = thisHTML + '<a href="Javascript:goFull(' + y + ');" onMouseOver="status=\'Click here to view the full image\';return true;" onMouseOut="status=\'\';return true;"><img src="' + thumbsImageDir + thisFolio[y] + '" alt="&copy; ' + artistName + '"><\/a>';	
thisHTML = thisHTML + "<\/td>";
}
//thisHTML = thisHTML + "<\/tr><\/table><img src=\"gifs/frameright08.gif\" alt=\"#\" id=\"frameright\" \/><\/div><\/div>";
thisHTML = thisHTML + "</tr><tr><td colspan='" + numCells + "' background='~stevehos/gifs/frameline2.gif'><img src='~stevehos/gifs/frameline2.gif' width='12' height='12' alt='#' border='0'></td></tr></table><\/div><br \/>CLICK ON ANY THUMBNAIL TO SEE A BIGGER VERSION<\/div>";
var x = new getObj("thumb_content");
if (document.getElementById || document.all) {x.obj.innerHTML = thisHTML; y.obj.innerHTML = thisTitle;}
else { x.obj.document.open();
x.obj.document.write(thisHTML);
x.obj.document.close();
}
}/**/
}

function showThumbs(thisImageNumber) {
if (document.images) {
thumbsGrid = 15;
var thisHTML = "<ol id='thumbslist'>";
if (thisFolioLength <= 10) {
	thumbsGrid = 10;
	thisHTML = "<ol id='thumbslist10'>";
	}
for (var y=thisImageNumber; y<(thisImageNumber+thumbsGrid); y++) {
if (y < thisFolioLength) {
thisHTML = thisHTML + '<li>';
thisHTML = thisHTML + '<table><tr><td>';
thisHTML = thisHTML + '<a href="Javascript:goFull(' + y + ');" onMouseOver="status=\'Click here to view the full image\';return true;" onMouseOut="status=\'\';return true;"><img src="' + thumbsImageDir + thisFolio[y] + '" alt="&copy; ' + artistName + '"><\/a>';
//if (thumbTitles) {
//var thumbTitleContent = thistitle[y];
//thisHTML = thisHTML + '<br /><span class="thumbslabel">' + thumbTitleContent.toUpperCase() + '</span>';
//}
thisHTML = thisHTML + '<\/td><\/tr><\/table>';
thisHTML = thisHTML + '<\/li>';	}
else { thisHTML = thisHTML + '<li><img src="~stevehos/gifs/spacer.gif" width="' + thumbWidth + '"  height="' + thumbHeight + '" alt="" border="0"><\/li>'; }
}
thisHTML = thisHTML + "<\/ol>";
// ADD TITLE
//var thisthumbstitle = eval("thisfoliotitle" + thisItemNum);
//var thisTitle = thisthumbstitle;
//
var x = new getObj("thumb_content");
//var y = new getObj("foliotitle");
if (document.getElementById || document.all) {x.obj.innerHTML = thisHTML; y.obj.innerHTML = thisTitle;}
else { x.obj.document.open();
x.obj.document.write(thisHTML);
x.obj.document.close();
//y.obj.document.open();
//y.obj.document.write(thisTitle);
//y.obj.document.close();
}
}
}

function getAnimation(reqAnimation) {
	//alert("run animation");
		var thisPage = new getObj("page_content");
	//thisHTML = "AC_AX_RunContent( 'classid','clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B','codebase','http://www.apple.com/qtactivex/qtplugin.cab','width','500','height','300','src','/movies/02_lexus.mp4','type','image/x-macpaint','pluginspage','http://www.apple.com/quicktime/download','qtsrc','/movies/02_lexus.mp4','autoplay','true' );"
	//thisHTML = "HELLO<script type=\"text/javascript\">alert('here');<\/script>";
	//var thisHTML = "<OBJECT CLASSID=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\" CODEBASE=\"http:\/\/www.apple.com\/qtactivex\/qtplugin.cab\" WIDTH=\"500\" HEIGHT=\"300\" ><PARAM NAME=\"src\" VALUE=\"\/movies\/02_lexus.mp4\" ><PARAM NAME=\"autoplay\" VALUE=\"true\" ><EMBED SRC=\"QTMimeType.pntg\" TYPE=\"image\/x-macpaint\" PLUGINSPAGE=\"http:\/\/www.apple.com\/quicktime\/download\" QTSRC=\"\/movies\/02_lexus.mp4\" WIDTH=\"500\" HEIGHT=\"300\" AUTOPLAY=\"true\"> <\/EMBED><\/OBJECT>";
	var thisHTML = pageAnim5 + pageAnim02_width + pageAnim6 + pageAnim02_height + pageAnim7 + pageAnim02_name + pageAnim8 + pageAnim02_name + pageAnim9 + pageAnim02_width + pageAnim10 + pageAnim02_height + pageAnim11;
	alert(thisHTML);
	if (document.getElementById || document.all) {
thisPage.obj.innerHTML = thisHTML; 
}
else {
thisPage.obj.document.open();
thisPage.obj.document.write(thisHTML);
thisPage.obj.document.close();
}
	}

