/*----------------------------------------------------------------------------\
|                          Selectable Elements 1.02                           |
|-----------------------------------------------------------------------------|
|                         Created by Erik Arvidsson                           |
|                  (http://webfx.eae.net/contact.html#erik)                   |
|                      For WebFX (http://webfx.eae.net/)                      |
|-----------------------------------------------------------------------------|
|          A script that allows children of any element to be selected        |
|-----------------------------------------------------------------------------|
|                Copyright (c) 2002, 2003, 2006 Erik Arvidsson                |
|-----------------------------------------------------------------------------|
| Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| use this file except in compliance with the License.  You may obtain a copy |
| of the License at http://www.apache.org/licenses/LICENSE-2.0                |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| Unless  required  by  applicable law or  agreed  to  in  writing,  software |
| distributed under the License is distributed on an  "AS IS" BASIS,  WITHOUT |
| WARRANTIES OR  CONDITIONS OF ANY KIND,  either express or implied.  See the |
| License  for the  specific language  governing permissions  and limitations |
| under the License.                                                          |
|-----------------------------------------------------------------------------|
| Dependencies:  This file requires that SelectableElements is first defined. |
| This class can  be found in the file selectableelements.js at WebFX.        |
|-----------------------------------------------------------------------------|
| 2002-09-19 | Original Version Posted.                                       |
| 2002-09-27 | Fixed a bug in IE when mouse down and up occured on different  |
|            | rows.                                                          |
| 2003-02-11 | Minor problem with addClassName and removeClassName that       |
|            | triggered a bug in Opera 7. Added destroy method               |
| 2006-05-28 | Changed license to Apache Software License 2.0.                |
|-----------------------------------------------------------------------------|
| Created 2002-09-04 | All changes are in the log above. | Updated 2006-05-28 |
\----------------------------------------------------------------------------*/

function SelectableListItems(oListElement, bMultiple) {
	SelectableElements.call(this, oListElement, bMultiple);
}
SelectableListItems.prototype = new SelectableElements;


SelectableListItems.prototype.getItems = function () {
	return this._htmlElement.getElementsByTagName("LI");
};

SelectableListItems.prototype.isItem = function (node) {
	return node != null && node.tagName == "LI";
};

/* End Traversable Collection Interface */

SelectableListItems.prototype.getNext = function (el) {
	var next = this._getFirstDescendant(el);
	if (el != next)
		return next;
	next = this._getNextSibling(el);
	var p = el.parentNode;
	while (next == null) {
		while (p != null && !this.isItem(p))
			p = p.parentNode;
		if (p == null)
			return null;
		next = this._getNextSibling(p);
		p = p.parentNode;

	}
	return next;
};

SelectableListItems.prototype._getNextSibling = function (el) {
	var n = el.nextSibling;
	while (n != null && !this.isItem(n))
		n = n.nextSibling;
	return n;
};

SelectableListItems.prototype._getFirstDescendant = function (el) {
	var lis = el.getElementsByTagName("LI");
	if (lis.length == 0)
		return el;
	return lis[0];
};

SelectableListItems.prototype.getPrevious = function (el) {
	var previous = this._getPreviousSibling(el);
	var p = el.parentNode;
	if (previous == null) {
		while (p != null && !this.isItem(p))
			p = p.parentNode;
		return p;
	}
	return this._getLastDescendant(previous);
};

SelectableListItems.prototype._getPreviousSibling = function (el) {
	var p = el.previousSibling;
	while (p != null && !this.isItem(p))
		p = p.previousSibling;
	return p;
};

SelectableListItems.prototype._getLastDescendant = function (el) {
	var lis = el.getElementsByTagName("LI");
	if (lis.length == 0)
		return el;
	return lis[lis.length - 1];
};


/* End Traversable Collection Interface */

/* Indexable Collection Interface not implemented */


