headlines = new Array();
bodies = new Array();  

$(document).ready(function() {
	show_alert(0, headlines.length);
});

function show_alert( index, length ){
	var next_index = index+1;
  var thisMessage = "<span class='alert-headline'>" + headlines[index] + "</span>" + "  " + "<span id='alert_body' class='alert-body'></span>";
	$("#alerts").html(thisMessage);

	for(i=1; i<bodies[index].length; i++) {
		setTimeout("$('#alert_body').html(bodies["+index+"].substring(0, "+(i+1)+"))", 100+i*100);
  }

	if( index+1 >= length) { next_index = 0; }

	setTimeout("show_alert("+ next_index +", "+ length + ")", 5000);
}
