//<![CDATA[

// JavaScript Document
function fnRolMove_Type1() {
	this.GoodsSetTime = null;
	this.BannerCurrent = 0;
	this.DateNum = 5;
	
	this.Start = function() {
		this.Obj = document.getElementById(this.BoxName);
		this.ObjBox = document.getElementById(this.DivName);

		this.ObjUl = this.ObjBox.getElementsByTagName("ul")[0];
		this.ObjLi = this.ObjUl.getElementsByTagName("li");
		
		// ¹è³Ê °¹¼ö¸¦ ÆÄ¾ÇÇÏ´Â ºÎºÐ
		this.ObjLiNum = this.ObjLi.length;
		
		// ¹è³Ê ºÎºÐÀÇ ÃÑ ³ÐÀÌ¸¦ ÆÄ¾ÇÇÏ´Â ºÎºÐ
		this.TotalWidth = this.DateWidth * this.ObjLiNum;

		this.ObjBox.style.width = this.TotalWidth + "px";
		
		if ( this.ObjLiNum % this.DateNum == 0 ) {
			this.BannerEnd = this.TotalWidth - ( this.DateWidth * this.DateNum );
		} else {
			this.BannerEnd = this.TotalWidth - this.DateWidth;
		}
		
		// ¹è³Ê¸¦ ½×°í ÀÖ´Â ºÎºÐÀÇ ¹Ú½º¿¡ Css¸¦ ÀÔÈ÷±â
		this._Style();
		// Javascript ÀÛµ¿½Ã ´ÙÀ½, ÀÌÀü ¹öÆ°À» »ðÀÔÇÏ±â
		this._ControlAdd();
	
		// ´ÙÀ½, ÀÌÀü ¹öÆ°À» Å¬¸¯½Ã ÀÌµ¿ÇØ¾ß ÇÒ À§Ä¡ °è»êÇÏ±â
		this.BannerPrevLeft = this.BannerEnd;
		this.BannerNextLeft = this.DateWidth * this.DateNum ;

		this.PrevBtnLinkImg.Num = this.BannerPrevLeft;
		this.PrevBtnLinkImg.onclick = function() {
			eval(this.fnName + "._moveFrame(" + this.Num + ",'prev')" );
			return false;
		}
		
		this.NextBtnLinkImg.Num = this.BannerNextLeft;
		this.NextBtnLinkImg.onclick = function() {
			eval(this.fnName + "._moveFrame(" + this.Num + ",'next')" );
			return false;
		}
	}
	
	this._ControlAdd = function() {
		this.NewControl = document.createElement('div');
		this.NewControl.id = "BannerListCon";
		this.Obj.appendChild(this.NewControl);
		
		//this.PrevBtnLink = document.createElement('a');
		//this.PrevBtnLink.fnName = this.fnName;
		//this.PrevBtnLink.href = "#";
		//this.NewControl.appendChild(this.PrevBtnLink);
		
		this.PrevBtnLinkImg = document.createElement('img');
		this.PrevBtnLinkImg.fnName = this.fnName;
		this.PrevBtnLinkImg.className = "btn";
		//this.PrevBtnLinkImg.href = "#prev";
		this.PrevBtnLinkImg.src = "/phps/mainbanner/img/btn_prev.gif";
		this.PrevBtnLinkImg.alt = "ÀÌÀü";
		this.NewControl.appendChild(this.PrevBtnLinkImg);

		
		//this.NextBtnLink = document.createElement('a');
		//this.NextBtnLink.fnName = this.fnName;
		//this.NextBtnLink.href = "#";
		//this.NewControl.appendChild(this.NextBtnLink);
		
		this.NextBtnLinkImg = document.createElement('img');
		this.NextBtnLinkImg.fnName = this.fnName;
		this.NextBtnLinkImg.className = "btn";
		//this.NextBtnLinkImg.href = "#next";
		this.NextBtnLinkImg.src = "/phps/mainbanner/img/btn_next.gif";
		this.NextBtnLinkImg.alt = "´ÙÀ½";
		this.NewControl.appendChild(this.NextBtnLinkImg);

	}
	
	this._Style = function() {
		this.BoxStyle = this.ObjBox.parentNode;
		this.BoxStyle.className = "BannerListStyle";
		this.BoxUlStyle = this.ObjBox.getElementsByTagName("ul")[0];
		this.BoxUlStyle.className = "BannerUlStyle";
	}
	
	// ´ÙÀ½, ÀÌÀü ¹öÆ°À» Å¬¸¯½Ã ¹è³Ê¸¦ ÀÌµ¿ Ã³¸®¸¦ ÇÏ´Â ºÎºÐ
	this._moveFrame = function(val,fnmove) {
		clearTimeout(this.GoodsSetTime);

		if ( Math.abs(val - this.BannerCurrent) > 5 ) {
			this.BannerCurrent = this.BannerCurrent + ( val - this.BannerCurrent ) * this.Speed;
		} else {
			this.BannerCurrent = val;
		}
		
		this.ObjUl.style.left = ( -1 * this.BannerCurrent ) + "px";
		
		if ( this.BannerCurrent != val ) {
			this.GoodsSetTime = setTimeout(this.fnName + "._moveFrame(" + val + ",'" + fnmove + "')",10);
		} else {
			this.CurrentPicNum = this.BannerCurrent / this.DateWidth;
			
			this.BannerPrevLeft = this.BannerCurrent - ( this.DateWidth * this.DateNum );
			this.BannerNextLeft = this.BannerCurrent + ( this.DateWidth * this.DateNum );
			
			if ( this.BannerCurrent == 0 ) {
				this.BannerPrevLeft = this.BannerEnd;
			} else if ( this.BannerCurrent == this.TotalWidth - ( this.DateWidth * this.DateNum ) ) {
				this.BannerNextLeft = 0;
			}
			this.PrevBtnLinkImg.Num = this.BannerPrevLeft;
			this.PrevBtnLinkImg.onclick = function() {
				eval(this.fnName + "._moveFrame(" + this.Num + ",'prev')" );
				return false;
			}
			
			this.NextBtnLinkImg.Num = this.BannerNextLeft;
			this.NextBtnLinkImg.onclick = function() {
				eval(this.fnName + "._moveFrame(" + this.Num + ",'next')" );
				return false;
			}
		}
	}
}
//]]>
