/* http://www.kryogenix.org/code/browser/searchhi/ */
/* Modified  by webdesign.weisshart.de/  28.03.06*/

var ref = "";

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;
			klasse = "searchword"+w; // different colors for differnt searchterms

			if (pn.className != klasse) {
				// 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("em"); // modified from span to em

				hiword.className = klasse;
				hiword.appendChild(hiwordtext);
				pn.insertBefore(before,node);
				pn.insertBefore(hiword,node);
				pn.insertBefore(after,node);
				pn.removeChild(node);
			}
		}
	}
}

function Highlight() {
	if (!document.createElement) return;

	// added for site search
	if (window.location.search) ref = unescape(window.location.search);

	if (document.referrer.search(/google.+/) != -1 || document.referrer.search(/lycos.+/) != -1 || document.referrer.search(/yahoo.+/) != -1 || document.referrer.search(/fireball.+/) != -1 ||document.referrer.search(/search\.msn.+/) != -1 ) {
		ref = decodeURIComponent(document.referrer);
		if (ref.indexOf('?') == -1) return;
	}

	// for site search:
	// if your search file is not called suchen.*, you must modify the following line 2x! 
	if (document.referrer.search(/suchen.+/) != -1 && document.URL.indexOf("suchen") == -1 ) {
		ref = unescape(document.referrer);	
		if (window.location.search) ref = unescape(window.location.search);
	}

	//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 || qsip.length == 5) continue;
        	if (qsip[0] == 'q' || qsip[0] == 'query' ||qsip[0] == 'p' || qsip[0] == 's'|| qsip[0] == 'highlight') { // q= for Google, p= for Yahoo, query= Fireball, Lycos etc., s= for wordpress
	        if (qsip[1].length < 3 ) continue;


			// words not to be highlighted:
			qsip[1] = qsip[1].replace(/\"|\'|\*|;|\bbei\s*\b|\bfür\s*\b|\b.n\s*\b|\bvon\s*\b|\bnicht\s*\b|\bde.\s*\b|\bdie\s*\b|\bdas\s*\b|\bauf\s*\b|\ein\b|\bund\s*\b|\bwie\s*\b|\bkann\s*\b|\bich\s*\b|\bman\s*\b|\bmit\s*\b|\ist\s*\b|Suchbegriff/gi,'');
			
			qsip[1] = qsip[1].replace(/Suchbegriff/gi,'');
                        if (document.URL.indexOf('blog') >= 1) qsip[1] = qsip[1].replace(/\d\d|\d/g,''); // 1/2-digit number in blogs
                        
			// remove all blanks and '+' before and after searchterm (bugfix: crashes FF & Op)
			qsip[1] = qsip[1].replace(/^(\s+|\++)/,'').replace(/(\++)$/,'').replace(/(\s+)$/,'');
			
			if (qsip[1] != '') {
			words = unescape(qsip[1].replace(/\+/g,' ')).split(/\s+/);
				for (w=0;w<words.length;w++) {
					if (words[w].length >= 3)
					words[w] = words[w].replace(/\.|,|;|!|\?|:|"|'|-|\//gi,'');
					highlightWord(document.getElementsByTagName("body")[0],words[w]);
                		}
			}
	        }
	}
}

window.onload = Highlight;



// Diese Datei läd den ganzen jquery firlefanz!
// scrollTo ist von interface.js abhängig!

(function($){
	/* table-striping */
	$.fn.stripe = function(){
		return this.each(function(){
			var $$=$(this);
			$$.find("tr:nth-child(odd)").addClass("odd");
			$$.find("tr:nth-child(even)").addClass("even");
		});
	};
	
/* scrollTo taken from the Interface plugin for jQuery
* Copyright (c) 2006 Stefan Petre - http://interface.eyecon.ro
*/

// from iutil.js
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('9.J={1C:6(e){4 x=0;4 y=0;4 7=e.Y;4 12=1H;c(9(e).8(\'A\')==\'T\'){4 N=7.B;4 Q=7.z;12=1f;7.B=\'1r\';7.A=\'1q\';7.z=\'1d\'}4 3=e;R(3){x+=3.1h+(3.O&&!9.1m.1i?d(3.O.17)||0:0);y+=3.1n+(3.O&&!9.1m.1i?d(3.O.18)||0:0);3=3.1t}3=e;R(3&&3.1e&&3.1e.16()!=\'f\'){x-=3.u||0;y-=3.F||0;3=3.1D}c(12==1f){7.A=\'T\';7.z=Q;7.B=N}a{x:x,y:y}},1B:6(3){4 x=0,y=0;R(3){x+=3.1h||0;y+=3.1n||0;3=3.1t}a{x:x,y:y}},1s:6(e){4 w=9.8(e,\'1E\');4 h=9.8(e,\'1G\');4 o=0;4 q=0;4 7=e.Y;c(9(e).8(\'A\')!=\'T\'){o=e.V;q=e.U}p{4 N=7.B;4 Q=7.z;7.B=\'1r\';7.A=\'1q\';7.z=\'1d\';o=e.V;q=e.U;7.A=\'T\';7.z=Q;7.B=N}a{w:w,h:h,o:o,q:q}},1F:6(3){a{o:3.V||0,q:3.U||0}},1I:6(e){4 h,w,C;c(e){w=e.I;h=e.G}p{C=5.j;w=1c.14||P.14||(C&&C.I)||5.f.I;h=1c.10||P.10||(C&&C.G)||5.f.G}a{w:w,h:h}},1p:6(e){4 t=0,l=0,w=0,h=0,s=0,E=0;c(e&&e.1u.16()!=\'f\'){t=e.F;l=e.u;w=e.15;h=e.W;s=0;E=0}p{c(5.j){t=5.j.F;l=5.j.u;w=5.j.15;h=5.j.W}p c(5.f){t=5.f.F;l=5.f.u;w=5.f.15;h=5.f.W}s=P.14||5.j.I||5.f.I||0;E=P.10||5.j.G||5.f.G||0}a{t:t,l:l,w:w,h:h,s:s,E:E}},1v:6(e,D){4 3=9(e);4 t=3.8(\'1w\')||\'\';4 r=3.8(\'1x\')||\'\';4 b=3.8(\'1A\')||\'\';4 l=3.8(\'1z\')||\'\';c(D)a{t:d(t)||0,r:d(r)||0,b:d(b)||0,l:d(l)};p a{t:t,r:r,b:b,l:l}},1y:6(e,D){4 3=9(e);4 t=3.8(\'1J\')||\'\';4 r=3.8(\'1M\')||\'\';4 b=3.8(\'27\')||\'\';4 l=3.8(\'28\')||\'\';c(D)a{t:d(t)||0,r:d(r)||0,b:d(b)||0,l:d(l)};p a{t:t,r:r,b:b,l:l}},26:6(e,D){4 3=9(e);4 t=3.8(\'18\')||\'\';4 r=3.8(\'22\')||\'\';4 b=3.8(\'23\')||\'\';4 l=3.8(\'17\')||\'\';c(D)a{t:d(t)||0,r:d(r)||0,b:d(b)||0,l:d(l)||0};p a{t:t,r:r,b:b,l:l}},2e:6(L){4 x=L.2d||(L.2b+(5.j.u||5.f.u))||0;4 y=L.2c||(L.29+(5.j.F||5.f.F))||0;a{x:x,y:y}},X:6(g,13){13(g);g=g.1O;R(g){9.J.X(g,13);g=g.1L}},1N:6(g){9.J.X(g,6(3){19(4 Z 1T 3){c(1Z 3[Z]===\'6\'){3[Z]=1a}}})},1X:6(3,H){4 k=9.J.1p();4 11=9.J.1s(3);c(!H||H==\'1W\')9(3).8({1U:k.t+((1g.1o(k.h,k.E)-k.t-11.q)/2)+\'1j\'});c(!H||H==\'20\')9(3).8({1Y:k.l+((1g.1o(k.w,k.s)-k.l-11.o)/2)+\'1j\'})},2f:6(3,1l){4 1k=9(\'25[@M*="S"]\',3||5),S;1k.24(6(){S=K.M;K.M=1l;K.Y.2a="21:1R.1P.1V(M=\'"+S+"\')"})}};[].1b||(1S.1Q.1b=6(v,n){n=(n==1a)?0:n;4 m=K.1K;19(4 i=n;i<m;i++)c(K[i]==v)a i;a-1});',62,140,'|||el|var|document|function|es|css|jQuery|return||if|parseInt||body|nodeEl|||documentElement|clientScroll||||wb|else|hb||iw||scrollLeft|||||position|display|visibility|de|toInteger|ih|scrollTop|clientHeight|axis|clientWidth|iUtil|this|event|src|oldVisibility|currentStyle|self|oldPosition|while|png|none|offsetHeight|offsetWidth|scrollHeight|traverseDOM|style|attr|innerHeight|windowSize|restoreStyles|func|innerWidth|scrollWidth|toLowerCase|borderLeftWidth|borderTopWidth|for|null|indexOf|window|absolute|tagName|true|Math|offsetLeft|opera|px|images|emptyGIF|browser|offsetTop|max|getScroll|block|hidden|getSize|offsetParent|nodeName|getMargins|marginTop|marginRight|getPadding|marginLeft|marginBottom|getPositionLite|getPosition|parentNode|width|getSizeLite|height|false|getClient|paddingTop|length|nextSibling|paddingRight|purgeEvents|firstChild|Microsoft|prototype|DXImageTransform|Array|in|top|AlphaImageLoader|vertically|centerEl|left|typeof|horizontally|progid|borderRightWidth|borderBottomWidth|each|img|getBorder|paddingBottom|paddingLeft|clientY|filter|clientX|pageY|pageX|getPointer|fixPNG'.split('|'),0,{}))
// from ifxscrollto.js
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('4.10.X({m:7(d,6,3){o=4.d(d);C 9.12(\'L\',7(){v 4.K.m(9,o,6,3)})},14:7(d,6,3){C 9.19(7(){4(\'a[@O*="#"]\',9).17(7(e){E=9.O.16(\'#\');4(\'#\'+E[1]).m(d,6,3);C J})})}});4.K.m=7(e,o,6,3){q z=9;z.o=o;z.e=e;z.6=/S|Q/.Z(6)?6:J;z.3=3;p=4.I.11(e);s=4.I.T();z.M=7(){U(z.A);z.A=V;4.W(z.e,\'L\')};z.t=(v G).F();s.h=s.h>s.H?(s.h-s.H):s.h;s.w=s.w>s.N?(s.w-s.N):s.w;z.g=p.y>s.h?s.h:p.y;z.j=p.x>s.w?s.w:p.x;z.8=s.t;z.b=s.l;z.D=7(){q t=(v G).F();q n=t-z.t;q p=n/z.o.i;f(t>=z.o.i+z.t){z.M();1a(7(){z.B(z.g,z.j)},13)}c{f(!z.6||z.6==\'S\'){f(!4.3||!4.3[z.3]){r=((-k.P(p*k.R)/2)+0.5)*(z.g-z.8)+z.8}c{r=4.3[z.3](p,n,z.8,(z.g-z.8),z.o.i)}}c{r=z.8}f(!z.6||z.6==\'Q\'){f(!4.3||!4.3[z.3]){u=((-k.P(p*k.R)/2)+0.5)*(z.j-z.b)+z.b}c{u=4.3[z.3](p,n,z.b,(z.j-z.b),z.o.i)}}c{u=z.b}z.B(r,u)}};z.B=7(t,l){18.15(l,t)};z.A=Y(7(){z.D()},13)};',62,73,'|||easing|jQuery||axis|function|startTop|this||startLeft|else|speed||if|endTop||duration|endLeft|Math||ScrollTo||||var|st|||sl|new|||||timer|scroll|return|step|parts|getTime|Date|ih|iUtil|false|fx|interfaceFX|clear|iw|href|cos|horizontal|PI|vertical|getScroll|clearInterval|null|dequeue|extend|setInterval|test|fn|getPosition|queue||ScrollToAnchors|scrollTo|split|click|window|each|setTimeout'.split('|'),0,{}))

	
/* scrollTo taken from the Interface plugin for jQuery
* Copyright (c) 2006 Stefan Petre - http://interface.eyecon.ro
*/
//eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('3.R=6(e){7 l=0;7 t=0;7 w=3.a(3.X(e,\'1e\'));7 h=3.a(3.X(e,\'1f\'));7 m=e.L;7 B=e.F;1a(e.S){l+=e.T+(e.8?3.a(e.8.W):0);t+=e.V+(e.8?3.a(e.8.10):0);e=e.S}l+=e.T+(e.8?3.a(e.8.W):0);t+=e.V+(e.8?3.a(e.8.10):0);c{x:l,y:t,w:w,h:h,m:m,B:B}};3.1d=6(e){b(e){w=e.k;h=e.C}f{w=(d.Y)?d.Y:(1.4&&1.4.k)?1.4.k:1.9.L;h=(d.H)?d.H:(1.4&&1.4.C)?1.4.C:1.9.F}c{w:w,h:h}};3.U=6(e){b(e){t=e.i;l=e.A;w=e.r;h=e.D}f{b(1.4&&1.4.i){t=1.4.i;l=1.4.A;w=1.4.r;h=1.4.D}f b(1.9){t=1.9.i;l=1.9.A;w=1.9.r;h=1.9.D}}c{t:t,l:l,w:w,h:h}};3.a=6(v){v=12(v);c 14(v)?0:v};3.16.E=6(s){o=3.17(s);c u.18(6(){n 3.P.E(u,o)})};3.P.E=6(e,o){7 z=u;z.o=o;z.e=e;z.p=3.R(e);z.s=3.U();z.J=6(){1b(z.j);z.j=1c};z.t=(n N).Z();z.M=6(){7 t=(n N).Z();7 p=(t-z.t)/z.o.I;b(t>=z.o.I+z.t){z.J();11(6(){z.q(z.p.y,z.p.x)},13)}f{G=((-g.O(p*g.Q)/2)+0.5)*(z.p.y-z.s.t)+z.s.t;K=((-g.O(p*g.Q)/2)+0.5)*(z.p.x-z.s.l)+z.s.l;z.q(G,K)}};z.q=6(t,l){d.19(l,t)};z.j=15(6(){z.M()},13)};',62,78,'|document||jQuery|documentElement||function|var|currentStyle|body|intval|if|return|window||else|Math||scrollTop|timer|clientWidth||wb|new|||scroll|scrollWidth|||this||||||scrollLeft|hb|clientHeight|scrollHeight|ScrollTo|offsetHeight|st|innerHeight|duration|clear|sl|offsetWidth|step|Date|cos|fx|PI|getPos|offsetParent|offsetLeft|getScroll|offsetTop|borderLeftWidth|css|innerWidth|getTime|borderTopWidth|setTimeout|parseInt||isNaN|setInterval|fn|speed|each|scrollTo|while|clearInterval|null|getClient|width|height'.split('|'),0,{}));
	/* apply the scroll */
	$.fn.scrollToHash = function(){
		return this.each(function(){
			$(this).click(function(){
				$(this.hash).ScrollTo(1500,'easeout')[0].blur();
				return false;
			});
		});
	};
	/* in-page nav menu plugin by Joel Birch */
	$.fn.contentMenu = function(o){
		o = $.extend({
			"head"		: "<h3>Some handy in Page Links:</h3>",
			"beforeLink": "Goto ",
			"divClass"	: "contentMenu",
			"aClass"	: "inPage",
			"insertMethod"	: "insertBefore",
			"insertTarget"	: this.eq(0) }, o || {});
		$.cmCount = $.cmCount+1 || 0;
		var $list = $("<ul>");
		var lastInd = this.length-1;
		var lis = '';
		var menu = $('<div class="'+o.divClass+'"></div>').append(o.head,$list);
		switch (o.insertMethod){
			case "insertAfter":
				menu.insertAfter(o.insertTarget);
				break;
			case "append":
				o.insertTarget.append(menu);
				break;
			case "prepend":
				o.insertTarget.prepend(menu);
				break;
			default :
				menu.insertBefore(o.insertTarget);
		}
		return this.each(function(i){
			this.id = this.id || "menu"+$.cmCount+"-el"+i;
			lis += '<li><a href="#'+this.id+'" class="'+o.aClass+'">'+o.beforeLink+'<em>'+$(this).text()+'</em></a></li>';
			if (i==lastInd){ $list.append(lis); }
		});
	};
	/*  plugin by Joel Birch */
	$.fn.anchorsToImg =	function() {
		this.find("a").add(this.filter("a")).each(function() {
			if (this.href.substr(this.href.length-4)==('.jpg' || '.gif' || '.png') ) { /*workaround for IE substr bug - but even this doesn't work*/
				var $$ = $(this);
				$$.after('<img src="'+$$.attr("href")+'" alt="" />').remove();
			}
		}).end();
		return this;
	};
	/*  plugin by Joel Birch - version 1.0 beta*/	
	$.so={};
	$.so.pr=[]; //instance properties and methods
	$.so.o=[{ //instance options
		ssClass : 'showoff',
		initCSS : {},
		animIn : {opacity:'show'},
		animOut : {opacity:'hide'},
		speedIn : 2400,
		speedOut : 2400,
		delay : 5000,
		scaleImages : true,
		autoPlay : true
	}];
	$.fn.showoff = function(o){
		return this.each(function(i){
			//properties
			this.serial = $.so.o.length;
			$.so.o[this.serial]=$.extend({},$.so.o[0], o || {});
			var s=this.serial,
				items = [],
				ind = 0,
				paused = false,
				an = false,
				parWidth = '';
				$$ = $(this).addClass($.so.o[s].ssClass),
			//methods
				getNext = function(){
					var $item = $($.so.pr[s].next || items[getIndex()]).hide().css({position:'absolute'});
					setScale($item);
					return $item.appendTo($$);
				},
				getIndex = function(){
					return ind = (ind < items.length-1) ? ind+1 : 0;
				},
				setScale = function($item) {
					var v = ($.so.o[s].scaleImages) ? '100%' : '';
					$item.find("img").css({height:v,width:v});
				},
				getPrev = function(){
					return $$.children(":first");
				},
				showItem = function($item){ 
					an=true;
					$item.css($.so.o[s].initCSS)
					.animate($.so.o[s].animIn,$.so.o[s].speedIn,function(){
						an=false;
						$.so.pr[s].next=null;
						if ($.so.o[s].autoPlay && !paused) {
							$$[0].t=setTimeout(change,$.so.o[s].delay);	//perpetuate slideshow
						}
					});
				},
				hideItem = function($item){
					$item.animate($.so.o[s].animOut,$.so.o[s].speedOut,function(){
						getPrev().remove();
					});
				},
				pause = function(){
					paused=true;
					clearTimeout($$[0].t);
				},
				change = function(){
					paused=false;
					if (!an) {
						hideItem( getPrev() );
						showItem( getNext() );
					}
				};
			//retain scope of functions for use in plugin plugins
			$.so.pr[s]={
				resume : change,
				pause : pause
				};
			//parent needs to be position relative or absolute
			var pos = $$.css('position');
			if (pos != 'absolute' && pos != 'relative') { $$[0].style.position='relative'; }
			//populate array then empty container
			items = $$.children();
			var $first = $$.children().gt(1).remove().end();
			//init
			setScale( $first );
			if ($.so.o[s].autoPlay){
				change();
			}
		});
	};

	/* initialise all */
	$(function(){
		//$("#greeting").hide();	
		$(".techTable").stripe();
		
		// read language cookie
		// set in frontend_render/language_switch.php
		if (GetCookie("setlang") == "en") {
		  $("body").find("#rightBlock h3,div.exd_head").contentMenu({aClass:"scrolls",divClass:"inPageMenu",beforeLink:"Goto ",head:"<h4>Index:</h4>"});
		}else{
		  $("body").find("#rightBlock h3,div.exd_head").contentMenu({aClass:"scrolls",divClass:"inPageMenu",beforeLink:"Gehe zu ",head:"<h4>Index:</h4>"});
		}
		
		$("a.scrolls").scrollToHash();
		$('#rightBlock').ScrollToAnchors(500);
		
	});


//alert(GetCookie("setlang"));
	
	
	/*$(window).load(function(){
		$("#greeting").slideDown(1500,function(){
			this.style.height = '';
			setTimeout(function() {
				$("#introExtra").anchorsToImg().showoff({
					initCSS : {width:"103px",height:"74px"},
					animIn : {opacity:"show",width:228,height:164},
					animOut : {opacity:"hide",width:275,height:198},
					speedOut : 1000 })
				.find("img.hide")
					.removeClass("hide");
			},1500);
		});
	});*/
}) (jQuery);

// Cookies setzen mit PHP und mit JS auslesen, für die Übersetzuing
// des Seiten Index Menü welches eingeblendet wird (auf basis aller <hx> tags)
//Cookie lesen:
function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
      i = document.cookie.indexOf(" ", i) + 1;
      if (i == 0) break;
  }
  return null;
}

// Cookie-Wert auslesen:
function getCookieVal(offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}