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 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;
    }

function showDetail(idx,bild,desc){
	
	//div = window.document.getElementById('event_nfo');
	div = window.document.createElement('div');
	div.setAttribute('id','gd_'+idx);
	window.document.body.appendChild(div);
	if(div != null) {
		div.innerHTML = buildDetail(bild,desc);
		div.style.position = 'absolute';
		div.style.padding = '5px';
		div.style.left = '200px';
		div.style.top = 10+'px';
		//div.style.maxWidth= '500px';
		div.style.zIndex= '250'; 
		div.style.border= '1px solid #FF9900';
		div.style.backgroundColor = '#FFEAC9';
	}
	var g = $("#gd_"+idx);
	g.show();
	var h = g.height();
	g.hide();
	if((h+mousey+10) >= $(document).height()) {
		g.css("top",$(document).height()-20-h);
	} else {
		g.css("top", mousey+10);
	}
	g.mouseover(function() {
		var t =$(this).attr("tid");
		if(t) {
			clearTimeout(t);
		}
	});
	g.mouseout(function() {
		//discardDetail($(this).attr("id").substr(3));
		hideDetail($(this).attr("id").substr(3));
	});
	g.show();	
}

function hideDetail(idx) {
	var d =  $("#gd_"+idx);
	var t = setTimeout( "discardDetail("+idx+")",100);
	d.attr("tid",t);
}

function discardDetail(idx){
	div = window.document.getElementById('gd_'+idx);
	if(div != null) {
		div.style.visibility = 'hidden';
		window.document.body.removeChild(div);
		div = null;
	}
}

function buildDetail(bild,desc) {
	var template = "<table class='bg_dunkel' cellspacing='1' cellpadding='4'  border='0'>";
	template += "<tr>\n";
	if(bild) {		
		template += "<td class='weiss_m' align='left' valign='top'><img src='http://www.forschung-sachsen-anhalt.de/gfx/geraete/"+bild;
		//else template += "<td class='weiss_m' align='left'><img width='100' height='100' src='http://www.forschung-sachsen-anhalt.de/gfx/geraete/no_pic.png";
		template += "'></img></td>\n";
		//template += "</tr>\n";
	}
	if(desc) {
		//template += "<tr>\n";
		template += "<td align='left' class='weiss_m' valign='top'><p style='max-width: 300px;'>"+desc+"</p>";
	//else template += "<td align='left' class='weiss_m'>Keine Beschreibung";
		template += "</td>";
	}
	template += "</tr>\n";
	template += "</table>";
	
	return template;
	
}
