var timer = 5;

var photos = [
['2007A', 'Students in front of a new building provided by SchoolBox'],
['2007B', 'A new school fence donated by SchoolBox'],
['2007C', 'A new soccer uniform and ball mean new hope for this student'],
['2007D', 'A government official assists the SchoolBox Big Smiles Program'],
['2007E', 'Big Smiles is Right!'],
['2007F', 'SchoolBox donor Michelle Bird helps to deliver maps'],
['2007G', 'For just $2.00 SchoolBox equips students with needed materials'],
['2007H', 'Helping these kids play soccer is a huge joy for SchoolBox'],
['2007I', 'Look for SchoolBox Coordinator Ronald Chavarria in this photo'],
['2007J', 'Kids are wonderful!'],
['2007K', 'Members of the Schoolbox Youth Soccer League'],
['2007L', 'SchoolBox staff celebrate with these students'],
['2007M', 'A successful fundraising drive is happily celebrated in Canada'],
['2007N', 'President Tom Affleck with teachers at the site of a new washroom'],
['2007O', 'Smiles are great!'],
['2007P', 'Students from one partner school search for metal in a dump'],
['2007Q', 'Students holding their new educational packages'],
['2007R', 'There is plenty of joy to go around...'],
['2007S', 'Plenty of joy'],
['2007T', 'This little guy gives his educational package a big hug'],
['2008A', 'March/April - 2008 Two Groups Visit Nicaragua'],
['2008B', 'May 2008 - Joseph Murray filming the SchoolBox Video'],
['2008C', 'May 2008 - SchoolBox builds New Washrooms'],
['2008D', 'June 2008 - Volunteers from Western Canada lay the foundation for a new school'],
['2008E', 'June 2008 - SchoolBox gets a new office!'],
['2008F', 'June 2008 - SchoolBox partners with Elephant Thoughts for new desks'],
['2008G', 'June 2008 - SchoolBox completes the first stage of the Blaney Library Project'],
['2008H', 'Nov 2008 - The Maloney Brothers finish the work that their parents started on the San Santiago School in March of 2008'],
['2008I', 'Oct 2008 - SchoolBOX expands to reach 26 communities'],
['2008J', 'Summer 2008 - The future of the San Santiago School never looked brighter!'],
['2008K', 'Summer 2008 - Volunteers and their friends taking a break'],
['2008L', 'Summer 2008 - San Santiago Build Group at the Beginning of the trip!'],
['2008M', 'Summer 2008 - One of the many children that will benifit from the new school'],
['2008O', 'Summer 2008 - Volunteers work hard but also have fun'],
['2008P', 'Summer 2008 - The San Santiago School Goes UP!'],
['2008Q', 'Summer 2008 - Volunteers work hard at laying cement blocks'],
['2008R', 'Summer 2008 - Volunteers are jovial and full of High-fives'],
['2008S', 'Summer 2008 - Flo poses with 4 happy cement workers during the San Santiago school build'],
['2008N', 'Nov 2008 - San Pedro School Build Land March 2009 '],
['2009A', 'Dec 2008 - Newly built San Santiago School'],
['2009B', 'Dec 2008 - Desks installed in San Santiago School'],
['2009C', 'Dec 2008 - Two very happy students in the San Santiago School'],
['2009D', 'Dec 2008 - Blaine Library completed'],
['2009E', 'Dec 2008 - Lots of enthusiastic students'],
['2009F', 'Jan 2009 - Newly installed fans and electrical supply in Jezreel School'],
['2009G', 'Jan 2009 - Septic Tank installed for 40 Juntos Con Tigo Education Centre students in La Chureca'],
['2009H', 'Feb 2009 - Reading Week in the Sun: Carrying Dirt!'],
['2009I', 'Feb 2009 - Little Corn Island, Big Success: School Build #3 '],
['2009J', 'Feb 2009 - Tables & Chairs: Simple Tools for the School in the Dump'],
['2009K', 'Feb 2009 - Back to Class in February with 1,323 Educational Packages'],
['2009L', 'March 2009 - School Build #4: Pre School, Ometepe Island, Nicaragua'],
['2009M', 'March 2009 - Return to San Pedro: Volunteer Group builds Pre-School'],
['2009N', 'April 2009 - Supplies For Success 2019 packets at Ometepe'],
['2009O', 'April 2009 - San Pedro School Completed'],
['2009P', 'May 2009 - BIG smiles all round! 464 students with toothbrushes'],
['2009Q', 'May 2009 - Soccer Dreams 54 young soccer players with uniforms'],
['2009R', 'May 2009 - The First SchoolBOX Soccer Tournament 1'],
['2009S', 'May 2009 - The First SchoolBOX Soccer Tournament 2'],
['2009T', 'May 2009 - The First SchoolBOX Soccer Tournament 3'],
['2009U', 'May 2009 - The First SchoolBOX Soccer Tournament 4'],
['2009V', 'May 2009 - The First SchoolBOX Soccer Tournament 5'],
['2009W', 'July 2009 - Ruben Dario construction begins!'],
['2009X', 'July 2009 - Tools4Schools helps Little Corn Island School complete their dream'],
['2009Y', 'August 2009 - Vitality Media AYES documentary'],
['2009Z', 'August 2009 - 1st AYES Program Volunteer Trip'],
['2009ZA', 'August 2009 - Supplies4Success: 1,023 packets to 1,023 happy students'],
['2009ZB', 'August 2009 - Tools4Schools: Construction of 4 new classrooms!']
];

var img, count = 1;

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


function changetextnode(divid,newtext)
{
	if (document.getElementById){
		var div=document.getElementById(divid)
		var newNode=document.createTextNode(newtext)
		div.replaceChild(newNode,div.childNodes[0])
		return true;
	}
}

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;
	changetextnode('title',photos[count][1]);

    if (++count == photos.length) { 
		count = 0; 
//		window.close();
//		count--;	
	}
//	else {
	    window.setTimeout('cueNextSlide()', timer * 1000);		// only set the timer to do another load if the slideshow is not finished
//		}
  };

  next.src = 'slideshow/' + 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();
      };
    }
  }
}

