$(function() {
	// Change this constant to match the latest-news directory/index name
	var LATEST_NEWS_BASEURL = '/insurance/insurance-contact/latest-news'

	// Retrieve the Latest News box and set it's state to "loading"
	var container = $('.latest_news_box .latest_news_body').html('<p>Loading latest news feed...</p>');

	// Load .news elements from the latest-news index in a temporary dom element
	$('<div>').load(LATEST_NEWS_BASEURL + ' .news', function() {

		// Create a ul container 
		container = container.html('<ul>').find('ul');

		// Iterate over the three first news items (considered as the latests)
		$(this).find('.news:lt(3)').each(function(idx) {
			// Fetch the title and link
			var title = $(this).find('.title').text();
			var linkParts = $(this).find('.link').attr('href').split('/');
			var link = linkParts[linkParts.length-1];
			// Append a list item to the container
			container.append($('<li><a href="' + LATEST_NEWS_BASEURL + '/' + link + '">' + title + '</a></li>'));
		});

	});
});