/* Should we even bother trying to make the browser do this? */
if (document.getElementsByTagName) {

	/* This bit lets us use Array.push() in browsers that lack it, like IE5. */
	if (typeof(Array.prototype.push)!="function") {
		Array.prototype.push = function() {
			var A_p = 0
			for (A_p = 0; A_p < arguments.length; A_p++) {
				this[this.length] = arguments[A_p]
			}
			return this.length
		}
	}
	/* (Swiped from: http://www.samspublishing.com/articles/article.asp?p=30111&seqNum=3&rl=1) */
	
	start = function() {
		var theCOLLAPSERs = document.getElementsByTagName("div");
		var theTOGGLERs = document.getElementsByTagName("a");
		COLLAPSERList = new Array();
		TOGGLERList = new Array();
		for (i=0;i<theCOLLAPSERs.length;i++) {
			if (theCOLLAPSERs[i].className=='collapser') {
				COLLAPSERList.push(theCOLLAPSERs[i]);
			}
		}
		for (i=0;i<theTOGGLERs.length;i++) {
			if (theTOGGLERs[i].className=='toggler') {
				TOGGLERList.push(theTOGGLERs[i]);
			}
		}
		if (COLLAPSERList.length == TOGGLERList.length) {
			for (i in TOGGLERList) {
				COLLAPSERList[i].className = 'collapserClosed';
				TOGGLERList[i].className = 'togglerOff';
				TOGGLERList[i].idnum = i;
				TOGGLERList[i].onclick = function() { toggle(this.idnum); return false; };
			}
		} else {
			alert('HTML error: Differing numbers of toggler TOGGLERs vs. COLLAPSERs!');
		}
	}
	function toggle(thisidnum) {
		thisTOGGLER = TOGGLERList[thisidnum];
		if (thisTOGGLER.className == 'togglerOff') {
			thisTOGGLER.className = 'togglerOn';
		} else {
			thisTOGGLER.className = 'togglerOff';
		}
		thisCOLLAPSER = COLLAPSERList[thisidnum];
		if (thisCOLLAPSER.className == 'collapserClosed') {
			thisCOLLAPSER.className = 'collapserOpen';
		} else {
			thisCOLLAPSER.className = 'collapserClosed';
		}
	}
	
	AttachEvent(window, "load", start)
} else {
	//alert('Piece of crap browser detected');
}