function slide(src,text) 
{
	this.src = src; // Image
	this.text = text; // Text
	this.loaded = false;

	// Create an image object for the slide
	if (document.images) 
	{
		this.image = new Image();
	}
	
	// Preloads the slide
	this.load = function() 
	{
		if (!document.images) { return; }

		if (!this.loaded) 
		{
			this.image.src = this.src;
			this.loaded = true;
		}
	}
}

function slideshow(slideshowname) 
{
	this.name = slideshowname;
	
	// IMAGE element on your HTML page.
	this.image;
	
	// ID of a DIV element on your HTML page that will contain the text.
	this.textid;
	
	// These are private variables
	this.slides = new Array();
	this.current = 0;
	this.timeoutid = 0;

	//--------------------------------------------------
	// Public methods
	//--------------------------------------------------
	this.add_slide = function(slide) 
	{
		var i = this.slides.length;
		slide.load();
		this.slides[i] = slide;
	}

	//--------------------------------------------------
	this.update = function() 
	{
		// Make sure the slideshow has been initialized correctly
		if (!this.valid_image()) { alert('Not a valid image.');return; }
	
		// Convenience variable for the current slide
		var slide = this.slides[this.current];
		slide.load();
		this.image.src = slide.image.src;
	
		// Update the text
		this.display_text();
	}

	//--------------------------------------------------
	this.goto_slide = function(n) 
	{
		if (n == -1) 
			n = this.slides.length - 1;
		
		if (n < this.slides.length && n >= 0) 
			this.current = n;
		
		this.update();
	}


	//--------------------------------------------------
	this.get_text = function() 
	{
		return(this.slides[ this.current ].text);
	}

	//--------------------------------------------------
	this.display_text = function() 
	{
		text = this.slides[this.current].text;

		// If a text id has been specified,
		// then change the contents of the HTML element
		if (this.textid)
		{
			r = this.getElementById(this.textid);
			if (!r) { return false; }
			if (typeof r.innerHTML == 'undefined') { return false; }
			
			// Update the text
			r.innerHTML = text;
		}
	}

  //==================================================
  // Private methods
  //==================================================

	//--------------------------------------------------
	this.valid_image = function() 
	{
		// Returns 1 if a valid image has been set for the slideshow
	
		if (!this.image)
			return false;
		else
			return true;
	}

	//--------------------------------------------------
	this.getElementById = function(element_id) 
	{
		if (document.getElementById) 
			return document.getElementById(element_id);
		else if (document.all) 
			return document.all[element_id];
		else if (document.layers) 
			return document.layers[element_id];
		else 
			return undefined;
	}
}

/**
 * Pass a slideshow to this function to draw the navigation
 */
function drawNav(slideshow)
{
	
}