/* ================================================================ 
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(theID) {

  var i=document.getElementById(theID);
  if (theID=="alps") {
    theSrc="webpages/randy.jpg";
  } else {
    theSrc=i.src;
  }
  
// alert (" "+theSrc+" "+theID+" ");
  var e=document.getElementById('webShot').getElementsByTagName('img');
  e[0].setAttribute('src',theSrc);    

  var c=document.getElementById('txt_'+theID);
  var newTxt=c.innerHTML;
  document.getElementById('webCaption').innerHTML = newTxt;
}

// user hovered over a thumb
function thumbClick() {
  doThumb(this.id);
}

var bAddEvent;

// attach listeners to each eType in gallery
function listenTo(gallery,eType) {
  if (eType===undefined) {
   eType = 'img';
  }
  var e=document.getElementById(gallery).getElementsByTagName(eType);
	for (var i=0; i<e.length; i++) {
		if (bAddEvent) {
			e[i].addEventListener('mouseover',thumbClick, false);
		} else {
			e[i].onmouseover = function () {doThumb(this.id);}  
		}
  }
}

function installThem() {
  listenTo('thumbs');
  listenTo('banner');
}

function installMyListeners () {
	if (window.addEventListener){
		bAddEvent=1;
		window.addEventListener('load',installThem, false);
	} else if (window.attachEvent){
		bAddEvent=0;
		window.attachEvent('onload',installThem);
	}
}