var ff_imagecontainer, ff_opacitystep;

window.onload = function(){
	imgff_init('left-pane', 0.1, true);
}

function imgff_init(container, opacitystep, anim)
{
	ff_imagecontainer	= document.getElementById(container);
	ff_opacitystep		= (opacitystep ? opacitystep : 0.1);
	
	if (anim)
	{	
		ff_imagecontainer.appendChild(ff_imagecontainer.firstElementChild);
		ff_imagecontainer.lastElementChild.style.opacity = 0;
		imgff_adjustopacity();

		if (ff_imagecontainer.children.length > 1)
		{
			var imgtimer = setInterval(function(){
				imgff_shownext();
				imgff_adjustopacity();
			}, 8000);
		}
	}
}

function imgff_shownext()
{
	ff_imagecontainer.appendChild(ff_imagecontainer.firstElementChild);
	ff_imagecontainer.lastElementChild.style.opacity = 0;
}

function imgff_adjustopacity()
{
	var opacitytimer = setInterval(function(){
		if (ff_imagecontainer.lastElementChild.style.opacity == 1)
		{
			clearInterval(opacitytimer);
			opacitytimer = undefined;
			if (ff_imagecontainer.children.length > 1) ff_imagecontainer.lastElementChild.previousElementSibling.style.opacity = 0;
		}
		else
			ff_imagecontainer.lastElementChild.style.opacity = parseFloat(ff_imagecontainer.lastElementChild.style.opacity) + ff_opacitystep;
	}, 100);
}

