// Author: Shuns (www.netgrow.com.au/files), Version: 1.1
var dump3=function(object, showTypes){var dump='';var st=typeof showTypes=='undefined' ? true : showTypes;var winName='dumpWin';var browser=_dumpIdentifyBrowser();var w=760;var h=500;var leftPos=screen.width ?(screen.width-w)/ 2 : 0;var topPos=screen.height ?(screen.height-h)/ 2 : 0;var settings='height='+h+',width='+w+',top='+topPos+',left='+leftPos+',scrollbars=yes,menubar=yes,status=yes,resizable=yes';var title='Dump';var script='function tRow(s){t=s.parentNode.lastChild;tTarget(t, tSource(s));}function tTable(s){var switchToState=tSource(s);var table=s.parentNode.parentNode;for(var i=1;i < table.childNodes.length;i++){t=table.childNodes[i];if(t.style){tTarget(t, switchToState);}}}function tSource(s){if(s.style.fontStyle=="italic"||s.style.fontStyle==null){s.style.fontStyle="normal";s.title="click to collapse";return "open";}else{s.style.fontStyle="italic";s.title="click to expand";return "closed";}}function tTarget(t, switchToState){if(switchToState=="open"){t.style.display="";}else{t.style.display="none";}}';dump+=(/string|number|undefined|boolean/.test(typeof(object))||object==null)? object : recurse(object, typeof object);winName=window.open('', winName, settings);if(browser.indexOf('ie')!=-1||browser=='opera'||browser=='ie5mac'||browser=='safari'){winName.document.write('<html><head><title> '+title+' </title><script type="text/javascript">'+script+'</script><head>');winName.document.write('<body>'+dump+'</body></html>');}else{winName.document.body.innerHTML=dump;winName.document.title=title;var ffs=winName.document.createElement('script');ffs.setAttribute('type', 'text/javascript');ffs.appendChild(document.createTextNode(script));winName.document.getElementsByTagName('head')[0].appendChild(ffs);}winName.focus();function recurse(o, type){var i;var j=0;var r='';type=_dumpType(o);switch(type){case 'regexp':var t=type;r+='<table'+_dumpStyles(t,'table')+'><tr><th colspan="2"'+_dumpStyles(t,'th')+'>'+t+'</th></tr>';r+='<tr><td colspan="2"'+_dumpStyles(t,'td-value')+'><table'+_dumpStyles('arguments','table')+'><tr><td'+_dumpStyles('arguments','td-key')+'><i>RegExp: </i></td><td'+_dumpStyles(type,'td-value')+'>'+o+'</td></tr></table>';j++;break;case 'date':var t=type;r+='<table'+_dumpStyles(t,'table')+'><tr><th colspan="2"'+_dumpStyles(t,'th')+'>'+t+'</th></tr>';r+='<tr><td colspan="2"'+_dumpStyles(t,'td-value')+'><table'+_dumpStyles('arguments','table')+'><tr><td'+_dumpStyles('arguments','td-key')+'><i>Date: </i></td><td'+_dumpStyles(type,'td-value')+'>'+o+'</td></tr></table>';j++;break;case 'function':var t=type;var a=o.toString().match(/^.*function.*?\((.*?)\)/im);var args=(a==null||typeof a[1]=='undefined'||a[1]=='')? 'none' : a[1];r+='<table'+_dumpStyles(t,'table')+'><tr><th colspan="2"'+_dumpStyles(t,'th')+'>'+t+'</th></tr>';r+='<tr><td colspan="2"'+_dumpStyles(t,'td-value')+'><table'+_dumpStyles('arguments','table')+'><tr><td'+_dumpStyles('arguments','td-key')+'><i>Arguments: </i></td><td'+_dumpStyles(type,'td-value')+'>'+args+'</td></tr><tr><td'+_dumpStyles('arguments','td-key')+'><i>Function: </i></td><td'+_dumpStyles(type,'td-value')+'>'+o+'</td></tr></table>';j++;break;case 'domelement':var t=type;r+='<table'+_dumpStyles(t,'table')+'><tr><th colspan="2"'+_dumpStyles(t,'th')+'>'+t+'</th></tr>';r+='<tr><td'+_dumpStyles(t,'td-key')+'><i>Node Name: </i></td><td'+_dumpStyles(type,'td-value')+'>'+o.nodeName.toLowerCase()+'</td></tr>';r+='<tr><td'+_dumpStyles(t,'td-key')+'><i>Node Type: </i></td><td'+_dumpStyles(type,'td-value')+'>'+o.nodeType+'</td></tr>';r+='<tr><td'+_dumpStyles(t,'td-key')+'><i>Node Value: </i></td><td'+_dumpStyles(type,'td-value')+'>'+o.nodeValue+'</td></tr>';r+='<tr><td'+_dumpStyles(t,'td-key')+'><i>innerHTML: </i></td><td'+_dumpStyles(type,'td-value')+'>'+o.innerHTML+'</td></tr>';j++;break;}if(/object|array/.test(type)){for(i in o){var t=_dumpType(o[i]);if(j < 1){r+='<table'+_dumpStyles(type,'table')+'><tr><th colspan="2"'+_dumpStyles(type,'th')+'>'+type+'</th></tr>';j++;}if(typeof o[i]=='object' && o[i]!=null){r+='<tr><td'+_dumpStyles(type,'td-key')+'>'+i+(st ? ' ['+t+']' : '')+'</td><td'+_dumpStyles(type,'td-value')+'>'+recurse(o[i], t)+'</td></tr>';}else if(typeof o[i]=='function'){r+='<tr><td'+_dumpStyles(type ,'td-key')+'>'+i+(st ? ' ['+t+']' : '')+'</td><td'+_dumpStyles(type,'td-value')+'>'+recurse(o[i], t)+'</td></tr>';}else{r+='<tr><td'+_dumpStyles(type,'td-key')+'>'+i+(st ? ' ['+t+']' : '')+'</td><td'+_dumpStyles(type,'td-value')+'>'+o[i]+'</td></tr>';}}}if(j==0){r+='<table'+_dumpStyles(type,'table')+'><tr><th colspan="2"'+_dumpStyles(type,'th')+'>'+type+' [empty]</th></tr>';}r+='</table>';return r;};};_dumpStyles=function(type, use){var r='';var table='font-size:xx-small;font-family:verdana,arial,helvetica,sans-serif;cell-spacing:2px;';var th='font-size:xx-small;font-family:verdana,arial,helvetica,sans-serif;text-align:left;color: white;padding: 5px;vertical-align :top;cursor:hand;cursor:pointer;';var td='font-size:xx-small;font-family:verdana,arial,helvetica,sans-serif;vertical-align:top;padding:3px;';var thScript='onClick="tTable(this);" title="click to collapse"';var tdScript='onClick="tRow(this);" title="click to collapse"';switch(type){case 'string':case 'number':case 'boolean':case 'undefined':case 'object':switch(use){case 'table':r=' style="'+table+'background-color:#0000cc;"';break;case 'th':r=' style="'+th+'background-color:#4444cc;"'+thScript;break;case 'td-key':r=' style="'+td+'background-color:#ccddff;cursor:hand;cursor:pointer;"'+tdScript;break;case 'td-value':r=' style="'+td+'background-color:#fff;"';break;}break;case 'array':switch(use){case 'table':r=' style="'+table+'background-color:#006600;"';break;case 'th':r=' style="'+th+'background-color:#009900;"'+thScript;break;case 'td-key':r=' style="'+td+'background-color:#ccffcc;cursor:hand;cursor:pointer;"'+tdScript;break;case 'td-value':r=' style="'+td+'background-color:#fff;"';break;}break;case 'function':switch(use){case 'table':r=' style="'+table+'background-color:#aa4400;"';break;case 'th':r=' style="'+th+'background-color:#cc6600;"'+thScript;break;case 'td-key':r=' style="'+td+'background-color:#fff;cursor:hand;cursor:pointer;"'+tdScript;break;case 'td-value':r=' style="'+td+'background-color:#fff;"';break;}break;case 'arguments':switch(use){case 'table':r=' style="'+table+'background-color:#dddddd;cell-spacing:3;"';break;case 'td-key':r=' style="'+th+'background-color:#eeeeee;color:#000000;cursor:hand;cursor:pointer;"'+tdScript;break;}break;case 'regexp':switch(use){case 'table':r=' style="'+table+'background-color:#CC0000;cell-spacing:3;"';break;case 'th':r=' style="'+th+'background-color:#FF0000;"'+thScript;break;case 'td-key':r=' style="'+th+'background-color:#FF5757;color:#000000;cursor:hand;cursor:pointer;"'+tdScript;break;case 'td-value':r=' style="'+td+'background-color:#fff;"';break;}break;case 'date':switch(use){case 'table':r=' style="'+table+'background-color:#663399;cell-spacing:3;"';break;case 'th':r=' style="'+th+'background-color:#9966CC;"'+thScript;break;case 'td-key':r=' style="'+th+'background-color:#B266FF;color:#000000;cursor:hand;cursor:pointer;"'+tdScript;break;case 'td-value':r=' style="'+td+'background-color:#fff;"';break;}break;case 'domelement':switch(use){case 'table':r=' style="'+table+'background-color:#FFCC33;cell-spacing:3;"';break;case 'th':r=' style="'+th+'background-color:#FFD966;"'+thScript;break;case 'td-key':r=' style="'+th+'background-color:#FFF2CC;color:#000000;cursor:hand;cursor:pointer;"'+tdScript;break;case 'td-value':r=' style="'+td+'background-color:#fff;"';break;}break;}return r;};_dumpIdentifyBrowser=function(){var agent=navigator.userAgent.toLowerCase();if (typeof window.opera != 'undefined'){return 'opera';} else if (typeof document.all != 'undefined'){if (typeof document.getElementById != 'undefined'){var browser = agent.replace(/.*ms(ie[\/ ][^ $]+).*/, '$1').replace(/ /, '');if(typeof document.uniqueID != 'undefined') {if (browser.indexOf('5.5') != -1){return browser.replace(/(.*5\.5).*/, '$1');}else{return browser.replace(/(.*)\..*/, '$1');}}else{return 'ie5mac';}}}else if(typeof document.getElementById != 'undefined'){if (navigator.vendor.indexOf('Apple Computer, Inc.')!=-1) {return 'safari';}else if(agent.indexOf('gecko')!=-1) {return 'mozilla';}}return false;};_dumpType=function(obj){var t=typeof(obj);if(t=='function'){var f=obj.toString();if((/^\/.*\/[gi]??[gi]??$/).test(f)){return 'regexp';}else if((/^\[object.*\]$/i).test(f)){t='object'}}if(t !='object'){return t;}switch(obj){case null:return 'null';case window:return 'window';case document:return document;case window.event:return 'event';}if(window.event &&(event.type==obj.type)){return 'event';}var c=obj.constructor;if(c !=null){switch(c){case Array:t='array';break;case Date:return 'date';case RegExp:return 'regexp';case Object:t='object';break;case ReferenceError:return 'error';default:var sc=c.toString();var m=sc.match(/\s*function(.*)\(/);if(m !=null){return 'object';}}}var nt=obj.nodeType;if(nt !=null){switch(nt){case 1:if(obj.item==null){return 'domelement';}break;case 3:return 'string';}}if(obj.toString !=null){var ex=obj.toString();var am=ex.match(/^\[object(.*)\]$/i);if(am !=null){var am=am[1];switch(am.toLowerCase()){case 'event':return 'event';case 'nodelist':case 'htmlcollection':case 'elementarray':return 'array';case 'htmldocument':return 'htmldocument';}}}return t;};

// ---------------------------------------------------------------------------------------------------------------------
// OMG MOAR animations like USA Football!
// ---------------------------------------------------------------------------------------------------------------------
function animateTopNavigation()
{
	var uls = $$("div#header > ul");
	
	// find the <ul> with the most <li>s in it
	var max = 0;
	for (var i = 0; i < uls.length; i++)
	{
		var count = uls[i].childElements().length;
		if (count > max)
		{
			max = count;
		}
	}
	
	var delay = 0;
	for (var i = 0; i < max; i++)
	{
		for (var j = 0; j < uls.length; j++)
		{
			var lis = uls[j].childElements();
			if (lis[i])
			{
				new Effect.Opacity
				(
				 	lis[i],
					{
						from: 0.0,
						to: 1.0,
						duration: 0.8,
						delay: delay
					}
				);
				
				delay += 0.1;
			}
		}
	}
}

function prepareTopNavigationAnimation()
{
	var lis = $$("div#header > ul > li");
	for (var i = 0; i < lis.length; i++)
	{
		new Effect.Opacity
		(
		 	lis[i],
			{
				to: 0.0,
				duration: 0
			}
		);
	}
	
	Event.observe(window, "load", animateTopNavigation);
}

// ---------------------------------------------------------------------------------------------------------------------
// [rel="external"] also becomes [target="_blank"] (opens external links in new windows)
// ---------------------------------------------------------------------------------------------------------------------
function externalLinks()
{ 
	if (!document.getElementsByTagName)
	{
		return; 
	}
	var anchors = document.getElementsByTagName("a"); 
	for (var i = 0; i < anchors.length; i++)
	{ 
		var anchor = anchors[i];
		 
		if (anchor.getAttribute("href") && anchor.getAttribute("rel")) 
		{
			var rels = anchor.getAttribute("rel").split(/\s+/);
			for (var j = 0; j < rels.length; j++)
			{
				if (rels[j].toLowerCase() == "external")
				{
					anchor.setAttribute("target", "_blank");
				}
				break;
			} 
		}
	} 
}

Event.observe(window, "load", externalLinks);

// ---------------------------------------------------------------------------------------------------------------------
// Suckerfish
// ---------------------------------------------------------------------------------------------------------------------
function bindSuckerfish(target)
{
	target.attachEvent("onmouseover", function()
	{
		target.className += " sfhover";
	});
	
	target.attachEvent("onmouseout", function()
	{
		target.className = target.className.replace(new RegExp(" sfhover\\b"), "");
	});
}

// only IE7 has native XHR support; IE6 and below has attachEvent and no native XHR
if (window.attachEvent && !window.XMLHttpRequest)
{
	window.attachEvent("onload", function()
	{
		var lis = document.getElementsByTagName("li");
		for (var i = 0; i < lis.length; i++)
		{
			bindSuckerfish(lis[i]);
		}
	});
}

// ---------------------------------------------------------------------------------------------------------------------
// Base64 encoding/decoding (from http://www.webtoolkit.info/javascript-base64.html)
// ---------------------------------------------------------------------------------------------------------------------
var Base64 = {

	// private property
	_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",

	// public method for encoding
	encode : function (input) {
		var output = "";
		var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
		var i = 0;

		input = Base64._utf8_encode(input);

		while (i < input.length) {

			chr1 = input.charCodeAt(i++);
			chr2 = input.charCodeAt(i++);
			chr3 = input.charCodeAt(i++);

			enc1 = chr1 >> 2;
			enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
			enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
			enc4 = chr3 & 63;

			if (isNaN(chr2)) {
				enc3 = enc4 = 64;
			} else if (isNaN(chr3)) {
				enc4 = 64;
			}

			output = output +
			this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
			this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);

		}

		return output;
	},

	// public method for decoding
	decode : function (input) {
		var output = "";
		var chr1, chr2, chr3;
		var enc1, enc2, enc3, enc4;
		var i = 0;

		input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

		while (i < input.length) {

			enc1 = this._keyStr.indexOf(input.charAt(i++));
			enc2 = this._keyStr.indexOf(input.charAt(i++));
			enc3 = this._keyStr.indexOf(input.charAt(i++));
			enc4 = this._keyStr.indexOf(input.charAt(i++));

			chr1 = (enc1 << 2) | (enc2 >> 4);
			chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
			chr3 = ((enc3 & 3) << 6) | enc4;

			output = output + String.fromCharCode(chr1);

			if (enc3 != 64) {
				output = output + String.fromCharCode(chr2);
			}
			if (enc4 != 64) {
				output = output + String.fromCharCode(chr3);
			}

		}

		output = Base64._utf8_decode(output);

		return output;

	},

	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";

		for (var n = 0; n < string.length; n++) {

			var c = string.charCodeAt(n);

			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}

		}

		return utftext;
	},

	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;

		while ( i < utftext.length ) {

			c = utftext.charCodeAt(i);

			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}

		}

		return string;
	}

}

