function setOpacity(obj, opacity) {
	opacity = (opacity == 100)?99.999:opacity;
	obj.style.filter = "alpha(opacity:"+opacity+")";
	obj.style.KHTMLOpacity = opacity/100;
	obj.style.MozOpacity = opacity/100;
	obj.style.opacity = opacity/100;
}

function fadeIn(objId,opacity) {
	if (document.getElementById) {
		obj = document.getElementById(objId);
		if (opacity <= 100) {
			setOpacity(obj, opacity);
			opacity += 10;
			window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
		}
	}
}

function fadeEm() {
	
	var Images = {
		i: 0,
		urls: ["video/img1.jpg", "video/img2.jpg", "video/img3.jpg", "video/img4.jpg", "video/img5.jpg", "video/img6.jpg"],
	
		GetTimeoutFn: function(i) {
			return function() {
				if (Images.i > 0) {
					document.getElementById('fades').style.background="url(/images/" + Images.urls[i - 1] + ")";
				} else {
					document.getElementById('fades').style.background="url(/images/" + Images.urls[i] + ")";
				}
				document.getElementById('fades').src = '/images/' + Images.urls[i];
				setOpacity(document.getElementById('fades'),0);
				fadeIn('fades',0);
			};
		}
	};
	
	for (Images.i; Images.i < Images.urls.length; Images.i++) {
		setTimeout(Images.GetTimeoutFn(Images.i), Images.i * 4500);
	}
	setTimeout("fadeEm()", (Images.urls.length + 1) * 3500);
	
}

document.observe("dom:loaded", function() {
	fadeEm();			
});
