window.onload=function(){

	/* this script cycles through the images on the homepage. It uses a live dom collection
	to determine the order of images (not too bad considering there's no  other JS going on),
	fading the foremost out with opacity then switching the order before showing again. */

	var fQ=2*1000, dQ=4*1000, q=document.getElementById('fader_images').getElementsByTagName('img'), lQ=q.length, cQ=lQ-1, start, delta, ie=!!q[0].filters;
	
	var now=function(){
		return (new Date()).getTime();
		};
		
	var next=function(){
		q[cQ].parentNode.insertBefore(q[cQ], q[0]);
		if (ie){
			q[0].style.setAttribute("filter", "alpha(opacity=100)");
			}
		else{
			q[0].style.opacity=1;
			}
		setTimeout(fade, dQ);
		};
	
	var fade=function(){
		start=now();
		setTimeout(fadeStep,13);
		q[cQ-1].style.display='block';
		};
	
	var fadeStep=function(){
		delta=now()-start;
		if (delta < fQ){
			aQ=100-(Math.floor(((1/fQ)*delta)*100));
			if (ie){
				q[cQ].style.setAttribute("filter", "alpha(opacity="+(aQ)+")");
				}
			else{
				q[cQ].style.opacity=aQ/100;
				}
			setTimeout(fadeStep,13);
			}
		else{
			if (ie){
				q[cQ].style.setAttribute("filter", "alpha(opacity=0)");
				}
			else{
				q[cQ].style.opacity=0;
				}
			next();
			}
		};
		
	setTimeout(fade, dQ);

	};
