function getHTTPObject()
{
	if (window.ActiveXObject) 
	{ return new ActiveXObject("Microsoft.XMLHTTP"); }
	else if (window.XMLHttpRequest) 
	{ return new XMLHttpRequest(); }
	else { alert("Your browser does not support AJAX."); return null; }
}

//This function will retrieve the last the publication TOC IDs along with their name
function getArticles(pubName, keywords)
{
    //Make sure 'undefined' does not get passed as a keyword and set the action var
	if (!keywords || keywords == "undefined") { keywords = null; action = null; } else { action = "search"; }
	
	httpObject = getHTTPObject();
	if (httpObject != null)
	{
		httpObject.open("GET", "get_articles.php?action=" + encodeURIComponent(action) + "&keywords=" + encodeURIComponent(keywords) + "&pub_name=" + encodeURIComponent(pubName), false);
		httpObject.send(null);
		httpObject.onreadystatechange = new function()
		{
            results = httpObject.responseText;
			if (results.substring(0,5) == "ERROR")
			{
				alert(results);
                document.getElementById("articles").innerHTML = results;
			}
			else
			{
               document.getElementById("articles").innerHTML = results;
            }
        }
    }
}

function performSearch()
{
	//Grab keywords and pass them to the all articles script
	var keywords = document.getElementById('searchField').value;
	document.location.href = 'all-articles.php?pub=all&action=search&keywords=' + encodeURIComponent(keywords);
}
