// CONSTRUCTOR FOR GROUP OF FADING IMAGES
	function FadingImages(instance, container, speed, interval, opacity_jump) 
	{
		this.instance = instance;
		this.container = container;
		this.images = new Array();
		this.img_count = 0;
		this.from = -1;
		this.to = -1;

		this.speed = speed || 100;
		this.interval = interval || 4000;

		if (opacity_jump)
			this.opacity_jump = opacity_jump / 100;
		else
			this.opacity_jump = 0.02;
	}

// function to add an image to the group
	FadingImages.prototype.AddImage = function(src, width, height, id, alt, title) 
	{
		var i = this.img_count;

		// add image object
			this.images[i] = new FadingImage(src, width, height, id, alt, title);
	
		// cache the image
			this.CacheImage(i);

		// create the actual image, if required
			this.CreateImage(i);

		this.img_count++;
	}


	FadingImages.prototype.CacheImage = function(i) 
	{
		this.images[i].cache.src = this.images[i].src;
	}

// function to physically create the image on the page
	FadingImages.prototype.CreateImage = function(i) 
	{
		var id = this.images[i].id;
		
		// is the image already there...?
			if (id)
			{
				var img = document.getElementById(id);

				if (img)
				{
					this.from = i;
					this.images[i].opacity = 1;

					return true;
				}
			}


		// right we'll have to create an image from scratch!!


		// check we've got somewhere to put the image
			var container = document.getElementById(this.container); 
			if (!container) return false;

		// contruct a new ID for the image
			this.images[i].id = this.container + "_" + this.img_count;

		// work out what we're changing from and to
			if (this.from < 0)
				this.from = i;
			else if (this.to < 0)
				this.to = i;

		// create image and set properties
			var img = document.createElement("img");
			img.src = this.images[i].src;
			img.id = this.images[i].id;

			img.width = this.images[i].width;
			img.height = this.images[i].height;
			img.alt = this.images[i].alt;
			img.title = this.images[i].title;
			img.style.position = "absolute";
			img.style.left = "0px";
			img.style.top = "0px";
			img.style.display = "none";

		// add image to container
			container.appendChild(img);
		
		// set opacity of image
			this.SetOpacity(i, 0);
	}

	FadingImages.prototype.Animate = function()
	{
		if (this.from > -1 && this.to > -1)
		{
			var from = this.images[this.from];
			var to = this.images[this.to];

			// if we're at the end of the animation...
				if (from.opacity <= 0 || to.opacity >= 1)
				{
					// force them just in case
						this.SetOpacity(this.from, 0);
						this.SetOpacity(this.to, 1);

					// change display styles for browsers with no alpha
						this.SetDisplay(this.from);

					// rotate
						this.from = (this.from + 1) % this.img_count;
						this.to = (this.to + 1) % this.img_count;

					// start Animation after a delay
						setTimeout(this.instance + ".Animate();", this.interval);

					return true;
				}

			// animate

				// set opacity
					this.SetOpacity(this.from, from.opacity - this.opacity_jump);
					this.SetOpacity(this.to, to.opacity + this.opacity_jump);

				// change display styles for browsers with no alpha
					this.SetDisplay(this.to);

			// start Animation after a delay
				setTimeout(this.instance + ".Animate();", this.speed);

			return true;
		}

		// work out what we're changing from and to
			if (this.from < 0)
				this.from = this.img_count;
			
			if (this.img_count > 1 && this.to < 0 && this.from > -1)
				this.to = (this.from + 1) % this.img_count;

			// start Animation after a delay
				setTimeout(this.instance + ".Animate();", this.interval);
	}


// set opacity of passed image
	FadingImages.prototype.SetOpacity = function(i, v)
	{
		var id = this.images[i].id;
		var img = document.getElementById(id);

		v = Math.min(1, Math.max(0, v));

		this.images[i].opacity = v;
		var opacity = this.images[i].opacity;

		var changed_alpha = 0;

		if (typeof(img.style.filter) == "string")
		{
			img.style.filter = "alpha(opacity=" + Math.round(opacity * 100) + ")";
			changed_alpha = 1;
		}
		else
		{
			try
			{
				img.style.opacity = opacity;
			}
			catch(e)
			{
				//
			}
		}
	}


// set display of passed image so that its "visible" once opaque
	FadingImages.prototype.SetDisplay = function(i)
	{
		var img = document.getElementById(this.images[i].id);
		img.style.display = (this.images[i].opacity > 0) ? "" : "none";
	}




// CONSTRUCTOR FOR SINGLE FADING IMAGE
	function FadingImage(src, width, height, id, alt, title) 
	{
		this.src = src;
		this.width = width;
		this.height = height;
		this.id = id;
		this.alt = alt;
		this.title = title;
		this.cache = new Image();
		this.opacity = 0;	// assume completely transparent
	}

