//Datei fkds.js - Fred Kasulzke Diashow 
//von Rolf Nakielski - www.nakielski.de

function fkds_start(inter){
	this.stop();
	var call = this.name + ".showNext()";
	this.showNext();
	this.aktiv = window.setInterval(call, inter);
}
function fkds_stop(){
	window.clearInterval(this.aktiv);
}
function fkds_prev(){
	this.stop();
	this.showPrev();
}
function fkds_next(){
	this.stop();
	this.showNext();
}
function fkds_showThumb(img){
	this.stop();
	this.dsPos = fkdnGetNumber(img.src) - this.numFirst;
	this.display();
}
function fkds_showPrev(){
	this.dsPos--;
	if (this.dsPos < 0){
		this.dsPos = this.anzshow - 1;
	}
	this.display();
}
function fkds_showNext(){
	this.dsPos++;
	if (this.dsPos >= this.anzshow){
		this.dsPos = 0;
	}
	this.display();
}
function fkds_display(){
	var neuNum = String(this.numFirst + this.dsPos + 1000).substring(2, 4);
	document.getElementById(this.id).src 
		= fkdnMake(fkdnGetPrefix(this.picFirst), neuNum, fkdnGetSuffix(this.picFirst));
}
function fkds(name, id, anzshow){
	this.name = name;
	this.id = id;
	this.anzshow = anzshow;
	this.picFirst = document.getElementById(id).src;
	this.numFirst = parseInt(fkdnGetNumber(this.picFirst), 10);
	this.dsPos = 0;
	this.aktiv;
	this.start = fkds_start;
	this.stop = fkds_stop;
	this.next = fkds_next;
	this.showNext = fkds_showNext;
	this.prev = fkds_prev;
	this.showPrev = fkds_showPrev;
	this.display = fkds_display;
	this.showThumb = fkds_showThumb;
}
function fkdnGetPrefix(dn){
	return dn.substring(0, dn.length - 6);
}
function fkdnGetNumber(dn){
	return dn.substring(dn.length - 6, dn.length - 4);
}
function fkdnGetSuffix(dn){
	return dn.substring(dn.length - 4, dn.length);
}
function fkdnMake(prefix, number, suffix){
	return prefix.concat(number).concat(suffix);
}
function fkdsMakeThumbs(id, inZeile, anz){
	var muster = document.getElementById(id);
	var parent = muster.parentNode;
	var opa = parent.parentNode; 
	var musterImg = muster.getElementsByTagName("img")[0];
	var musterPic = musterImg.src;
	var musterPicNum = parseInt(fkdnGetNumber(musterPic), 10);
	var anzInZeile = 1;
	for (var i = 1; i < anz; i++){
		if (anzInZeile >= inZeile){
			var neueZeile = document.createElement("TR");
			opa.appendChild(neueZeile);
			parent = neueZeile;
			anzInZeile = 0;
		}
		anzInZeile++;
		var neu = muster.cloneNode(true);
		var neuNum = String(musterPicNum + 1000 + i).substring(2, 4);
		neu.getElementsByTagName("img")[0].src = 
			fkdnMake(fkdnGetPrefix(musterPic), neuNum, fkdnGetSuffix(musterPic));
		parent.appendChild(neu);
	}
}
