$().ready(function()
{
	$('#newstable .archive').hide();
	$('#archivelink').click(function()
	{
		$('#newstable .archive').show();
		$(this).hide();
	});
});

//AJAX request to sort the news list
function sortColumn(sCol,iDir)
{
	var editDiv = document.getElementById('newsholder');
	var loadIndicatorDiv = document.getElementById('ajaxloadindicator');
	var xmlHttp = getAjaxObject(); // Does the posting
	var params = 'ajax=1&operation=sortNewsList&column='+sCol+'&direction='+iDir;
	xmlHttp.open('POST','index.php',true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params);
	loadIndicatorDiv.innerHTML = '<img src="./images/loading.gif" />'; // Show we're processing the info
	xmlHttp.onreadystatechange = function() //On state change, set the lastOperation
	{
		if (xmlHttp.readyState == 4) 
		{
		  	 if (xmlHttp.status == 200)
		  	 {
		  	 	editDiv.innerHTML = xmlHttp.responseText;
		  	 	clearNode(loadIndicatorDiv); // Clear Processing Indicator
		  	 }
		  	 else
		  	 {
		  	 	loadIndicatorDiv.innerHTML = '<p class="error">ERROR: Content could not be retrieved. Try later.</p>'; // Clear Processing Indicator
		  	 }
		}
		// Do this while the operation has not yet been compelted
		else
		{
			loadIndicatorDiv.innerHTML = '<p><img src="./images/loading.gif" /></p>'; // Show we're processing the info
		}
	}
}
