var timer = 3;

var photos = [
	['brian', 'Resnet Picture'],
	['arianna', 'Arianna'],
	['chris', 'A resnet picture'],
	['img_9133', 'Student Three'],
	['img_9115', 'Student Four'],
	['laila', 'Student Eighteen'],
	['img_9131', 'Student Nineteen'],
	['img_8805', 'Student Twenty'],
	['img_9125','Student Six'],
	['img_9128','Student Seven'],
	['thang','Student Eight'],
	['Shaneka','Shaneka'],
	['shadaya','shadaya'],
	['nelson','Student Ten'],
	['robert','Student Thirteen'],
	['img_8805','Student Fourteen'],
	['francis','Student Sixteen'],
	['img_8793','Student Seventeen'],
	['glen','Student Eighteen'],
	['img_8738','Student Nineteen']
];

var img, count = 1;

function pausecomp(millis)
{
var date = new Date();
var curDate = null;

do { curDate = new Date(); }
while(curDate-date < millis);
}


function startSlideshow()
{
  img = document.getElementById('photo');
  window.setTimeout('cueNextSlide()', timer * 2000);
}

function cueNextSlide()
{
  var next = new Image;
  next.onerror = function()
  {
    alert('Failed to load next image');
  };

  next.onload = function()
  { 

    img.src = next.src;
    img.alt = photos[count][1];

    img.width = next.width;
    img.height = next.height;

    if (++count == photos.length) { count = 0; }

    window.setTimeout('cueNextSlide()', timer * 1000);
  };

  next.src = 'slideshow/photos/' + photos[count][0] + '.jpg';
}

addLoadListener(startSlideshow);

function addLoadListener(fn)
{
  if (typeof window.addEventListener != 'undefined')
  {
    window.addEventListener('load', fn, false);
  }
  else if (typeof document.addEventListener != 'undefined')
  {
    document.addEventListener('load', fn, false);
  }
  else if (typeof window.attachEvent != 'undefined')
  {
    window.attachEvent('onload', fn);
  }
  else
  {
    var oldfn = window.onload;
    if (typeof window.onload != 'function')
    {
      window.onload = fn;
    }
    else
    {
      window.onload = function()
      {
        oldfn();
        fn();
      };
    }
  }
}

