function clearBox(Box)
{
	if (Box.value == Box.defaultValue)
	{
	Box.value="";
	}
}

function GetXmlHttpObject()
{ 
	var objXMLHttp=null;
	if (window.XMLHttpRequest)
	{
		objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
return objXMLHttp
}

function login(u,p)
{
	u = document.getElementById(u).value;
	p = document.getElementById(p).value;
	document.getElementById("loginText").innerHTML = "Logging in...";
	xmlHttp=GetXmlHttpObject();
	var url="functions.php";
	url=url+"?rand="+Math.random();
	xmlHttp.open("POST",url,false);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("action=login"+"&username="+u+"&password="+p);
	document.getElementById("loginText").innerHTML = xmlHttp.responseText;
	window.location.reload()
}

function logoff()
{
	document.getElementById("loginText").innerHTML = "Logging off...";
	xmlHttp=GetXmlHttpObject();
	var url="functions.php";
	url=url+"?rand="+Math.random();
	xmlHttp.open("POST",url,false);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("action=logoff");
	document.getElementById("loginText").innerHTML = xmlHttp.responseText;
	window.location.reload()
}

function post(t,c,id)
{
	title = document.getElementById(t).value;
	content = document.getElementById(c).value;

	document.getElementById("loginText").innerHTML = "Posting...";
	xmlHttp=GetXmlHttpObject();
	var url="functions.php";
	url=url+"?rand="+Math.random();
	xmlHttp.open("POST",url,false);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("action=post"+"&id="+id+"&name="+title+"&content="+content);
	document.getElementById("loginText").innerHTML = xmlHttp.responseText;
	window.location.reload();
}

function edit(t,c,n,m,r)
{
	title = document.getElementById(t).value;
	content = document.getElementById(c).value;
	number = document.getElementById(n).value;
	
	if (document.getElementById("em_1").checked)
	{
		mode = document.getElementById("em_1").value;
	} else if (document.getElementById("em_2").checked)
	{
		mode = document.getElementById("em_2").value;
	} else if (document.getElementById("em_3").checked)
	{
		mode = document.getElementById("em_3").value;
	}
	ref = document.getElementById(r).value;

	document.getElementById("loginText").innerHTML = "Editing...";
	xmlHttp=GetXmlHttpObject();
	var url="functions.php";
	url=url+"?rand="+Math.random();
	xmlHttp.open("POST",url,false);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("action=edit"+"&news="+number+"&editmode="+mode+"&title="+title+"&content="+content+"&hour="+hour+"&minute="+minute);
	document.getElementById("loginText").innerHTML = xmlHttp.responseText;
	window.location.search = "t="+ref;
}

function showMore(postID)
{
	var entry = document.getElementById(postID);
	
	if (entry.style.display == "block") {
		entry.style.display="none";
	} else {
		entry.style.display="block";
	}
}