// ---------------------
// Kalenderfunktionen --
// ---------------------

var XMLHTTP = null;
var timeOut = null;
var tt		= null;
var isprocessing = false;
var ttisVisible = false;

document.onmousemove = updateMousePos;

if(window.XMLHttpRequest)
{
	XMLHTTP = new XMLHttpRequest();
} else if (window.ActiveXObject)
{
	try {
		XMLHTTP = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (ex) {
		try {
			XMLHTTP = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (ex) {			
		}
	}
}

function ajaxTimeOut()
{
	XMLHTTP.abort();
	isprocessing = false;
}

function setData()
{
	if(XMLHTTP.readyState == 4 && XMLHTTP.status == 200)
	{
		new Effect.Opacity('calcnt', { from: 1.0, to: 0.0, duration: 0.15 });
		response = eval('(' + XMLHTTP.responseText + ')');
		sleep = setTimeout("$('calprv').innerHTML = response.prev; $('calmnth').innerHTML = response.month; $('calnxt').innerHTML = response.next; $('calcnt').innerHTML = response.html; new Effect.Opacity('calcnt', { from: 0.0, to: 1.0, duration: 0.35 }); isprocessing = false;", 150);
		clearTimeout(timeOut);
	}
}

function loadMonth( Param )
{
	if(isprocessing == false)
	{
		XMLHTTP.open("GET", "ajax/calendar.load." + Param);
		XMLHTTP.onreadystatechange = setData;
		XMLHTTP.send(null);
		timeOut = setTimeout("ajaxTimeOut();", 2000);
		isprocessing = true;
	}
}

function updateMousePos(e) {
  x = (document.all) ? window.event.x + document.body.scrollLeft : e.pageX;
  y = (document.all) ? window.event.y + document.body.scrollTop  : e.pageY;
  if (tt != null && ttisVisible == false) {
    tt.style.left	= (x + 7) + "px";
    tt.style.top	= (y + 7) + "px";
    ttisVisible = true;
  }
}