var xa_image,xa_dofadein,xa_slides;

function xa_init(imgid,filter) {
  xa_image = document.getElementById(imgid);
  if (xa_image.style && typeof xa_image.style.MozOpacity != 'undefined') {
    xa_dofadein= true;
  } else {
    xa_dofadein = false;
    xa_image.style.filter = "progid:DXImageTransform.Microsoft." + filter;
  }
  xa_slides = new Array();
}

function xa_add(src) {
  image = new Image();
  image.src = src;
  xa_slides.push(image);
}

function xa_loop(timeout,current) {
  if (typeof current == "undefined") current = 0;
  if (xa_dofadein) {
    xa_image.src = xa_slides[current].src;
    xa_fadein();
  } else {
    xa_image.filters[0].Apply();
    xa_image.src = xa_slides[current].src;
    xa_image.filters[0].Play();
  }
  setTimeout("xa_loop(" + timeout + "," + ((current + 1) % xa_slides.length) + ")",timeout);
}

function xa_fadein(opacity) {
  if (typeof opacity == "undefined") opacity = 0.04;
  xa_image.style.MozOpacity = opacity;
  opacity += .05;
  if (opacity < 0.99) {
    setTimeout("xa_fadein(" + opacity + ")", 50);
  }
}
