
//Image Scroller

var i=0;
var changeInterval=2000;

var scrollPicture = new Array();

function initSlideShow()
{
    imageback = document.getElementById('scrollerBack');
    imageback.style.backgroundImage = 'url(' + scrollPicture[0] + ')';
    //Wait 5 seconds then start the changes
    window.setTimeout("StartChange()", changeInterval);
}

function StartChange()
{
   i++;
   imagefront = document.getElementById('scrollerFront');
   imagefront.onload = imageLoadHandler;
   if (i>scrollPicture.length-1) i=0;
   imagefront.src = scrollPicture[i];
}

function imageLoadHandler (evt) {
    //Wait a sec then fade in
    window.setTimeout("fadeIn('scrollerFront',0)",1000);
  }

function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}

function fadeIn(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity <= 100) {
	if (opacity == 0) obj.style.visibility = 'visible';
    	setOpacity(obj, opacity);
      	opacity += 2;
      	window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
    }
    else {
      //move the foreground to the background and clear foreground
      imageback = document.getElementById('scrollerBack');
      imagefront = document.getElementById('scrollerFront');
      imageback.style.backgroundImage = 'url(' + imagefront.src + ')';
      imagefront.style.visibility = 'hidden';
      //Then start again with next image
      window.setTimeout("StartChange()", changeInterval);
    }
    }
}
