
var rssUpdateInterval = 4; //Sekunden
function test1() {
	new Effect.Shake($('line1'), {duration:0.8});
	hideLoading();
}
function test() {
	window.setTimeout("test1()", 1000);
}
function showLoading(latency) {
	document.getElementById('ajaxLoading').style.display='block';
	//window.setTimeout(hideLoading() ,latency);
}
function hideLoading() {
	document.getElementById('ajaxLoading').style.display='none';
}
function initAjaxRSSTicker()
{

	var myAjax = new Ajax.PeriodicalUpdater(
	'line1',
	'/ajax/blogpipeupdate/',
	{
		method: 'get',
		frequency: rssUpdateInterval,
		decay:1,
		onSuccess: function(xhr) {
			
			if(myAjax.lastText == "undefined" || myAjax.lastText == undefined || xhr.responseText.substring(0, 310) != myAjax.lastText.substring(0, 310)) {
				showLoading(1200);
				if (navigator.userAgent.indexOf('MSIE') != -1) {
					test();
				}
				document.getElementById('line1').style.opacity="0";
				for( i=12; i>0; i-- )
				{
					document.getElementById('line'+(i+1).toString()).innerHTML=document.getElementById('line'+i.toString()).innerHTML;
				}
				window.setTimeout( firstDiv(xhr.responseText),0);
			}
		}
	})
}

function firstDiv(transport){
	document.getElementById('line1').innerHTML=transport;
	if (navigator.userAgent.indexOf('MSIE') != -1) {
		test();
	} else {
		window.setTimeout( blendingLi(0), 0);
	}
}

function blendingLi(appear){
	appear=appear+0.1;
	document.getElementById('line1').style.opacity=appear.toString();
	if(appear<1) {
		window.setTimeout("blendingLi("+appear+")",60);
	} else {
		hideLoading();
	}
}


Event.observe(document, 'dom:loaded', function(){
	initAjaxRSSTicker();
});


