// JavaScript Document
var xmlHttp

function ajaxfunc()
{ 
  
			var usr=document.loginform.username.value;
			var psw=document.loginform.password.value;
			if(document.loginform.remember.checked==true)
			 str3='remember';
			else
			 var str3="";
			loginvalidate(usr,psw,str3);
}

function loginvalidate(str1,str2,str3,str4)
{ 
 
document.getElementById("login").className="lodinggif";
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 

xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",'/logincheck.php?username='+str1+'&password='+str2+'&remember='+str3,true);
xmlHttp.send(null);
}

function logoutvalidate()
{
	
//document.getElementById("login").className="lodinggif";
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 

xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",'/logout.php',true);
xmlHttp.send(null);
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("login").className="";
document.getElementById("login").innerHTML=xmlHttp.responseText;
}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

function getCalendar(args)
{
	
//document.getElementById("login").className="lodinggif";
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 

xmlHttp.onreadystatechange=CalChanged;
xmlHttp.open("GET",'/templates/calendar.php?'+args,true);
xmlHttp.send(null);
}

function CalChanged() 
{ 
if (xmlHttp.readyState==4)
{
document.getElementById("p4ncal").innerHTML=xmlHttp.responseText;
}
}