// AJAX Load Script
var ajax_control = new sack();
var articleListObj;
var activeArticle = false;
var clickedArticle = false;
var contentObj;	

function mouseoverArticle()	// Highlight article
{
	if(this==clickedArticle)return;
	if(activeArticle && activeArticle!=this){
		if(activeArticle==clickedArticle)
			activeArticle.className='nl-articleClick';
		else
			activeArticle.className='';
		
	}
	this.className='articleMouseOver';
	activeArticle = this;	// Storing reference to this article
}

function showContent()	// Displaying content in the content <div>
{
	//alert(ajax_control.response);
	contentObj.innerHTML = ajax_control.response;	// ajax.response is a variable that contains the content of the external file	
}

function showWaitMessage()
{
	contentObj.innerHTML = 'Loading Content..... Please wait';
}
function getAjaxFile(fileName)
{
	ajax_control.requestFile = fileName;
//	ajax_control.onLoading = showWaitMessage;
	ajax_control.onCompletion = showContent;
		// Specifying which file to get
		// Specify function that will be executed after file has been found
		// Action when AJAX is loading the file
	ajax_control.runAJAX();		// Execute AJAX function	
}

function selectArticle()	// User have clicked on an article
{
	getAjaxFile(this.id + '.aspx');
	if(clickedArticle && clickedArticle!=this)clickedArticle.className='articleMouseOver';
	this.className='nl-articleClick';
	clickedArticle = this;
}


function initNarchive()
{
	articleListObj = document.getElementById('nl-articleList');
	var articles = articleListObj.getElementsByTagName('LI');
	for(var no=0;no<articles.length;no++){
		articles[no].onmouseover = mouseoverArticle;
		articles[no].onclick = selectArticle;
	}	
	
	contentObj = document.getElementById('nl-insert');
	getAjaxFile(articles[0].id + '.aspx');
	clickedArticle.className='articleMouseOver';
	articles[0].className='mem-articleClick';
	clickedArticle = articles[0];
	
}
