///////////////////////////////////////////////// slideshow.js /////////////////////////////////////////////////////////
// This file contains the functions necessary to create a slideshow with thumbnails                                   //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


// initializes slideshow
window.onload = function () {
   // get all links
   var links = document.getElementsByTagName("img");
   for (var i = 0; i < links.length; i++) {
      if(links[i].className == 'thumbnail') {
         links[i].onmouseover = function() {
            this.style.borderColor = '#941A33';
            this.style.cursor = 'pointer';
            swapImage(this.getAttribute('src'));
            if(this.getAttribute('alt') != '') { swapCaption(this.getAttribute('alt')); }
            return false;
         }
         links[i].onmouseout = function() { this.style.borderColor = 'black'; }
         links[i].onclick = function() {
            swapImage(this.getAttribute('src'));
            if(this.getAttribute('alt') != '') { swapCaption(this.getAttribute('alt')); }
            return false;
         }
      }
   }
}


// swaps old image with new one
function swapImage(src)
{
   document.getElementById('slide').setAttribute('src', src);
}

// swaps old caption with new one
function swapCaption(caption)
{
   document.getElementById('caption').innerHTML = caption;
}
