ImageRotator = function()
{
	var images = new Array();
	var image;
	var interval = 5000;
	var fromPane;
	var toPane;
	var timeout;
	
	this.setImages = function(array)
	{
		images = array;
	}
	
	this.setPauseInterval = function(seconds)
	{
		interval = seconds * 1000;
	}
	
	this.setFromPane = function(id)
	{
		if (id instanceof Object)
		{
			fromPane = id;
		}
		else
		{
			fromPane = document.getElementById(id);
		}
	}
	
	this.setToPane = function(id)
	{
		if (id instanceof Object)
		{
			toPane = id;
		}
		else
		{
			toPane = document.getElementById(id);
		}
	}
	
	this.start = function(args)
	{
		if (args)
		{
			if (args.fromPane)
			{
				this.setFromPane(args.fromPane);
			}
			
			if (args.toPane)
			{
				this.setToPane(args.toPane);
			}
			
			if (args.images)
			{
				this.setImages(args.images);
			}
			
			if (args.pauseInterval)
			{
				this.setPauseInterval(args.pauseInterval);
			}
		}
		
		// grab the first one and set the fromPane to it, in case it isn't already
		
		image = images.shift();
		
		images.push(image);
		
		fromPane.style.backgroundImage = "url(" + image + ")";
		
		// grab the second one and set the toPane to it
		
		image = images.shift();
		
		images.push(image);
		
		toPane.style.backgroundImage = "url(" + image + ")";
		
		timeout = setTimeout(rotateQuote, interval);
	}
	
	this.stop = function()
	{
		clearTimeout(timeout);
	}
	
	function rotateQuote()
	{
		var opacity;
		
		if (fromPane.filters)
		{
			opacity = fromPane.filters.alpha.opacity;
		}
		else
		{
			opacity = (fromPane.style.opacity == "" ? 1 : fromPane.style.opacity);
		}
		
		opacity = parseFloat(opacity);
		
		if (opacity > 0)
		{
			if (fromPane.filters)
			{
				fromPane.filters.alpha.opacity = opacity - 5;
			}
			else
			{
				fromPane.style.opacity = opacity - .05;
			}
			
			setTimeout(rotateQuote, 100);
		}
		else
		{
			fromPane.style.backgroundImage = "url(" + image + ")";
			
			if (fromPane.filters)
			{
				fromPane.filters.alpha.opacity = 100;
			}
			else
			{
				fromPane.style.opacity = 1;
			}
			
			image = images.shift();
			
			images.push(image);
			
			toPane.style.backgroundImage = "url(" + image + ")";
			
			setTimeout(rotateQuote, interval);
		}
	}
}