// ---------------------------------------------------------------------------------------------------------------------
// Autofontification
// ---------------------------------------------------------------------------------------------------------------------
function findFirstPopulatedTextNodeValue(root)
{
	if (root instanceof Text)
	{
		var trimmed = root.nodeValue.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
		if (trimmed != "")
		{
			return trimmed;
		}
	}
	else if (root.hasChildNodes())
	{
		for (var i = 0; i < root.childNodes.length; i++)
		{
			return findFirstPopulatedTextNodeValue(root.childNodes[i]);
		}
	}

	return null;
}

document.observe
(
	"dom:loaded",
	function()
	{
		var elems = $$(".fontified");

		for (var i = 0; i < elems.length; i++)
		{
			var elem = elems[i];

			elem.classNames().each
			(
				function(className)
				{
					if (matches = className.match(/^fontified-([a-z0-9_]+)-([0-9]+)-([0-9a-f]{6})$/))
					{
						var text = elems[i].firstChild.nodeValue;

						if (text != null)
						{
							elem.setStyle
							(
								{
									textIndent: "-5000px",
									backgroundImage: "url(/fontified_headers/renderText/" + Base64.encode(text) + "/" + matches[1] + "/" + matches[2] + "/" + matches[3] + ")",
									backgroundRepeat: "no-repeat"
								}
							);
						}
					}
				}
			);
		}
	}
)

