/* =========================

ki-swapper.js

Javascript, um Bilder und Texte auszutauschen

========================= */

var swapCurNo = 2;
var swapForwardLast = null;
var docDivsCount = 0;

if (document.getElementById) {
	document.write ('<style type="text/css">.noscript { display: none; }<\/style>');
}

function swapperStartup (swapHandle) {
	
	var docDivs = document.getElementsByTagName ('DIV');
	
	for (var docDiv = 0; docDiv < docDivs.length; docDiv++) {
		if (docDivs[docDiv].id.indexOf (swapHandle) > -1) docDivsCount++;
	}

	
} // function swapperStartup


function swapImageText (swapHandle, swapForward) {

	if (document.getElementById) {

		if ( (swapForwardLast == swapForward ) ) {
			swapCurNo = (swapForward == false) ? swapCurNo - 1 : swapCurNo + 1;
			swapCurNo = (swapCurNo < 2) ? docDivsCount : swapCurNo;
			swapCurNo = (swapCurNo > docDivsCount) ? 2 : swapCurNo;
		} 
		swapForwardLast = swapForward;
		
		var curPara = null;
  	var tmpTxtDiv = document.createElement('DIV');

		// save swap image in temporary image
		tmpImgSrc = document.getElementById (swapHandle + 'Image1').src;

		// move target image to swap image
		document.getElementById (swapHandle + 'Image1').src = document.getElementById (swapHandle + 'Image' + swapCurNo).src;

		// move temporary image to target image
		document.getElementById (swapHandle + 'Image' + swapCurNo).src = tmpImgSrc;

		// save swap text div in temporary text div
		tmpParas = document.getElementById (swapHandle + 'Texts1').getElementsByTagName('P');
		for (curPara in tmpParas ) {
			if (tmpParas[0] != null) tmpTxtDiv.appendChild (tmpParas[0]);
		}

		// move target paragraphs to swap paragraphs
		targetParas = document.getElementById (swapHandle + 'Texts' + swapCurNo).getElementsByTagName('P');
		for (curPara in targetParas) {
			if (targetParas[0] != null) document.getElementById (swapHandle + 'Texts1').appendChild (targetParas[0]);
		}
		
		// move temporary paragraphs to target paragraphs
		tmpParas = tmpTxtDiv.getElementsByTagName('P');
		for (curPara in tmpParas ) {
			if (tmpParas[0] != null) document.getElementById (swapHandle + 'Texts' + swapCurNo).appendChild (tmpParas[0]);
		}
		
		return false;
		
	}	// if (document.getElementById) {
		
} // function swapImageText 



