/*
	DoM Javascript Functions
		-Load XML
*/
	// Load XML
	function loadXMLDoc(dname)
	{
		if (window.XMLHttpRequest)
		{
			xmlhttp=new XMLHttpRequest();
		}
		else
		{
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		
		xhttp.open("GET",dname,false);
		xhttp.send();
		return xhttp.responseXML;
	}
	function editPosts(str)
	{
		var xmlhttp;
		if (str=="")
		{
			document.getElementById("post").innerHTML="";
			return;
		}
		if (window.XMLHttpRequest)
		{
		xmlhttp=new XMLHttpRequest();
		}
		else
		{
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function()
		{
			if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
			document.getElementById("post"+str).innerHTML=xmlhttp.responseText;
			}
		}
		xmlhttp.open("GET","functions.php?m=editpost&p="+str,true);
		xmlhttp.send();
	}
	function editTopic(str)
	{
		var xmlhttp;
		if (str=="")
		{
			document.getElementById("topic").innerHTML="";
			return;
		}
		if (window.XMLHttpRequest)
		{
		xmlhttp=new XMLHttpRequest();
		}
		else
		{
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function()
		{
			if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
			document.getElementById("topic").innerHTML=xmlhttp.responseText;
			}
		}
		xmlhttp.open("GET","functions.php?m=edittopic&t="+str,true);
		xmlhttp.send();
	}
	function reportPosts(str)
	{
		var xmlhttp;
		if (str=="")
		{
			document.getElementById("post").innerHTML="";
			return;
		}
		if (window.XMLHttpRequest)
		{
		xmlhttp=new XMLHttpRequest();
		}
		else
		{
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function()
		{
			if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
			document.getElementById("report"+str).innerHTML=xmlhttp.responseText;
			}
		}
		xmlhttp.open("GET","functions.php?m=reportpost&p="+str,true);
		xmlhttp.send();
	}
	function newCat()
	{
		var xmlhttp;
		if (window.XMLHttpRequest)
		{
		xmlhttp=new XMLHttpRequest();
		}
		else
		{
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function()
		{
				if (xmlhttp.readyState==4 && xmlhttp.status==200)
				{
				document.getElementById("newcat").innerHTML=xmlhttp.responseText;
				}
		}
		xmlhttp.open("GET","functions.php?m=newcat",true);
		xmlhttp.send();
	}
	function newForum(str)
	{
		var xmlhttp;
		if (str=="")
		{
			document.getElementById("newforum"+str).innerHTML="";
			return;
		}
		if (window.XMLHttpRequest)
		{
		xmlhttp=new XMLHttpRequest();
		}
		else
		{
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function()
		{
			if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
			document.getElementById("newforum"+str).innerHTML=xmlhttp.responseText;
			}
		}
		xmlhttp.open("GET","functions.php?m=newforum&c="+str,true);
		xmlhttp.send();
	}
	function editTopic(str)
	{
		var xmlhttp;
		if (str=="")
		{
			document.getElementById("topic").innerHTML="";
			return;
		}
		if (window.XMLHttpRequest)
		{
		xmlhttp=new XMLHttpRequest();
		}
		else
		{
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function()
		{
			if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
			document.getElementById("topic").innerHTML=xmlhttp.responseText;
			}
		}
		xmlhttp.open("GET","functions.php?m=edittopic&t="+str,true);
		xmlhttp.send();
	}
	function reportTopic(str)
	{
		var xmlhttp;
		if (str=="")
		{
			document.getElementById("reporttopic").innerHTML="";
			return;
		}
		if (window.XMLHttpRequest)
		{
		xmlhttp=new XMLHttpRequest();
		}
		else
		{
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function()
		{
			if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
			document.getElementById("reporttopic").innerHTML=xmlhttp.responseText;
			}
		}
		xmlhttp.open("GET","functions.php?m=reporttopic&t="+str,true);
		xmlhttp.send();
	}
	function deletePost(str)
	{
		var r=confirm("Do you want to delete this post?");
		if (r==true)
		{
			var xmlhttp;
			if (str=="")
			{
				document.getElementById("post"+str).innerHTML="";
				return;
			}
			if (window.XMLHttpRequest)
			{
			xmlhttp=new XMLHttpRequest();
			}
			else
			{
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			xmlhttp.onreadystatechange=function()
			{
				if (xmlhttp.readyState==4 && xmlhttp.status==200)
				{
				document.getElementById("post"+str).innerHTML=xmlhttp.responseText;
				}
			}
			xmlhttp.open("GET","functions.php?m=deletepost&p="+str,true);
			xmlhttp.send();
		}
		else
		{
			alert("Your post was not deleted");
		}
	}
	function deleteTopic(str)
	{
		var r=confirm("Do you want to delete this topic?");
		if (r==true)
		{
			var xmlhttp;
			if (str=="")
			{
				document.getElementById("reporttopic").innerHTML="";
				return;
			}
			if (window.XMLHttpRequest)
			{
			xmlhttp=new XMLHttpRequest();
			}
			else
			{
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			xmlhttp.onreadystatechange=function()
			{
				if (xmlhttp.readyState==4 && xmlhttp.status==200)
				{
				document.getElementById("reporttopic").innerHTML=xmlhttp.responseText;
				}
			}
			xmlhttp.open("GET","functions.php?m=deletetopic&t="+str,true);
			xmlhttp.send();
		}
		else
		{
			alert("Your topic was not deleted");
		}
	}
	function sendTo(url, id)
	{
		var xmlhttp;
		if (window.XMLHttpRequest)
		{
		xmlhttp=new XMLHttpRequest();
		}
		else
		{
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function()
		{
				if (xmlhttp.readyState==4 && xmlhttp.status==200)
				{
				document.getElementById(id).innerHTML=xmlhttp.responseText;
				}
		}
		xmlhttp.open("GET",url,true);
		xmlhttp.send();
	}
	function spotlight()
	{
		xmlDoc=loadXMLDoc("xml/spotlight.xml");

		x=xmlDoc.getElementsByTagName("title");

		for (i=0;i<x.length;i++)
		{
		document.write(x[i].childNodes[0].nodeValue);
		document.write("<br />");
		}
	}
	function showUser($str)
	{
		var xmlhttp;
		if (str=="")
		{
			document.getElementById("reporttopic").innerHTML="";
			return;
		}
		if (window.XMLHttpRequest)
		{
		xmlhttp=new XMLHttpRequest();
		}
		else
		{
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function()
		{
			if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
			document.getElementById("userhint").innerHTML=xmlhttp.responseText;
			}
		}
		xmlhttp.open("GET","aco.php?a=find_user&u="+str,true);
		xmlhttp.send();
	}
