// ExtendedSelectManager의 instance. Global객체.
var SelectEXT;
/************************* ExtendedSelectManager *************************/
/**
 * 기본적으로 select객체와 거의 동일하게 동작한다.
 * DOC에서의 select의 객체의 주요 속성에 대한 retrive는 잘 지원하지만 set은 지원 되지 않는다.
 * setValue(), setSelectedIndex()를 참고할 것.
 */

function ExtendedSelectManager() {
	this.isIE = window.navigator.userAgent.indexOf("MSIE") > 0;
	this.isNS = window.navigator.appName.indexOf("Netscape") == 0;
	this.browserVersion = parseFloat(window.navigator.appVersion);
	this.currentSObj == null;	// 현재 주목하고 있는 select객체.
	this.closeTimeOut = 1000;	// 마우스가 select에서 벗어났을때 펼처진 리스트를 숨기기까지의 시간. 밀리초.
	this.selectes = new Array();	// select객체를 담고 있는 리스트. key: select객체의 id, value: select객체.
	this.cursorName = this.isIE && this.browserVersion < 6 ? "hand" : "pointer";
	this.fontSize = 11;	// 글자 기본 크기.
	this.lineHeight = 12;	// 글자 기본 크기.
	this.unitSize = 17;	// 기본 크기. 단위 px. ex) option의 높이.
	this.defaultLineCount = 8;	// 펼처질 리스트에 보여질 option의 기본 개수.
	this.defaultWidth = 150;	// 펼처질 리스트의 기본 너비. 단위 px.
//	this.defaultBGColor = "#F5F2EB";	 기본 배경색.
	this.defaultBGColor = "#e9e9e9";	// 기본 배경색 2005-09-교체
//	this.defaultFontColor = "#FFFFFF";
	this.defaultFontColor = "#777777";
	this.defaultArrowColor = "#cccccc"; // 기본 배경색 2005-09-교체

//	this.arrowImage = "/images/bottom/btn_down.gif"; 



//SS_ENV.CR.ReverseBackground = '#F5F2EB';
//SS_ENV.CR.ReverseText = '#969696';
//SS_ENV.CR.Border = '#BABABA';
//SS_ENV.CR.BorderActive = '#BDBEBE';
//SS_ENV.ImgPrefix = '/images/bottom/';
//SS_ENV.DefaultHeight = '17px';
//SS_ENV.ButtonWidth = '16px';
		
		




	this.targets = new Array();
	this.appendTarget = function (sObjId) {
		this.targets[this.targets.length] = sObjId;
	}
	this.changeAll = function (sObjId) {
		if(this.targets.length > 0) {
			for(var i = 0; i < this.targets.length; i++)
				this.change(this.targets[i]);
		}
	}
	/**
	 * 노멀한 select를 ExtendedSelect로 바꾸는	.
	 * @public
	 * @param sObjId select객체의 id.
	 */
	this.change = function (sObjId) {
		if(true) {//this.isIE) {
			var sObj = document.getElementById(sObjId);
			if(sObj) {
				var extSelObj = new ExtendedSelect(sObj);
				this.selectes[sObjId] = extSelObj;
				sObj.parentNode.replaceChild(extSelObj.create(), sObj);
			}
		} else {
		}
	}
	/**
	 * ExtendedSelect의 값을 변경하는 메소드.
	 * @public
	 * @param sObjId select객체의 id.
	 * @param value 변경하고자 하는 값.
	 */
	this.setValue = function (sObjId, value) {
		if(this.isIE && this.selectes[sObjId]) {
			this.selectes[sObjId].setValue(value);
		} else {
			var sObj = document.getElementById(sObjId);
			if(sObj) sObj.value = value;
		}
	}
	/**
	 * ExtendedSelect의 selectedIndex를 변경하는 메소드.
	 * @public
	 * @param sObjId select객체의 id.
	 * @param index 변경하고자 하는 index.
	 */
	this.setSelectedIndex = function (sObjId, index) {
		if(this.isIE && this.selectes[sObjId]) {
			this.selectes[sObjId].setSelectedIndex(index);
		} else {
			var sObj = document.getElementById(sObjId);
			if(sObj) sObj.selectedIndex = index;
		}
	}
	/**
	 * ExtendedSelect에 설정된 현재 값을 가져오는 메소드.
	 * @public
	 * @param sObjId select객체의 id.
	 */
	this.getValue = function (sObjId) {
		if(this.isIE && this.selectes[sObjId]) {
			return this.selectes[sObjId].getValue();
		} else {
			var sObj = document.getElementById(sObjId);
			if(sObj) return sObj.value;
		}
	}
	/**
	 * 현재 주목하고 있는 ExtendedSelect를 기억해 두기 위한 메소드.
	 * @private
	 * @param sObj 현재 주목하고 있는 ExtendedSelect객체.
	 */
	this.setShowed = function (sObj) {
		if(this.currentSObj && this.currentSObj != sObj) {
			window.clearTimeout(this.currentSObj.closeTimer);
			this.currentSObj.close();
		}
		this.currentSObj = sObj;
	}
	/**
	 * 현재 주목하고 있는 ExtendedSelect객체의 펼처진 리스트를 숨기는 메소드.
	 * @private
	 */
	this.close = function () {
		if(SelectEXT.currentSObj != null)
			SelectEXT.currentSObj.close();
	}
// style 관련 메소드들.
	// 제목영역의 style.
	this.applyTitleStyle = function (title, sObj) {
		title.style.color = sObj.fontColor;
		title.style.fontSize = SelectEXT.fontSize + "px";
		title.style.textIndent = "3px";
		title.style.paddingTop = "2px";
		title.style.height = SelectEXT.unitSize + "px";
		title.style.lineHeight = SelectEXT.lineHeight + "px";
		title.style.overflow = "hidden";
		title.noWrap = true;


//SS_ENV.CR.Border = '#BABABA';
//SS_ENV.CR.BorderActive = '#BDBEBE';
//SS_ENV.ImgPrefix = 'http://ir.imbc.com/2006/images/';
//SS_ENV.DefaultHeight = '17px';
//SS_ENV.ButtonWidth = '16px';


		title.style.borderColor = "#e9e9e9";
		title.style.borderWidth  = "1px";	// 이 값은 변경 하지 말것. //
		title.style.borderStyle = "solid";

	}
	// 리스트의 style.
	this.applyListStyle = function (listObj, sObj) {
		listObj.style.fontSize = SelectEXT.fontSize + "px";
		listObj.style.lineHeight = SelectEXT.lineHeight + "px";
		if(SelectEXT.isIE) {
			listObj.style.overflowX = "hidden";
			listObj.style.overflowY = "auto";
		} else {
			listObj.style.overflow = "auto";
		}

		listObj.style.zIndex = 1;
		listObj.style.borderColor = "#000000";
		listObj.style.borderWidth  = "0px";	// 이 값은 변경 하지 말것. //
		listObj.style.borderStyle = "solid";
		listObj.style.color = SelectEXT.defaultFontColor;
		if (true) {//this.isIE && this.browserVersion >= 5.5) {
			listObj.style.scrollbarFaceColor = sObj.arrowColor;
			listObj.style.scrollbarHighlightColor = "#F0F0F0";
			listObj.style.scrollbarShadowColor = "#F0F0F0";
			listObj.style.scrollbar3dLightColor = sObj.bgColor;
			listObj.style.scrollbarArrowColor = sObj.fontColor;
			listObj.style.scrollbarTrackColor = sObj.bgColor;
			listObj.style.scrollbarDarkShadowColor = sObj.bgColor;
		}
	}
	// optGroup의 style.
	this.applyOptGroupStyle = function (optGroup, sObj) {
		optGroup.style.color = sObj.fontColor;
		optGroup.style.textIndent = "3px";
		optGroup.style.paddingTop = "2px";
		optGroup.style.height = SelectEXT.unitSize + "px";
		optGroup.style.lineHeight = SelectEXT.lineHeight + "px";
		optGroup.style.fontSize = SelectEXT.fontSize + "px";
		optGroup.style.fontStyle = "italic";
		optGroup.style.fontStyle = "italic";
		optGroup.style.fontWeight = "bold";
		optGroup.noWrap = true;
	}
	// option의 style.
	this.applyOptionStyle = function (option, sObj) {
		option.style.color = sObj.fontColor;
		option.style.cursor = SelectEXT.cursorName;
		option.style.fontSize = SelectEXT.fontSize + "px";
		option.style.textIndent = "3px";
		option.style.paddingTop = "2px";
		option.style.height = SelectEXT.unitSize + "px";
		option.style.lineHeight = SelectEXT.lineHeight + "px";
		option.noWrap = true;
	}
}
SelectEXT = new ExtendedSelectManager();

