// Parts of this script are under Copyright from (C) 1999 Dan Steinman
// and available at http://www.dansteinman.com/dynduo/
// Distributed under the terms of the GNU Library General Public License

window.onerror = null;

 function checkFrameset() {
	anzeige();
	googleSearchHighlight();
	}
		

function DynLayer(id,nestref) {
	if (ns4) {
		this.css = (nestref)? eval("document."+nestref+".document."+id) : document.layers[id]
		this.x = this.css.left
		this.y = this.css.top}
	if (ns5) {
		this.css = document.getElementById(id).style
		this.x = this.css.left
		this.y = this.css.top}
	if (ie4) {
		this.css = document.all[id].style
		this.x = this.css.pixelLeft
		this.y = this.css.pixelTop}
	this.moveTo = DynLayerMoveTo
	this.moveBy = DynLayerMoveBy
	this.show = DynLayerShow
	this.hide = DynLayerHide
}

function DynLayerMoveTo(x,y) {
	if (x!=null) {
		this.x = x
		this.css.left = this.x}
	if (y!=null) {
		this.y = y
		this.css.top = this.y}}

function DynLayerMoveBy(x,y) {
	this.moveTo(this.x+x,this.y+y)}
function DynLayerShow() {
	this.css.visibility = (ns4)? "show" : "visible"}
function DynLayerHide() {
	this.css.visibility = (ns4)? "hide" : "hidden"}

function init() {
		if (ns4) {
			windowWidth = window.innerWidth-16
			windowHeight = window.innerHeight}
		if (ns5) {
			windowWidth = window.innerWidth-16
			windowHeight = window.innerHeight}
		if (ie4) {
			windowWidth = document.body.offsetWidth-20
			windowHeight = document.body.offsetHeight}

		kpl = new DynLayer("kplDiv");
		//info = new DynLayer("infoDiv","kplDiv");
    massX = windowWidth-30;
    massY = windowHeight-30;
    if (massX>780) massX=780;
    if (massY>420) massY=420;
		kpl.moveTo(massX,massY);
		setTimeout("kpl.show();",1500);
		anzeige();
}


function fprint(){
window.print();

}

function top(){
window.scrollTo(0,0);
}

function oeffne(dat,w,h){

dat='https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=tipps%40i%2ddietrich%2ede&item_name=Office%2dTipps%20www%2ei%2ddietrich%2ede&no_shipping=1&return=http%3a%2f%2fwww%2ei%2ddietrich%2ede%2fthankyou%2ehtm&no_note=1&tax=0&currency_code=EUR&lc=DE&bn=PP%2dDonationsBF&charset=UTF%2d8';
 ziel=window.open(dat,'new','width='+w+',height='+h+',resizable=yes,scrollbars=yes,status=yes')
  ziel.moveTo(0,0);
  ziel.focus();
}

function deblur(lk){
if (document.all||document.getElementById)lk.blur();
}

/* http://www.kryogenix.org/code/browser/searchhi/ */
/* Modified 20021006 to fix query string parsing and add case insensitivity */
function highlightWord(node,word) {
	// Iterate into this nodes childNodes
	if (node.hasChildNodes) {
		var hi_cn;
		for (hi_cn=0;hi_cn<node.childNodes.length;hi_cn++) {
			highlightWord(node.childNodes[hi_cn],word);
		}
	}
	
	// And do this node itself
	if (node.nodeType == 3) { // text node
		tempNodeVal = node.nodeValue.toLowerCase();
		tempWordVal = word.toLowerCase();
		if (tempNodeVal.indexOf(tempWordVal) != -1) {
			pn = node.parentNode;
			if (pn.className != "hitword") {
				// word has not already been highlighted!
				nv = node.nodeValue;
				ni = tempNodeVal.indexOf(tempWordVal);
				// Create a load of replacement nodes
				before = document.createTextNode(nv.substr(0,ni));
				docWordVal = nv.substr(ni,word.length);
				after = document.createTextNode(nv.substr(ni+word.length));
				hiwordtext = document.createTextNode(docWordVal);
				hiword = document.createElement("span");
				hiword.className = "hitword";
				hiword.appendChild(hiwordtext);
				pn.insertBefore(before,node);
				pn.insertBefore(hiword,node);
				pn.insertBefore(after,node);
				pn.removeChild(node);
			}
		}
	}
}

function googleSearchHighlight() {
	if (!document.createElement) return;
	ref = document.referrer;
	if (ref.indexOf('?') == -1) return;
	qs = ref.substr(ref.indexOf('?')+1);
	qsa = qs.split('&');
	for (i=0;i<qsa.length;i++) {
		qsip = qsa[i].split('=');
	        if (qsip.length == 1) continue;
        	if (qsip[0] == 'q' || qsip[0] == 'search_exp' || qsip[0] == 'p') { // q= for Google, p= for Yahoo, search_exp for eigene 
			words = unescape(qsip[1].replace(/\+/g,' ')).split(/\s+/);
	                for (w=0;w<words.length;w++) {
				highlightWord(document.getElementsByTagName("body")[0],words[w]);
                	}
	        }
	}
}

function on(num) {
	if (document.images) {
		document.images[name + num].src = bOn[num].src;}
	if (ns4){
		document.text.document.write('<p style=\"font-family:century gothic,verdana,arial;width:280px;letter-spacing:4px;font-size:10pt; font-weight:bold;color:white\">'+t[num]+'</p>');
		document.text.document.close();
		}
	if (ns5){
		document.getElementById("text").firstChild.data=t[num];
		}
	if (ie4){
		document.all.text.innerText=t[num];
		}
	window.status=stat[num];	
}
		
function off(num) {
	if (document.images) {
		document.images[name + num].src = bOff[num].src;}
	if (document.images && checked[num] == 1) {
		document.images[name + num].src = bOn[num].src;}

	if (ns4){
		document.text.document.write("");
		document.text.document.close();
		}
	if (ns5){
		document.getElementById("text").firstChild.data="";
		}
	if (ie4){
		document.all.text.innerText="";
		}
	window.status="";	
}

function show(num) {
	checked[num]=1;
	if (document.images) {
		document.images[name + num].src = bOn[num].src;
		for (i=1;i<=anzahl;i++) {
			if (i!=num)
			{
			document.images[name + i].src = bOff[i].src;	
			checked[i]=0;	
			}	
		}
	}
}
function ohne() {
		for (i=1;i<=anzahl;i++) {
			document.images[name + i].src = bOff[i].src;		
			checked[i]=0;
			}	
}
