var arrHeader = new Array();
var activeIndex = 0;
var changeInterval = 18;

function add2headArr(headid) {
  arrHeader.push(headid);

  //Set 1st Entry to "visible"; all other Elements to 0
  document.getElementById(arrHeader[0]).style.display = "block";
  
  //Set opac of all other Elements to 0
  if (arrHeader.length != 1) {
    opacity(arrHeader[arrHeader.length-1],100,0,1);
 //   document.getElementById(arrHeader[arrHeader.length-1]).style.display = "block";
  }
}

function dofade() {
  //determine next Item  
  nextIndex = activeIndex + 1;
  if (nextIndex >= arrHeader.length) nextIndex = 1;

  document.getElementById(arrHeader[nextIndex]).style.display = "block";



  opacity(arrHeader[activeIndex],100,0,1600);
  opacity(arrHeader[nextIndex],0,100,1600);
  
  activeIndex = nextIndex;
  setTimeout("dofade()",changeInterval*1000); 
}

function opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
} 

//change the opacity for different browsers 

function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";  
}


/*
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")";    
}

object.style.filter='alpha(opacity='+(op*10)+')';
element.style.filter='alpha(opacity='+(opac*10)+')';
object.filters.alpha.opacity = opacity; 
*/