/************************* ExtendedSelect *************************/
/**
 * id: document.getElementById()로 가져올수 있는 select객체의 id. unique해야 함.
 * name: form으로 넘거갈때에 사용되는 select의 이름. (내부적으로 hidden으로 넘겨줌.)
 * direction: 리스트가 펼처질 방향. "up", "down" default는 "down".
 * width: 제목영역의 가로길이. default는 SelectEXT.defaultWidth
 * listWidth: 리스트영역의 가로길이. default는 제목영역의 가로길이.
 * lineCount: 리스트가 펼쳐질때 보여질 option의 개수. 높이를 결정함. default는 8.
 * arrowImage: 제목영역의 화살표 이미지 URL. 설정되어 있지 않을때에는 ▼로 생성함.
 * style {
 * 	- width: 제목영역의 가로길이. 위의 width값을 덮어씌움.
 * 	- background-color: select의 배경색. default는 SelectEXT.defaultBGColor
 * }
 */
function ExtendedSelect(sObj) {
	this.id = sObj.id;	// id
	this.name = sObj.name;
	this.value;			// ExtendedSelect에 설정된 값.
	this.text;			// ExtendedSelect에 설정된 값에 해당하는 텍스트.
	this.direction = sObj.getAttribute("direction");	// 리스트가 펼쳐질 방향. up, down 을 지원. 기본값은 down.
	this.divAll = document.createElement("DIV");	// 전체 구조를 가지는 DIV.
	this.titleObj;	// select에 기본으로 보여지는 텍스트 노드.
	this.hiddenObj;	// form을 이용하여 데이타가 넘어갈때 필요한 input(hidden) 객체.
	this.listObj;	// select의 list부분을 구성하는 div 노드.

	this.bgColor = sObj.getAttribute("bgColor") ? sObj.getAttribute("bgColor") : SelectEXT.defaultBGColor;
	if(sObj.style.backgroundColor) this.bgColor = sObj.style.backgroundColor;
	this.fontColor = sObj.getAttribute("fontColor") ? sObj.getAttribute("fontColor") : SelectEXT.defaultFontColor;
	if(sObj.style.color) this.fontColor = sObj.style.color;
	this.arrowColor = sObj.getAttribute("arrowColor") ? sObj.getAttribute("arrowColor") : SelectEXT.defaultArrowColor;

	this.width = sObj.getAttribute("width") ? parseInt(sObj.getAttribute("width"), 10) : SelectEXT.defaultWidth;
	if(parseInt(sObj.style.width, 10) > 0) this.width = parseInt(sObj.style.width, 10);

	this.listWidth = sObj.getAttribute("listWidth") ? parseInt(sObj.getAttribute("listWidth"), 10) : this.width;

	if(sObj.getAttribute("lineCount"))
		this.height = parseInt(sObj.getAttribute("lineCount"), 10) * SelectEXT.unitSize + 2;
	else if(sObj.options.length < SelectEXT.defaultLineCount)
		this.height = sObj.options.length * SelectEXT.unitSize + 2;
	else
		this.height = SelectEXT.defaultLineCount * SelectEXT.unitSize + 2;

	this.arrowImage = sObj.getAttribute("arrowImage");

	this.children = new Array();	// option이나 optGroup을 가지는 리스트.
	this.options = new Array();	// option만을 가지는 리스트.
	this.selectedIndex = -1;	// 현재 선택된 option의 번호.
	this.onChange = sObj.onchange;	// select의 onChange 이벤트 핸들러를 가져옴.

	/**
	 * DOM을 이용하여 보여주기 위한 객체들을 생성하는 메소드.
	 */
	this.create = function () {
		// option 또는 optGroup이 들어갈 div.
		this.listObj = document.createElement("DIV");
		this.listObj.selObject = this;
		this.listObj.onmouseover = this.onMouseOver;
		this.listObj.onmouseout = this.onMouseOut;
		this.listObj.style.background = this.bgColor;
		this.listObj.style.visibility = "hidden";
		this.listObj.style.position = "absolute";
		this.listObj.style.width = (this.width + 2) + "px";
		this.listObj.style.height = this.height + "px";
		this.listObj.style.left = "0px";
		this.listObj.style.top = "-" + this.height +"px";
		if(this.direction)
		switch(this.direction) {
			case "down":
				//this.listObj.style.top = (this.height) + "px"; 다운시 아래것으로 교체
				this.listObj.style.top = "0px";
				break;
			case "up":
				break;
			default:
				break;
		}
		for(var i = 0; i < this.children.length; i++) // 하위의 option 또는 optGroup을 만들어서 붙임.
			this.listObj.appendChild(this.children[i].create());
		SelectEXT.applyListStyle(this.listObj, this);

		var tableObj = document.createElement("TABLE");
		tableObj.cellSpacing = 0;
		tableObj.cellPadding = 0;
		tableObj.border = 0;
		tableObj.borderStyle = "solid";
		tableObj.width = this.width + "px";
		tableObj.style.height = (SelectEXT.unitSize + 2) + "px";
		tableObj.bgColor = "#F0F0F0";
		
		var tr = tableObj.insertRow(0);
		tr.selObject = this;
		tr.style.cursor = SelectEXT.cursorName;

		// 제목 영역이 들어갈 div.
		var div = document.createElement("DIV");
		div.selObject = this;
		div.style.width = (this.width - SelectEXT.unitSize + 2) + "px";
		div.style.height = SelectEXT.unitSize + "px";
		div.style.background = this.bgColor;
		this.titleObj = document.createTextNode("선택하세요");
		div.appendChild(this.titleObj);
		var td = tr.insertCell(0);
		td.align = "left";
		td.vAlign = "middle";
		td.style.width = (this.width - SelectEXT.unitSize + 2) + "px";
		td.style.color = this.listObj.style.color;
		SelectEXT.applyTitleStyle(div, this);
		td.appendChild(div);
		// 아래방향 화살표 이미지.
		var arrow;
		if(this.arrowImage) {
			arrow = new Image();
			arrow.src = this.arrowImage;
			arrow.border = 0;
			arrow.width = SelectEXT.unitSize;
			arrow.height = SelectEXT.unitSize;

		} else {
			arrow = document.createElement("DIV");
			arrow.style.fontSize = SelectEXT.fontSize + "px";
			arrow.style.paddingTop = "2px";
			arrow.style.background = this.listObj.style.scrollbarFaceColor;
			arrow.style.color = this.listObj.style.scrollbarArrowColor;
			arrow.style.width = SelectEXT.unitSize + "px";
			arrow.style.height = SelectEXT.unitSize + "px";
			arrow.appendChild(document.createTextNode("▼"));
		}
		arrow.selObject = this;
		td = tr.insertCell(1);
		td.align = "center";
		td.vAlign = "middle";
//		title.style.borderColor = "#BDBEBE";
//		title.style.borderWidth  = "1px";	// 이 값은 변경 하지 말것. //
//		title.style.borderStyle = "solid";



//		td.width = (SelectEXT.unitSize + 2) + "px";
//		td.height = (SelectEXT.unitSize + 2) + "px";
//		td.style.backgroundColor = this.arrowColor;
		td.appendChild(arrow);

		tr.onclick = this.onClick;
		tr.onmouseover = this.onMouseOver;
		tr.onmouseout = this.onMouseOut;

		// 생성하면서 셋팅할 값과 보여줄 텍스트를 계산.
		if(this.selectedIndex == -1) {
			this.selectedIndex = 0;
		}
		if(this.options[this.selectedIndex]) {
			this.value = this.options[this.selectedIndex].value;
			this.text = this.options[this.selectedIndex].text;
		}
		this.titleObj.nodeValue = this.text;
		this.titleObj.parentNode.title = this.text;
		if(SelectEXT.isIE) {
			this.hiddenObj = document.createElement("<input name='"+this.name+"'>");	
			this.hiddenObj.selObject = this;
			this.hiddenObj.onpropertychange = this.onValueChange;
		} else {
			this.hiddenObj = document.createElement("INPUT");	
			this.hiddenObj.name = this.name;
		}
		this.hiddenObj.type = "hidden";
		this.hiddenObj.value = this.value;
		this.hiddenObj.text = this.text;
		this.hiddenObj.selectedIndex = this.selectedIndex;
		this.hiddenObj.options = this.options;

		this.divAll.id = this.id;
		this.divAll.style.display = "inline";
		this.divAll.style.position = "relative";
		this.divAll.style.backgroundColor = this.bgColor;
		this.divAll.appendChild(tableObj);
		this.divAll.appendChild(this.listObj);
		this.divAll.appendChild(this.hiddenObj);

		// 생성된 table을 return.
		return this.divAll;
	}
	this.onClick = function (e) {
		var obj = e ? e.target : window.event.srcElement;
		if(obj && obj.selObject) obj.selObject.onClickProc();
	}
	this.onClickProc = function () {
		this.toggleShow();
	}
	this.onMouseOver = function (e) {
		var obj = e ? e.target : window.event.srcElement;
		if(obj && obj.selObject) obj.selObject.onMouseOverProc();
	}
	this.onMouseOverProc = function () {
		this.stopClose();
	}
	this.onMouseOut = function (e) {
		var obj = e ? e.target : window.event.srcElement;
		if(obj && obj.selObject) obj.selObject.onMouseOutProc();
	}
	this.onMouseOutProc = function () {
		this.startClose();
	}
	this.onValueChange = function () {	// IE only...
		var e = window.event;
		var obj = e.srcElement;
		if(obj && obj.selObject) {
			var sObj = obj.selObject;
			switch(e.propertyName) {
				case "value":
					if(sObj.value != obj.value) sObj.setValue(obj.value);
					break;
				case "text":
					if(sObj.text != obj.text) sObj.setText(obj.text);
					break;
				case "selectedIndex":
					if(sObj.selectedIndex != obj.selectedIndex) sObj.setSelectedIndex(obj.selectedIndex);
					break;
				case "style.display":
					if(sObj.divAll.style.display != obj.style.display) sObj.divAll.style.display = obj.style.display;
					break;
				case "style.visibility":
					if(sObj.divAll.style.visibility != obj.style.visibility) sObj.divAll.style.visibility = obj.style.visibility;
					break;
			}
		}
	}
	/**
	 * 이 ExtendedSelect를 벗어나는 경우 펼쳐저 있던 리스트를 숨기기 위한 timer를 작동시키는 메소드.
	 */
	this.startClose = function () {
		this.stopClose();
		if(this.listObj.style.visibility == "visible")
			this.closeTimer = window.setTimeout(SelectEXT.close, SelectEXT.closeTimeOut);
	}
	/**
	 * 일정 시간 이내(SelectEXT.closeTimeOut)에 다시 들어왔을때 timer를 멈추게 하는 메소드.
	 */
	this.stopClose = function () {
		if(this.closeTimer != null) {
			window.clearTimeout(this.closeTimer);
			this.closeTimer = null;
		}
	}
	/**
	 * 펼쳐진 리스트를 숨기는 메소드.
	 */
	this.close = function () {
		this.listObj.style.visibility = "hidden";
	}
	/**
	 * 리스트를 펼치는 메소드.
	 */
	this.show = function () {
		this.listObj.style.visibility = "visible";
		if(this.selectedIndex >= 0 && this.selectedIndex < this.options.length) {
			this.options[this.selectedIndex].onMouseOverProc();
			if(SelectEXT.isIE) this.options[this.selectedIndex].divObj.focus();
		}
		// 이 ExtendedSelect가 주목받고 있다는 것을 기억해둠.
		SelectEXT.setShowed(this);
	}
	/**
	 * ExtendedSelect를 클릭하는 경우 펼침/숨김을 하기 위한 메소드.
	 */
	this.toggleShow = function () {
		if(this.listObj.style.visibility == "visible") this.close();
		else this.show();
	}
	/**
	 * 값을 설정하는 메소드.
	 */
	this.setValue = function (value) {
		var opt = null;
		if(this.selectedIndex >= 0 && this.selectedIndex < this.options.length)
			this.options[this.selectedIndex].onMouseOutProc();
		var founded = false;
		for(var i = 0; i < this.options.length; i++) {
			opt = this.options[i];
			if(opt.value == value) {
				opt.selected = true;
				this.selectedIndex = i;
				founded = true;
			} else {
				opt.selected = false;
			}
		}
		if(!founded) this.selectedIndex = -1;
		this.refresh();
	}
	this.setText = function (text) {
		var opt = null;
		if(this.selectedIndex >= 0 && this.selectedIndex < this.options.length)
			this.options[this.selectedIndex].onMouseOutProc();
		var founded = false;
		for(var i = 0; i < this.options.length; i++) {
			opt = this.options[i];
			if(opt.text == text) {
				opt.selected = true;
				this.selectedIndex = i;
				founded = true;
			} else {
				opt.selected = false;
			}
		}
		if(!founded) this.selectedIndex = -1;
		this.refresh();
	}
	this.setSelectedIndex = function (index) {
		if(index >= 0 && index < this.options.length)
			this.selectedIndex = index;
		else if(index == -1)
			this.selectedIndex = -1;
		this.refresh();
	}
	/**
	 * 제목 영역을 다시 뿌려주는 메소드.
	 */
	this.refresh = function () {
		if(this.selectedIndex >= 0 && this.selectedIndex < this.options.length) {
			if(this.value != this.options[this.selectedIndex].value) {
				this.value = this.options[this.selectedIndex].value;
				this.hiddenObj.value = this.value;
				this.hiddenObj.selectedIndex = this.selectedIndex;
				this.text = this.options[this.selectedIndex].text;
				this.titleObj.nodeValue = this.text;
				this.titleObj.parentNode.title = this.text;
				this.hiddenObj.text = this.text;
				// 값이 변경된 경우이므로 select에 설정되어있는 onChange이벤트 핸들러를 호출한다.
				if(this.onChange) this.onChange();
			}
		} else if(this.selectedIndex == -1){
			this.value = "";
			this.hiddenObj.value = this.value;
			this.hiddenObj.selectedIndex = this.selectedIndex;
			this.text = "";
			this.titleObj.nodeValue = "　";
			this.titleObj.parentNode.title = this.text;
			this.hiddenObj.text = this.text;
			if(this.onChange) this.onChange();
		}
	}

	// 초기화 작업.
	var nodeList = sObj.childNodes;
	if(nodeList && nodeList.length > 0) {
		for(var i = 0; i < nodeList.length; i++) {
			if(nodeList[i].tagName) {
				if(nodeList[i].tagName.toLowerCase() == "optgroup") {
					var optGroup = new ExtendedOptGroup(this);
					optGroup.init(this, nodeList[i]);
					this.children[this.children.length] = optGroup;
				} else if(nodeList[i].tagName.toLowerCase() == "option") {
					var opt = new ExtendedOption(this);
					opt.init(nodeList[i], "");
					this.children[this.children.length] = opt;
				}
			}
		}
	}
}

