var items, currentitem, currentindex, currentopacity=0, currentposition, newswidth;
 
function initNewsTicker() {
	var news = document.getElementById("newsticker");
	if (news != null) {
		items = news.getElementsByTagName("li");
		if (items != null) {
			if (items.length != 0) {
				for (i=0; i<items.length; i++) {
					items[i].style.opacity = 0;
					items[i].style.filter = "alpha(opacity=0)";
					items[i].style.display = "none";
				}
				currentindex = 0;
				currentopacity = 1;
				currentposition = 0;
				currentitem = items[currentindex];
				currentitem.style.opacity = 1;
				currentitem.style.filter = "alpha(opacity=100)";
				currentitem.style.display = "block";
				window.setTimeout(fadeout, 3000);
			}
		}
	}
}
 
function next() {
	currentindex = ++currentindex % items.length;
	currentitem = items[currentindex];
	currentitem.style.display = "block";
	currentitem.style.opacity = 1;
	currentitem.style.filter = "alpha(opacity=100)";
	currentopacity = 1;
	fadein();
}
 
function fadein() {
	if(currentposition > 0) {
		currentposition -= 2;
		currentitem.style.margin = "0 0 0 "+currentposition+"px";
		window.setTimeout(fadein, 8);
	} 
	else {
		currentposion = 0;
		currentitem.style.margin = "0 0 0 0";
		window.setTimeout(fadeout, 5000);
	}
}
 
function fadeout() {
	currentopacity -= 0.02;
	currentopacity = parseInt(currentopacity*100)/100;
	if (currentopacity > 0) {
		currentitem.style.opacity = currentopacity;
		currentitem.style.filter = "alpha(opacity="+(currentopacity*100)+")";
		window.setTimeout(fadeout, 20);
	}
	else {
		currentitem.style.opacity = 0;
		currentitem.style.filter = "alpha(opacity=0)";
		currentitem.style.display = "none";
		currentposition = 250;
		currentopacity = 0;
		next();
	}
}
