/* QUIRKSMODE JAVASCRIPT */

var blogs = ['/blog/','/bugreports/','/elsewhere/'];
var archivedText = 'You\'re looking at outdated content that is no longer maintained. Use with care.';

window.onunload = function () {

	// execute unload routine of page, if present

	if (self.exit)
		exit();
	
	// execute unload routine for blog pages, if present

	if (self.exitBlogs)
		exitBlogs();
}

window.onload = function () {
	
	
	/* Initialise example scripts on content pages in all browsers */
	
	if (self.init)
		init();

	/* See if browser supports advanced interface */

	var advancedJavaScriptSupport = document.createElement && document.getElementsByTagName;
	if (!advancedJavaScriptSupport) return;
	
	/* Zebra lists */
	
	var lists = getElementsByTagNames('ol,ul');
	for (var i=0;i<lists.length;i++) {
		var items = lists[i].childNodes;
		var counter = 1;
		for (var j=0;j<items.length;j++) {
			if (items[j].nodeName == 'LI' && !items[j].getElementsByTagName('li').length) {
				counter++;
				if (counter % 2 == 1)
					items[j].className = 'odd';
			}
		}
	}
	
	/* Initialise blog and bilingual scripts, if they're there */

	if (self.initBlogs)
		initBlogs();
	
	if (self.initBilingual)
		initBilingual();
}

/***************************************/
/*                                     */
/*             UTILITIES               */
/*                                     */
/***************************************/


/* GETELEMENTSBYTAGNAMES */

function getElementsByTagNames(list,obj) {
	if (!obj) var obj = document;
	var tagNames = list.split(',');
	var resultArray = new Array();
	for (var i=0;i<tagNames.length;i++) {
		var tags = obj.getElementsByTagName(tagNames[i]);
		for (var j=0;j<tags.length;j++) {
			resultArray.push(tags[j]);
		}
	}
	var testNode = resultArray[0];
	if (!testNode) return [];
	if (testNode.sourceIndex) {
		resultArray.sort(function (a,b) {
				return a.sourceIndex - b.sourceIndex;
		});
	}
	else if (testNode.compareDocumentPosition) {
		resultArray.sort(function (a,b) {
				return 3 - (a.compareDocumentPosition(b) & 6);
		});
	}
	return resultArray;
}
