/*
Class: LoadedItemManager
	
	
Note:
	The LoadedItemManager requires an XHTML doctype.

Arguments:


Options:

	
Events:

*/
var LoadedItemManager = new Abstract ({
		
	itemArray : [],
	
	// this method checks the internal array for the existance of the number.
	// if it exists then return true otherwise return false.
	isLoaded : function (item) {
		if ( this.itemArray.indexOf(item) >= 0 )
		{
			return true;
		}
		else
		{
			return false;
		}
	},
	
	// this method sets the number passed in into the internal array.
	// this signifies that the item is loaded on the page.
	loadItem : function (itemNumber) {
		
		this.itemArray.push(itemNumber);
		this.itemArray.sort(function(a,b){return a-b;});
	},
	
	// this method removes the value passed in from the internal array.
	// this signifies that the item has been removed from the page.
	unloadItem : function(itemNumber) {
		this.itemArray.remove(itemNumber);
	},
	
	numberOfLoadedItems : function() {
		return this.itemArray.length;
	},
	
	findItemNeighbor : function (itemNumber) {
		var index = 0
		var neighbor = 0;
		for ( index = 0; index < this.itemArray.length; index++ )
		{
			if ( this.itemArray[index] == itemNumber) { 
				if (this.itemArray[index - 1]) {
					neighbor = this.itemArray[index - 1] ;
				}
				else {
						neighbor = this.itemArray[index + 1];
				}
			}
			
//			if ((this.itemArray[index] < itemNumber) || (this.itemArray[index] > itemNumber)  )
//			{
//				neighbor = this.itemArray[index];
//			}
		}
		return neighbor;
	}
});