var currentLeft = 0;
var currentRight = 0;
var leftSwapLabels;
var rightSwapLabels;

function swapInit(left, right) {
	leftSwapLabels = left.split(";");
	rightSwapLabels = right.split(";");
	
	//nastaveni prvniho textu
	swapLeft();
	swapRight();
	
	//periodicke nastavovani textu
	setInterval("swapLeft();",2200);
	setInterval("swapRight();",2200);
}

function swapLeft() {
	var swapDiv = document.getElementById("swappingTextLeft");
	
	//smaze predchozi text, pokud tam neco je
	if (swapDiv.hasChildNodes()) {
		swapDiv.removeChild(swapDiv.firstChild);
	}
	
	//pokud doslo scrolovani nakonec, presune se na zacatek
	if (currentLeft == leftSwapLabels.length) {
		currentLeft = 0;
	}
	
	//nastavi text
	var text = document.createTextNode(leftSwapLabels[currentLeft]);
	swapDiv.appendChild(text);
	
	//prejde na dalsi prvek pole
	currentLeft++;
}

function swapRight() {
	var swapDiv = document.getElementById("swappingTextRight");
	if (swapDiv.hasChildNodes()) {
		swapDiv.removeChild(swapDiv.firstChild);
	}
	
	if (currentRight == rightSwapLabels.length) {
		currentRight = 0;
	}
	
	var text = document.createTextNode(rightSwapLabels[currentRight]);
	swapDiv.appendChild(text);
	currentRight++;
}
