var timer = 5;

var panels = [
    ['panel', 'In my opinion Jaanz is the best singing school in Australia. They are always a hotbed for talent, David Caplice management-Guy Sebastian, Human Nature, David Campbel'],
    ['panel1', 'To the all time greatest singing teacher lets see what we can do with the world, Delta Goodrem, International recording artist'],
    ['panel2', 'To the wonderful David Jaanz...You have taught me how to use my voice and soul, Stephanie Mcintosh, International recording artist'],
    ['panel3', 'David Jaanz is a genius! He knows just how to bring out the artists real and true voice...He is the best in the business!, Tom Nichols, Producer UK Universal records']
];

var img, count = 1;

function startSlideshow()
{
  img = document.getElementById('panel');
  window.setTimeout('cueNextSlide()', timer * 1000);
}

function cueNextSlide()
{
  var next = new Image;

  next.onerror = function()
  {
    alert('Failed to load next image');
  };

  next.onload = function()
  {
    img.src = next.src;
    img.alt = panels[count][1];

    img.width = next.width;
    img.height = next.height;

    if (++count == panels.length) { count = 0; }

    window.setTimeout('cueNextSlide()', timer * 1000);
  };

  next.src = 'assets/images/' + panels[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();
      };
    }
  }
}
