/** <![CDATA[ */
function goToNext()
{ //public
	this.currentslide++ ;
	if ( this.currentslide == this.slides.length )
		this.currentslide = 0 ;
	this.paint( this.currentslide ) ;
}
function goToPrev()
{ //public
	this.currentslide-- ;
	if ( this.currentslide < 0 )
		this.currentslide = this.slides.length - 1 ;
	this.paint( this.currentslide ) ;
}
function goToSlide( slide )
{ // public
	if ( 0 <= slide < this.slides.length )
		this.currentslide = slide ;
	this.paint( slide ) ;
}
function hiLiteNav( slide )
{
	for(i=0;i<this.slides.length;i++)
	{
		document.getElementById( this.navDOMId + i ).style.color = "" ;
	}
	document.getElementById( this.navDOMId + this.currentslide ).style.color = "#CC0000" ;
	document.getElementById( this.navDOMId + this.currentslide ).blur() ;
		
}

function paint( slide )
{ //private
	document.getElementById( this.imgDOMId ).src = this.slides[ slide ].getImageSource() ;
	document.getElementById( this.headerDOMId ).innerHTML = this.slides[ slide ].getHeaderText() ;
	document.getElementById( this.textDOMId ).innerHTML = this.slides[ slide ].getMainText() ;
	this.hiLiteNav( slide ) ;
}
function testIt(){alert("testing"); }
function paintNav()
{ // private - runs on load.
	document.getElementById( this.navDOMId ).innerHTML = "" ; // wipe existing
	var newNode ;
	// Previous Button
	newNode = document.createElement("button") ;
	newNode.id = this.navDOMId + "Prev" ;
	text = document.createTextNode("Prev") ;
	newNode.appendChild( text ) ;
	document.getElementById( this.navDOMId ).appendChild( newNode ) ;
	newNode.handleNo = this.slideShowNumber ;
	newNode.onclick = function(){ window.slideShowHandle[this.handleNo].goToPrev(); } ; 
	newNode.className = "prev" ;
	
	// Next Button
	newNode = null ;
	newNode = document.createElement("button") ;
	newNode.id = this.navDOMId + "Next" ;
	text = document.createTextNode("Next") ;
	newNode.appendChild( text ) ;
	document.getElementById( this.navDOMId ).appendChild( newNode ) ;
	newNode.handleNo = this.slideShowNumber ;
	newNode.onclick = function(){ window.slideShowHandle[this.handleNo].goToNext(); } ; 
	newNode.className = "next" ;
	//Steps
	for (i=0;i<this.slides.length;i++)
	{
		newNode = null ;
		newNode = document.createElement("button") ;
		newNode.id = this.navDOMId + i ;
		text = document.createTextNode( i + 1) ;
		newNode.appendChild( text ) ;
		document.getElementById( this.navDOMId ).appendChild( newNode ) ;
		newNode.handleNo = this.slideShowNumber ;
		newNode.slideNo = i ;
		newNode.onclick = function(){ window.slideShowHandle[this.handleNo].goToSlide( this.slideNo ); } ; 
	}
	
}
slideShowCounter = 0 ;
window.slideShowHandle = Array() ;

function SlideShow()
{ // object
	window.slideShowHandle.push( this );
	this.slideShowNumber = slideShowCounter ;
	slideShowCounter++ ;
	
	this.slideShowTitle = "Tenebril Picture Tour" ;
	this.getSlideShowTitle = function() { return this.slideShowTitle ; }
	this.setSlideShowTitle = function( ssTitle ) { this.slideShowTitle = ssTitle ; }
	
	this.currentslide = 0 ;
	this.slides = Array() ;

	this.addSlide = function( head, img, txt ) { this.slides.push( new SlideObject( head, img, txt ) ) ; }

	this.titleDOMId = "odjSlideShowTitle" ;
	this.headerDOMId = "odjSlideShowHead" ;
	this.textDOMId = "odjSlideShowText" ;
	this.imgDOMId = "odjSlideShowImage" ;
	this.navDOMId = "odjSlideShowNav" ;
	
	this.setDOMIds = function( titleId, headerId, textId, imageId, navId ) { this.titleDOMId = titleId; this.headerDOMId = headerId ; this.textDOMId = textId ; this.imgDOMId = imageId ; this.navDOMId = navId ; }

	this.paintNav = paintNav ;
	this.hiLiteNav = hiLiteNav ;
	this.goToNext = goToNext ;
	this.goToPrev = goToPrev ;
	this.goToSlide = goToSlide ;
	this.paint = paint ;
	
	this.startShow = function() { document.getElementById( this.titleDOMId ).innerHTML = this.getSlideShowTitle() ; this.paintNav() ; this.paint(0) ; }
	this.testMe = function() {alert("You did it");}
}

function SlideObject( head, img, txt )
{ // object to hold invididual slide data.
	this.headerText = head ;
	this.imageSource = img ;
	this.mainText = txt ;
	
	this.getHeaderText = function() { return this.headerText ; }
	this.getImageSource = function() { return this.imageSource ; }
	this.getMainText = function() { return this.mainText ; }
}
/** ]]> */