onLoadList = new Array();

// Example: addOnLoad("someFunction");
function addOnLoad(func){
	onLoadList[onLoadList.length] = func;
}

function runOnLoad(){
	for(i in onLoadList){
		var addPar = "";
		//alert(onLoadList[i])
		if (onLoadList[i].indexOf("(") == -1) addPar = "()";
		eval(onLoadList[i]+addPar);
	}
}
window.onload = runOnLoad;


/* // ||||||||||||||||||||||||||||||||||||||||||||||||||
// Creating a new image element will force the browser
// to redraw the image. Simple image src swaping will not.
// 'Src swap' version
*/


function doNav(){
	//var image = document.getElementById("theimage");
	//var newimage = document.createElement("img");
	//var parent = image.parentNode;
	/*
	parent.replaceChild(newimage, image);
	newimage.setAttribute("id","theimage");
	newimage.setAttribute("src",this.href);
	newimage.setAttribute("alt",this.xtitle);
	//newimage.setAttribute("width",image.getAttribute("width"));
	//newimage.setAttribute("height",image.getAttribute("height"));
	*/
	var bgObj = document.getElementById('top');
	bgObj.style.backgroundImage = "url(" + this.href +")";
	curNav.className = "";
	this.className = "on";
	this.blur();
	curNav = this;
	return false;
}


function get_firstChild(o) { 
	return (o.firstChild.nodeName == "#text") ? o.firstChild.nextSibling : o.firstChild;
}




// ||||||||||||||||||||||||||||||||||||||||||||||||||

function attachNav(){

	
	var i, e;
	var imageTotal = 0;
	var wrap = document.getElementById("imgnav")
	if (!wrap) return;
	for (i = 0; i < wrap.childNodes.length; i ++) {
		if ((wrap.childNodes[i].nodeName == "OL") || (wrap.childNodes[i].nodeName == "UL")){
			var nav = wrap.childNodes[i];
			
			
		}
	}
	
	//var nav = get_firstChild(wrap); //wrap.firstChild; //.parentNode.parentNode;
	nav.className = "imgnav";

	var navItems = new Array();
	
	for (i = 0; i < nav.childNodes.length; i ++) {
		if (nav.childNodes[i].nodeName == "LI") {
			navItems[navItems.length] = nav.childNodes[i];
			imageTotal++;
		}
	}
	
	if (document.createElement) 
	{
		//var descli = document.createElement("li");
		//descli.className = "desc";
		var descdiv = document.createElement("div");
			descdiv.setAttribute("id","intro");
		//	descli.appendChild(descdiv);		
		//	nav.appendChild(descli);
			
			
			//wrap.appendChild(descdiv);
			wrap.insertBefore(descdiv,nav);
			
			
		/*
		var imgdiv = document.createElement("div");
			imgdiv.className = "bild";
		var image = document.createElement("img");
			image.setAttribute("id","theimage");
		*/	
			var link = get_firstChild(navItems[0]);
			
		/*
		
			image.setAttribute("src",link.href);
			image.setAttribute("alt",link.title);
			image.setAttribute("id","theimage");
			imgdiv.appendChild(image);
			
			wrap.insertBefore(imgdiv,nav); 
		*/
	}
	
	
	
	for(i = 0; i < navItems.length; i ++){
		e = get_firstChild(navItems[i]); //document.getElementById("imgnav"+i);
		if (e) {
			
			get_firstChild(navItems[i]).title = e.firstChild.nodeValue;
			e.firstChild.nodeValue = i+1;
			
			
			e.onclick = doNav;
			if (e.title != "") {
				e.onmouseover = function() { 
					var d = document.getElementById('intro');
					if (d) d.innerHTML = this.title;
					//window.status = this.title; return true;
					}
				
				e.onmouseout = function() { 
					var d = document.getElementById('intro');
					if (d) d.innerHTML = curNav.title;
					//window.status = ''; return true;
					}
			}
			e.onfocus = e.blur;
			if(i == 0) { 
				curNav = this;
				e.onclick();
				e.onmouseover();
			}
		}
	}
}
addOnLoad("attachNav");




if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
	document.writeln('<style type="text/css">img { visibility:hidden; } </style>');
	//window.attachEvent("onload", fnLoadPngs);
	//window.attachEvent("onload", alphaBackgrounds);
	addOnLoad("fnLoadPngs");
	addOnLoad("alphaBackgrounds");
}

function fnLoadPngs() {
	var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
	var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5);

	for (var i = document.images.length - 1, img = null; (img = document.images[i]); i--) {
		if (itsAllGood && img.src.match(/\.png$/i) != null) {
			var src = img.src;
			img.style.width = img.width + "px";
			img.style.height = img.height + "px";
			img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')"
			img.src = "img/x.gif";
		}
		img.style.visibility = "visible";
	}
}

function alphaBackgrounds(){
	var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
	var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5);
	for (i=0; i<document.all.length; i++){
		var bg = document.all[i].currentStyle.backgroundImage;
		if (itsAllGood && bg){
			if (bg.match(/\.png/i) != null){
				var mypng = bg.substring(5,bg.length-2);
				document.all[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+mypng+"', sizingMethod='scale')";
				document.all[i].style.backgroundImage = "url(img/x.gif)";
			}
		}
	}
}