XMLHttpRequestObject = false;
if (window.XMLHttpRequest)
{
XMLHttpRequestObject = new XMLHttpRequest();
}
else if(window.ActiveXObject)
{
XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP")
}
function checkComment(action,id,from,resultsPerPage)
{
commentName = document.addComment.commentName.value
comment = document.addComment.theComment.value;
extra = "addComment";
submitted = "commentName="+commentName+"&theComment="+comment
getArticles(action,from,resultsPerPage,extra,id,submitted,'')

}

function getArticles(action,from,resultsPerPage,extra,id,theComment,from2)
{

if(XMLHttpRequestObject)
       {
var obj = document.getElementById("myArticles");
if(extra === "search")
{
searchQuery = document.search.search.value;
endQuery = "search="+searchQuery;
}
else if(extra === "addComment")
{
endQuery = "addComment="+id;
}
else if(extra === "viewComment")
{
endQuery = "viewComment="+id+"&from2="+from2;
}
else {endQuery = ""}
theComment == "undefined" ? commentQuery= "" : commentQuery = "&"+theComment ;
url = "storyline/articleCall.php?action="+action+"&from="+from+"&resultsPerPage="+resultsPerPage+"&"+endQuery+commentQuery;
//alert(url);
XMLHttpRequestObject.open("GET",url);

XMLHttpRequestObject.onreadystatechange = function()
            {
if(XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200)
                {
obj.innerHTML = XMLHttpRequestObject.responseText;
obj.style.display="block";
                 }
            }
XMLHttpRequestObject.send(null);
        }
} 

function hideObj(theobj)
{
var obj = document.getElementById(theobj);
obj.style.display = "none";
}
function showObj(theobj)
{
var obj = document.getElementById(theobj);
obj.style.display = "block";
}

function addComment(id)
{
if(XMLHttpRequestObject)
       {
var obj = document.getElementById("comments");
url = "storyline/comments.php";
XMLHttpRequestObject.open("GET",url);
XMLHttpRequestObject.onreadystatechange = function()
            {
if(XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200)
                {
obj.innerHTML = XMLHttpRequestObject.responseText;
obj.style.display="block";
                 }
            }
XMLHttpRequestObject.send(null);
       }
}
