var d=document, imgs = new Array(), zInterval = null, current=0, pause=false;
var i = 0;
function finit() {
  if(!d.getElementById || !d.createElement)return;
  imgs = d.getElementById("inner").getElementsByTagName("img");
  for(i=1;i<imgs.length;i++) imgs[i].xOpacity = 0;
  imgs[0].style.display = "block";
  imgs[0].xOpacity = .99;
  setTimeout(fblendp,1500);
}
function fblendp() {
  cOpacity = imgs[current].xOpacity;
  if(imgs[current+1]) {
    nIndex = current+1;
    done=false;
  } else {
//    nIndex = 0;
    done=true;
  }
  nOpacity = imgs[nIndex].xOpacity;
  if(current==2) {
    cOpacity-=.02;
  }
  nOpacity+=.02;
  imgs[nIndex].style.display = "block";
  if(nIndex==3) {
    imgs[0].xOpacity = cOpacity;
    imgs[1].xOpacity = cOpacity;
    imgs[2].xOpacity = cOpacity;
    imgs[nIndex].xOpacity = nOpacity;
    setOpacity(imgs[0]);
    setOpacity(imgs[1]);
    setOpacity(imgs[2]);
    setOpacity(imgs[nIndex]);
  } else {
    imgs[nIndex].xOpacity = nOpacity;
    setOpacity(imgs[current]);
    setOpacity(imgs[nIndex]);
  }
  if(done){
    imgs[0].style.display = "none";
    imgs[1].style.display = "none";
    imgs[2].style.display = "none";
    window.document.location.href="/start.php"
    return;
  } else {
    if((nOpacity>.98)||(cOpacity<=0.02)) {
//      imgs[current].style.display = "none";
      current = nIndex;
      setTimeout(fblendp,1000);
    } else {
      setTimeout(fblendp,40);
    }
  }
  function setOpacity(obj) {
    if(obj.xOpacity>.99) {
      obj.xOpacity = .99;
      return;
    }
    obj.style.opacity = obj.xOpacity;
    obj.style.MozOpacity = obj.xOpacity;
    obj.style.filter = "alpha(opacity=" + (obj.xOpacity*100) + ")";
  }
}

function finit2() {
  if(!d.getElementById || !d.createElement)return;
  imgs = d.getElementById("rotate").getElementsByTagName("img");
  for(i=1;i<imgs.length;i++) imgs[i].xOpacity = 0;
  imgs[0].style.display = "block";
  imgs[0].xOpacity = .99;
  setTimeout(fblend2,4000);
}
function fblend2() {
  cOpacity = imgs[current].xOpacity;
  if((pause==true)&&(cOpacity>0.96)) {
    setTimeout(fblend2,1000);
  } else {
  if(imgs[current+1]) {
    nIndex = current+1;
    done=false;
  } else {
    nIndex = 0;
  }
  nOpacity = imgs[nIndex].xOpacity;
  cOpacity-=.02;
  nOpacity+=.02;
  imgs[nIndex].style.display = "block";
  imgs[current].xOpacity = cOpacity;
  imgs[nIndex].xOpacity = nOpacity;
  setOpacity2(imgs[current]);
  setOpacity2(imgs[nIndex]);
  if(cOpacity<=0) {
    imgs[current].style.display = "none";
    current = nIndex;
    setTimeout(fblend2,4000);
  } else {
    setTimeout(fblend2,20);
  }
  }
  function setOpacity2(obj) {
    if(obj.xOpacity>.99) {
      obj.xOpacity = .99;
      return;
    }
    obj.style.opacity = obj.xOpacity;
    obj.style.MozOpacity = obj.xOpacity;
    obj.style.filter = "alpha(opacity=" + (obj.xOpacity*100) + ")";
  }
}
