function RetrieveTopFaqs(projectId, curProjectId, displayType, category)
{
    if (parseInt(projectId, 10) == "NaN")
    {
        alert("Not a valid project");
        return ;
    }
    
    if (parseInt(curProjectId, 10) == "NaN")
    {
        alert("Not a valid project");
        return ;
    }
    
    if (parseInt(category, 10) == "NaN")
    {
        alert("Not a valid category");
        return ;
    }
    
    xmlHttp = GetXmlHttpObject();
	
    if (xmlHttp == null)
    {
	    alert ("Browser does not support HTTP Request");
	    return;
    }

    var url = "ProcessTops.asp?ProjectId=" + projectId + "&CurProjectId=" + curProjectId + "&displayType=" + displayType + "&category=" + category;
          
    var parameters = "";
    parameters=encodeURI(parameters);
    xmlHttp.onreadystatechange = RetrieveTopFaqs_StateChanged;
    //xmlHttp.open("GET", url, true);
    xmlHttp.open("POST", url, true);
    xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", parameters.length);
    xmlHttp.send('');

}

function RetrieveFaqList(projectId, curProjectId, category, strpage, blnIsGlobalSearch)
{
    if (parseInt(projectId, 10) == "NaN")
    {
        alert("Not a valid project");
        return ;
    }
    
    if (parseInt(curProjectId, 10) == "NaN")
    {
        alert("Not a valid project");
        return ;
    }
    
    if (parseInt(category, 10) == "NaN")
    {
        alert("Not a valid category");
        return ;
    }
    
    xmlHttp = GetXmlHttpObject();
	
    if (xmlHttp == null)
    {
	    alert ("Browser does not support HTTP Request");
	    return;
    }
	
    var url = "exploreMQA.asp?projectid=" + projectId + "&curProjectId=" + curProjectId + "&category=" + category + "&strpage=" + strpage + "&blnIsGlobalSearch=" + blnIsGlobalSearch;
    var parameters = "";
    parameters=encodeURI(parameters);
    xmlHttp.onreadystatechange = RetrieveTopFaqs_StateChanged;
    //xmlHttp.open("GET", url, true);
    xmlHttp.open("POST", url, true);
    xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", parameters.length);
    xmlHttp.send('');
}

function RetrieveTopFaqs_StateChanged()
{
    var element = document.getElementById("TopsArea");
	
    if (xmlHttp.readyState == 0)
    {
	    // The request is uninitialized.
	    ProcessHTMLInsert(element, "<p><div class='tops explore_folder_info_padding'><img src='Images/loading.gif' alt='' />&nbsp;Loading...</div></p>");
    }
    else if (xmlHttp.readyState == 1)
    {
	    // The request is set up, but not sent.
	    ProcessHTMLInsert(element, "<p><div class='tops explore_folder_info_padding'><img src='Images/loading.gif' alt='' />&nbsp;Loading...</div></p>");
    }
    else if (xmlHttp.readyState == 2)
    {
	    // The request was sent and is in process.
	    ProcessHTMLInsert(element, "<p><div class='tops explore_folder_info_padding'><img src='Images/loading.gif' alt='' />&nbsp;Loading...</div></p>");
    }
    else if (xmlHttp.readyState == 3)
    {
	    // The request is in process.
	    ProcessHTMLInsert(element, "<p><div class='tops explore_folder_info_padding'><img src='Images/loading.gif' alt='' />&nbsp;Loading...</div></p>");
    }
    else if ((xmlHttp.readyState == 4) || (xmlHttp.status == 200))
    {
	    // The response is complete.
	    try
		{
			var strHTML = xmlHttp.responseText;
			
			ProcessHTMLInsert(element, strHTML);
		}
	    catch (err)
	    {
		    var txtErr = "There was an error on this page.\n\n";
		    txtErr += "Please try again later.\n\n";
			
		    ProcessHTMLInsert(element, txtErr);
	    }
    }
}

function ProcessHTMLInsert(parentElement, strHTML)
{
    try
    {
	    parentElement.innerHTML = strHTML;
    }
    catch (err) 
    {
	    // IE fails unless we wrap the string in another element.
	    var wrappingDiv = document.createElement("div");
	    wrappingDiv.innerHTML = strHTML;
	    parentElement.innerHTML = "";
	    parentElement.appendChild(wrappingDiv);
    }
}

function GetXmlHttpObject()
{
    var objXMLHttp = null;
	
    try
    {
	    objXMLHttp = new ActiveXObject("Msxml2.XMLHTTP"); //ie6 newest and fastest
    }
    catch (e)
    {
	    try
	    {
		    objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP"); //ie5.5
	    }
	    catch (e)
	    {
		    objXMLHttp = null;
	    }
    }
	
    if (objXMLHttp == null)
    {
	    objXMLHttp = new XMLHttpRequest(); //standard
    }
	
    return objXMLHttp;
}
