var timer = 7;
//var displayfilter="progid:DXImageTransform.Microsoft.GradientWipe(GradientSize=1.0 Duration=0.7)"
//var displayfilter ="progid:DXImageTransform.Microsoft.Slide(slideStyle='HIDE', bands=1)"
var displayfilter = "progid:DXImageTransform.Microsoft.Wipe(GradientSize=1.0, wipeStyle=0, motion='reverse')"


var indexphotos = [
['AYES August 09 480h.jpg', 'SchoolBOX helps through the Aboriginal Youth Empowering Students (AYES) program '],
['soccerteam.jpg', 'SchoolBOX has 8 communities participating in our youth soccer program'],
['ruben_dario_ construction_aug3_640x480.JPG', 'SchoolBOX has built 5 school buildings, a library and so much more...'],
['Supplies4SUccess_640x480.JPG', 'SchoolBOX has provided 5848 educational packages to children in 2009'],
['2007J_640x480.JPG', 'SchoolBOX helps 735 school children brush their teeth daily.'],
['P6215127_640x480.JPG', 'SchoolBOX is working with 6,993 students in 30 communities!'],
['Little COrn build completed july 09 480h.jpg', 'Building hopes and dreams together by Making Education Possible']
];

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 = indexphotos[count][1];

    img.width = next.width;
    img.height = next.height;
	if (img.filters && window.createPopup){
		img.style.filter=displayfilter;
		img.filters[0].Apply();
	}

	changetextnode('title',indexphotos[count][1]);
	if (img.filters && window.createPopup) img.filters[0].Play();

    if (++count == indexphotos.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';
  next.src = 'Images/slides/' + indexphotos[count][0];

}
function modifyimage(loadarea, imgindex, colindex){
if (document.getElementById){
	var imageobj=document.getElementById(loadarea)
	if (imageobj.filters && window.createPopup){
		imageobj.style.filter=displayfilter;
		imageobj.filters[0].Apply();
	}
	imageobj.innerHTML=get_image_html(hat_table[imgindex],colindex);
	if (imageobj.filters && window.createPopup) imageobj.filters[0].Play();
	return false;
}
}


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();
      };
    }
  }
}
