// JavaScript Document

var headlineIndex = 0;
var items;

function cycleHeadline() {	
	$("#headline .headline_content").animate( { "opacity": "toggle" }, 1000, function() {
		$(this).html("<div class=\"headline_text\"><h1>" + items[headlineIndex].title + "</h1><div class=\"headline_innertext\">" + items[headlineIndex].preamble + "</div></div><img src=\"news/large/" + items[headlineIndex].large + "\" />");	
		headlineIndex = (headlineIndex + 1) % 3;
  	});
	$("#headline .headline_content").animate( { "opacity": "toggle" }, 1000);
	$("#headline").click(function() {
		document.location = 'news/index.php?i=' + items[(headlineIndex - 1)	% 3].id;			  
	});
}


$(document).ready(function() {
						   
	$.getJSON("news/gethighlights.php", function(data) {	
			
			items = data.items;
			cycleHeadline();
			setInterval("cycleHeadline()", 7500);

	});
	
	
	$("#news").addClass("active");
	$(".imgbar a").lightBox();							   
});
