function PopupZone() {

	var Play = null;
	
	this.init = function( CreateName, ZoneName, ControlName, Height, Delay ) {
		
		// 생성된 객체 이름
		this.CreateName = CreateName;
		// 팝업존 이름
		this.ZoneName = ZoneName;
		// 팝업존 컨트롤 이름
		this.ControlName = ControlName;
		// 팝업존 높이
		this.Height = Height;
		// 팝업존 딜레이 시간
		this.Delay = Delay * 1000;
		// 현재 팝업
		this.CurrentPop = 0

		this.RollFlag = true;

		// 팝업존 오브젝트
		this.Zone = document.getElementById(this.ZoneName).getElementsByTagName("ul")[0].getElementsByTagName("li");
		// 팝업존 컨트롤 오브젝트
		this.Control = document.getElementById(this.ControlName).getElementsByTagName("li");

		// 팝업존 내용 수
		this.Length = this.Zone.length - 1;
		
		// 시작버튼
		this.StartButton = this.Control[0].getElementsByTagName("img")[0];
		// 중지버튼
		this.StopButton = this.Control[1].getElementsByTagName("img")[0];
		// 이전버튼
		this.PrevButton = this.Control[2].getElementsByTagName("img")[0];
		// 다음버튼
		this.NextButton = this.Control[3].getElementsByTagName("img")[0];
		// 전체보기
		//this.ListButton = this.Control[4].getElementsByTagName("img")[0];

		// 시작엥커
		this.StartAnchor = this.Control[0].getElementsByTagName("a")[0];
		// 종료엥커
		this.StopAnchor = this.Control[1].getElementsByTagName("a")[0];
		// 이전엥커
		this.PrevAnchor = this.Control[2].getElementsByTagName("a")[0];
		// 다음엥커
		this.NextAnchor = this.Control[3].getElementsByTagName("a")[0];
		// 전체보기
		//this.ListAnchor = this.Control[4].getElementsByTagName("a")[0];

		// function 에서 사용할 객체 저장
		var PopupZoneThis = this;

		// 이벤트 설정 --------------------------------------------------------------------------------------------

		// 시작버튼 On
		this.StartAnchor.onclick = function() {
			eval( PopupZoneThis.CreateName + ".Start()" );
		};

		// 멈춤버튼 On
		this.StopAnchor.onclick = function() {
			eval( PopupZoneThis.CreateName + ".Stop()" );
		};

		// 이전버튼 IN
		this.PrevAnchor.onmouseover = this.PrevAnchor.onfocus = function() {
			eval( PopupZoneThis.CreateName + ".ImageReplace(" + PopupZoneThis.CreateName + ".PrevButton,true)" );
		};
		// 이전버튼 OUT
		this.PrevAnchor.onmouseout = this.PrevAnchor.onblur = function() {
			eval( PopupZoneThis.CreateName + ".ImageReplace(" + PopupZoneThis.CreateName + ".PrevButton,false)" );
		};
		// 이전버튼 On
		this.PrevAnchor.onclick = function(event) {
			eval( PopupZoneThis.CreateName + ".Prev()" );
		};


		// 다음버튼 IN
		this.NextAnchor.onmouseover = this.NextAnchor.onfocus = function() {
			eval( PopupZoneThis.CreateName + ".ImageReplace(" + PopupZoneThis.CreateName + ".NextButton,true)" );
		};
		// 다음버튼 OUT
		this.NextAnchor.onmouseout = this.NextAnchor.onblur = function() {
			eval( PopupZoneThis.CreateName + ".ImageReplace(" + PopupZoneThis.CreateName + ".NextButton,false)" );
		};
		// 다음버튼 On
		this.NextAnchor.onclick = function() {
			eval( PopupZoneThis.CreateName + ".Next()" );
		};
/*
		// 전체보기버튼 IN
		this.ListAnchor.onmouseover = this.ListAnchor.onfocus = function() {
			eval( PopupZoneThis.CreateName + ".ImageReplace(" + PopupZoneThis.CreateName + ".ListButton,true)" );
		};
		// 전체보기버튼 OUT
		this.ListAnchor.onmouseout = this.ListAnchor.onblur = function() {
			eval( PopupZoneThis.CreateName + ".ImageReplace(" + PopupZoneThis.CreateName + ".ListButton,false)" );
		};
		// 전체보기버튼 On
		this.ListAnchor.onclick = function() {
			eval( PopupZoneThis.CreateName + ".ListOpen()" );
		};
*/

		// 팝업내용 이벤트 -----------------------------------------------------------------------------------------

		for( var LoopI=0; LoopI<=this.Length; LoopI++ ) {

			this.PopupLink = this.Zone[LoopI].getElementsByTagName("a")[0];
			this.PopupLink.LoopI = LoopI;
			this.PopupLink.CreateName = this.CreateName;
			
			this.PopupLink.onfocus = function() {
				eval( this.CreateName + ".On(" + this.LoopI + ")" );
			};

			this.PopupLink.onmouseover = function() {
				eval( this.CreateName + ".Stop()" );
			};
			
			this.PopupLink.onmouseout = function() {
				eval( this.CreateName + ".Start()" );
			};

		}

	};
	
	this.ListOpen = function() {
		document.getElementById("popup_list").style.display = 'block';
	};

	this.ListClose = function() {
		document.getElementById("popup_list").style.display = 'none';
	};

	// 이미지 변환
	this.ImageReplace = function( ImgObject, Type ) {
		
		if( Type ) {
			ImgObject.src = ImgObject.src.replace("_off.gif","_on.gif");
		} else {
			ImgObject.src = ImgObject.src.replace("_on.gif","_off.gif");
		}
		
	};
	
	// 시작
	this.Start = function() {

		if( this.Length >= 0 ) {

			this.ImageReplace(this.StartButton,true);
			this.ImageReplace(this.StopButton,false);

			this.RollFlag = true;
			var RollThis = this;
			var Action = function() {
				if( RollThis.RollFlag ) {
					RollThis.Next();
				}
			};
			
			Play = window.setInterval(Action,this.Delay);

		}

	};
	
	// 멈춤
	this.Stop = function() {

		if( this.Length >= 0 ) {

			this.ImageReplace(this.StartButton,false);
			this.ImageReplace(this.StopButton,true);

			this.RollFlag = false;
			if( Play ) window.clearInterval(Play);
			Play = null;

		}

	};
	
	// 이전
	this.Prev = function() {
		if( this.Length >= 0 ) {
			this.CurrentPop = ( this.CurrentPop <= 0 ) ? this.Length : --this.CurrentPop;
			this.Move();
		}
	};

	// 다음
	this.Next = function() {
		if( this.Length >= 0 ) {
			this.CurrentPop = ( this.CurrentPop >= this.Length ) ? 0 : ++this.CurrentPop;
			this.Move();
		}
	};
	
	// 활성화
	this.On = function( intPop ) {
		this.CurrentPop = intPop;
		this.Move();
	};

	// 이동
	this.Move = function() {
		var tmpTop = 0 - this.CurrentPop * this.Height;
		document.getElementById(this.ZoneName).getElementsByTagName("ul")[0].style.top = tmpTop+ "px";
	};
	
}



