// JavaScript Document
function handleAjaxCompletion(response, status, request, section) {
	if (status == 'error') {
		$(section).empty().append('<p class="error"><span>Error &ndash; Could not load content</span></p>');
	} else {
		$(section).html(response.html);
	}
}

function handleNews(response, status, request, section) {
	handleAjaxCompletion(response, status, request, '#news .ajaxContainer');
}
function handleEvents(response, status, request, section) {
	handleAjaxCompletion(response, status, request, '#featuredEvents .ajaxContainer');
}

$(document).ready(function() {
	var dest = $('#news .ajaxContainer')
	$.getJSON('http://now.biola.edu/snippet/biola/news/json/?callback=?', handleNews);
	$.getJSON('http://now.biola.edu/snippet/biola/events/json/?callback=?', handleEvents);
	$.getJSON('http://now.biola.edu/snippet/biola/alert/json/?callback=?', function(response) {
		$('#alertContainer').html(response.html);
	});
});
