var xmlHttp;

function GetXmlHttpObject()
{ 
	var objXMLHttp=null

	if (window.XMLHttpRequest)
	{
		objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}

	return objXMLHttp
}

//-----------------------------------------------------------------------------------------------------
//These function controlls the Listing Area. It will show either a Downlaods list or a Downloada Folder List
function viewList(iCategoryID,iCount)
{
	//copy the contents of our local var to our global var for later use
	var url = "AJAX/_ajax-grabCelebrants.asp?iCategoryID=" + iCategoryID;
	
	//Setting variable for the amount of areas
	var iAreaTotal = document.getElementById("iAreaTotal").value = iCount

	//setting the current Category
	document.getElementById("iCount").value = iCount
	
	//checks weather to open or close
	if (document.getElementById("showCelebrants" + iCount).style.display == 'none')
	{
		//Hiding any open Celebrant areas
		for (var i=1; i<iAreaTotal; i++) {
		document.getElementById("showCelebrants" + i).innerHTML					= ""
		document.getElementById("showCelebrants" + i).style.display				= "none";	
		}
		
		xmlHttp=GetXmlHttpObject()

		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		}

		document.getElementById("showCelebrants" + iCount).innerHTML					= ""
		document.getElementById("showCelebrants" + iCount).style.display				= "none";
		document.getElementById("showCelebrantsLoading" + iCount).style.display			= "inline";

		xmlHttp.onreadystatechange=stateChanged_viewList
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	} else {
		document.getElementById("showCelebrants" + iCount).innerHTML					= ""
		document.getElementById("showCelebrants" + iCount).style.display				= "none";
	}
	
}

function stateChanged_viewList() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		// finding out what area was clicked on
		var iCount = document.getElementById("iCount").value

		document.getElementById("showCelebrants" + iCount).innerHTML					= xmlHttp.responseText;
		document.getElementById("showCelebrants" + iCount).style.display				= "inline";
		document.getElementById("showCelebrantsLoading" + iCount).style.display		= "none";
	} 
} 