/*****

Image Cross Fade Redux
Version 1.0
Last revision: 02.15.2006
steve@slayeroffice.com

Please leave this notice intact. 

Rewrite of old code found here: http://slayeroffice.com/code/imageCrossFade/index.html


*****/
function addLoadEvent(func) 
{
  var oldonload = window.onload;
  if (typeof window.onload != 'function') 
  {
    window.onload = func;
  } 
  else 
  {
    window.onload = function() 
	{
      oldonload();
      func();
    }
  }
}

addLoadEvent(so_init);

var d=document, imgs = new Array(), zInterval = null, current=0, pause=false;

function so_init() {
	//window.open('POP_Christmas.html','jevensternaam','left=200,top=100,width=500,height=375');
	
	if(!d.getElementById || !d.createElement)return;

	imgs = d.getElementById("imageContainer").getElementsByTagName("img");
	for(i=1;i<imgs.length;i++) imgs[i].xOpacity = 0;
	imgs[0].style.display = "block";
	imgs[0].xOpacity = .99;
	
	setTimeout(so_xfade,5000);
}

function so_xfade() 
{
	cOpacity = imgs[current].xOpacity;
	nIndex = imgs[current+1]?current+1:0; //loopje; get index new foto

	nOpacity = imgs[nIndex].xOpacity;
	
	cOpacity-=.05; //current lower
	nOpacity+=.05; // new increase
	
	imgs[nIndex].style.display = "block";
	imgs[current].xOpacity = cOpacity;
	imgs[nIndex].xOpacity = nOpacity;
	
	setOpacity(imgs[current]); 
	setOpacity(imgs[nIndex]);
	
	if(cOpacity<=0) //switch to new
	{
		imgs[current].style.display = "none";
		current = nIndex;
		setTimeout(so_xfade,3500);
	} 
	else 
	{
		setTimeout(so_xfade,60);
	}
	
	function setOpacity(obj) 
	{
		if(obj.xOpacity>.99) 
		{
			obj.xOpacity = .99;
			return;
		}
		// Safari 1.2, newer Firefox and Mozilla, CSS3
		obj.style.opacity = obj.xOpacity;
		// Older Mozilla and Firefox
		obj.style.MozOpacity = obj.xOpacity;
		// IE/Win
		obj.style.filter = "alpha(opacity=" + (obj.xOpacity*100) + ")";
	}
	
}