var bildUrls= new Array(); // thumb3Urls oder imgUrls
var curBild= 0;
var lastThumb= document.getElementById('thumbNo[0]');

var bildView;
var bildNumbers;

var timer=null;
var diaStr;
var diaTimeout= 5000;

/* befüllt Datenarrays aus hiddenField */	
function initPicView(dataField, bildView_, bildNumbers_, diaStr_)
{
	var dataStr= dataField.value;
	bildUrls= dataStr.split(",");
	
	bildView= document.getElementById(bildView_);
	bildNumbers= document.getElementById(bildNumbers_);
	diaStr= document.getElementById(diaStr_);
	showBild(curBild);
}

// -------------------------------------------------------------------------

/* zeigt Bild entsprechend dem gewählten thumb */
function showBild(inx)
{
	showBild_(inx, false);
}
function showBild_(inx, diaShow)
{
	if(!diaShow) stopDiaShow();
	
	// thumb selektion anzeigen
	if(lastThumb!='undefined')
	{
		lastThumb.className='thumbnail';
		lastThumb= document.getElementById('thumbNo['+inx+']');
		lastThumb.className='thumbnail_on';
	}
	
 	curBild= inx;
 	bildView.src= bildUrls[curBild];
 	// 1/10
 	if(bildNumbers!=null && bildNumbers!='undefined')
	 	bildNumbers.innerHTML= (curBild+1)+"/"+(bildUrls.length);
}

function showNext()
{
	showNext_(false);
}
function showNext_(diaShow)
{
	if(!diaShow) stopDiaShow();
	if(curBild<bildUrls.length-1) curBild++;
	else curBild=0;
	showBild_(curBild, diaShow);
}

function showPrevious()
{
	stopDiaShow();
	if(curBild<=0) cuBild= bildUrls.length-1;
	else curBild--;
	showBild(curBild);
}
function showFirst()
{
	stopDiaShow();
	curBild=0;
	showBild(curBild);
}
function showLast()
{
	stopDiaShow();
	curBild=bildUrls.length-1;
	showBild(curBild);
}

// ------------------------------------

function diaShow()
{
	if(timer!=null)
	{
		stopDiaShow();
		return;
	}
	showNext_(true);
	timer= window.setInterval("showNext_(true)", diaTimeout);
	diaStr.innerHTML= "Stop";
}
function stopDiaShow()
{
	window.clearInterval(timer); 
	timer=null;
	diaStr.innerHTML= "Dia-Show";
}



