var action = 0;
var elementX, elementY, body_width, body_height, layer_width, layer_height, set_layer_width, mode, showPic1, showPic2, Content;
var layerName = 'NLprofToolTip';
var layerPic = 'NLprofToolTipPic';

function NLprofToolTipMove(FromTop, FromLeft, e)
{
	document.getElementById(layerName).style.top = (FromTop+25) +"px";
	document.getElementById(layerName).style.left = (FromLeft+5) +"px";
	
	document.getElementById(layerPic).style.top = (FromTop+11) +"px";
	document.getElementById(layerPic).style.left = (FromLeft+15) +"px";
}

function NLprofToolTipWindowWidth() {
  if (window.innerWidth) {
    return window.innerWidth;
  } else if (document.body && document.body.offsetWidth) {
    return document.body.offsetWidth;
  } else {
    return 0;
  }
}

function NLprofToolTipWindowHeight() {
  if (window.innerHeight) {
    return window.innerHeight;
  } else if (document.body && document.body.offsetHeight) {
    return document.body.offsetHeight;
  } else {
    return 0;
  }
}

function NLprofToolTip(text, set_layer_width, mode_set)
{
	
		NLprofToolTipMove(0, 0);
		document.getElementById(layerName).style.width = "0px";
		document.getElementById(layerName).style.visibility = "hidden";
		document.getElementById(layerPic).style.visibility = "hidden";
		
		showPic1 = 0;
		showPic2 = 0;
		mode = 0;
		
		if (text) {
			
			if (set_layer_width)
			document.getElementById(layerName).style.width = set_layer_width + "px";
			
				Content = '<table width="100%" border="0" cellspacing="0" cellpadding="5" class="nlprof_tool_tip"><tr><td width="100%" class="body">'+text+'</td>';
				if (mode_set==1) 
				Content = Content+'<td width="100%">'+text+'</td><td valign="top"><a href="javascript:void(0);" onClick="NLprofToolTip()">X</a></td>';
				else if (mode_set==2)
				Content = '<table width="100%" border="0" cellspacing="0" cellpadding="0" class="nlprof_tool_tip2"><tr><td width="100%"><img src="../img/bar01_nav.gif" width="169" height="30" border="0" alt=""><div style="background-image:url(../img/bar01_middle.gif); padding: 5px 5px 5px"><iframe src=\''+text+'\' name=\'info\' width=\''+set_layer_width+'\' height=\'\' scrolling=\'no\' marginheight=\'0\' marginwidth=\'0\' frameborder=\'0\' style=\'border-width:0px; border-style:solid; border-color:#999999\'>Ihr Browser kann leider keine eingebetteten Frames anzeigen</iframe></div><img src="../img/bar01_down.gif" width="169" height="16" border="0" alt=""></td>';
				
				
				Content = Content+'</tr></table>';
			
			if (mode_set)
				mode = 1;
				
			document.getElementById(layerName).innerHTML = Content;
			
			action = 1;
			
		} else action = 0;
}

function NLprofToolTipInit(e) {
	
	if (action==1) {
		body_width = NLprofToolTipWindowWidth() + document.body.scrollLeft;
		body_height = NLprofToolTipWindowHeight() + document.body.scrollTop;
		
		layer_width = document.getElementById(layerName).offsetWidth;
		layer_height = document.getElementById(layerName).offsetHeight;
		
		elementX = (document.all) ? window.event.x + document.body.scrollLeft : e.pageX;
     	elementY = (document.all) ? window.event.y + document.body.scrollTop : e.pageY;
		
		if ((elementX+layer_width+40)>=body_width) {
			showPic1 = 0;
			elementX = elementX-(layer_width+10);
		} else showPic1 = 1;
		
		if ((elementY+layer_height+40)>=body_height) {
			showPic2 = 0;
			elementY = elementY-(layer_height+40);
		} else showPic2 = 1;
		
		if ((document.getElementById(layerName).style.visibility == "hidden" && mode==1) || !mode)
		NLprofToolTipMove(elementY, elementX, e);
		
		document.getElementById(layerName).style.visibility = "visible";
		
		if (showPic1==1 && showPic2==1 && !mode)
		document.getElementById(layerPic).style.visibility = "visible";
		else if (!mode)
		document.getElementById(layerPic).style.visibility = "hidden";
		
	} else {
		
		NLprofToolTipMove(0, 0);
		document.getElementById(layerName).style.width = "0px";
		document.getElementById(layerName).style.visibility = "hidden";
		document.getElementById(layerPic).style.visibility = "hidden";
		
		showPic1 = 0;
		showPic2 = 0;
		mode = 0;
		
	}
}