/*	Chris' Slide Show 1.0
	Written by: Christopher Chin <cchin@geocities.com>
	Description: Given a list of Graphics and descriptions, can display randomly and user controlled
	Usage: Just use the myList.addItem command in the slidedb.js file, to add pictures
	in this method:
 		myList.addItem("PictURL", Picture Name", "Description");
*/

function setCookie(name, value, expire) {
   document.cookie = name + "=" + escape(value)
   + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
}

function getCookie(Name) {
   var search = Name + "="
   if (document.cookie.length > 0) { // if there are any cookies
      offset = document.cookie.indexOf(search) 
      if (offset != -1) { // if cookie exists 
         offset += search.length 
         // set index of beginning of value
         end = document.cookie.indexOf(";", offset) 
         // set index of end of cookie value
         if (end == -1) 
            end = document.cookie.length
         return unescape(document.cookie.substring(offset, end))
      } 
   }
}

function addItem(newPict, NewName, Description)
{
	if(current==this.length)
	{
		this[0] = "<FONT SIZE=+2>";
		this[0] += NewName;
		this[0] += "</FONT><br>";
		this[0] += Description;
		this[0] += "<BR><IMG SRC='";
		this[0] += newPict;
		this[0] += "'>";
	}
	this.length++;
}

function SimpleList() 
{	this.length = 0;
	this.addItem = addItem;
	return this;
}

function rewind()
{
	setCookie(cookieName, 0);
	history.go(0);
}

function random()
{
	var result = Math.round(myList.length * Math.random());
	if (result == myList.length)
		result = 0;
	setCookie(cookieName, result);
	history.go(0);
}

function next()
{
	if(current==myList.length-1)
		current=-1;
	setCookie(cookieName, current+1)
	history.go(0);
}

function prev()
{
	if(current==0)
		current=myList.length;
	setCookie(cookieName, current-1)
	history.go(0);
}

// **********************************************************************
	myList = new SimpleList()
