/**
 * Horizontal Navigator
 * 이전 다음으로 이동하는 UI 처리시 사용 됨
 *
 * @param itemEls , 반복되는 element id array, prototype $$ selector 사용바람 
 * @param rotaion , 순환 여부
 * @author aimh@skcomms.co.kr
 */
var HorizontalNavigator = Class.create();
HorizontalNavigator.prototype =  {<!--{{{-->
	_items : null, 
	_activeIndex : 0,
	_nextIndex : 1,
	_prevIndex : -1,
	_currentIndex : 0,
	_rotation : 0,
	
	initialize : function(itemEls, rotation) {
		this._items = itemEls;
		this._rotation = rotation ? rotation : this._rotation;
	},

	view : function(currentIndex) {
		this._items[currentIndex].style.display = "";		
		this._nextIndex = currentIndex + 1;
		this._prevIndex = currentIndex - 1;
	},

	prev : function() {
		if(this._prevIndex > -1) {
			this._items[this._activeIndex].style.display = "none";
			this.view(this._prevIndex);
			this._activeIndex--;
		}
		else {
			if(this._rotation) {
				this._items[this._activeIndex].style.display = "none";
				this._activeIndex = this._items.length - 1;
				this._prevIndex = 0;
				this.view(this._activeIndex);
			}
		}
	},
	
	next : function() {
		if(this._nextIndex < this._items.length) {
			this._items[this._activeIndex].style.display = "none";
			this._activeIndex++;
			this.view(this._nextIndex);
		}
		else {
			if(this._rotation) {
				this._items[this._activeIndex].style.display = "none";
				this._activeIndex = 0;
				this._nextIndex = 0;
				this.view(this._activeIndex);
			}
		}
	}
}<!--}}}-->


/**
 * Banner Rotation
 *
 * @param itemEls ,  반복되는 element id array, prototype $$ selector 사용바람 
 * @author aimh@skcomms.co.kr , 09/04/02
 */
var RotateBanner = Class.create();
RotateBanner.prototype = {/*{{{*/
	_items : null,
	_activeIndex : 0,
	_current : 0,
	_next : 0,

	initialize : function(itemEls) {
		this._items = itemEls;
	},

	rotate : function() {
		if (this._items && this._items.length) {
			this._current = this._activeIndex;
			this._next = (++this._activeIndex  == this._items.length) ? 0 : this._activeIndex;
			if (this._next ==0) this._activeIndex = 0;
			this._items[this._current].style.display="none";
			this._items[this._next].style.display="";
		}
	}
}/*}}}*/
