/* SLIDESHOW Control ---------------------------------------------------------- */
// Vars
countOfSlides = 1;
showImgId = 1;
playit = false;
stopit = false;
restartit = false;
dfolder = '';
timoutstarted = false;
timeSpeed = 3000; // Zeitabstand in Milisekunden
// Set Count Of
function setCountOfSlides (pInt) {
	countOfSlides = pInt;
}// setCountOfSlides
// Set Default Folder
function setDefaultFolder (pFolder) {
	dfolder = pFolder;
}// setDefaultFolder
// Show First Image
function firstImg () {
	stop ();
	Effect.Fade ( // Fade
		'slide'+showImgId+'', 
		{
			duration:0,
			fps:50
		}
	);
	Effect.Appear (
		'slide1', 
		{
			duration:0,
			fps:50
		}
	);
	showImgId = 1;
	if (!timoutstarted) setTimeout ('restart (); play ();', timeSpeed);
	timoutstarted = true;
}
function startNext () {
	stop ();
	nextImgHard ();
}
function startPrev () {
	stop ();
	preImgHard ();
}
// Show Next Image
function nextImg () {
	idToShow = showImgId+1;
	idToHide = showImgId;
	if (showImgId == countOfSlides) idToShow = 1;
	Effect.Appear (
		'slide'+idToShow+'', 
		{
			duration:0.8,
			fps:50
		}
	);
	Effect.Fade ( // Fade
		'slide'+idToHide+'', 
		{
			duration:0.8,
			fps:50
		}
	);
	showImgId++;
	if (showImgId > countOfSlides) showImgId = 1;	
}// nextImg
// Show Next Image Hard
function nextImgHard () {
	idToShow = showImgId+1;
	idToHide = showImgId;
	if (showImgId == countOfSlides) idToShow = 1;
	document.getElementById('slide'+idToShow).style.display = 'block';
	document.getElementById('slide'+idToHide).style.display = 'none';
	showImgId++;
	if (showImgId > countOfSlides) showImgId = 1;
}// Show Next Image Hard
// Show Previous Image Hard
function preImgHard () {
	idToShow = showImgId-1;
	idToHide = showImgId;
	if (showImgId == 1) idToShow = countOfSlides;
	document.getElementById('slide'+idToShow).style.display = 'block';
	document.getElementById('slide'+idToHide).style.display = 'none';
	showImgId--;
	if (showImgId < 1) showImgId = countOfSlides;
}// Show Prev Image Hard
// Show Previous Image
function preImg (pShow, pHide) {
	if (pShow) idToShow = pShow;
	else idToShow = showImgId-1;
	if (pHide) idToHide = pHide;
	else idToHide = showImgId;
	if (showImgId == 1) idToShow = countOfSlides;
	Effect.Appear (
		'slide'+idToShow+'', 
		{
			duration:0.8,
			fps:50
		}
	);
	Effect.Fade ( // Fade
		'slide'+idToHide+'', 
		{
			duration:0.8,
			fps:50
		}
	);
	showImgId--;
	if (showImgId < 1) showImgId = countOfSlides;
}// preImg
// Play Slideshow
function play () {
	if (!stopit || restartit) {
		timoutstarted = false;
		nextImg ();
		setTimeout ('play();', timeSpeed);
	}
}// play
// Play Slideshow Hard
function playHard () {
	document.getElementById('slide').src = dfolder+'/bild'+showImgId+'.jpg';
	showImgId++;
	if (showImgId > countOfSlides) showImgId = 1;
	setTimeout ('playHard();', 1000);
}// play
// Stop Slideshow
function stop () {
	stopit = true;
	restartit = false;
	playit = false;
}
// Restart Slideshow
function restart () {
	restartit = true;
}



/* EditMode Functions --------------------------------------------------------- */
function getElementsByClass(searchClass,node,tag) {
  var classElements = new Array();
  if (node == null)
    node = document;
  if (tag == null)
    tag = '*';
  var els = node.getElementsByTagName(tag);
  var elsLen = els.length;
  var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
  for (i = 0, j = 0; i < elsLen; i++) {
    if (pattern.test(els[i].className) ) {
      classElements[j] = els[i];
      j++;
    }
  }
  return classElements;
}
function init (colId) {
	var el = getElementsByClass('sprache'+colId);
	for (i=0 ; i<el.length ; i++) el[i].style.display = "none";
	var el2 = getElementsByClass('active'+colId);
	for (i=0 ; i<el2.length ; i++) el2[i].className = "";
}
function changeLang (idToShow, tabId, colId) {
	init (colId);
	document.getElementById(''+idToShow+'').style.display = "block";
	document.getElementById(''+tabId+'').className = "active"+colId;
}// changeLang