// Index show
var downTimer = null;
var timer = new Array();
var x = new Array();
var xp = new Array();
var xl = '';
var pos = new Array();
var uplimit = 1;
var downlimit = 0.0;
var maxitems = 0;
var maincnt = 0;

function aa() {
  x[maincnt].style.opacity=pos[maincnt]+'';
  x[maincnt].style.filter='alpha(opacity='+100*pos[maincnt]+');';
  pos[maincnt]+=0.01;
  if(pos[maincnt]>uplimit) endAnimation();
}

function moveDown() {
  pos[maincnt] = downlimit;
  if (!timer[maincnt]) timer[maincnt] = setInterval("aa();",8);

}

function endAnimation() {
  if (!timer[maincnt]) return false;
  clearInterval(timer[maincnt]);
  pos[maincnt] = 0;
  timer[maincnt] = null;
}

function initAnimation(items) {
  maxitems = items;
  for(cnt=0;cnt<=items;cnt++) {
    x[cnt] = document.getElementById('production_detail_image_'+cnt);
    xp[cnt] = document.getElementById('xp_'+cnt);
    pos[cnt] = 0;
    timer[cnt] = null;
  }
  xl = document.getElementById('datalink');
  startShow();
}

function animateDownShow() {
  moveDown();
  maincnt++;
  if(maincnt<maxitems) xl.href=('productions/productionslist.php?id='+xp[maincnt].value);

  if(maincnt>=maxitems) {
    maincnt = 0;
    stopShow();

    for(cnt=0;cnt<maxitems;cnt++) {
      x[cnt].style.opacity='0.0';
      x[cnt].style.filter='alpha(opacity=0';
    }

    initAnimation(maxitems);
  }
}

function startShow() {
  x[maincnt].style.opacity='1.0';
  x[maincnt].style.filter='alpha(opacity=100';
  maincnt++;
  if (!downTimer) downTimer = setInterval(animateDownShow,9600);
}

function stopShow() {
  if (!downTimer) return false;
  clearInterval(downTimer);
  downTimer = null;
}