/************************* ExtendedOptGroup *************************/
function ExtendedOptGroup(sObj) {
	this.sObj = sObj;	// 부모가 되는 ExtendedSelect 객체.
	this.label;	// optGroup의 label.
	this.divObj;	// optGroup과 그 하위에 포함되는 option이 들어갈 div.
	this.options = new Array();	// option 리스트.
	/**
	 * 초기화 메소드.
	 */
	this.init = function(sObj, optGroup) {
		this.label = optGroup.label;
		var nodeList = optGroup.childNodes;
		if(nodeList && nodeList.length > 0) {
			for(var i = 0; i < nodeList.length; i++) {
				if(nodeList[i].tagName && nodeList[i].tagName.toLowerCase() == "option") {
					var opt = new ExtendedOption(this.sObj);
					opt.init(nodeList[i], "　");	 // optGroup 밑으로 들어가는 option이므로 들여쓰기를 함.
					this.options[this.options.length] = opt;
				}
			}
		}
	}
	/**
	 * 화면에 뿌려질 객체를 만드는 메소드.
	 */
	this.create = function () {
		this.divObj = document.createElement("DIV");
		this.divObj.selObject = this;
		this.divObj.onmouseover = this.onMouseOver;
		this.divObj.onmouseout = this.onMouseOut;
		var div = document.createElement("DIV");
		div.title = this.label;
		div.selObject = this;
		div.onmouseover = this.onMouseOver;
		div.onmouseout = this.onMouseOut;
		div.appendChild(document.createTextNode(this.label));
		SelectEXT.applyOptGroupStyle(div, this.sObj);
		this.divObj.appendChild(div);
		for(var i = 0; i < this.options.length; i++) {
			this.divObj.appendChild(this.options[i].create());
		}
		return this.divObj;
	}
	this.onMouseOver = function (e) {
		var obj = e ? e.target : window.event.srcElement;
		if(obj && obj.selObject) obj.selObject.onMouseOverProc();
	}
	this.onMouseOverProc = function () {
		this.sObj.stopClose();
	}
	this.onMouseOut = function (e) {
		var obj = e ? e.target : window.event.srcElement;
		if(obj && obj.selObject) obj.selObject.onMouseOutProc();
	}
	this.onMouseOutProc = function () {
		this.sObj.startClose();
	}
}

