// JavaScript Document

var newsContent;
			
function retrieveXml()
{
	// Make sure the request is loaded (readyState = 4)
	if (req.readyState == 4)
	{
		// Make sure the status is "OK"
		if (req.status == 200)
		{
			newsContent = req.responseXML.getElementsByTagName('news');
			displayList(articlesToList);
		}
		else
		{
			alert("There was a problem retrieving the XML data:\n" + req.statusText);
		}
	}
}

		
function displayList(noOfArticles){
	var swappableSection = document.getElementById('newsArticles');
	var newsArticles = newsContent;
	var str = '<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">';	
	for(j=0; j < noOfArticles; j++)
	{
		var newsNode = newsArticles.item(j);
		if(newsNode != null && newsNode.hasChildNodes())
		{
			var newsid = newsNode.getAttribute('id');
			var newsTitle = getValue(newsNode, "newsTitle");
			var newsDate = getValue(newsNode, "newsDate");
			var shortDesc = getValue(newsNode, "shortDesc");
			str += '<tr><td valign="top" style="text-align:right;">';
			str += '<img src="images/newsBlock.gif" alt="NewsBlock" width="6" height="6" vspace="5" hspace="5" align="right" /></td>';
			str += '<td style="padding-bottom:10px;" valign="top"><strong>'+newsTitle+'</strong><br />';
			str += newsDate+'<br />';
			str += shortDesc+'<br />';
			str += '» <a href="news.php?newsId='+newsid+'">Read On</a>';
			str +='</td></tr>';
			
						

		}
	}
	str += '</table>';
	swappableSection.innerHTML = str;
}

