//// ServiceMethodes

picsFlashed = false;

function getVariable(id){
	return this[id];
}

function DOMtoXML( node, blanks ){
	
	//if( typeof(node) == "string" ) node = $(node);	
	
	if(!blanks) var blanks = "";
	
	var xStr = "";
	if(node){
		if(node.nodeType==1){		
			
			var nn = node.nodeName.toLowerCase();
			xStr = "\n"+blanks+"<"+nn;	
			
			if(node.attributes) for(var i=0; i<node.attributes.length; i++){
				var a = node.attributes[i];
				var an = a.nodeName;
				var av = node.getAttribute(an);
				if(av!=null && String(av)!="" && String(av).indexOf("function")!=0) xStr+=" "+an+"=\'"+av+"\'";
				//if(a.nodeValue.indexOf("function()")!=0) xStr+=" "+a.nodeName+"=\'"+a.nodeValue+"\'";
			}
			
			if(node.childNodes.length>0){			
				//xStr += " childNodes=\""+node.childNodes.length+"\">";
				xStr += ">";
				var containsElements = false;
				for(var i=0; i<node.childNodes.length; i++){
					if(node.childNodes[i].nodeType==1){
						xStr += DOMtoXML( node.childNodes[i], blanks+"	" );
						containsElements = true;
					} else {
						xStr += node.childNodes[i].nodeValue;
					}
				}
				if(containsElements) xStr+="\n"+blanks;
				xStr+="</"+nn+">";	
			} else {
				xStr+="/>";		
			}
			
		} else {
			
			xStr = "\n"+blanks+node.nodeValue;
			
		}
	}
	//if(blanks=="") alert("xml\n------------------\n"+xStr);
	
	return xStr;
}

