
function Diashow()
{
	this._self = this;
	this.cur_page = 0;
	this.cur_image = 0;
	this.preloads = new Array();
	this.big_preloads = new Array();
	this.big_placeholder = '';

	this.Init = function()
	{
		this.pages = this.thumbs.length;
		this._InitPage( 0 );
	};

	this.NextPage = function()
	{
		this.cur_page++;
		if( this.cur_page >= this.pages )
			this.cur_page = 0;
		this._InitPage( this.cur_page );
		this.Show( this.cur_image );
	};

	this.PrevPage = function()
	{
		this.cur_page--;
		if( this.cur_page < 0 )
			this.cur_page = this.pages-1
		this._InitPage( this.cur_page );
		this.Show( this.cur_image );
	};

	this.Show = function( ct )
	{
		this.cur_image = ct;
		var elem = document.getElementById( this.big_placeholder );
		elem.src = this._Load( this.cur_page, ct );
		for( i=0; i<this.line_placeholders.length; i++ )
		{
			var line = document.getElementById( this.line_placeholders[ i ] );
			line.src = '../images_neu/spacer.gif';
		}
		line = document.getElementById( this.line_placeholders[ ct ] );
		line.src = '../images_neu/img_onmouse.gif';
	};

	this._Load = function( page, ct )
	{
		if( this.big_preloads[ page ] && this.big_preloads[ page ][ ct ] )
			return this.big_preloads[ page ][ ct ].src;

		if( !this.big_preloads[ page ] )
			this.big_preloads[ page ] = new Array();

		this.big_preloads[ page ][ ct ] = new Image();
		this.big_preloads[ page ][ ct ].src = this.big[ page ][ ct ];
		return this.big_preloads[ page ][ ct ].src;
	}

	this._InitPage = function( page )
	{
		var len1 = this.thumbs[ page ].length;
		var limit = this.placeholders.length;
		if( len1 < limit )
			limit = len1;

		for( i=0; i<limit; i++ )
		{
			var elem = document.getElementById( this.placeholders[ i ] );
			if( this.preloads[ page ] && this.preloads[ page ][ i ] )
				elem.src = this.preloads[ page ][ i ].src;
			else
			{
				if( !this.preloads[ page ] )
					this.preloads[ page ] = new Array();

				this.preloads[ page ][ i ] = new Image();
				this.preloads[ page ][ i ].src = this.thumbs[ page ][ i ];
				elem.src = this.preloads[ page ][ i ].src;
			}
		}
	}
}

function _Diashow_Init()
{
	this.pages = this.thumbs.length;
	InitPage( 0 );
}

function _Diashow_InitPage( page )
{
	var len1 = this.thumbs[ page ].length;
	var limit = this.placeholders.length;
	if( len1 < limit )
		limit = len1;

	for( i=0; i<limit; i++ )
	{
		var elem = document.getElementById( this.placeholders[ i ] );
		if( this.preloads[ page ] && this.preloads[ page ][ i ] )
			elem.src = this.preloads[ page ][ i ].src;
		else
		{
			if( !this.preloads[ page ] )
				this.preloads[ page ] = new Array();

			this.preloads[ page ][ i ] = new Image();
			this.preloads[ page ][ i ].src = this.thumbs[ page ][ i ];
			elem.src = this.preloads[ page ][ i ].src;
		}
	}
}

function _Diashow_NextPage()
{
	this.cur_page++;
	if( this.cur_page >= this.pages )
		this.cur_page = 0;
	InitPage( this.cur_page );
	ShowPic( this.cur_image );
}

function _Diashow_PrevPage()
{
	this.cur_page--;
	if( this.cur_page < 0 )
		this.cur_page = this.pages-1
	_Diashow_InitPage( this.cur_page );
	_Diashow_ShowPic( this.cur_image );
}
function _Diashow_LoadImage( page, ct )
{
	if( this.big_preloads[ page ] && this.big_preloads[ page ][ ct ] )
		return this.big_preloads[ page ][ ct ].src;

	if( !this.big_preloads[ page ] )
		this.big_preloads[ page ] = new Array();

	this.big_preloads[ page ][ ct ] = new Image();
	this.big_preloads[ page ][ ct ].src = this.big[ page ][ ct ];
	return this.big_preloads[ page ][ ct ].src;
}


function _Diashow_ShowPic( ct )
{
	this.cur_image = ct;
	var elem = document.getElementById( this.big_placeholder );
	elem.src = _Diashow_LoadImage( this.cur_page, ct );
	for( i=0; i<this.line_placeholders.length; i++ )
	{
		var line = document.getElementById( this.line_placeholders[ i ] );
		line.src = '../images_neu/spacer.gif';
	}
	line = document.getElementById( this.line_placeholders[ ct ] );
	line.src = '../images_neu/img_onmouse.gif';
}
