//// Site's main code// 15/11/04 JM: Created// Set up the pagefunction pageLoad(strLang) { return true; }// Generate a ToC from page headingsfunction generateTOC(){	//Get language or fallback to english	var lang = document.getElementsByTagName('html')[0].getAttribute('Lang');	if (lang == 'undefined')	{		lang = 'en';	}		var topText, pageContentText;	switch(lang)	{		case 'cs':			topText = 'Horní strana';			pageContentText = 'Obsah strany';							break;				case 'de':			topText = 'Nach oben';			pageContentText = 'Seiteninhalt';							break;				case 'fr':			topText = 'Sous';			pageContentText = 'Sur cette page';							break;					case 'it':			topText = 'All\'inizio:';			pageContentText = 'Contenuto della pagina';							break;					case 'nl':			topText = 'Naar boven';			pageContentText = 'Op deze pagina';						break;					case 'pl':			topText = 'Do góry';			pageContentText = 'Zawartość strony';			break;				case 'zh':			topText = '页首';			pageContentText = '页面内容';							break;				default:			topText = 'Top';			pageContentText = 'On this page';			break;	}			var menu = document.getElementById('TOC');		if (null == menu)	{		return;	}		var headings =  $('#colContent h2, #colContent h3, #colContent h4');  //getElementsByTagNames('h2,h3,h4', document.getElementById('colContent'));	var anchorContainer, anchor, linkId;		if (headings.length < 3) { return;}	//only make a TOC if more than one heading		// Don't allow more than 10 headings unless they're all top level ones	if (headings.length > 10){		headings = headings =  $('#colContent h2'); //getElementsByTagNames('h2', document.getElementById('colContent'));	}		menu.className = 'TOC'; //add classname; only do this now we know we have items as it will make the element appear - visible borders etc	var tocAnchor = document.createElement('a');	tocAnchor.setAttribute('name', 'pageTop');	tocAnchor.id = 'pageTop';	tocAnchor.className = 'TOCTitle';		var anchorText = document.createTextNode(pageContentText);	tocAnchor.appendChild(anchorText);	menu.appendChild(tocAnchor);	//Create the TOC	tocList = document.createElement("ul");		for (var entryPosition=0; entryPosition<headings.length; entryPosition++) 	{		var thisEntry = headings[entryPosition];				// Determine the link		linkId = thisEntry.id || uniqueId('tocTarget' + entryPosition);		// Define the anchor container		anchorContainer = document.createElement("li");		anchorContainer.className = 'tocEntry' + thisEntry.nodeName.toLowerCase();		// Define the anchor		var anchor = document.createElement("a");		var killTagsRegex = /<\/?[^>]*?>/gim; // Removes tags |  gim - all matches, case insensitive, multiline		var tocText = thisEntry.innerHTML.replace(killTagsRegex, '');		anchor.innerHTML = tocText;		anchor.href = '#' + linkId;		// Add the item		anchorContainer.appendChild(anchor);		if (anchor.innerHTML.replace(/\&nbsp;/, '').replace(/\&#160;/, '').replace(/\s/, '').length > 0) //not an empty link		{			tocList.appendChild(anchorContainer);			// Modify the link target			thisEntry.id = linkId;	// Change the element to ensure it has an id			//Make the wrapper around heading so we can add 'top of page' etc with impunity			var goTopWrapper = document.createElement('a');			goTopWrapper.href='#pageTop';			goTopWrapper.className = 'top';			var goTopContent = document.createTextNode(topText); //Language concerns?			goTopWrapper.appendChild(goTopContent);			var hWrapper = document.createElement('div');			hWrapper.className = 'tocHeader';			hWrapper.appendChild(goTopWrapper);			//then copy heading inside wrapper			var hClone = thisEntry.cloneNode(true);			hWrapper.appendChild(hClone);				//add wrapper next to target...			thisEntry.parentNode.replaceChild(hWrapper, thisEntry);		}	}	menu.appendChild(tocList);}// Generate a unique identity name// Field: Identity to form the root - required by TOCfunction uniqueId(root){	var unique = root;		while (document.getElementById(unique)) 	{		unique += "_";	}		return unique;}$(document).ready(generateTOC);// Text functionsvar _strWhitespace=" \t\n\r";function LTrim(strTest) {	var lLoop=0;	while ((lLoop < strTest.length) && (_strWhitespace.indexOf(strTest.charAt(lLoop))) != -1) lLoop++;	return strTest.substring(lLoop, this.length);};function RTrim(strTest) {	var lLoop=this.length;	while ((lLoop >= 0) && (_strWhitespace.indexOf(strTest.charAt(lLoop)) != -1)) lLoop--;	return strTest.substring(0, lLoop + 1);};function Trim(strTest) {	return LTrim(RTrim(strTest));};