var current = 0;
var current_pic = 0;
preload = new Image(); preload.src=pictures[1];

function kicker() {
  if (preload.complete) {
    current = 0;
    current_pic++;
    document.getElementById('back').style.backgroundImage = 'url(' + document.images.picture.src + ')';
    if (current_pic >= pictures.length) {
      current_pic = 0;
    }
    setOpacity(document.images.picture, 0);
    document.images.picture.src = pictures[current_pic];
    preload.src = pictures[current_pic + 1 >= pictures.length? 0: current_pic + 1];
    window.setTimeout("fader();", 100);
  } else {
    window.setTimeout("kicker();", 1000);
  }

}

function fader () {

  current += 10;
  setOpacity(document.images.picture, current);
  if (current < 100) {
    window.setTimeout("fader();", 100);
  } else {
    window.setTimeout("kicker();", 5000);
  }
}

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