/************************* ExtendedOption *************************/
function ExtendedOption(sObj) {
	this.sObj = sObj;	// 부모가 되는 ExtendedSelect 객체.
	this.value;	// option의 값.
	this.text;	// option의 텍스트.
	this.selected;	// 이 option이 선택되었는가?
	this.indent;	// 화면에 뿌려질때 들어쓰기 값.
	this.divObj;	// 화면에 뿌려지는 div.
	this.index;	// 이 option의 순서.
	/**
	 * 초기화 메소드.
	 */
	this.init = function (opt, indent) {
		this.value = opt.value;
		this.text = opt.text;
		this.selected = opt.selected;
		this.indent = indent;
		this.index = this.sObj.options.length;
		this.sObj.options[this.index] = this;
		if(this.selected) {
			this.sObj.selectedIndex = this.index;
		}
	}
	/**
	 * 화면에 뿌려질 객체를 만드는 메소드.
	 */
	this.create = function () {
		this.divObj = document.createElement("DIV");
		this.divObj.optObject = this;
		this.divObj.onclick = this.onClick;
		this.divObj.onmouseover = this.onMouseOver;
		this.divObj.onmouseout = this.onMouseOut;
		this.divObj.appendChild(document.createTextNode(this.indent + this.text));
		this.divObj.title = this.text;
		SelectEXT.applyOptionStyle(this.divObj, this.sObj);
		return this.divObj;
	}
	this.onClick = function (e) {
		var obj = e ? e.target : window.event.srcElement;
		if(obj) obj.optObject.onClickProc();
	}
	this.onClickProc = function () {
		if(this.sObj.options[this.sObj.selectedIndex])
			this.sObj.options[this.sObj.selectedIndex].onMouseOutProc();
		this.sObj.selectedIndex = this.index;
		this.sObj.refresh();
		this.sObj.close();
	}
	this.onMouseOver = function (e) {
		var obj = e ? e.target : window.event.srcElement;
		if(obj) obj.optObject.onMouseOverProc();
	}
	this.onMouseOverProc = function () {
		this.divObj.style.background = this.sObj.fontColor;
		this.divObj.style.color = this.sObj.bgColor;
		this.sObj.stopClose();
	}
	this.onMouseOut = function (e) {
		var obj = e ? e.target : window.event.srcElement;
		if(obj) obj.optObject.onMouseOutProc();
	}
	this.onMouseOutProc = function () {
		this.divObj.style.background = this.sObj.bgColor;
		this.divObj.style.color = this.sObj.fontColor;
		this.sObj.startClose();
	}
}
