/* ================================================================ 
This copyright notice must be untouched at all times.
The original version of this script and the associated (x)html
is available at http://www.stunicholls.com/various/tabbed_pages.html
Copyright (c) 2005-2007 Stu Nicholls. All rights reserved.
This script and the associated (x)html may be modified in any 
way to fit your requirements.
=================================================================== 
Code totally rewritten by Randy Brandt, but inspired by the
original Stu Nicholls design so I left his credit above 
// getEls[z].className=getEls[z].className.replace('on', 'off');}
*/

function doThumb(theTitle,theCaption,theID) {
      document.getElementById('bigCaption').innerHTML=theCaption;

/*
  console.warn('theTitle:'+theTitle);
  console.warn('theCaption:'+theCaption);
  console.warn('theID:'+theID);
*/
  var e=document.getElementById('gallery').getElementsByTagName('div');

	for (var i=0; i<e.length; i++) {
	  if (e[i].id==theID) {
		e[i].className='eOn bigPhoto';
 // document.getElementById(thisTitle).className="eOn"; 
	  } else {
		e[i].className='eOff bigPhoto';
    //  document.getElementById(e[i].title).className="eOff"; 
	  }
	}
}

/*

function doThumb(theTitle,theCaption,theID) {
  var e=document.getElementById('bigPhoto').getElementsByTagName('img');
  e[0].setAttribute('src',theTitle);  
  
 // console.warn('src:'+theTitle);
// alert ('src:'+theTitle);
  
// hide or show the fancy staff div
 var b=document.getElementById('bigPhoto');
 var f=document.getElementById('staffBox');
 if (theTitle=="staff") {
    f.style.display="block";
    b.style.display="none";
    theCaption="";
  } else {
    f.style.display="none";
    b.style.display="block";
  }
  document.getElementById('bigCaption').innerHTML = theCaption;
}
*/
// user hovered over a thumb
function thumbClick() {
  doThumb(this.alt,this.title,this.id);
}

// attach listeners to each img in the thumb gallery
function installImgListeners() {
  var e=document.getElementById('thumbs').getElementsByTagName('img');
//alert ("install "+e.length);

	for (var i=0; i<e.length; i++) {
    if (e[i].addEventListener){
      e[i].addEventListener('mouseover',thumbClick, false);
//alert ("attach to:"+e[i].title);

    } else if (e[i].attachEvent){ // IE
      e[i].onmouseover = function () {doThumb(this.alt,this.title,this.id);}  
    }
  }
}