window.addEvent("load",function () 
{
	var host = "/";
	if (String(window.location.host).match(/desktopxp|localhost|192.168/i)) host+= "www.p4fastel.co.uk/";
	if (String(window.location.href).match(/\/test\//i)) host+= "test/";

	// clear background colour on the container, given that we should now have the image loaded
		$("wrapper_home_bg").setStyle("background-color", "transparent");

	// cache all the images
		var off = new Image();
		off.src = host + "images/bg_home_off.png";

		var green = new Image();
		green.src = host + "images/bg_home_on_green.png";

		var red = new Image();
		red.src = host + "images/bg_home_on_red.png";

	// the current cycle we're on
		var current = 0;

	// cycle
		var cycle = [1,0,1,0,2,0,2,0,2,0,2];

	// duration of cycles
		var delay = 1000;

	// animation
		var DoAnimation = function () 
		{
			if (!$("wrapper_home_bg")) return;

			if (current >= cycle.length) return;

			var which = parseInt(cycle[current]);

			if (!which)
				var new_image = off.src;
			else if (which == 1)
				var new_image = red.src;
			else
				var new_image = green.src;

			// obviously IE6 needs to be different
				if (Browser.Engine.trident4 && $("wrapper_home_bg").style.filter && $("wrapper_home_bg").style.filter.match(/AlphaImageLoader/i))
					$("wrapper_home_bg").style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + new_image + "', sizingMethod='crop')";
				else
					$("wrapper_home_bg").src = new_image;

			// set the next one going
				DoAnimation.delay(delay);

			current++;

		}

	// start animation
		DoAnimation();
	
});