

/*
	    Universal Slideshows Script
		============================
		(c) copyright
		Trefnet Nederland BV
		Havinghastraat 32
		1817 DA Alkmaar 
		
		T. 072 - 527 00 40
		F. 072 - 527 00 41
		============================
		Hint : This code sets all neccasary styles, and not all slides must have the same size.
		       You might want to set the height and display hard on the elements.
*/

	var oTopSlideShowSettings       = {} ;
	oTopSlideShowSettings.timeover  = 800 ;
	oTopSlideShowSettings.timeout   = 6000 ;
	oTopSlideShowSettings.instances = new Array() ;

	function TopSlideShow( oRoot, nTimeOut, nTimeOver )
	{
		this.root      = oRoot ;
		this.children  = new Array() ;
		this.pointer   = 0 ;
		this._magic    = Math.random() * 100000 ;
		this.timeout   = nTimeOut  ? nTimeOut : oTopSlideShowSettings.timeout ;
		this.timeover  = nTimeOver ? nTimeOver : oTopSlideShowSettings.timeover ;
		this.init() ;
	} ;
	
	TopSlideShow.prototype.init = function()
	{
		var nHeight = 100 ;
		this.children = this.root.getElementsByTagName( 'img' ) ;
 
		$( this.root ).find( 'img' ).css( { display : 'none' } ) ; 
		$( this.root ).find( 'img:first' ).css( { display : 'block' } ) ;
		
		oTopSlideShowSettings.instances[ this._magic ] = this ;
		if( this.children.length )
			setTimeout( 'TopSlideShow.prototype.advance(' + this._magic + ')', this.timeout  ) ;
	} ;
	
	TopSlideShow.prototype.nextSlide = function()
	{
		var nLast = this.pointer ;
		this.pointer++ ;
		if( this.pointer == this.children.length )
			this.pointer = 0 ;
		$( this.children[nLast] ).fadeOut( this.timeover ) ;
		$( this.children[this.pointer] ).fadeIn( this.timeover ) ;
		setTimeout( 'TopSlideShow.prototype.advance(' + this._magic + ')', this.timeout  ) ;
	} ;
	
	TopSlideShow.prototype.advance = function( nNumber )
	{
		oTopSlideShowSettings.instances[nNumber].nextSlide() ;
	} ;
	
	
	
	$( document ).ready( function()
			{
				new TopSlideShow( document.getElementById( 'topslideparent' ) ) ;
			}) ;
