﻿iv = {
	//CSS classes
	dynamicClass: 'dyn',
	currentLinkClass: 'current',
	showClass: 'show',

	//IDs
	parentID: 'listWrapper',
	tocID: 'toolinfotoc',

	//Global properties
	current: null,
	sections: [],
	sectionLinks: [],

	init: function() {
		var targetName, targetElement;
		if (!document.getElementById || !document.createTextNode) {
			return;
		}
		var parent = document.getElementById(iv.parentID);
		var toc = document.getElementById(iv.tocID);
		if (!parent || !toc) {
			return;
		}
		DOMhelp.cssjs('add', parent, iv.dynamicClass);

		var toclinks = toc.getElementsByTagName('a');
		for (var i = 0; i < toclinks.length; i++) {
			DOMhelp.addEvent(toclinks[i], 'click', iv.getSection, false);
			targetName = toclinks[i].getAttribute('href').replace(/.*#/, '');
			toclinks[i].targetName = targetName;

			if (i == 0) {
				var presetLink = targetName;
			}
			targetElement = document.getElementById(targetName);
			if (targetElement) {
				iv.sections[targetName] = targetElement.parentNode.parentNode;
				iv.sectionLinks[targetName] = toclinks[i];
			}
		}
		var loc = window.location.hash.replace('#', '');
		loc = document.getElementById(loc) ? loc : presetLink;
		iv.showSection(loc);
	},

	getSection: function(e) {
		var t = DOMhelp.getTarget(e);
		iv.showSection(t.targetName);
	},

	showSection: function(sectionName) {
		if (iv.current != null) {
			DOMhelp.cssjs('remove', iv.sections[iv.current], iv.showClass);
			DOMhelp.cssjs('remove', iv.sectionLinks[iv.current], iv.currentLinkClass);
			iv.current = sectionName;
		}
		DOMhelp.cssjs('add', iv.sections[sectionName], iv.showClass);
		DOMhelp.cssjs('add', iv.sectionLinks[sectionName], iv.currentLinkClass);
		iv.current = sectionName;
	}
}
DOMhelp.addEvent(window, 'load', iv.init, false);

var dropdown = {
    init: function() {
        //startList = function() {
        if (document.all && document.getElementById) {
            navRoot = document.getElementById("nav");
            for (i = 0; i < navRoot.childNodes.length; i++) {
                node = navRoot.childNodes[i];
                if (node.nodeName == "LI") {
                    node.onmouseover = function() {
                        this.className += " over";
                    }
                    node.onmouseout = function() {
                        this.className = this.className.replace(" over", "");
                    }
                }
            }
        }
    }
}
DOMhelp.addEvent(window, 'load', dropdown.init, false);

//}
//window.onload = startList;

//var heading = {
//    init: function() {
//        if (!document.getElementById || !document.createTextNode) {
//            return;
//        }
//        var navRoot = document.getElementById("searchPage");
//        var headings = navRoot.getElementsByTagName("h2");
//        for (i = 0; i < heading.length; i++) {
//            headings[i].onmouseover = function() {
//                this.className += " over";
//            }
//            headings[i].onmouseout = function() {
//                this.className = this.className.replace(" over", "");
//            }
//        }
//    }
//}
//DOMhelp.addEvent(window, 'load', heading.init, false);

var tables = {
	init: function() {
		if (!document.getElementById || !document.createTextNode) {
			return;
		}
		var tabell = document.getElementsByTagName("table");
		for (var j = 0; j < tabell.length; j++) {
			if (tabell[j].className.indexOf("noscript") < 0) {
				var rows = tabell[j].getElementsByTagName("tr");
				for (i = 0; i < rows.length; i++) {
					//manipulate rows
					if (i % 2 == 0) {
						rows[i].className = " even";
					} else {
						rows[i].className = " odd";
					}
				}
			}
		}
	}
}
DOMhelp.addEvent(window, 'load', tables.init, false);


//var unticker = {
//	init: function() {
//		var frm = document.forms[0];

//		for (i = 0; i < frm.elements.length; i++) {
//			if (frm.elements[i].type == "checkbox") {
//				frm.elements[i].checked = false;
//			}
//		}	
//	}
//}
//DOMhelp.addEvent(window, 'load', unticker.init, false);



