var KeyVisual = {
	contextPath: '',
	currentItemIndex: 0,
	timeout: 5000,
	items: new Array(),
	timerId: -1,
	prevRow: null,
	
	addItem: function(rowId) {
		this.items.push(rowId);
	},
	
	run: function() {
		this.showNext();
	},
	
	resume: function() {
		this.timerId = window.setTimeout(function() { KeyVisual.showNext(); }, this.timeout);
	},
	
	showNext: function() {
		if (this.items.size() == 0)
			return;
		
		if (this.prevRow != null) {
			var prevButton = this.prevRow.down('strong').down('a');
			prevButton.removeClassName('selected');
			this.prevRow.down('div.imgArea').hide();
		}
		
		var rowObj = $(this.items[this.currentItemIndex]);
		var linkButton = rowObj.down('strong').down('a');
		linkButton.addClassName('selected');
		rowObj.down('div.imgArea').show();
		this.prevRow = rowObj;
		
		this.currentItemIndex++;
		if (this.currentItemIndex >= this.items.size())
			this.currentItemIndex = 0;
		
		this.timerId = window.setTimeout(function() { KeyVisual.showNext(); }, this.timeout);
	},
	
	stopTimer: function() {
		if (this.timerId != -1) {
			window.clearTimeout(this.timerId);
			this.timerId = -1;
		}
	},
	
	showItem: function(linkObj) {
		var parentRow = linkObj.up('li');
		this.currentItemIndex = this.items.indexOf(parentRow.identify());
		
		this.showNext();
		this.stopTimer();
	}
};