/*
	Image Cross Fade Redux
	Version 1.0
	Last revision: 02.15.2006
	steve@slayeroffice.com

	Rewrite of old code found here: http://slayeroffice.com/code/imageCrossFade/index.html
*/

window.addEventListener?window.addEventListener('load',so_init_pub,false):window.attachEvent('onload',so_init_pub);

var d_pub=document, imgs_pub = new Array(), zInterval_pub = null, current_pub=0, pause_pub=false;


function so_init_pub()
{
	if(!d_pub.getElementById || !d_pub.createElement)return;

	imgs_pub = d_pub.getElementById('pub').getElementsByTagName('img');
	for(i=1;i<imgs_pub.length;i++) imgs_pub[i].xOpacity = 0;
	imgs_pub[0].style.display = 'block';
	imgs_pub[0].xOpacity = .99;

	setTimeout(myaffiche,350);
	setTimeout(so_xfade_pub,10);
}

function myaffiche()
{
	document.getElementById('pub').style.display = 'block';
}

function so_xfade_pub()
{
	cOpacity = imgs_pub[current_pub].xOpacity;
	nIndex = imgs_pub[current_pub+1]?current_pub+1:0;
	nOpacity = imgs_pub[nIndex].xOpacity;

	cOpacity-=.05;
	nOpacity+=.05;

	imgs_pub[nIndex].style.display = 'block';
	imgs_pub[current_pub].xOpacity = cOpacity;
	imgs_pub[nIndex].xOpacity = nOpacity;

	setOpacity(imgs_pub[current_pub]);
	setOpacity(imgs_pub[nIndex]);

	if(cOpacity<=0)
	{
		imgs_pub[current_pub].style.display = 'none';
		current_pub = nIndex;
		setTimeout(so_xfade_pub,4000);
	}
	else
	{
		setTimeout(so_xfade_pub,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) + ')';
	}
}
