		var ajaxTimeout;
		var xmlToShow;
		var DEF_PAGE_URL;
		var daRotator;
		var daHRotator;
		

 		function ajaxObject() {
 			var A;
			try
			{
				A=new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e)
			{
				try
				{
					A=new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (oc)
				{
					A=null;
				}
			}
			if(!A && typeof XMLHttpRequest != "undefined") A = new XMLHttpRequest();
			//if (!A) alert("error");
			return A;
		}

		function ajaxInit()
		{
			if (ajaxObject())
			{
				ajaxEnabled = true;
				ajaxInitLinks();

				// create instance of BitstyleRotator 
				daRotator = new BitstyleRotator('normal'); 
				daRotator.countDown(); 

				// create instance of BitstyleRotator for HOME
				daHRotator = new BitstyleRotator('home'); 
				if (DEF_PAGE_ID == "ajax1") daHRotator.countDown(); 
			}
		}


		// lädt eine seite per ajax
		// wird über vorbereitete links aufgerufen, also mainnav und subnav
		// 
		function ajaxLoad(uri, id)
		{
			//trace("ajaxLoad(" + uri + ", " + id + ")");
			// seite wird gesetzt, damit z.B. Druckversion die korrekte "aktuelle" Seite anzeigt
			DEF_PAGE_LAST_URL = DEF_PAGE_URL;
			DEF_PAGE_URL = uri;
			DEF_PAGE_ID_LAST = DEF_PAGE_ID;
			DEF_PAGE_ID = id;


			// wenn auf home drauf
			if (DEF_PAGE_ID == "ajax1")
			{
				changeContentBoxStatus("Off", false);
				// boxes @ home einbauen
				daHRotator.start();
			}
			// wenn von home weg
			else if (DEF_PAGE_ID_LAST == "ajax1" || DEF_PAGE_ID != "ajax1")
			{
				pfeil = (DEF_PAGE_ID != "ajax112" && DEF_PAGE_ID != "ajax107" && DEF_PAGE_ID != "ajax117");
				changeContentBoxStatus("On", pfeil);
				// boxes @ home alle machen
				daHRotator.stop();
			}


			// navi setzen
			ajaxPageTransform(id);

			if (uri.indexOf("?")) uri = uri + '&ajax';
			else  uri = uri + '?ajax';


			var x;
			x = ajaxObject();
			x.open("GET", uri, true);
			x.onreadystatechange = function()
			{
				if (x.readyState != 4) return;
				xmlToShow = x.responseText;
				ajaxWaitForShow();
			}
			x.send(null);
			delete x;
		}


		function ajaxHandleLink()
		{
			timeoutOpacity(-1);
			ajaxLoad(this.href, this.id);
			if (this.blur) this.blur();
			return false;
		}

		// id des aktuellen main navi punktes
		var actMainId = 0;
		// wird über den load-befehl eines "ajax.." links aufgerufen
		// hier also ggf header zeigen und sunavi anpassen
		function ajaxPageTransform(id)
		{
			pid = id.substr(4);
			
			//trace("ajaxPagesMain.length:" + ajaxPagesMain.length);
			for (var index in ajaxPagesMain)
			{
				if (index == pid)
				{
					// geklickter link ist mainnavi gewesen
					// setze neue actMainId
					if (actMainId != pid)
					{
						actMainId = pid;

						// subnavi
						subnaviEmpty();
						obj = document.getElementById('naviSub');
						if (obj && ajaxPagesSub['' + pid] && ajaxPagesSub['' + pid].length)
						{
							for (var subId in ajaxPagesSub['' + pid])
							{
								neuLi = document.createElement("li");
								neuA = document.createElement("a");
								neuA.setAttribute("href", ajaxPagesSub['' + pid][subId][1]);
								neuA.setAttribute("id", "ajax" + subId);
								neuText = document.createTextNode(ajaxPagesSub['' + pid][subId][0])
								neuA.appendChild(neuText);
								neuLi.appendChild(neuA);
								obj.appendChild(neuLi);
							}
						}

						neuLi = document.createElement("li");
						neuLi.className = 'empty';
						neuText = document.createTextNode("leer")
						neuLi.appendChild(neuText);
						if (obj) obj.appendChild(neuLi);

						// links neu initiieren
						ajaxInitLinks();
					}
				}
			}

			// set em class on
			setMainNavOn(pid);
			setSubNavOn(pid);
		}

		// hauptnavi erst alle off, dann den onnen auf on
		function setMainNavOn(id)
		{
			obj = document.getElementById("naviMain");
			arrA = obj.getElementsByTagName("a");

			actMain = getMainIdById(id);
			for (var i in arrA)
			{
				if (typeof(arrA[i].firstChild) == "object")
				{
					mon = '/bilder/navi/img.php?status=on&text=' + arrA[i].title;
					moff = '/bilder/navi/img.php?status=off&text=' + arrA[i].title;

					if (arrA[i].id == "ajax" + actMain)
					{
						arrA[i].firstChild.src = mon;
						arrA[i].firstChild.onmouseover = null;
						arrA[i].firstChild.onmouseout = null;
					}
					else
					{
						arrA[i].firstChild.src = moff;
						arrA[i].firstChild.onmouseover = function () { this.src = '/bilder/navi/img.php?status=on&text=' + this.alt; }
						arrA[i].firstChild.onmouseout = function () { this.src = '/bilder/navi/img.php?status=off&text=' + this.alt; }
					}
				}
			}
		}

		// subnavi erst alle off, dann den onnen auf on
		function setSubNavOn(id)
		{
			obj = document.getElementById("naviSub");
			if (!obj) return false;
			arrA = obj.getElementsByTagName("a");
			actSub = getSubIdById(id);
			for (var i in arrA)
			{
				if (arrA[i]) arrA[i].className = (arrA[i].id == "ajax" + actSub) ? 'on' : '';
			}
		}



		// 
		function subnaviEmpty()
		{
			obj = document.getElementById('naviSub');
			if (!obj) return false;
			while (obj.hasChildNodes())
			{
				obj.removeChild(obj.firstChild);
			}
		}







		function ajaxInitLinks()
		{
			links = document.getElementsByTagName("a"); 
			for (var i = 0; i < links.length; i++)
			{
				if (links[i].id.substr(0, 4) == "ajax" && links[i].id != "ajax120")
				{
					//trace(links[i].id + "-" + links[i].href);
					links[i].onclick = ajaxHandleLink;
				}
			}
		}


		function getMainIdById(id)
		{
			for (var indexMain in ajaxPagesSub)
			{
				for (var indexSub in ajaxPagesSub[indexMain])
				{
					if (parseInt(indexSub) == parseInt(id)) return parseInt(indexMain);
				}
			}

			if (ajaxPagesMain[id]) if (ajaxPagesMain[id].length) return id;
			return 0;
		}



		function getSubIdById(id)
		{
			for (var indexMain in ajaxPagesSub)
			{
				for (var indexSub in ajaxPagesSub[indexMain])
				{
					if (parseInt(indexSub) == parseInt(id)) return parseInt(indexSub);
				}
			}
			return 0;
		}



















		// inhalte anzeigen
		function ajaxShow()
		{
			obj = document.getElementById('maincontentbox');
			obj.innerHTML = xmlToShow + '&nbsp;';
			ajaxInitLinks();
			timeoutOpacity(1);

			// scroller anzeigen
			jsInit();
		}

		// warten bis inhalte da
		function ajaxWaitForShow()
		{
			if (!cActive) ajaxShow();
			else ajaxTimeout = window.setTimeout('ajaxWaitForShow()', 20);
		}

		// tracen
		function trace(value)
		{
			//obj = document.getElementById("tracer");
			//obj.innerHTML = value + "<br />" + obj.innerHTML;
		}



		// opacity blendings
		var cOpacity = 100;
		var cTimer = false;
		var cActive = false;
		var cTimeout = 10;


		function startEs()
		{
			timeoutOpacity(-1);
		}

		function timeoutOpacity(intDir)
		{
			if (cTimer) window.clearTimeout(cTimer);
			cActive = true;

			if (intDir < 0) cOpacity -= 20;
			else cOpacity += 20;

			obj = document.getElementById('maincontentbox');
			setOpacity(obj, cOpacity);

			if (intDir < 0)
			{
				if (cOpacity > 0) cTimer = window.setTimeout('timeoutOpacity('+intDir+')', cTimeout);
				else
				{
					cActive = false;
				}
			}
			else
			{
				if (cOpacity < 100) cTimer = window.setTimeout('timeoutOpacity('+intDir+')', cTimeout);
				else cActive = false;
			}
		}



		function setOpacity(obj, opacity) {
			opacity = (opacity == 100)?99.999:opacity; // IE/Win
			obj.style.filter = "alpha(opacity:"+opacity+")"; // Safari<1.2, Konqueror
			obj.style.KHTMLOpacity = opacity/100;  // Older Mozilla and Firefox
			obj.style.MozOpacity = opacity/100; // Safari 1.2, newer Firefox and Mozilla, CSS3
			obj.style.opacity = opacity/100;
		}


		function changeLang(lang)
		{
			var newURL;
			newURL = DEF_PAGE_URL;

			newURL = newURL.replace(/\/de\//, "/" + lang + "/");
			newURL = newURL.replace(/\/en\//, "/" + lang + "/");
			newURL = newURL.replace(/\/es\//, "/" + lang + "/");

			location.href = newURL;
		}



		// static





		function changeContentBoxStatus(status, pfeil) {
			obj = document.getElementById("mainbg");
			obj.className = "status" + status;

			
			obj2 = document.getElementById("maincontentbox");
			obj2.className = (pfeil) ? 'boxbig' : 'boxbigno';
		}



		function newsClose() {
			timeoutOpacity(-1);
			ajaxLoad(DEF_PAGE_LAST_URL, DEF_PAGE_ID_LAST);
		}
