// JavaScript Document
function showProjects()
{
	getDataMain("currentProjects", "contentArea");
}
function showLinks()
{
	getDataMain("links", "contentArea");
}
function showInfo()
{
	getDataMain("moreInfo", "contentArea");
}
function showServerInfo()
{
	getDataMain("serverInfo", "contentArea");
}
function editContent(title)
{
	getDataMain(title, "contentMenu");
}
function showEditContent()
{
		text='<center><br /><br /><br /><br /><br /><br /><br /><br /><br /><img src="loadingWhite.gif" width="31" align="middle" height="31" /></center>';
		$("#menuContentLoad").html(text);
		$("#menuContentLoad").fadeIn("slow");
		$("#menuOverlay").fadeIn("slow");
		$("#menuContent").delay(200).fadeIn("slow");
}
function updateContent(title)
{	
	tinyMCE.execCommand('mceRemoveControl', false, 'contentForm');
	content="content=" + escape(document.getElementById("contentForm").value);
	hideEditContent();
	text='<center><br /><br /><br /><br /><br /><br /><img src="loading.gif" width="31" align="middle" height="31" /></center>';
	$("#overlay").html(text);
	$("#overlay").fadeIn("slow");
	var url="data.php?request=updateContent&title=" + title + "&random=" + Math.random();
	var xmlhttp = new XMLHttpRequest();
	xmlhttp.open("POST",url,true);
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", content.length);
	xmlhttp.setRequestHeader("Connection", "close");
	
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4)
		{
			document.getElementById("contentArea").innerHTML=xmlhttp.responseText;
			$("#menuContentLoad").fadeOut("slow");
			$("#overlay").fadeOut("slow");
		}
	}
	xmlhttp.send(content);
}
function hideEditContent()
{
	$("#menuOverlay").fadeOut("slow");
	$("#menuContent").fadeOut("slow");
	tinyMCE.execCommand('mceRemoveControl', false, 'contentForm');
}
function getDataMain(content, location)
{
	xmlhttp=new XMLHttpRequest();
	if(location == "contentArea")
	{
		text='<center><br /><br /><br /><img src="loading.gif" width="31" align="middle" height="31" /></center>';
		$("#overlay").html(text);
		$("#overlay").fadeIn("slow");
		var url="data.php?request=showInfo&section=" + content + "&random=" + Math.random();
		xmlhttp.onreadystatechange=function()
		{
			if (xmlhttp.readyState==4)
			{
				document.getElementById(location).innerHTML=xmlhttp.responseText;
				$("#menuContentLoad").fadeOut("slow");
				$("#overlay").fadeOut("slow");
			}
		}
	}
	if(location == "contentMenu")
	{
		showEditContent();
		var url="data.php?request=showMenu&title=" + content + "&random=" + Math.random();
		xmlhttp.onreadystatechange=function()
		{
			if (xmlhttp.readyState==4)
			{
				document.getElementById("menuContent").innerHTML=xmlhttp.responseText;
				tinyMCE.execCommand('mceAddControl', false, 'contentForm');
				$("#menuContentLoad").fadeOut("slow");
			}
		}
	}
	xmlhttp.open("GET",url,true);
	xmlhttp.send("NULL");
}