/*
	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_initb,false):window.attachEvent('onload',so_initb);

var db=document, imgsb = new Array(), zIntervalb = null, currentb=0, pauseb=false;

function so_initb()
{

	if(!db.getElementById || !db.createElement)return;


	imgsb = db.getElementById('cofferte').getElementsByTagName('div');
	for(ib=1;ib<imgsb.length;ib++) imgsb[ib].xOpacityb = 0;
	imgsb[0].style.display = 'block';
	imgsb[0].xOpacityb = .99;

	setTimeout(so_xfadeb,3000);
}

function so_xfadeb()
{
	cOpacityb = imgsb[currentb].xOpacityb;
	nIndexb = imgsb[currentb+1]?currentb+1:0;
	nOpacityb = imgsb[nIndexb].xOpacityb;

	cOpacityb-=.05;
	nOpacityb+=.05;

	imgsb[nIndexb].style.display = 'block';
	imgsb[currentb].xOpacityb = cOpacity;
	imgsb[nIndexb].xOpacityb = nOpacity;

	setOpacityb(imgsb[currentb]);
	setOpacityb(imgsb[nIndexb]);

	if(cOpacityb<=0)
	{
		imgsb[currentb].style.display = 'none';
		currentb = nIndexb;
		setTimeout(so_xfadeb,3000);
	}
	else
	{
		setTimeout(so_xfadeb,50);
	}

	function setOpacityb(objb)
	{
		if(objb.xOpacityb>.99)
		{
			objb.xOpacityb = .99;
			return;
		}

		objb.style.opacity = objb.xOpacityb;
		objb.style.MozOpacity = objb.xOpacityb;
		objb.style.filter = 'alpha(opacity=' + (objb.xOpacityb*100) + ')';
	}
}

