function init() {
		if (window.event) {
   		if (document.captureEvents){
				document.captureEvents(Event.MOUSEMOVE);
			} else {
				window.captureEvents(Event.MOUSEMOVE);
			}
		}
		old_mouse = document.onmousemove;
		document.onmousemove = getXY;
}

init();

var mousex;
var mousey;
var div;

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

function getDocumentWidth() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
  return myWidth;
}

function getDocumentHeight() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerHeight ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}

function getXY(e) {
    if(old_mouse != undefined) old_mouse(e);
    if(!e) e = window.event;
    var body = (window.document.compatMode && window.document.compatMode == "CSS1Compat") ?
    window.document.documentElement : window.document.body || null;
    
    mousey = e.pageY ? e.pageY : e.clientY + body.scrollTop;
    mousex = e.pageX ? e.pageX : e.clientX + body.scrollLeft;
     
	w = (getDocumentWidth()-990)/2;
	if(w < 0) w = 0;
	//w = w - 10;
    if(div != null) {    	
    	div.style.left = (mousex-w)+'px';
		div.style.top = (mousey+20)+'px';
    }
    
}

function showInfo(stime,etime,desc){
	
	//div = window.document.getElementById('event_nfo');
	div = window.document.createElement('div');
	div.setAttribute('id','evt_nfo');
	window.document.body.appendChild(div);
	w = (getDocumentWidth()-980)/2;
	if(w < 0) w = 0;
	
	if(div != null) {
		div.innerHTML = buildInfo(stime,etime,desc);
		div.style.position = 'absolute';
		div.style.padding = '5px';
		div.style.left = (mousex-w)+'px';
		div.style.top = (mousey+20)+'px';
		div.style.visibility = 'visible';
		div.style.width= '500px';
		div.style.zIndex= '250'; 
		div.style.border= '2px solid #FFEAC9';
		div.style.backgroundColor = '#FFFFFF';
	}
}

function hideInfo(){
	//div = window.document.getElementById('event_nfo');
	div = window.document.getElementById('evt_nfo');
	if(div != null) {
		div.style.visibility = 'hidden';
		window.document.body.removeChild(div);
		div = null;
	}
}

function buildInfo(stime,etime,desc) {
	var template = "<table class='bg_dunkel' cellspacing='1' cellpadding='4' width='100%' border='0'>";
	template += "<tr>\n";
	template += "<td class='weiss_m' width='20%' align='right'>Beginn</td>\n";
	template += "<td class='weiss_m' width='80%' align='left'>"+stime;
	template += "</td>\n";
	template += "</tr>\n";
	template += "<tr>\n";
	template += "<td class='weiss_m' align='right'>Ende</td>\n";
	template += "<td align='left' class='weiss_m'>"+etime;
	template += "</td></tr>\n";
	template += "<tr><td class='weiss_m' align='right' valign='top'>Beschreibung</td>\n";
  	var nfo = window.document.getElementById('event_desc_'+desc);
	var beschr = ""; 
	if(nfo) {
		beschr = nfo.innerHTML;
  	}
  	template += "<td class='weiss_m' align='left' valign='top'>"+beschr+"</td></tr>\n";
	template += "</table>";
	
	return template;
	
}
