// JavaScript Document

/* Copyright (c) 2010 - cirrus b.v.
 *
 * Version: 1.0
 * 
 */

var xmlDOMTree = undefined;


var HTML_template = '<table border="0" cellspacing="10" id="news" width="480">' +
						'<tr valign="middle">' +
          					'<td width="100" align="left" valign="top" class="newsdivider">%%DATE%%</td>' +
          					'<td valign="top">%%CONTENT%%</td>' +
        				'</tr>' +
      				 '</table>';

function loadNews(xmlFilePath) {
		$.ajax({
				type: "GET",
				url:  xmlFilePath,	
				dataType: "xml",
				success: function(xml) {
					xmlDOMTree = xml;
					newsReadyToRead();
				}
			});
}


function newsReadyToRead() {
	var htmlContent = "";
	
	$(xmlDOMTree).find('news').each(function(){
		htmlContent += HTML_template.replace("%%CONTENT%%",$(this).find('content').text())
									.replace("%%DATE%%",$(this).find('date').text());	
	});
	
	$("#newssection").html(htmlContent);
	$('#news_gallery a').lightBox();

}
