var cleared = false;
function clearfield(obj)
{
	if (!cleared)
	{
		cleared = true;
		obj.value = "";
	}
}
function fillfield(obj)
{
	if (obj.value == "")
	{
		cleared = false;
		obj.value="Search...";
	}
}
function submitLogoutForm()
{
	document.getElementById("logoutform").submit();
}
function attemptLogin()
{
prepAjax();
str="username=" + document.getElementById("username").value + "&password=" + document.getElementById("password").value;
xmlHttp.onreadystatechange=function()
{
	if (xmlHttp.readyState==4)
	{
		if (xmlHttp.responseText.charAt(0)=='O')
			window.location.href=window.location.href;
		else
			document.getElementById("loginstatus").innerHTML=xmlHttp.responseText;
	}
}
xmlHttp.open("POST","/attemptlogin",true);
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
xmlHttp.send(str);
return false;
}
function getUsers()
{
	prepAjax();
	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState==4)
		{
			document.getElementById("userlist").innerHTML=xmlHttp.responseText;
		}
	}
	xmlHttp.open("GET","/userlist",true);
	xmlHttp.send(null);
	return false;
}
function prepAjax()
{
supported = true;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
	supported = false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
      document.getElementById("calendarstuff").innerHTML = xmlHttp.responseText;
      }
    }
}

