//<![CDATA[
function slComponent(last) {
  this.last = last;
  var current = 0;
  var timer = 0;
  function next() {
    if(last == 0) return;
    reset();
    hide();
    current = this.last == current ? 0 : current+1;
    show();
    start();
  }
  function start() {
    timer = setTimeout("slShow.next()", 5000);
  }
  function show() {
    opacity('sl' + current, 0, 100);
    document.getElementById('sl' + current).style.zIndex = 1;
  }
  function hide() {
    opacity('sl' + current, 100, 0);
    document.getElementById('sl' + current).style.zIndex = 0;
  }
  function opacity(id, start, end) {
    var opTimer = 0;
    if(start > end) {
      for(i=start; i>=end; i--) {
        setTimeout("slShow.setOpacity('" + id + "', " + i + ")", opTimer * 10);
        opTimer++;
      } 
    }
    else {
      for(i=start; i<=end; i++) {
        setTimeout("slShow.setOpacity('" + id + "', " + i + ")", opTimer * 10);
        opTimer++;
      } 
    }
  }
  function setOpacity(id, opacity) {
    var el = document.getElementById(id).style; 
    el.opacity = opacity/100;
    el.filter = "alpha(opacity=" + opacity + ")";
  }
  function reset() {
    if(timer) {
      clearTimeout(timer);
      timer = 0;
    }
  }
  this.next = next;
  this.start = start;
  this.setOpacity = setOpacity;
  this.reset = reset;
}
//]]>
