//////
// JavaScript Slideshow
///

function slide(pathName, capt)
{
   this.path = pathName;
	 this.caption = capt;
}

function slideShow(imgTagIdent)
{
    this.tagId = imgTagIdent;
    this.slides = new Array();
    this.currSlide = 0;
		this.pauseMs = 5000;
		this.add = addSlide;
		this.play = playSlides;
		this.step = stepSlide;
		this.restart = restartSlides;
		this.setPauseTime = setPause;
		this.writeHTMLStr = writeSlideHTML;		
}

function writeSlideHTML()
{
    if( this.slides.length > 0 )
		{
      document.write('<img src=' + this.slides[0].path 
  		   + ' id="' + this.tagId + '" name="' + this.tagId 
  			 + '" alt="' + this.slides[0].caption + '" ' 
  			 + '" title="' + this.slides[0].caption + '" />' );
		}
}

function addSlide(slideObj)
{
    this.slides[ this.slides.length ] = slideObj;
}

function restartSlides()
{
    this.currSlide = 0;
		var imgObj = getWithID( this.tagId );
		if( imgObj != null )
		{
		    imgObj.src = this.slides[ this.currSlide ].path;
		}
}

function setPause(iPauseMs)
{
    this.pauseMs = iPauseMs;
}

function playSlides()
{
    for(var ii=this.currSlide; ii < this.slides.length; ii++ )
		{
		   setTimeout("this.step()", (ii * this.pauseMs));
		}
		//this.restart();
}

function stepSlide()
{
    if( this.currSlide < this.slides.length - 1 )
		{
        this.currSlide++;
		    var imgObj = getWithID( this.tagId );
		    if( imgObj != null )
		    {
		        imgObj.src = this.slides[ this.currSlide ].path;
		    }
		}
		else
		    alert('End of Show, restart.');				
}

function dhdfSlideShow()
{
    this.theShow = new slideShow("DHDFSlides");
		//this.theShow.add( new slide("LFDPics/attention.png", "Attention") );
		//this.theShow.add( new slide("LFDPics/bow.png", "Bow") );
		this.theShow.add( new slide("LFDPics/hipshorse.png", "Horse Stance") );
		this.theShow.add( new slide("LFDPics/hipslfwd.png", "Left Fwd Stance") );
		this.theShow.add( new slide("LFDPics/hipshorse.png", "Horse Stance") );
		this.theShow.add( new slide("LFDPics/hipsrfwd.png", "Right Fwd Stance") );
		this.theShow.add( new slide("LFDPics/hipshorse.png", "Horse Stance") );
		this.theShow.add( new slide("LFDPics/hipsrfwda.png", "Right Fwd Stance") );
		this.theShow.add( new slide("LFDPics/hipshorse.png", "Horse Stance") );
		this.theShow.add( new slide("LFDPics/hipslfwda.png", "Left Fwd Stance") );
		this.theShow.add( new slide("LFDPics/hipshorse.png", "Horse Stance") );
}

function formOneSlideShow()
{
    this.theShow = new slideShow("Form1Slides");
}

/////
// the show list and shows
///
var masterShowList = new Array();
masterShowList[ masterShowList.length ] = new dhdfSlideShow();
masterShowList[ masterShowList.length ] = new formOneSlideShow();

///
// global functions for working the show list
///
function playShow(showIdentifier)
{
    var sh = findShow(showIdentifier);
		if( sh != null )
		{
		    sh.play();
		}
}

function stepShow(showIdentifier)
{
    var sh = findShow(showIdentifier);
		if( sh != null )
		{
		    sh.step();
		}
}

function resetShow(showIdentifier)
{
    var sh = findShow(showIdentifier);
		if( sh != null )
		{
		    sh.restart();
		}
}

function findShow(showIdentifier)
{
    for(var ii=0; ii<masterShowList.length; ii++) {
		    if( masterShowList[ii].theShow.tagId == showIdentifier ) return masterShowList[ii].theShow;
		}
		
		return null; 
}

function drawShowHTML(showIdentifier)
{
    var sh = findShow(showIdentifier);
		if( sh != null )
		{
		    sh.writeHTMLStr();
				document.write('<br/><form><input  TYPE="button" VALUE="Restart" onClick="resetShow('
				     + '\'' + showIdentifier + '\')" />');
				document.write('<input  TYPE="button" VALUE="Step" onClick="stepShow('
				     + '\'' + showIdentifier + '\')" />');
				document.write('<input  TYPE="button" VALUE="Animate" onClick="playShow('
				     + '\'' + showIdentifier + '\')" /></form>');
		}
}



