﻿var baseUrl = null;

function init () {
	
	baseUrl = $('base').attr('href');

	
		//
		// Adds "over"-class to list items. 
		// This hack enables hover effects on list items for IE6.
		//
	if (document.all&&document.getElementById) {
		var tabNavNode = document.getElementById("tabNav");
		if (tabNavNode != null) {
			addClassToListItems (tabNavNode);
		}
		var subTabNavNode = document.getElementById("subTabNav");
		if (subTabNavNode != null) {
			addClassToListItems (subTabNavNode);
		}		
	}

		//
		// If the variable infoBox isn't empty, we set its value to the innerHTML of the infoBox node.
		//
	if (document.getElementById("infoBox")) {	
		if (typeof(infoText) == "string" && infoText != "") {
			document.getElementById("infoBox").innerHTML = infoText;
		}
	}
	
		//
		// If the variable lastBreadcrumb is set, we append its value to the breadcrumbNav
		// and remove the "cur" class from the previous last item, so it gets a default link layout
		//
	if (document.getElementById("breadcrumbNav")) {		
		if (typeof(lastBreadcrumb) == "string" && lastBreadcrumb != "") {
			var breadcrumbNav = document.getElementById("breadcrumbNav");
			var navItems = breadcrumbNav.getElementsByTagName('a');
			var lastItem = navItems[navItems.length-1];
			lastItem.className = "";			
			breadcrumbNav.innerHTML = breadcrumbNav.innerHTML + "&nbsp;&gt;&nbsp;" + lastBreadcrumb;
		}			
	}
}

	//
	// JS function adds css-class "over" to listitems. This is needed in IE for mouseover
	//
function addClassToListItems (parentNode) {
	var listitems = parentNode.getElementsByTagName('li')
	for (i=0; i<listitems.length; i++) {
		node = listitems[i];
		if (node.nodeName=="LI") {
			node.onmouseover=function() {
				this.className+=" over";
			}
  			node.onmouseout=function() {
  				this.className=this.className.replace(" over", "");
  			}
  	 	}
  	}
}


/*
The height and width of the total page (usually the body element).
This is a tricky one, some browsers require scrollHeight, others offsetHeight, 
but all browsers support both properties. 
Therefore I see which property has the larger value. 
This means the page height the script below gives is never smaller than the window height.
http://www.quirksmode.org/viewport/compatibility.html
*/
function getPageDimensions() {
	var x,y;
	var test1 = document.body.scrollHeight;
	var test2 = document.body.offsetHeight
	if (test1 > test2) // all but Explorer Mac
	{
		x = document.body.scrollWidth;
		y = document.body.scrollHeight;
	}
	else // Explorer Mac;
		 //would also work in Explorer 6 Strict, Mozilla and Safari
	{
		x = document.body.offsetWidth;
		y = document.body.offsetHeight;
	}
	return new Array(x,y);
}