
/* +++ the Solution for M$ Browsers +++ */

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			if (this.className.search("sfhover\\b") == -1) {
				this.className+=" sfhover";
			}
			var currentNode = this;
			while (currentNode.parentNode.parentNode.tagName == "LI") {
				if (currentNode.parentNode.parentNode.className.search("active-js\\b") == -1) {
					currentNode.parentNode.parentNode.className+=" active-js";
				}
				currentNode = currentNode.parentNode.parentNode;
			}
		}
		sfEls[i].onmouseout=function() {
			var currentNode = this;
			while (currentNode.parentNode.parentNode.tagName == "LI") {
				currentNode.parentNode.parentNode.className=currentNode.parentNode.parentNode.className.replace(new RegExp(" active-js\\b"), "");
				while (currentNode.parentNode.parentNode.className.charAt(0) == " ") {
					currentNode.parentNode.parentNode.className = currentNode.parentNode.parentNode.className.slice(1, currentNode.parentNode.parentNode.className.length);
				}
				if (currentNode.parentNode.parentNode.className == "" || currentNode.parentNode.parentNode.className == " ") {
					currentNode.parentNode.parentNode.removeAttribute("class");
				}
				currentNode = currentNode.parentNode.parentNode;
			}
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			this.className=this.className.replace(new RegExp("sfhover\\b"), "");
			if (this.className == "" || this.className == " ") {
				this.removeAttribute("class");
			}
		}
	}
}

/* +++ the Solution for good Browsers +++ */

sfHoverFF = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			var currentNode = this;
			while (currentNode.parentNode.parentNode.tagName == "LI") {
				if (currentNode.parentNode.parentNode.className.search("active-js\\b") == -1) {
					currentNode.parentNode.parentNode.className+=" active-js";
				}
				currentNode = currentNode.parentNode.parentNode;
			}
		}
		sfEls[i].onmouseout=function() {
			var currentNode = this;
			while (currentNode.parentNode.parentNode.tagName == "LI") {
				currentNode.parentNode.parentNode.className=currentNode.parentNode.parentNode.className.replace(new RegExp("active-js\\b"), "");
				while (currentNode.parentNode.parentNode.className.charAt(0) == " ") {
					currentNode.parentNode.parentNode.className = currentNode.parentNode.parentNode.className.slice(1, currentNode.parentNode.parentNode.className.length);
				}
				if (currentNode.parentNode.parentNode.className == "" || currentNode.parentNode.parentNode.className == " ") {
					currentNode.parentNode.parentNode.removeAttribute("class");
				}
				currentNode = currentNode.parentNode.parentNode;
			}
			if (this.className == "" || this.className == " ") {
				this.removeAttribute("class");
			}
		}
	}
}

/* +++ now triggering the right one +++ */

if (window.attachEvent) {
	window.attachEvent("onload", sfHover);
} else {
	window.addEventListener("load", sfHoverFF, false);
}

/* +++ ended triggering +++ */

function setLastNavItemOffset() {
	liItems = document.getElementById('nav').getElementsByTagName('LI');
	for (var i=0; i<liItems.length; i++) {
		if (liItems[i].className.indexOf('lastMainNavItem') != -1 && liItems[i].getElementsByTagName('UL')[0]) {
			//alert (liItems[i].offsetWidth);
			repositioner = liItems[i].offsetWidth - liItems[i].getElementsByTagName('UL')[0].getElementsByTagName('LI')[0].offsetWidth;
			liItems[i].getElementsByTagName('UL')[0].style.marginLeft = repositioner + "px";
		}
	}
}

function highlightAbschnitte() {
	if (document.getElementById('contentColumn').getElementsByTagName('LI').length > 0) {
		allLI = new Array;
		allLI = document.getElementById('content').getElementsByTagName('LI');
		for (i = 0; i < allLI.length; i++) {
			if (allLI[i].className == 'csc-section') {
				if (allLI[i].getElementsByTagName('A')[0].innerHTML.indexOf('Abschnitt') == 0) {
					// alert(allLI[i].getElementsByTagName('A')[0].innerHTML);
					allLI[i].getElementsByTagName('A')[0].className += ' highlightAbschnitt';
				}
			}
		}
	}
}

function getTopOffset(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		do {
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curtop];
}

function handleGallery() {
	if (document.getElementById('externalthumbs')) {
		var galleryContainer = document.getElementById('externalthumbs');
		var thumbDivs = new Array();
		thumbDivs = galleryContainer.firstChild.nextSibling.firstChild.getElementsByTagName('div');
		for (var i = 0; i < thumbDivs.length; i++) {
			thumbDivs[i].onclick = stopTheSlideShow;
		}
	}
}

function stopTheSlideShow() {
	var rgsmoothgalleryOffset = getTopOffset(document.getElementById('externalthumbs').previousSibling);
	var currentScrollTop = document.documentElement.scrollTop || document.body.scrollTop;
	if (currentScrollTop > rgsmoothgalleryOffset) {
		//alert(currentScrollTop);
		if (document.documentElement.scrollTop) {
			document.documentElement.scrollTop = rgsmoothgalleryOffset - 20;
		} else {
			document.body.scrollTop = rgsmoothgalleryOffset - 20;
		}
	}
}