// ---------------------------------------------------------------------------------------------------------------------
// Login field focus/blur
// ---------------------------------------------------------------------------------------------------------------------
function toggleLoginField(node, isFocusing)
{
	if (isFocusing && node.value == "Enter ADA Number")
	{
		node.value = "";
	}
	else if (!isFocusing && node.value == "")
	{
		node.value = "Enter ADA Number";
	}
}

// ---------------------------------------------------------------------------------------------------------------------
// Awesome web 4.0-style news ticker
// ---------------------------------------------------------------------------------------------------------------------
var yShift = 15; // pixels up/down that the news items will move
var animDuration = 0.3; // time in seconds to spend on the animation (will execute twice, once for each direction)
var holdDuration = 5; // time in seconds to wait until cycling the news item (animDuration will be factored in)

function changeNewsItem(executer)
{
	// ghetto-static field
	if (typeof(changeNewsItem.lis) == "undefined")
	{
		changeNewsItem.lis = $$("div#home div#news ul > li");
	}
	var lis = changeNewsItem.lis;

	// find the one li that is not display: none
	var currentLi = null;
	var nextLi = null;

	for (var i = 0; i < lis.length; i++)
	{
		if (lis[i].getStyle("display") != "none")
		{
			currentLi = lis[i];
			nextLi = lis[(i == lis.length - 1 ? 0 : i + 1)];

			break;
		}
	}

	if (!currentLi || !nextLi)
	{
		// assume the first LI
		if (lis.length == 0)
		{
			throw "No news item LIs found to animate";
		}

		currentLi = lis[0];
		nextLi = lis[(lis.length == 1 ? 0 : 1)];
	}

	// animate up the old one and then hide it, and then show and animate up the new one
	new Effect.Parallel
	(
		[
			new Effect.Tween
			(
				currentLi,
				0,
				yShift,
				{
					sync: true
				},
				function(value)
				{
					currentLi.setStyle
					(
						{
							marginTop: value + "px"
						}
					)
				}
			),
			new Effect.Opacity
			(
				currentLi,
				{
					from: 1,
					to: 0,
					sync: true
				}
			)
		],
		{
			duration: animDuration,
			beforeStart: function()
			{
				currentLi.setStyle
				(
					{
						display: ""
					}
				);
			},
			afterFinish: function()
			{
				currentLi.setStyle
				(
					{
						display: "none"
					}
				);

				nextLi.setStyle
				(
					{
						opacity: 0,
						display: ""
					}
				);

				new Effect.Parallel
				(
					[
						new Effect.Tween
						(
							nextLi,
							-yShift,
							0,
							{
								sync: true
							},
							function(value)
							{
								nextLi.setStyle
								(
									{
										marginTop: value + "px"
									}
								)
							}
						),
						new Effect.Opacity
						(
							nextLi,
							{
								from: 0,
								to: 1,
								sync: true
							}
						)
					],
					{
						duration: animDuration
					}
				)
			}
		}
	);
}

