function hide(elementID){
	eval('if (window.document.getElementById("SlideShowElement_'+elementID+'")) window.document.getElementById("SlideShowElement_'+elementID+'").style.display = \'none\'');	
}
function show(elementID,SlideShowID){
	// if there was a previous element it will be hidden
	eval('if(prevElement_'+SlideShowID+'>0)hide(prevElement_'+SlideShowID+');');
	
	// display current element
	eval('if (window.document.getElementById("SlideShowElement_'+elementID+'")) window.document.getElementById("SlideShowElement_'+elementID+'").style.display = \'block\'');
	
	// save id of current element for hiding it later on
	eval('prevElement_'+SlideShowID+' = '+elementID);
	
}

// Starts paused Slideshow or stops running SlideShow
function StartStop(SlideShowID){
	eval('if(AutoSlideShow_'+SlideShowID+' ==0) {startIfReady('+SlideShowID+'); }else stopSlideShow('+SlideShowID+');');
}


// If the Page is already loaded the 'startSlideShow' funciton will be called, else the 'startIfReady' will call itsself after waiting for 0,2 seconds
// this ensures, that the slideshow doesn't start before all elements are loaded
function startIfReady(SlideShowID){
	if(document.readyState == 'complete' || !(document.all)){		
		eval('startSlideShow('+SlideShowID+')');
	}
	else
		window.setTimeout('startIfReady('+SlideShowID+'),200');
}


function startSlideShow(SlideShowID){
	// the 'AutoSlideShow_' variable indicates whether the Slideshow runs automaticly or not
	eval('AutoSlideShow_'+SlideShowID+' = 1');

	// if end of the slideshow is reached, the index will be set to the begining(0)
	eval('if(SlideIndex_'+SlideShowID+'>= DivNames_'+SlideShowID+'.length -1){SlideIndex_'+SlideShowID+'=0;}');

	// if the index is '0' the element will be shown immediately 
	eval('if(SlideIndex_'+SlideShowID+'== 0)show(DivNames_'+SlideShowID+'[SlideIndex_'+SlideShowID+'],'+SlideShowID+')');


	// calls the Change function in a given Interval as long as it is not terminated by the 'clearInterval' funktion
	eval('Interval_'+SlideShowID+' = window.setInterval(\'change('+SlideShowID+')\',SlideInterval_'+SlideShowID+'*1000)');
	
}
function stopSlideShow(SlideShowID){

	eval('window.clearInterval(Interval_'+SlideShowID+')');
	
	// the 'AutoSlideShow_' variable indicates whether the Slideshow runs automaticly or not
	eval('AutoSlideShow_'+SlideShowID+' = 0');
}

function change(SlideShowID){
	// increase index (next element)	
	eval('SlideIndex_'+SlideShowID+'++');
	
	// If SlideShow is shown in a loop and its the last element, the index will be set to the first element(0)
	eval('if(SlideIndex_'+SlideShowID+' >= DivNames_'+SlideShowID+'.length && InfiniteLoop_'+SlideShowID+' == 1)SlideIndex_'+SlideShowID+'=0');
	
	// If the current index is valid show the element, else stop slideshow
	eval('if(SlideIndex_'+SlideShowID+' < DivNames_'+SlideShowID+'.length)show(DivNames_'+SlideShowID+'[SlideIndex_'+SlideShowID+'],'+SlideShowID+');else{(stopSlideShow('+SlideShowID+'));SlideIndex_'+SlideShowID+'--;show(DivNames_'+SlideShowID+'[SlideIndex_'+SlideShowID+'],'+SlideShowID+')}');
}

// Stops automatic Slideshow and shows, depending on the 'Mode' parameter an element
function StopLink(SlideShowID,Mode){
	stopSlideShow(SlideShowID);
	if(Mode == 'first')
		eval('SlideIndex_'+SlideShowID+' = 0')
	if(Mode == 'last')
		eval('SlideIndex_'+SlideShowID+' = DivNames_'+SlideShowID+'.length -1');
	if(Mode == 'next')
		eval('if(SlideIndex_'+SlideShowID+' +1 <= DivNames_'+SlideShowID+'.length -1){SlideIndex_'+SlideShowID+'++;}');
	if(Mode == 'prev')
		eval('if(SlideIndex_'+SlideShowID+' -1 >=0)SlideIndex_'+SlideShowID+'--;');
	eval('show(DivNames_'+SlideShowID+'[SlideIndex_'+SlideShowID+'],'+SlideShowID+')');
}



