
window.onload = function() {
	run_ticker();
}

function run_ticker() {
	counter = 0;
	speed = 50;
	delayBetweenLines = 3000;
	arrLines = new Array();
	el = document.getElementById("tickerItem");
	
	arrLines[0] = el.firstChild.nodeValue;
	lines = document.getElementsByTagName("SPAN");
	for(i = 0; i < lines.length; i++) {
		if(lines[i].className.indexOf("tickerItem") > 0) {
			arrLines[arrLines.length] = lines[i].firstChild.nodeValue; 
		}
	}
	actText = arrLines[0];
	actLine = 0;
	parse_ticker();
}

function parse_ticker() {
	if(counter == 0) { el.firstChild.nodeValue = ""; }
	if(counter < actText.length) {
		el.firstChild.nodeValue += actText.substring(counter, counter+1);
		counter++;
		setTimeout("parse_ticker()", speed);
	} else {
		if(actLine < arrLines.length-1) { actLine++; } else { actLine = 0;}
		actText = arrLines[actLine];
		counter = 0;
		setTimeout("parse_ticker()", delayBetweenLines);
	}
}

var msgWin = window.msgWin;
/* popup pro obrazky a galerie */
function popup(alink, type) { 
	var retValue = false;
	switch(type) {
		case 1: // img_from_link
			prefix = "/popup_image.php?path=";
			break;
		case 2: // gal_from_link
			prefix = ""; 
			break;
	}

	path = prefix + alink.href + "&title=" + alink.getAttribute("TITLE");
	
	if (msgWin != null && !msgWin.closed) { 
		msgWin.location.href = path;
		msgWin.focus();
	} else {
		msgWin = window.open(path, "_gallery","height=150,menubar=0,personalbar=0,resizable=1,scrollbars=1,toolbar=0,width=150,top=100,left=100,status=0");
		if (msgWin == null || typeof(msgWin) == "undefined") {
			retValue = true; 
			}
		else { 
			alink.target = "_gallery";
			msgWin.focus(); 
		} 
	} 
	return retValue; 
}

function popup_confirmation(mail) {
	if(window.open("/confirm_newsletter/add.html?nlemail=" + mail, "_confirm","height=250,menubar=0,personalbar=0,resizable=1,scrollbars=0,toolbar=0,width=350,top=100,left=100,status=0")) {
		return true;
	} else {
		return false;
	}
}                      