	/* functions for popup comments (MP, 2004-07-28) 
		usage: 
			1. create a div element (id="popupComment") in your document (style="z-index:15;display:none;visibility:hidden;position:absolute;width:200px;background-color:rgb(255,255,180);border:solid 1px #cdcdcd;")
			2. in your document, activate a listener for the mousemove-event:
				document.onmousemove = setPopupCommentPosition;	
			3. any element with a popup-text should use the event-handlers:
				onmouseover="javascript:setPopupCommentText('Title (optional)', 'Line1<br><br>Line2...');showPopupComment();" 
				onmouseout="javascript:killPopupComment();"
			
	*/

	function showPopupComment( ) {
		if(document.getElementById("popupComment")) {
			document.getElementById("popupComment").style.display="block";
			document.getElementById("popupComment").style.visibility="visible";
		}
	}
	function killPopupComment() {
		if(document.getElementById("popupComment")) {
			document.getElementById("popupComment").style.display="none";
			document.getElementById("popupComment").style.visibility="hidden";
		}
	}
	function setPopupCommentText(theTitle, theText, Event) {
		if(document.getElementById("popupComment")) {
			if( !isIE) {
				/* remove all child nodes */
				while(document.getElementById("popupComment").hasChildNodes() ) {
					document.getElementById("popupComment").removeChild(document.getElementById("popupComment").lastChild);
				}
			}
			/* set title */
			if(theTitle.length > 0) {
				if(isIE) {
					theTitle = "<div style=\"background-color:#006095;font-weight:bold;color:#FFFFFF;padding:2px;\">" + theTitle + "</div>";
				} else {
					var theTitleDiv = document.createElement("div");
					var theTitleText = document.createTextNode( theTitle );
					document.getElementById("popupComment").appendChild( theTitleDiv );
                    document.getElementById("popupComment").lastChild.style.backgroundColor = "#006095"
                    document.getElementById("popupComment").lastChild.style.fontWeight = "bold";
                    document.getElementById("popupComment").lastChild.style.color = "#FFFFFF";
                    document.getElementById("popupComment").lastChild.style.padding = "2px";
					document.getElementById("popupComment").lastChild.appendChild( theTitleText );
				}
			}
			/* set text */
			if(isIE) { 
				document.getElementById("popupComment").innerHTML =  theTitle + theText;
			} else {
				var textArray = theText.split("<br>");
				for(x=0; x<textArray.length; x++) {
					var br = document.createElement("br");
					var theTextText = document.createTextNode( textArray[x] );
					if(textArray[x].length > 0) 
						document.getElementById("popupComment").appendChild( theTextText );
					document.getElementById("popupComment").appendChild( br );
				}
			}
		}
	}
	function setPopupCommentPosition(Event) {
		if(document.getElementById("popupComment")) {
			var xPos = (isIE ? window.event.clientX : Event.pageX );
			var elemWidth = parseInt(document.getElementById("popupComment").style.width);
			/* check if there is enough space to display the div to the right of the cursor */
            
			if( (xPos + elemWidth) > getWidth() ) 
                isIE ? document.getElementById("popupComment").style.left = (xPos - elemWidth - 2) : document.getElementById("popupComment").style.left = (xPos - elemWidth - 2) + "px;";
			else
                isIE ? document.getElementById("popupComment").style.left = (xPos +  20) : document.getElementById("popupComment").style.left = (xPos +  20) + "px;";
			isIE ? document.getElementById("popupComment").style.top = ((isIE ? window.event.clientY : Event.pageY ) + 10) : document.getElementById("popupComment").style.top = ((isIE ? window.event.clientY : Event.pageY ) + 10) + "px;";
		}
	}

	function getWidth ()
	{
		return isIE ? this.document.body.offsetWidth : (this.window.innerWidth + (isNetscape ? 4 : 0));
	}
	
