// JavaScript Document
// * Dependencies * 

// this function requires the following snippets:

// JavaScript/images/switchImage

//

// BODY Example:

// <body onLoad="mySlideShow1.play(); mySlideShow2.play();">

// <img src="originalImage1.gif" name="slide1">

// <img src="originalImage2.gif" name="slide2">

//

// SCRIPT Example:

// var mySlideList1 = ['image1.gif', 'image2.gif', 'image3.gif'];

// var mySlideShow1 = new SlideShow(mySlideList1, 'slide1', 3000, "mySlideShow1");

// var mySlideList2 = ['image4.gif', 'image5.gif', 'image6.gif'];

// var mySlideShow2 = new SlideShow(mySlideList2, 'slide2', 1000, "mySlideShow2");

function switchImage(imgName, imgSrc) 
{
  //
  if (document.images)
  {
    if (imgSrc != "none")
    {
      document.images[imgName].src = imgSrc;
    }
  }
  
}

function switchLink(linkName, linkURL){
     if (linkURL != "none")
    {
      //document.link[linkName].href = linkURL;
	  document.getElementById(linkName).href = linkURL;
    } 
}


function SlideShow(slideList, urlList, image, linkname, speed, name)          

{

  this.slideList = slideList;

  this.urlList = urlList;

  this.image = image;
  
  this.linkname = linkname;

  this.speed = speed;

  this.name = name;

  this.current = 0;

  this.timer = 0;

}

SlideShow.prototype.play = SlideShow_play;  
 
SlideShow.prototype.pause = SlideShow_pause;  

function SlideShow_play()       

{
//alert('playing slideshow');
  with(this)

  {

    if(current++ == slideList.length-1) current = 0;

    switchImage(image, slideList[current]);
	switchLink(linkname, urlList[current]);

    clearTimeout(timer);

    timer = setTimeout(name+'.play()', speed);

  }

}

function SlideShow_pause()       
{
	//with(this)
	//{
    //  timer = clearTimeout(name+'.play()', speed);
	//}
	//alert(name);
	//clearTimeout(name);
	//alert ('pausing');
   with(this)

  {
    clearTimeout(timer);

  }
}
