<!-- //
// JavaScript Document

/* Easy Slideshow
Copyright 2009 Mark Paglin

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

The GNU General Public License is available online at:
http://www.fsf.org/ or write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

/*
screen_id is the id of the <img> tag where the images will display.

url_id is the id of the <a> tag where the images will display.

image_array is a string of the form: imageurl1,imageurl2,imageurl3 etc.

link_array is a string of the form: linkurl1,linkurl2,linkurl3 etc.

duration is in milliseconds

firstImageindex, lastImageindex, currentimageindex are integers, usually: 0, (total images minus 1), 0

Example: 

Javascript: slideshow('screen1','url1','../images/image1.jpg,../images/image2.jpg,../images/image3.jpg','../html/page1.html,../html/html2.jpg,../html/htm3.jpg',3000,0,2,0);

HTML: <a href="#" id="url1"><img src="" id="screen1"></a>

Images without corresponding links will use link from previous image.

This function supports multiple slideshows on a page.

*/

function slideshow(screen_id,url_id,image_array,link_array,duration,firstImageindex,lastImageindex,currentimageindex)
	{	
	var ref_image_array = image_array.split(",");
	var ref_link_array = link_array.split(",");
	if (currentimageindex > lastImageindex)	// if past last slide
		{
		currentimageindex = firstImageindex;
		}
	document.getElementById(screen_id).src = ref_image_array[currentimageindex]; // send slide to screen
	if (ref_link_array[currentimageindex] != "")
		{
		document.getElementById(url_id).href = ref_link_array[currentimageindex]; // send link to url
		}
	if (lastImageindex > firstImageindex)
		{
		currentimageindex++;
		setTimeout("slideshow(\'" + screen_id + "\',\'" + url_id + "\',\'" + image_array + "\',\'" + link_array + "\',\'" + duration + "\',\'" + firstImageindex + "\',\'" + lastImageindex + "\',\'" + currentimageindex + "\')",duration);	
		}
	}
//-->
