/*
 * Provides the functionality for backwards/forwards buttons 
 * Written by Dan "Ducky" Little 3/17/2007
 */


function NavigatorHistory(EventManager) {
	var ViewHistory = new Array();
	var currentIndex = -1;
	
	this.onNavigate = function(viewCirc) {
		if(!viewCirc.navigatorLog) {
			currentIndex++;
			ViewHistory[currentIndex] = viewCirc;
			ViewHistory[currentIndex].navigatorLog = true;
		}
	}

	this.previous = function () {
		currentIndex--;
		if(ViewHistory[currentIndex]) {
			EventManager.triggerEvent('navigate', ViewHistory[currentIndex]);
		} else {
			currentIndex++;
		}
	}

	this.next = function () {
		currentIndex++;
		if(currentIndex >= ViewHistory.length) {
			currentIndex--;
		} else {
			EventManager.triggerEvent('navigate', ViewHistory[currentIndex]);
		}
	}
}
