 // FIXME Merge to trunk, fixed scroll bug. jk
/**
 * Javascript für die Einblendung eines Hilfetextes.
 *
 * @Author Arne Göbel
 * @since 11.09.2006 
 **/
	$(document).ready(function(){
		if ($("#tooltip").length <= 0){
			$("body").append('<div id="tooltip"></div>');
		}
	});

	ContentInfo = "";

    var mouse_X;
    var mouse_Y;
    var tip_active = 0;
	var viewportwidth;
	var viewportheight;

    function update_tip_pos(){
		getViewport();
   		var diff;
   		if (mouse_X > (viewportwidth - 260)){
   			diff = -270;
   		}else{
   			diff = 10;
   		}
   		document.getElementById('tooltip').style.left = (mouse_X + diff ) + 'px';
   		document.getElementById('tooltip').style.top  = mouse_Y + 'px';
    }


    var ie = document.all?true:false;
    if (!ie) document.captureEvents(Event.MOUSEMOVE)

    document.onmousemove = getMouseXY;


    function getMouseXY(e) {

		if (!e) {
			e = window.event;
		}	
		
		if (self.pageYOffset) { // all except Explorer
			x = self.pageXOffset;
			y = self.pageYOffset;
		}
		else if (document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict
			x = document.documentElement.scrollLeft;
			y = document.documentElement.scrollTop;
		}
		else if (document.body) { // all other Explorers
			x = document.body.scrollLeft;
			y = document.body.scrollTop;
		}			
       mouse_X = e.clientX + x;
       mouse_Y = e.clientY + y;

        if (mouse_X < 0){mouse_X = 0;}
        if (mouse_Y < 0){mouse_Y = 0;}

        if(tip_active){update_tip_pos();}
    }

    function tip_it(which, TContent){
		if (!which && !TContent) {
       		tip_active = 0;
       		document.getElementById('tooltip').style.visibility = "hidden";
			return true;
		}

		update_tip_pos();
		tip_active = 1;
		document.getElementById('tooltip').style.visibility = "visible";
		
		ContentInfo = '';
		if (which){
			ContentInfo = ContentInfo+'<div class="tooltiptitle">'+which+'</div>';
		}
		if (TContent){
			ContentInfo =	ContentInfo+'<div class="tooltipcontent">'+
		                	'<div>'+TContent+'</div>'+
		                    '</div>';
		}
		
		document.getElementById('tooltip').innerHTML = ContentInfo;

		return true;
    }
    
    function getViewport(){
		 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
		 
		 if (typeof window.innerWidth != 'undefined')
		 {
		      viewportwidth = window.innerWidth,
		      viewportheight = window.innerHeight
		 }
		 
		// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
		
		 else if (typeof document.documentElement != 'undefined'
		     && typeof document.documentElement.clientWidth !=
		     'undefined' && document.documentElement.clientWidth != 0)
		 {
		       viewportwidth = document.documentElement.clientWidth,
		       viewportheight = document.documentElement.clientHeight
		 }
		 
		 // older versions of IE
		 
		 else
		 {
		       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
		       viewportheight = document.getElementsByTagName('body')[0].clientHeight
		 }
    }