<!--
/*
 * writer : oh su young
 * date : 2004-08-12
 * description : tab type scroller
 *
 * --------------------------------------------------
 * <div id="tab" style="display:none" onMouseOver="javascript:_TS.tabMU=true;" onMouseOut="javascript:_TS.tabMU=false;">
 * <div id="tab" style="display:none" onMouseOver="javascript:_TS.tabMU=true;" onMouseOut="javascript:_TS.tabMU=false;">
 *
 * var _TS = new TabScroller();
 * _TS.I(tab);	//tab => div object(document.all.tab)
 * --------------------------------------------------
 */
 
function TabScroller() {
	this.tabSpeed = 5000;	//change speed
	this.tabDelay = 0;		//
	this.tabMU = false;		//mouse up/over/out
	this.tabNum = 0;			//start div num
	this.tabTotalNum = 0;	//total display 
	this.OD = null;				//object div
	this.OT = null;				//object setTimeout
	this.OTfn = "";		//object setTimeout Instance

	this.I = tabInit;
	this.S = tabScrollerProc;
	this.MP = tabMovePrev;
	this.MN = tabMoveNext;
}

function tabInit(_OD, _OTfn) {
	if (!_OTfn || typeof(_OTfn) == "undefined") _OTfn = "_TS";
	
	this.OD = _OD;
	this.OTfn = _OTfn;
	this.tabTotalNum = this.OD.length;
	this.S();
}

function tabScrollerProc() {
	var i;

	if(!this.tabMU) {
		if(this.tabNum >= this.tabTotalNum) this.tabNum = 0;
		
		for(i = 0; i < this.tabTotalNum; i++) {
			if(i == this.tabNum) {
				this.OD[i].style.display = "block";
			} else {
				this.OD[i].style.display = "none";
			}
		}
		
		this.tabNum++;
	}

	this.OT = setTimeout(this.OTfn + ".S();", this.tabSpeed);
}

function tabMovePrev() {
	var tabDisp = this.tabNum - 1;
	if (tabDisp < 0) {
		tabDisp = this.tabTotalNum - 1;
	}
	
	var tabPrev = tabDisp - 1;
	if (tabPrev < 0) {
		tabPrev = this.tabTotalNum - 1;
	}
	
	this.tabNum = tabPrev;
	if (this.OT != null) {
		clearTimeout(this.OT);
	}
	this.S();
}

function tabMoveNext() {
	var tabNext = this.tabNum;
	if (tabNext >= this.tabTotalNum) {
		tabNext = 0;
	}
	
	this.tabNum = tabNext;
	if (this.OT != null) {
		clearTimeout(this.OT);
	}
	this.S();
}
//-->