document.observe
(
	"dom:loaded",
	function()
	{
		var lis = $$("div#home div#news ul > li");
		if (lis.length > 0)
		{
			new PeriodicalExecuter(changeNewsItem, holdDuration + (animDuration * 2));
		}
	}
);

// ---------------------------------------------------------------------------------------------------------------------
// Awesome web 9.0-style home page paragraph fader-in thing
// ---------------------------------------------------------------------------------------------------------------------
var homePYShift = 20;

document.observe
(
	"dom:loaded",
	function()
	{
		var ps = $$("div#home-copy > p");
		if (ps.length == 2)
		{
			var p1 = ps[0];
			var p2 = ps[1];

			new Effect.Parallel
			(
				[
					new Effect.Move
					(
						p1,
						{
							x: 0,
							y: -homePYShift,
							mode: "relative",
							sync: true
						}
					),
					new Effect.Opacity
					(
						p1,
						{
							from: 0,
							to: 1,
							sync: true
						}
					),
					new Effect.Move
					(
						p2,
						{
							x: 0,
							y: homePYShift,
							mode: "relative",
							sync: true
						}
					),
					new Effect.Opacity
					(
						p2,
						{
							from: 0,
							to: 1,
							sync: true
						}
					),

				],
				{
					duration: 1.5,
					beforeStart: function()
					{
						p1.setStyle
						(
							{
								opacity: 0,
								display: "block",
								marginTop: homePYShift + "px",
								top: homePYShift
							}
						);
						
						p2.setStyle
						(
							{
								opacity: 0,
								display: "block",
								marginTop: -homePYShift + "px",
								top: -homePYShift
							}
						);

					}
				}
			);
		}
	}
)

