/*
Programmer: Darryl Ballard
Date created: 2010-05-11
Last updated: 2010-05-11
Version: 1.1.0

Purpose:
	Puts the class "first" and "last" on the first LI and last LI respectively of ULs and OLs.
	Operates on nested lists.
	Example: Turns a list like:
		<ul>
			<li><a href="foo">Foo</a></li>
			<li class="prime">
				<a href="bar">Bar</a>
				<ul>
					<li>Blah</li>
				</ul>
			</li>
			<li class="prime"><a href="baz">Baz</a></li>
		</ul>
	into:
		<ul>
			<li class="first"><a href="foo">Foo</a></li>
			<li class="prime">
				<a href="bar">Bar</a>
				<ul>
					<li class="first last">Blah</li>
				</ul>
			</li>
			<li class="prime last"><a href="baz">Baz</a></li>
		</ul>
	
Requires:
	Prototype 1.6
	
Version History:
	1.1.0, 2010-05-17: Removed the class requirement, applies first and last to all lists.
	
	1.0.0, 2010-05-11: Done.  Applies to lists within an element with class "mark_first_and_last".
*/

// Require that Prototype is available
if (typeof Prototype != "undefined") {
	document.observe("dom:loaded", function() {
		var listsToMark = $$("ul, ol");
		var i;
		
		for (i = 0; i < listsToMark.length; i++) {
			var childElements = listsToMark[i].childElements();
			
			if (childElements.length > 0) {
				// Mark the first child
				childElements[0].addClassName("first");
				
				// Mark the last child
				childElements[childElements.length - 1].addClassName("last");
			}
		}
	});
}

