  var tt, td;
  var tt_to; //Timeout-Referenz 
  var tt_to_ms = 500; //Timeout in ms, bis tt ausgeblendet wird
  var tt_max_width = 300; //maximale Breite des tts
  var tt_max_height = 200; //maximale Höhe des tts
  
  function getAbsoluteX (elm) {
	  var x = 0;	  
	  if (elm && typeof elm.offsetParent != "undefined") {
	    while (elm && typeof elm.offsetLeft == "number") {
	      x += elm.offsetLeft;
	      elm = elm.offsetParent;
	    }
	  }
	  return x;
	}
	
	function getAbsoluteY(elm) {
	   var y = 0;
	   if (elm && typeof elm.offsetParent != "undefined") {
	     while (elm && typeof elm.offsetTop == "number") {	     	 
	       y += elm.offsetTop;
	       elm = elm.offsetParent;
	     }
	   }
	   return y;
	}

  function getDivX (elm) {
	  var x = 0;	  
	  if (elm && typeof elm.offsetParent != "undefined") {
	    while (elm && typeof elm.offsetLeft == "number") {
	    	if (elm.tagName == "DIV") return x;
	    	//alert("Tag=" + elm.tagName + " elm.offsetLeft=" + elm.offsetLeft + " Att=" + elm.getAttribute("style", 0));
	      x += elm.offsetLeft;
	      elm = elm.offsetParent;
	    }
	  }
	  return x;
	}
	
	function getDivY(elm) {
	   var y = 0;
	   if (elm && typeof elm.offsetParent != "undefined") {
	     while (elm && typeof elm.offsetTop == "number") {
	     	 if (elm.tagName == "DIV") return y;
	       y += elm.offsetTop;
	       elm = elm.offsetParent;
	     }
	   }
	   return y;
	}
        
  function showpop(t, val){  	  	
  	window.clearInterval(tt_to);
  	td = t;
  	tt = document.getElementById("tt");
  	if (tt == null) return;	               
		
	tt.style.height = "";
		
	//x-Positionierung
  	x = getDivX(t);		
	dw = (document.all) ? document.body.clientWidth : self.innerWidth; //Dokumentbreite  	
    ax = getAbsoluteX(t);	  	  	
  	//alert (" tt_x=" + ax + " tt_max_width=" + tt_max_width + " doc_w=" + dw);  	  	
  	if (ax + tt_max_width > dw){ //passt nicht rechts bis Fensterrahmen -> links anzeigen
  		//tt.style.left = (dw - tt_max_width) + "px";  		
  		tt.style.left = (x + t.offsetWidth - tt_max_width) + "px";
  	}else{
  		tt.style.left = x + "px";
  	}		
  	tt.style.top 	= (getDivY(t) + t.offsetHeight) + "px"; //vorläufige y-Positionierung  	
  	tt.style.display = "block";  	
	tt.innerHTML = "Lade Daten vom Server...";
	xajax_search_event(val);	  
  }
  
  function posTooltip(){  	
  	//y-Positionierung
  	dh = (document.all) ? document.body.clientHeight : self.innerHeight; //Dokumenthöhe
  	adh = document.body.scrollHeight;
  	adt = document.body.scrollTop;
    ay = getAbsoluteY(td);
    //d_up = ay;
    //d_down = dh - (ay + td.offsetHeight);
    d_up = ay - adt;
    d_down = dh - (ay - adt + td.offsetHeight);
    y = getDivY(td);
    //alert ("adh=" + adh + "adt=" + adt + "dh=" + dh + "ay=" + ay + "y=" + y + "d_up=" + d_up + " d_down=" + d_down);
  	if ((tt.offsetHeight > d_down) && (tt.offsetHeight > d_up)){
  		//tt passt weder über noch unterhalb -> Höhe reduzieren
  		if (d_up > d_down){
  			//alert("oberhalb");
  			tt.style.height = d_up + "px";// ay + "px"; //d_up;
  			tt.style.top = (y - parseInt(tt.style.height)) + "px";
  		}else{
  			tt.style.height = d_down - 3;
  			tt.style.top = y + td.offsetHeight + "px";  			
  		}
  	}else if(tt.offsetHeight > d_down){ 
  		tt.style.top = (y - tt.offsetHeight) + "px";
  	}else{	
  		tt.style.top 	= y + td.offsetHeight + "px";
  	}  	
  }
 
  function timepop(){
  	tt_to = window.setTimeout("hidepop()",tt_to_ms); 
  }

  function stoptimer(){
  	window.clearInterval(tt_to); 
  }
  
  function hidepop(){
  	tt=document.getElementById("tt");
    tt.style.display = "none";
  }

