ImageContainer =  function(id) 
{
	this.timer;
	this.images = Array();
	this.titles  = Array();
	this.num_images= 0;
	this.current_image = 0;
	this.loaded_images = Array();
	this.delay = 10000;
	this.image_container = document.getElementById(id);
	this.title_container;

	this.setImage = function()
	{
		if(this.title_container)
		{
			this.title_container.innerHTML = this.titles[this.current_image];
		}
		this.image_container.src = this.images[this.current_image++].src;
		if(this.current_image>=this.num_images) this.current_image = 0;
	}
	
	this.setTitleContainer = function(id)
	{
		this.title_container = document.getElementById(id);
	}
	
	this.setDelay = function(delay)
	{
		this.delay = delay;	
	}
	
	this.startTimer = function()
	{
		var scope = this;
		this.timer = setInterval(function() { scope.setImage();},this.delay);	
	}


	this.loadImage = function(name)
	{
		var num = this.num_images;
		this.images[num] = new Image();
	
		this.images[num].src = name;
		this.images[num].onLoad = this.imageLoaded(this.num_images);
	}
	
	this.loadImageWithTitle = function(name,title)
	{
		var num = this.num_images;
		this.images[num] = new Image();
	
		this.images[num].src = name;
		this.images[num].onLoad = this.imageLoaded(this.num_images);
		
		this.titles[num] = new String(title);
	}
	
	this.imageLoaded = function(number)
	{
	
		this.num_images = this.loaded_images.push(number);
	}	
	
}	