var ng = navigator.userAgent.toLowerCase();
if( (ng.indexOf('iphone')==-1) && (ng.indexOf('opera')==-1) ){	
	
	traceWin = false;	
	trace = function(str){
		/*
		if(!traceWin){		
			traceWin = window.open("about:blank", "traceWin", "scrollbars=yes,resizable=yes,width=300,height=500,left=10,top=10");
			traceWin.document.open();
			traceWin.document.write("<style type='text/css'>body, p{ font-family:Courier, Courier New; font-size:7px; }</style>");
					
			//var b = window.document.getElementsByTagName("body")[0];
			//b.onunload = function(){ if(traceWin) traceWin.close(); };
		}
		traceWin.document.writeln( "<nobr>: "+str+"</nobr><br/>" );
		
		//new Effect.Appear(traceHolder, { duration: 3.0 });	
		//traceHolder.str += str+"<br/>";
		//tracePlain.firstDescendant().replace("<div>"+traceHolder.str+"</div>");
		*/
	}
	
	checkString = "Tolles Texterkennungstool das anzeigt wie weit die Schrift im aktuellen Browser läuft m.";
	
	//////////////////////////////////////
	
	checkStringWidth = function(str){
		var id = "checkText"+Math.random();
		Element.insert(window.document.getElementsByTagName("body")[0], { top:"<span id='"+id+"' style='font-family: Verdana, Arial, Helvetica, sans-serif;  font-size: 10px;'>"+str+"</span>" });
		var e = $(id);
		var w = Element.getWidth(e);
		Element.remove(e);
		return w;	
	}
	
	getLocalPath = function(str){
		
		var n = str.indexOf("#")
		if(n!=-1)	str = str.substring(0,n);
		
		if( str.indexOf("http://")==0 ){
			h = str.split("/");
			h.splice(0,3);
			str = "/"+h.join("/");
		}
		
		return str;
	}
	
	deStealthMail = function (node,linkText){
		var mail = "";
		for(var i=0; i<node.childNodes.length; i++){
			var n = node.childNodes[i];
			if(n.src!=undefined) mail+="@";
			else if(n.nodeType==3) mail+=n.data;
		}
		node.href="mailto:"+mail;
		if (linkText == "") node.innerHTML = mail;
		else node.innerHTML = linkText;
	}
	
	deStealthMails = function(e){
		//if(!e) var e=document;
		if(!e) var e = $("body00");
		var nodes = Element.select(e, "a");
		//var nodes = Element.select(e, "[href='#stealth']");
		//alert(e+"\n\n"+nodes);
		var linkText = "";
		for(var i=0; i<nodes.length; i++) {
			if( (nodes[i].href).indexOf("#stealth")!=-1 ) {
				var linkImage = nodes[i].getElementsByTagName("img");
				var linkText = linkImage[0].getAttribute('alt');
				if(linkText == null) {linkText = ""};
				deStealthMail(nodes[i],linkText);
			}
		}
	}
	
	naviGate = function( href, a ){
		// trace"naviGate("+href+", "+a+")");
		if(a!=undefined) contentHolder.fromRight = ( Element.up(a, '.pagingL')!=undefined );
		var n = chronicle.getLink( getLocalPath(href) );
		contentHolder.loadXML(href);
		if(n) if(n.loadHref) n.loadHref(true);
		
		//trace("activate Link: "+n);
		
		//if(n) n.setActive(true);	
		
	}
	
	linkToAjax = function( a ){	
		if( (!a.target || a.target=="_self") && !Element.hasClassName(a, "nonAjax") && a.href.indexOf("mailto:")==-1 && a.href.indexOf("javascript:")!=0 ){
			Element.extend(a);
			
			// a.href = getLocalPath(a.href);
			// trace("href: "+getLocalPath(a.href)+" // "+a.href);
			
			a.onclick = function(){
				//alert(this.href);
				naviGate(this.href, this);
				this.blur();
				return false;
			}
		} else a.onclick = function(){ this.blur(); return true; }
	}
	
	allLinksToAjax = function( e, isPrPics ){
		// trace"allLinksToAjax("+e+")");
		
		deStealthMails(e);
	
		// Links ersetzen
	
		var ls = Element.select( e, 'a');
		for(var i=0; i<ls.length; i++){
			linkToAjax(ls[i]);
			//trace(ls[i]);
		}
		
		if(isPrPics!=true){
			
			// Alter Textlength ///////////////
			var ct = Element.select(e, '.contentText', '.accEno .eRight .eHead');
			for(var i=0; i<ct.length; i++){
				Element.setStyle(ct[i], {
					width: contentHolder.contentTextWidth+"px"
				});
			}
			
			// Zoom Images //////////////////
			
			if(contentHolder.activeContent){		
				
				var a = Element.select(contentHolder.activeContent, ".zoomImage")[0];
				
				if(a){
					var img = a.getElementsByTagName("img")[0];
					a.img = img;
					a.img.a = a;
					a.isBig = false;
					
					var cNames = $w(a.className)
					for(var i=0; i<cNames.length; i++) if(cNames[i]!="zoomImage"){
						var cDimensions = cNames[i].split("z");
						a.maxWidth = Number(cDimensions[1]);
						a.maxHeight = Number(cDimensions[2]);
						break;					
					}			
					
					a.onclick = function(){
						if(!this.zooming){
							this.zooming=true;						
							this.blur();
							if(!this.smallWidth){
								Element.absolutize(this.img);
								var l = this.img.getStyle('left');
								this.smallLeft = parseInt( l.substring(0,l.length-2) );
								
								var t = this.img.getStyle('top');
								this.smallTop = parseInt( t.substring(0,t.length-2) );
														
								this.smallWidth = this.img.getWidth();					
								this.smallHeight = this.img.getHeight();
								
								this.smallStyle = {
									top: this.smallTop+"px",
									left:	this.smallLeft+"px",
									width: this.smallWidth+"px",
									height:this.smallHeight+"px"
								}
							}
									
							//Calculate Size
							
							var vpo = Element.viewportOffset(this.img);					
							var vpd = document.viewport.getDimensions();
							
							var f = Math.min( (vpd.width-80)/this.smallWidth, (vpd.height-120)/this.smallHeight );
							if(this.maxWidth) f = Math.min( f, this.maxWidth/this.smallWidth );	
							
							this.bigWidth = this.smallWidth*f; 
							this.bigHeight = this.smallHeight*f;
							
							this.bigLeft = this.smallLeft + vpd.width/2 - this.bigWidth/2 - vpo.left;					
							this.bigTop = this.smallTop + vpd.height/2 - this.bigHeight/2 - vpo.top;
							
							this.bigStyle = {
								top: this.bigTop+"px",
								left: this.bigLeft+"px",
								width: this.bigWidth+"px",
								height:this.bigHeight+"px"
							}
							
							//Load Image
							if(!this.loadedBig){
								this.loadedBig = true;
								
								this.imgPreloader = new Image();
								this.imgPreloader.a = this;							
								this.imgPreloader.src = this.href;							
								this.appendChild(this.imgPreloader);
								
								Element.absolutize(this.imgPreloader);							
								Element.hide(this.imgPreloader);						
								Element.setStyle( this.imgPreloader, this.smallStyle );
								
								this.imgPreloader.onload = (function(){
									Element.show(this.imgPreloader);
									Element.remove(this.img);
									this.img =this.imgPreloader;
									//delete this.imgPreloader;
									this.imgPreloader = undefined;
								}).bind(this);
								
								Element.insert( this, { top:"<div style='width:940px;height:570px;background-color:#FFFFFF'>&nbsp;</div>" } );
								
								this.bg = this.getElementsByTagName("div")[0];
								Element.absolutize(this.bg);
								
								this.bg.a = this;
								this.bg.hide();
								//var vpo = Element.viewportOffset(this.bg);							
							}
							
							var st = {
								duration: .5
							}					
							
							this.isBig = !this.isBig;
							
							if(this.isBig){ // Zoom In
								Element.setStyle( contentHolder, { zIndex: 1100 });
								
								if(this.bg){
									this.bg.setStyle({
										left:			"-70px",//-vpo.left+"px",
										top:			"-50px",//-vpo.top+"px",
										width:		"940px",//vpd.width+"px",
										height:		"570px"//vpd.height+"px"
									});
									this.bg.fx = new Effect.Appear(this.bg, {
										duration: .3 // Core Effect properties
									});
								}
								
								st.style = this.bigStyle;
								st.delay = 0.3;							
								st.afterFinish = function(ob){
									ob.element.a.zooming = false;
								}
							} else { // Zoom Out
								if(this.bg){
									this.bg.fx = new Effect.Fade(this.bg, {
										delay:	.5,
										duration: .8,
										afterFinish: function(ob){
											Element.setStyle( contentHolder, { zIndex: 900 });
											ob.element.a.zooming = false;
										}
									});
								}
														
								st.style = this.smallStyle;	
								//st.delay = 0;
								//st.afterFinish = undefined;
							}
							
							new Effect.Morph(this.img, st);
							
							if(this.imgPreloader) new Effect.Morph(this.imgPreloader, st);
						}
						return false;
					}
				}
			}
			
			// Accordeon ///////////////////
			
			var accs = Element.select( e, ".accordion");
			for(var i=0; i<accs.length; i++){
				var acc = accs[i];		
				
				acc.activate = function( e ){
					//alert("activate: "+e);
					for(var i=0; i<this.activeElements.length; i++){
						if(e==this.activeElements[i]){
							var isActive = true;
						} else {
							//this.activeElements[i].className = (this.activeElements[i].hasClassName("first"))? "accE first" : "accE";
							
							this.activeElements[i].className = this.activeElements[i].normalClassName;
							
							var b = this.activeElements[i].bodies;	
							for(var j=0; j<b.length; j++){
								//if( b[j].fx ) b[j].fx.cancel();
								if( b[j].fx ) for(var k=0; k<b[j].fx.effects.length; k++) b[j].fx.effects[k].cancel();
							
								//b[j].fx = Effect.closeAcc( b[j], { duration: 0.7 });							
								b[j].fx = new Effect.Parallel([
									new Effect.Morph( b[j], { sync: true, style: {
										height: '0px',
										paddingBottom: '0px'
									} }),
									new Effect.Fade( b[j] )
									//new Effect.Opacity( b[j], { sync: true, to: 0})
								], { 
									duration: 0.7
								});
								
							}
							
							this.activeElements.splice(i, 1);
							i--;
						}
					}
					
					if(!isActive && e){
					
						this.activeElements.push(e);
						//e.className = (this.activeElements[i].hasClassName("first"))? "accEactive first" : "accEactive";				
						e.className = e.normalClassName+" accEon";
						
						var b = this.activeElements[i].bodies;				
						for(var j=0; j<b.length; j++){
							//if( b[j].fx ) b[j].fx.cancel();
							if( b[j].fx ) for(var k=0; k<b[j].fx.effects.length; k++) b[j].fx.effects[k].cancel();
							
							//b[j].fx = Effect.openAcc( b[j], { duration: 0.7 });
							b[j].fx = new Effect.Parallel([
								new Effect.Morph( b[j], { sync: true, style: { 
									height: b[j].height,
									paddingBottom: b[j].paddingBottom
								} }),
								new Effect.Appear( b[j] )
								//new Effect.Opacity( b[j], { sync: true, to: 1})
							], {							
								duration: 0.7
							});	
							
							
						}
					}
				}			
			
				acc.activeElements = Element.select( acc, '.accEactive.');
				acc.elements = Element.select( acc, '.accE').concat( acc.activeElements );
				for(var j=0; j<acc.elements.length; j++){		
					var e = acc.elements[j];
					e.accordion = acc;
					//e.className = (e.hasClassName("first"))? "accEactive first" : "accEactive";
					e.normalClassName = e.className = (e.hasClassName("clearfix"))? "accEactive clearfix" : "accEactive";
					e.bodies = Element.select( e, ".eBody");			
					for(var k=0; k<e.bodies.length; k++){
						b = e.bodies[k];
						b.height = Element.getStyle( b, 'height' );
						var h = Number( b.height.substring(0, b.height.length-2) );
						if( Element.ancestors(b)[0].hasClassName("eLeft")&&h<40 ) b.height = "150px";
						//alert(b.height);
						b.paddingBottom = Element.getStyle( b, 'padding-bottom' );
						//alert(b.paddingBottom);
						b.setStyle( {			
							'paddingBottom':'0px',
							'opacity':	0,
							'height':	'0px',
							'display': 'none',
							'overflow':'hidden'
							//'padding-bottom':	'0px'
							//display:'none', height:'80px'
						});
					}
					e.onmouseover = function(){
						// alert(this);
						this.accordion.activate(this);
					}
				}
			}	
			var ls = Element.select( e, '[class="prPics"]');
		} else {
			var ls = [e];	
		}
		
		for(var i=0; i<ls.length; i++){
			var pics = ls[i];
			if(isPrPics!=true) pics.className = 'prPicsJS';
			var la = Element.select( pics, 'a');
			for(var j=0; j<la.length; j++){
				var a = la[j];
				a.span = Element.select( a, 'span')[0];
				a.img = Element.select( a, 'img')[0];
				a.onmouseover = function(){
					if(this.fxFade) this.fxFade.cancel();
					this.fxFade = new Effect.Opacity(this.img, { to:0, duration: 0.3 });
					//new Effect.Fade(this.img, { duration: 0.3 });				
				};
				a.onmouseout = function(){
					if(this.fxFade) this.fxFade.cancel();
					this.fxFade = new Effect.Opacity(this.img, { to:1, duration: 0.3 }); 
					//new Effect.Appear(this.img, { duration: 0.3 });
				};
			}
		}	
	}
	
	initAjax = function(){
		if(!inited){
			var inited =true;
					
			// General	
			
			$('body00').setStyle({ overflow:'hidden' });
									
			contentHolder = $('content');
			contentHolder.contentTextWidth = checkStringWidth(checkString)-2;
			// trace"contentHolder.contentTextWidth: "+contentHolder.contentTextWidth);
			inav = $('iNav');
			ihead = $('iHeadline');		
			navi = $('nav');
			
			allLinksToAjax($('body00'));	
					
			// Navi //////////////////////////////////////////////
			
			navi.links = navi.select('a');
			navi.lists = [];
			
			//navi.active = undefined;
			chronicle = [];
			chronicle.add =function( h, n, notActive ){
				h = getLocalPath(h);
				var ob;
				for(var i=0; i<this.length; i++) if(this[i].href==h){  ob =this[i];	break; }
				if(ob==undefined){
					ob = { href:h, navi:n };
					this.splice(0,0, ob);
				}
				if( notActive!=false ) chronicle.active = ob;
				return ob;
			}
			chronicle.getLink =function( h ){
				h = getLocalPath(h);
				for(var i=0; i<this.length; i++){
					//trace("search("+h+": "+i+" | "+this[i].href);
					if(this[i].href==h){
						return this[i].navi;
						break;
					}
				}
				return undefined;
			}
			
			navi.naviGateLink = function(href){
				var ok = false;
				for(var i=0; i<this.links.length; i++){				
					if(this.links[i].localHref==href){
						// trace("\""+this.links[i].localHref+"\"==\""+href+"\"");
						this.links[i].loadHref();
						return ok = true;
						break;
					}
				}
				return ok;
			}
			navi.activeLinks = [];
			navi.deactivate = function(){
				for(var i=0; i<this.activeLinks.length; i++) this.activeLinks[i].setActive(false);
				this.activeLinks = [];
			}
			navi.setVisibility = function(v){
				if(v!=this.visible){
					this.visible = v;
					var links = Element.select(navi, "a");
					for(var i=0; i<links.length; i++){
						if(links[i].effect) links[i].effect.cancel();
						links[i].effect = ( Element.hasClassName(links[i], "naviActive") )? new Effect.Opacity(links[i], { to: 1, duration: .5 }) : links[i].effect = new Effect.Opacity(links[i], { to: this.visible, duration: (v)? .5 : 2, delay: (v)? 0 : 1 });
					}
				}
			}
			
			navi.onmouseout = function(){ navi.setVisibility(false); }
			navi.onmouseover = function(){ 			
				navi.setVisibility(true);
				var accs = Element.select( window.document, '[class="accordion"]');
				for(var i=0; i<accs.length; i++) if(accs[i].activate) accs[i].activate(undefined);
			}
			
			for(var i=0; i<navi.links.length; i++){
				
				var a = navi.links[i];		
				Element.extend(a);			
				a.localHref = getLocalPath(a.href);
				
				var ancestors = Element.ancestors(a);
				
				a.parent = ancestors[0];
				a.parentList = ancestors[1];
				
				if(a.parentList.items){
					a.parentList.items.push(a);				
				} else {
					navi.lists.push(a.parentList);
					a.parentList.items = [a];	
				}
				
				Element.setStyle( a.parentList, {	'top': (a.parentList==navi)? "0px" : "23px" });
				a.parentLink = (ancestors[2])? ancestors[2].childElements()[0] : null;
				
				if(!a.parentList.processed){
					a.parentList.processed = true;
					a.parentList.displayStyle = a.parentList.getStyle('display');
					a.parentList.setStyle({ display:"block" });
				}
				a.x = Position.positionedOffset(a.parent)[0];		
				a.w = Element.getWidth(a);
							
				a.childList = Element.select( a.parent, 'ul' )[0];
				if(a.childList){		
					a.childList.childLinks = a.childLinks = Element.select( a.childList, 'a' );
					//var dp = Element.getStyle(a.childList, "display");
					a.childList.changeOpacity = function(d){
						//trace("opacity: "+Element.getStyle(this, 'opacity')+" | display:"+Element.getStyle(this, 'display'));
						/*					
						for(var i=0;i<this.childLinks.length; i++){
							var l = this.childLinks[i].parent;
							if(l.fxFade) l.fxFade.cancel();
							if(d==true) l.fxFade = new Effect.Appear(l, { duration: 0.5 });
							else l.fxFade = new Effect.Fade(l, { duration: 0.3 });						
						}
						*/
						if(this.fxFade) this.fxFade.cancel();
						if(d==true) this.fxFade = new Effect.Appear(this, { duration: 0.5 });
						else this.fxFade = new Effect.Fade(this, { duration: 0.5 });
						
					}
					//Element.show(a.childList);				
				} else {
					a.childLinks = null;
				}
							
				if(a.hasClassName('naviActive')){
					navi.activeLinks.push(a);
					chronicle.add( a.localHref, a );
				} else {
					chronicle.add( a.localHref, a, false );
				}
				
				a.loadHref = function(noLoad){			
					//this.active = true;				
					var master = this;
					if(!noLoad){
						if(this.childLinks) for(var i=0; i<this.childLinks.length; i++){
							if(this.childLinks[i].href == this.href){
								var master = this.childLinks[i];
								break;
							}
						}
					}
					//trace( !(master) );
					if(master==this){
						navi.active = {
							href: this.href, //(noLoad)? : this.href,
							navi:this
						}
						navi.setVisibility(true);
						navi.deactivate();
						master.setActive(true);					
						if(!noLoad) contentHolder.loadXML(master.href);							
					} else {
						master.loadHref(noLoad);
					}				
				}
				
				a.getActive = function(){	return (this.__active==true);	}			
				a.setActive = function(a , follow){
					this.active = this.__active = a;
					if(a){
					
						if(this.childList) this.childList.changeOpacity(true);
						
						//trace("active: "+this);
						navi.activeLinks.push(this);
						this.className = 'naviActive';
						
						// Verschieben					
						new Effect.Move(this.parentList, { 
							x: -this.x,
							y: (this.parentList==navi)? 0 : 23,
							mode: 'absolute',
							duration: 0.5/*,
							delay: 0.5*/
						});
						
						if(this.parentLink.setActive) this.parentLink.setActive(true, true);
						
						if(!follow && this.childList){
							new Effect.Move(this.childList, { 
								x: 0,
								y: 23,
								mode: 'absolute',
								duration: 0.5/*,
								delay: 0.5*/
							});					
						}
						
					} else {
					
						this.className = 'naviInActive';
						if(this.childList) this.childList.changeOpacity(false);
						
					}
				}
				a.onclick = function(){
					//alert("test"+this);
					this.loadHref();
					this.blur();
					return false;
				}
			}
			
			//var txt = "";
			
			for(var i=0; i<navi.lists.length; i++){
				var x = 0;
				for(var j=0; j<navi.lists[i].items.length; j++){
					var item = navi.lists[i].items[j];
					item.x = x;
					Element.setStyle(item.parent, { left:x+"px" });
					x += item.w + 16;
					/*
					var ul = navi.links[i].parentList;
					//txt += "\n\n"+ul.displayStyle;
					if(ul.displayStyle) ul.setStyle({ display:ul.displayStyle });
					*/
				}
			}		
			
			for(var i=0; i<navi.links.length; i++){
				/*if(navi.links[i].parentList) navi.links[i].parent.setStyle({ display: navi.links[i].parentList.displayStyle });
				*/
				var ul = navi.links[i].parentList;
				//txt += "\n\n"+ul.displayStyle;
				if(ul.displayStyle) ul.setStyle({ display:ul.displayStyle });			
			}
				
			// Content
			
			contentHolder.xMax = 600; //1500;
			contentHolder.xMin = -600; //-1500;
			contentHolder.activeContent = contentHolder.firstChild;
			contentHolder.fromRight = false;
			
			contentHolder.processContent = function(transport){
				// trace"--------------");
				// trace(this+".processContent("+this.activeContent+")");
				
				Element.extend(this.activeContent);
				var e = this.activeContent;
				e.isFlash = false;
				
				if(transport) if(transport.responseText){
			
					var text = e.responseText = transport.responseText;
					e.scriptBlocks = transport.responseText.extractScripts();
					e.flashIds = [];
					e.flashDivs = [];
					var s = "swfobject.embedSWF(";
					var pos = text.indexOf(s);
					while(pos!=-1){
						var endPos = text.indexOf( ")", pos );					
						var txt = text.substring( pos+s.length, endPos );
						var attributes = txt.split(",");
						var flashId = attributes[1].substring(2,attributes[1].length-1);					
						e.flashIds.push(flashId);
						var flashDiv = $(flashId);
						e.flashDivs.push( flashDiv );
						var pos = text.indexOf(s, endPos);
					}
					
					if( swfobject.hasFlashPlayerVersion("8") ){
					
						var nf = Element.select(e, ".noFlash");
						for(var i=0; i<nf.length; i++) Element.remove(nf[i]);
						
						//if( e.flashDivs.length>0 ){
						for(var i=0; i<e.flashDivs.length; i++) if( !Element.hasClassName( e.flashDivs[i], "flashSwitch" ) ){
							e.isFlash = true;
							flashDiv.setStyle({ 'display':'none' });
							break;
						}
					
					} else {
					
					}
					/*e.scriptBlocks = [];
					// trace(":: Scriptblöcke finden ::::");
					// Scriptblöcke finden
					var text = transport.responseText
					var pos = text.indexOf("<script");
					// trace(pos+" // "+(pos!=-1));
					while(pos!=-1){
						// trace("while");
						var posStart = text.indexOf(">", pos)+1;
						// trace("posStart:"+posStart);
						if(text.charAt(posStart-1) == "/"){
							// trace("closed Script: "+text.substring(pos,posStart) );
						} else {
							var posEnd = text.indexOf("</script>", posStart);
							var scriptText = text.substring(posStart, posEnd);
							e.scriptBlocks.push(scriptText);
							// trace(posStart+" - "+posEnd+" scriptBlocks["+(e.scriptBlocks.length-1)+"] = "+scriptText);
							eval(scriptText);
						}
						pos = text.indexOf("<script", posEnd);
						// trace(pos+" // "+(pos!=-1));
					}*/
				}
				
				// Bild Navigation /////////////////////////////////////////////
				
				var prPics = undefined;
				var prPics = Element.select( e, ".prPicsJS" )[0];
				
				if(picsFlashed){
					//picsFlashed = false;
				} else if(prPics){		
					// trace"edit prPics: "+prPics);			
					// Pfeile bearbeiten
					
					var setVis = function(v){
						//alert(this+".visible = "+this.visible+" => "+v);
						if(v!=this.visible){
							this.visible = v;
							if(this.fx) this.fx.cancel();
							this.fx = (v)? new Effect.Appear(this.parentNode) : new Effect.Fade(this.parentNode);
						}				
					}
					
					prPics.arrowLast = Element.select( e, ".lastImageBlock" )[0];
					if(prPics.arrowLast){
						prPics.arrowLast.master = prPics;
						
						prPics.arrowLast.visible = !(Element.getStyle( prPics.arrowLast.parentNode, "display" ) == "none");
						prPics.arrowLast.setVisibility = setVis;					
						prPics.arrowLast.onclick = function(){
							this.master.lastBlock();
							this.blur();
							return false;
						}
					}
					
					prPics.arrowNext = Element.select( e, ".nextImageBlock" )[0];
					if(prPics.arrowNext){
						prPics.arrowNext.master = prPics;
						prPics.arrowNext.visible = !(Element.getStyle( prPics.arrowNext, "display" ) == "none");
						prPics.arrowNext.setVisibility = setVis;
						prPics.arrowNext.onclick = function(){
							this.master.nextBlock();
							this.blur();
							return false;
						}
						
						prPics.href = prPics.arrowNext.href;
						prPics.arrowNext.href = "is weg";
						var pos = prPics.href.indexOf("?")
						if(pos!=-1) prPics.href = prPics.href.substring(0,pos);				
					}
					
					prPics.nextBlock = function(){
						var no = this.position+6;
						
						if(no<this.blockNo){	
							var b = this.blocks[0];
							
							this.blocks.splice(0,1);
							this.position++;
							
							if(b.fx) b.fx.cancel();
							b.fx = new Effect.Parallel([
								new Effect.Morph( b, { 
									style: { width: '0px' },
									sync: true,
									afterFinish: function(ob){
										if(ob.element) Element.remove(ob.element);				
									}
								}),
								new Effect.Opacity( b, { sync: true, to: 0 })
							], { 
								duration: 0.7							
							});
							
							new Ajax.Request( prPics.href+"?block="+no, {
								asynchronous:true,
								method: 'post',
								evalScripts: false,
								parameters: {
									'reload': Math.random()
								},
								onSuccess: function(transport){								
									var a = new Element('div');
									a.update(transport.responseText);							
									var c = a.firstChild.firstChild;
									Element.insert( prPics.blocks[prPics.blocks.length-1], { after:c });
									prPics.blocks.push( c );
									allLinksToAjax( c, true );
									Element.setStyle( c, {width:"0px", opacity:0} );
									c.fx = new Effect.Parallel([
										new Effect.Morph( c, {
											style: { width: '130px'	},
											sync:true
										}),
										new Effect.Opacity( c, {
											sync: true,
											to: 1
										})
									], {
										duration: 1
									});
								}
							});				
						}
						this.controlArrows();
					}
					
					prPics.lastBlock = function(no){
						var no = this.position-1;
						//alert("nextBlock: "+no);
						if(no>=0){	
							var b = this.blocks[5];
							//b.remove();
							this.blocks.splice(this.blocks.length-1,1);
							this.position--;
							
							if(b.fx) b.fx.cancel();					
							b.fx = new Effect.Parallel([
								new Effect.Morph( b, { 
									style: { width: '0px' },
									sync: true,
									afterFinish: function(ob){
										if(ob.element) Element.remove(ob.element);				
									}
								}),
								new Effect.Opacity( b, { sync: true, to: 0 })
							], { 
								duration: 0.7							
							});
							
							new Ajax.Request( prPics.href+"?block="+no, {
								asynchronous:true,
								method: 'post',
								evalScripts: false,
								parameters: {
									'reload': Math.random()
								},
								onSuccess: function(transport){
									var a = new Element('div');
									a.update(transport.responseText);							
									var c = a.firstChild.firstChild;
									Element.insert( prPics.blocks[0], { before:c });
									prPics.blocks.splice(0,0,c);
									allLinksToAjax( c, true );	
									Element.setStyle( c, {width:"0px", opacity:0} );
									c.fx = new Effect.Parallel([
										new Effect.Morph( c, {
											style: { width: '130px'	},
											sync:true
										}),
										new Effect.Opacity( c, {
											sync: true,
											to: 1
										})
									], {
										duration: 1
									});
								}
							});	
							this.controlArrows();
						}				
					}
					
					prPics.controlArrows = function(){
						if(this.arrowNumbers)	this.arrowNumbers.innerHTML = (this.position+1)+" / "+(this.blockNo-6+1);
						if(this.arrowLast) this.arrowLast.setVisibility( (this.position>0) );
						if(this.arrowNext) this.arrowNext.setVisibility( (this.position<this.blockNo-6) );
					}
					
					prPics.processBlock = function(block){
						var cname = block.className
						if(cname.length<8){
							return false;
						} else {
							var cnames = cname.split(" ");
							block.no == undefined;
							for(var i=0; i<cnames.length; i++) if( cnames[i].indexOf("prPicsDiv")==0 ){
								block.no = Number( cnames[i].substring(9) );
								break;
							}
							return (block.no != undefined);	
						}
					}
					
					prPics.blocks = Element.select( e, "div" );
					for(var i=0; i<prPics.blocks.length; i++){
						if( !prPics.processBlock(prPics.blocks[i]) ){
							prPics.blocks.splice(i,1);
							i--;	
						}
					}
					
					prPics.position = prPics.blocks[0].no;								
					prPics.blockNo = Number(Element.select( e, ".blockNo")[0].innerHTML);
					prPics.arrowNumbers = Element.select( e, ".pagingNo" )[0];
					prPics.controlArrows();		
				}
				
				// innerNav austauschen /////////////////////////////////////////////
				
				var inavNew = Element.select( e, ".innerNav" )[0];
				
				var same = false;
				if(inavNew){
					Element.remove( inavNew );
					var al = (inav.activeMenu)? inav.activeMenu.childElements().length : 0;
					var nl = inavNew.childElements().length;
					same = (al == nl);
					trace("process innerNav: same="+same+", "+inavNew.innerHTML);
				}	else trace("process no innerNav: same="+same);
				
				if(same){
					if(inav.activeMenu){
						Element.remove(inav.activeMenu);
						//delete inav.activeMenu;
						inav.activeMenu = undefined;
					}
					if(inavNew) inav.activeMenu = inav.appendChild(inavNew);
				} else {
					if(inav.activeMenu){
						if(inav.activeMenu.fx) inav.activeMenu.fx.cancel();
						inav.activeMenu.fx = new Effect.Fade( inav.activeMenu, { 
							duration: .7,
							afterFinish:function(ob){
								if(ob.element) Element.remove(ob.element);				
							}
						});
						var t = .5;	
						//delete inav.activeMenu;
						inav.activeMenu = undefined;
					} else{
						var t = 0;				
					}
					
					if(inavNew){
						inav.activeMenu = inav.appendChild(inavNew);
						Element.setStyle(inav.activeMenu ,{ 'opacity':0 } );
						inav.activeMenu.fx = new Effect.Opacity( inav.activeMenu, { 
							from:0, to:1, duration: 1, delay: t
						});
					}
				}
			
				// Headline austauschen /////////////////////////////////////////////
				
				var iheadNew = Element.select( e, ".headline" )[0];
				//trace("reaches Head 2");
				var same = false;
				
				if(iheadNew){
					Element.remove( iheadNew );				
					var e = (ihead.activeHead)? ihead.activeHead.innerHTML : "";
					var ne = iheadNew.innerHTML;				
					same = (e == ne);
					//alert(e+" == "+ne+" = "+same);
					// trace("process headline: same="+same+", "+iheadNew.innerHTML);
				} // else trace("process no headline: same="+same);
				//trace("reaches Head 3");
				if(same){
					if(ihead.activeHead){
						Element.remove(ihead.activeHead);					
						ihead.activeHead = undefined;
						//delete ihead.activeHead;
					}
					if(iheadNew) ihead.activeHead = ihead.appendChild(iheadNew);
				} else {
					if(ihead.activeHead){
						if(ihead.activeHead.fx) ihead.activeHead.fx.cancel();
						ihead.activeHead.fx = new Effect.Fade( ihead.activeHead, { 
							duration: .7,
							afterFinish:function(ob){
								if(ob.element) Element.remove(ob.element);				
							}
						});
						var t = .5;	
						ihead.activeHead = undefined;
						//delete ihead.activeHead;
					} else{
						var t = 0;				
					}
					
					if(iheadNew){
						ihead.activeHead = ihead.appendChild(iheadNew);
						Element.setStyle(ihead.activeHead ,{ 'opacity':0 } );
						ihead.activeHead.fx = new Effect.Opacity( ihead.activeHead, { 
							from:0, to:1, duration: 1, delay: t
						});
					}
				}
				//trace("reaches Head 4");
			}
			
			SWFAddress.onChange = function() {  
				//var h = window.location.hash.substring(1);
				var h = SWFAddress.getValue();			
				var un = getLocalPath(window.location.href);						
				//trace("SWFAddress.onChange => "+chronicle.active.href+" // "+un+" => "+h);
				if(h=="/") h = un;
				
				if(chronicle.active.href!=h){					
					if(chronicle.active.href){					
						naviGate(h);
					} else {
						contentHolder.activeHref = un;
					}
				}
			}
			
			contentHolder.loadXML = function (href, fromRight){
				var h = getLocalPath(href);						
				chronicle.add( h, navi.active );
				SWFAddress.setValue(h);
				
				if(this.activeContent){
					var noFlash = true;
								
					if(this.activeContent.isFlash){
						// trace"is Flash");
						Element.remove(this.activeContent);
						/*new Effect.Opacity(this.activeContent, { 
							from:1, 
							to:0,
							duration: .7,
							afterFinish:function(ob){
								ob.element.remove();				
							}
						});*/
						
						
					} else {
						// trace"is no Flash");
						var pos = (this.fromRight)? this.xMax : this.xMin;
						new Effect.Parallel([
							new Effect.Move(this.activeContent, { sync:true, x:pos, y:0, mode:'absolute' ,
								afterFinish:function(ob){
									if(ob.element) Element.remove(ob.element);				
								}
							}), 
							new Effect.Opacity(this.activeContent, { sync:true, from:1, to:0 })
						], { 
							duration: 0.7
						});
					}
					/*
					new Effect.Move(this.activeContent, { x:pos, y:0, mode: 'absolute', afterFinish:function(ob){
						ob.element.remove();				
					}});			
					new Effect.Opacity(this.activeContent, { from: 1.0, to: 0.7, duration: 0.5 });
					*/
				}
				
				var pos = (this.fromRight)? this.xMin : this.xMax;		
				var c = this.activeContent = new Element('div', { 'style':'position:absolute;left:'+pos+'px; width:960px;height:500px;' });
				c.href = href;
				this.appendChild(c);
				pageTracker._trackPageview( href );
				var ob = new Ajax.Updater(c, href, {
					method: 'post',
					evalScripts: false,
					parameters:{
						'reload': Math.random()
					},
					onComplete: function(transport){					
						// trace"xml loaded");
						
						allLinksToAjax( contentHolder.activeContent );
						contentHolder.processContent(transport);
						
						var c=contentHolder.activeContent;
						
						if(c){
							//Element.hide(c);			
							//	Element.setOpacity( c, 0 );
							/*
							new Effect.Parallel([
								new Effect.Move(c, { sync:true, x:0, y:0, mode:'absolute' }),
								new Effect.Appear(c)				
								//new Effect.Opacity(c, { sync:true, from:0, to:1 })
							], {
								delay: 0.3,
								duration: 0.7,
								afterFinish:function(){
									if( contentHolder.activeContent.responseText ){
										var c = contentHolder.activeContent;
										c.responseText.evalScripts();
										if(c.flashDivs) for(var i=0; i<c.flashDivs.length; i++){
											c.flashDivs[i].setStyle({ 'display': 'block' });
										}
									}
								}							
							});
							*/
							new Effect.Parallel([
								new Effect.Move(c, { sync:true, x:0, y:0, mode:'absolute' }),
								new Effect.Appear(c)				
								//new Effect.Opacity(c, { sync:true, from:0, to:1 })
							], {
								//delay: 0.2,
								duration: 0.7,
								afterFinish:function(){
									if( contentHolder.activeContent.responseText ){
										var c = contentHolder.activeContent;
										if( swfobject.hasFlashPlayerVersion("8") ) c.responseText.evalScripts();
										
										if(c.flashDivs) for(var i=0; i<c.flashDivs.length; i++){
											c.flashDivs[i].setStyle({ 'display': 'block' });
										}
																			
									}
								}
								
							});
						}
					}					
				});
				//ob.test = "lu";
				
				//new Effect.Move(c, { x:0, y:0, mode: 'absolute' });
				
				if(c){
					//Element.hide(c);			
					Element.setOpacity( c, 0 );
					
				}
			}
				
				
			// init ////////////////////////////////////////////////////
									
			allLinksToAjax(contentHolder.activeContent);
			contentHolder.processContent();	
			
			if(window.isHome){
				Element.setOpacity("container", 0 );
				/*Element.hide("body00");
				new Effect.Appear("body00", { 
					duration: 1, delay: 4
				});*/
				new Effect.Opacity("container", { 
					from:0, to:1, duration: 1, delay: 1
				});
			}
		}
	}

	document.observe("dom:loaded", initAjax );
}