//check (from piwi, for box-JS):

var tempN = navigator.appName;
var tempV = parseInt(navigator.appVersion);
var myplatform = navigator.platform; 
var tempUA = navigator.userAgent;
var pattern= /Opera/;
var oper=tempUA.match(pattern);

     if (tempN =="Netscape" && tempV >=4 && tempV < 5)       { var piwi_version="n4"; }
else if (tempN =="Netscape" && tempV >= 5)                   { var piwi_version="n6"; }
else if (tempN =="Microsoft Internet Explorer" && tempV >=4) { var piwi_version="ie"; }
else if (tempN =="Opera" && tempV >=5)                       { var piwi_version="op"; }
else { var piwi_version="xx";}


//'spamsafe' mailto:

function schreiben_an(domain,rcpt)
{
  open('mailto:'+rcpt+'@'+domain,'_new');
}





var helptipdiv;
var showhelptipdiv=1;


function showHelpTip(e,  sHtml, bHideSelects){

	// find anchor element
	var el = e.target || e.srcElement;
	while (el.tagName != "A")
		el = el.parentNode;
	
	// is there already a tooltip? If so, remove it
	if (el._helpTip) {
		helpTipHandler.hideHelpTip(el);
	}

	helpTipHandler.hideSelects = Boolean(bHideSelects);

	// create element and insert last into the body
	
        
        helpTipHandler.createHelpTip(el, sHtml);
	
	// position tooltip
	helpTipHandler.positionToolTip(e);

	// add a listener to the blur event.
	// When blurred remove tooltip and restore anchor
	el.onblur = helpTipHandler.anchorBlur;
	el.onkeydown = helpTipHandler.anchorKeyDown;
}

var helpTipHandler = {
	hideSelects:	false,
	
	helpTip:		null,
	
	showSelects:	function (bVisible) {
		if (!this.hideSelects) return;
		// only IE actually do something in here
		var selects = [];
		if (document.all)
			selects = document.all.tags("SELECT");
		var l = selects.length;
		for	(var i = 0; i < l; i++)
			selects[i].runtimeStyle.visibility = bVisible ? "" : "hidden";	
	},
	
	create:	function () {
		var d = document.createElement("DIV");
		d.className = "help-tooltip";
		document.body.appendChild(d);		
		this.helpTip = d;
	},
	
	createHelpTip:	function (el, sHtml) {
		if (this.helpTip == null) {
			this.create();
		}

		var d = this.helpTip;
		d.innerHTML = URLDecode(sHtml);
		d._boundAnchor = el;
		el._helpTip = d;
		return d;
	},
	
	anchorBlur:	function (e) {
		var el = this;
		helpTipHandler.hideHelpTip(el);
	},
	
	anchorKeyDown:	function (e) {
		if (!e) e = window.event
		if (e.keyCode == 27) {	// ESC
			helpTipHandler.hideHelpTip(this);
		}
	},
	
	removeHelpTip:	function (d) {
                showhelptipdiv=0;
		d._boundAnchor = null;
		d.style.filter = "none";
		d.innerHTML = "";
		d.onmousedown = null;
		d.onmouseup = null;
		d.parentNode.removeChild(d);
		//d.style.display = "none";
	},
	
	hideHelpTip:	function (el) {
		var d = el._helpTip;
		/*	Mozilla (1.2+) starts a selection session when moved
			and this destroys the mouse events until reloaded
		d.style.top = -el.offsetHeight - 100 + "px";
		*/		
		

                showhelptipdiv=0;
		d.style.visibility = "hidden";
		//d._boundAnchor = null;

		el.onblur = null;
		el._onblur = null;
		el._helpTip = null;
		el.onkeydown = null;
		
		this.showSelects(true);
	},
	
	positionToolTip:	function (e) {
		this.showSelects(false);		
		var scroll = this.getScroll();
		var d = this.helpTip;
		
		// width
		if (d.offsetWidth >= scroll.width)
			d.style.width = scroll.width - 10 + "px";
		else
			d.style.width = "";
		
		// left
		if (e.clientX > scroll.width - d.offsetWidth)
			d.style.left = scroll.width - d.offsetWidth + scroll.left + "px";
		else
			d.style.left = e.clientX - 2 + scroll.left + "px";
		
		// top
		if (e.clientY + d.offsetHeight + 18 < scroll.height)
			d.style.top = e.clientY + 18 + scroll.top + "px";
		else if (e.clientY - d.offsetHeight > 0)
			d.style.top = e.clientY + scroll.top - d.offsetHeight + "px";
		else
			d.style.top = scroll.top + 5 + "px";

	        helptipdiv=d;
		
		d.style.visibility = "hidden";
	},
	
	// returns the scroll left and top for the browser viewport.
	getScroll:	function () {
		if (document.all && typeof document.body.scrollTop != "undefined") {	// IE model
			var ieBox = document.compatMode != "CSS1Compat";
			var cont = ieBox ? document.body : document.documentElement;
			return {
				left:	cont.scrollLeft,
				top:	cont.scrollTop,
				width:	cont.clientWidth,
				height:	cont.clientHeight
			};
		}
		else {
			return {
				left:	window.pageXOffset,
				top:	window.pageYOffset,
				width:	window.innerWidth,
				height:	window.innerHeight
			};
		}
		
	}

};



















function URLDecode(expression )
{

   var HEXCHARS = "0123456789ABCDEFabcdef"; 
   var encoded = expression;
   var plaintext = "";
   var i = 0;
   while (i < encoded.length) {
       var ch = encoded.charAt(i);
	   if (ch == "+") {
	       plaintext += " ";
		   i++;
	   } else if (ch == "%") {
			if (i < (encoded.length-2) 
					&& HEXCHARS.indexOf(encoded.charAt(i+1)) != -1 
					&& HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
				plaintext += unescape( encoded.substr(i,3) );
				i += 3;
			} else {
				alert( 'Bad escape combination near ...' + encoded.substr(i) );
				plaintext += "[ERROR]";
				i++;
			}
		} else {
		   plaintext += ch;
		   i++;
		}
	} // while
   return plaintext;

};




function setHelpTipVisible()
{
if(showhelptipdiv) 
 helptipdiv.style.visibility="visible";

};



function dontShowGlossar()
{
 showhelptipdiv=0;
 
};

var close_soon=false;
function fadeGlossar()
{
 close_soon=true;
 window.setTimeout("hideGlossar(1)",1500); 
}

function hideGlossar(fade_glossar)
{
 if (fade_glossar)
 {
  if (close_soon)
    helptipdiv.style.visibility="hidden";
 }
 else    
   helptipdiv.style.visibility="hidden";

 close_soon=false;
}


function showGlossar(e,  sHtml, bHideSelects)
{
 
 sHtml='<table><tr valign=top><td>'+sHtml+'</td><td>[<span style="cursor:hand" onClick="hideGlossar()">x</span>]</td></tr></table>'
 showHelpTip(e,sHtml,bHideSelects);
 showhelptipdiv=1;
 window.setTimeout("setHelpTipVisible()",500); 
};