// ---------------------------------------------------------------------------------------------------------------------
// Extremely necessary Web 23847.0 News and Articles page flipper dealie
// ---------------------------------------------------------------------------------------------------------------------
var articlesTransitionLock = false;
var articlesCount = 2; // number of articles to show at once
var articleAnimSpeed = 0.2; // how quickly the fade occurs for each item
var articleAnimDelay = 0.02; // the delay between element fades

function getDirectChildren(nodeList)
{
	var elems = [];
	for (var i = 0; i < nodeList.length; i++)
	{
		nodeList[i].childElements().each
		(
			function(elem)
			{
				elems.push(elem);
			}
		);
	};

	return elems;
}

function nextArticleGroup()
{
	if (articlesTransitionLock)
	{
		return; // don't allow a transition if one's already in progress
	}

	articlesTransitionLock = true;

	// find the two <li>s that are not display: none
	var lis = $$("div#articles > ul > li");
	if (lis.length == 0)
	{
		throw "No <li>s found for News and Articles";
	}
	else if (lis.length <= articlesCount)
	{
		throw "Only " + lis.length + " <li>s defined for News and Articles; need at least " + (articlesCount + 1) +
				" (" + articlesCount + " articles and the Read All link)";
	}
	else if ((lis.length - 1) % articlesCount != 0)
	{
		throw "Number of <li>s (minus one) for News and Articles must be perfectly divisible by " + articlesCount;
	}

	var activeLis = [];
	var nextLis = [];
	var lastIndex = null;
	for (var i = 0; i < lis.length - 1; i++)
	{
		if (lis[i].getStyle("display") != "none")
		{
			activeLis.push(lis[i]);
			lastIndex = i;
		}
	}

	if (activeLis.length == 0)
	{
		throw "Couldn't detect index of the current pair of visible <li>s";
	}

	var index = lastIndex;
	for (var i = 0; i < articlesCount; i++)
	{
		index++;

		if (index >= lis.length - 1)
		{
			index = 0;
		}

		nextLis.push(lis[index]);
	}

	var stackSize = 0;
	Effect.multiple
	(
		getDirectChildren(activeLis),
		Effect.Opacity,
		{
			from: 1,
			to: 0,
			duration: articleAnimSpeed,
			delay: articleAnimDelay,
			beforeStart: function()
			{
				stackSize++;
			},
			afterFinish: function()
			{
				stackSize--;

				if (stackSize == 0)
				{
					for (var i = 0; i < activeLis.length; i++)
					{
						activeLis[i].setStyle
						(
							{
								display: "none"
							}
						);
					}

					var nextElems = getDirectChildren(nextLis);
					for (var i = 0; i < nextElems.length; i++)
					{
						nextElems[i].setStyle
						(
							{
								opacity: 0
							}
						);
					}

					for (var i = 0; i < nextLis.length; i++)
					{
						nextLis[i].setStyle
						(
							{
								display: "block"
							}
						);
					}

					Effect.multiple
					(
						getDirectChildren(nextLis),
						Effect.Opacity,
						{
							from: 0,
							to: 1,
							duration: articleAnimSpeed,
							delay: articleAnimDelay,
							beforeStart: function()
							{
								stackSize++;
							},
							afterFinish: function()
							{
								stackSize--;

								if (stackSize == 0)
								{
									articlesTransitionLock = false;
								}
							}
						}
					);
				}
			}
		}
	);
}
