﻿/**
 * DropDownListBTD
 * 
 * @author     banhthidiem <banhthidiem@gmail.com>
 * @copyright  2008 Bach Khoa Computer Inc.
 * @version    1.5 2008/09/30
 */
 
 var EventNameDDL =
{
	/******* Event Name of DropDownList *******/
	click : "click",
	blur : "blur",
	focus : "focus",
	change : "change",
	
	/******* Event Name of Item DropDownList *******/
	itemClick : "itemClick",
	itemMouseOver : "itemMouseOver",
	itemMouseMove : "itemMouseMove",
	itemMouseOut : "itemMouseOut"
};

var ColummTypeDDL =
{
	label : "label",
	image : "image"
};

DropDownListBTD = function (idParent, listData, myName, myStyle, isCbo) {
	if (idParent == null) return;
	this.myName = myName;
	this.isBTD = true;
	this.isHideList = false;
	this.myStyle = typeof (myStyle) == "undefined" ? "" : myStyle;
	this.heightItem = 19;
	this.maxItem = listData.maxItem == null ? 10 : listData.maxItem;
	this.elContainerList = null;
	this.elContainer = null;
	this.oTableList = null;
	if (typeof (isCbo) == "undefined" || !isCbo) {
		this.elContainerParent = typeof (idParent) == "string" ? utilObj.getElById(idParent) : idParent;
		this.listData = utilObj.cloneObject(listData);
	}
	else {
		var oCbo = typeof (idParent) == "string" ? utilObj.getElById(idParent) : idParent;
		this.elContainerParent = oCbo.parentNode;
		this.listData = null;
		this.createListFromCbo(oCbo);
		this.elContainerParent.removeChild(oCbo);
	}

	this.listEvent = new Array();
	this.itemSelected = null;
	this.oldValue = "";
	this.oldElRow = null;

	/*************** Properties ******************/
	this.isTextBoxReadOnly = false;
	this.isReadOnly = false;
	this.enabledAutoCom = true;
	this.isMultiSelect = false;
	/*************** Properties ******************/

	if (this.elContainerParent != null) this.createMain();
	var self = this;
	this.alreadyKeyDown = false;

	this.whenKeyDown = function (e) {
		self.documentKeyDownDDL(e);
	};
};

DropDownListBTD.prototype.checkDataHasImage = function()
{
	var isHasImage = false;
	var maxHeight = 15;
	var listCols = this.listData.mapField.display;
	for (var i = 0; i < listCols.length; i++)
	{
		if (listCols[i].type == ColummTypeDDL.image)
		{
			isHasImage = true;
			if (maxHeight < listCols[i].height)
			{
				maxHeight = listCols[i].height;
			}
		}
	}
	var delta = ((utilObj.isIE || utilObj.isOpera) ? 5 : 7);
	if (isHasImage && maxHeight > this.heightItem - delta)
	{
		this.heightItem = maxHeight + delta;
	}
};

/*****************************************************************************
					Create element in DropDownList Start
*****************************************************************************/

DropDownListBTD.prototype.createMain = function() {
	try {
		//this.checkDataHasImage();
		this.createContainer();
		var self = this;
		utilObj.addEvent(document, "mousedown", function(e) { self.documentMouseDownDDL(e); }); 
		utilObj.addEvent(window, "resize", function(e) { self.hideList(e); });
		utilObj.addEvent(document, "scroll", function(e) { self.hideList(e); });
	}
	catch (e)
	{ }
};

DropDownListBTD.prototype.setWidth = function(w) {
	w += "";
	w = (w.indexOf("%", 0) == -1) ? ((w.indexOf("px", 0) == -1) ? w + "px" : w) : w;
	this.elContainer.style.width = w;
};

DropDownListBTD.prototype.getPositionView = function() {
	return utilObj.getElementPositionView(this.elContainer);
};

DropDownListBTD.prototype.getSize = function() {
	return utilObj.getElementSize(this.elContainer);
};

DropDownListBTD.prototype.createContainer = function()
{
	this.elContainer = utilObj.createEl("DIV");
	this.elContainer.className = "containerDDL" + this.myStyle;
	this.elContainerParent.appendChild(this.elContainer);
	this.createTextBox();
	this.createButton();
	this.createContainerList();
};

DropDownListBTD.prototype.createTextBox = function()
{
	var o = utilObj.createEl("INPUT");
	o.className = "inputDDL";
	o.readOnly = this.isTextBoxReadOnly;
	o.nameDDL = this.myName;
	var self = this;
	o["onmouseover"] = function(e) { self.mouseOverDDL(e); };
	o["onmouseout"] = function(e) { self.mouseOutDDL(e); };
	o["onclick"] = function(e) { self.mouseClickDDL(e); };
	o["onkeydown"] = function(e) { self.textBoxKeyDownDDL(e); };
	o["onfocus"] = function(e) { self.mouseFocusDDL(e); };
	o["onblur"] = function(e) { self.textBoxBlurDDL(e); };
	this.oTextBox = o;
	this.elContainer.appendChild(o);
};

DropDownListBTD.prototype.createButton = function() {
	var o = utilObj.createEl("DIV");
	o.className = "imgButtonDDL";
	o.nameDDL = this.myName;
	var self = this;
	o["onmouseover"] = function(e) { self.mouseOverDDL(e); };
	o["onmouseout"] = function(e) { self.mouseOutDDL(e); };
	o["onclick"] = function(e) { self.mouseClickDDL(e); };
	o["onfocus"] = function(e) { self.mouseFocusDDL(e); };
	this.oBtn = o;
	this.elContainer.appendChild(o);
};

DropDownListBTD.prototype.createContainerList = function()
{
	this.elContainerList = utilObj.createEl("DIV");
	this.elContainerList.className = "divListDDL";
	this.elContainerList.nameDDL = this.myName;
	this.elContainerList.style.top = "-1000px";
	this.elContainerList.style.left = "-1000px";
	utilObj.addChildToBody(this.elContainerList);
	this.createList();
	this.elContainerList.style.display = "none";
};

DropDownListBTD.prototype.createList = function()
{
	this.oTableList = utilObj.createEl("TABLE");
	this.oTableList.className = "tableListDDL";
	this.oTableList.nameDDL = this.myName;
	this.oTableList.style.visibility  = "visible";
	this.elContainerList.appendChild(this.oTableList);
	this.createTBodyList();
};

DropDownListBTD.prototype.createTBodyList = function()
{
	for (var i = 0; i < this.listData.data.length; i++) {
		this.insertRow(this.listData.data[i]);
	}
};

DropDownListBTD.prototype.insertRow = function (item) {
	var elRow = this.oTableList.insertRow(this.oTableList.rows.length);
	elRow.item = item;
	item.elRow = elRow;
	elRow.nameDDL = this.myName;
	elRow.className = "itemListDDL";
	for (var i = 0; i < this.listData.mapField.display.length; i++) {
		this.insertCell(elRow, this.listData.mapField.display[i]);
	}
	this.mapEventForRow(elRow);
	if (this.oTableList.rows.length == 1) {
		this.heightItem = utilObj.getElementSize(elRow.cells[0]).height;
	}
};

DropDownListBTD.prototype.insertCell = function(elRow, oCol)
{
	switch (oCol.type)
	{
		case ColummTypeDDL.label:
			this.createLabel(elRow, oCol);
			break;
		case ColummTypeDDL.image:
			this.createImage(elRow, oCol);
			break;
	}
};

DropDownListBTD.prototype.createLabel = function(elRow, oCol) {
	elCell = elRow.insertCell(elRow.cells.length);
	if (oCol.width != null) {
		elCell.style.minWidth = oCol.width + "px";
	}
	elCell.nameDDL = this.myName;
	elCell.element = utilObj.createEl("LABEL");
	elCell.element.nameDDL = this.myName;
	elCell.element.innerHTML = elRow.item[oCol.field];
	elCell.appendChild(elCell.element);
	return elCell;
};

DropDownListBTD.prototype.createImage = function(elRow, oCol) {
	elCell = elRow.insertCell(elRow.cells.length);
	elCell.nameDDL = this.myName;
	elCell.element = utilObj.createEl("IMG");
	elCell.element.nameDDL = this.myName;
	elCell.element.src = elRow.item[oCol.field];
	elCell.element.height = oCol.height;
	elCell.element.width = oCol.width;
	elCell.appendChild(elCell.element);
	return elCell;
};

/*****************************************************************************
					Create element in DropDownList End
*****************************************************************************/

/*****************************************************************************
					Create action when execute event Start
*****************************************************************************/

/*=================================Item Event=========================================*/
DropDownListBTD.prototype.mouseOverItemDDL = function(elRow, e)
{
	if (this.oldElRow != null && this.oldElRow != elRow)
	{
		this.oldElRow.className = "itemListDDL";
	}
	elRow.className = "itemListDDL_over";
	this.oldElRow = elRow;
};

DropDownListBTD.prototype.clickItemDDL = function (elRow, e) {
	this.hideList();
	if (this.itemSelected == null ||
		(this.itemSelected != null && this.itemSelected[this.listData.mapField.text] != elRow.item[this.listData.mapField.text]) || 
		this.oTextBox.value != this.oldValue) {
		this.itemSelected = elRow.item;
		this.oldValue = this.oTextBox.value;
		this.oTextBox.value = elRow.item[this.listData.mapField.text];
		this.oldElRow = elRow;
		this.executeEvent(e, EventNameDDL.change);
	}
};
/*===================================Item Event=======================================*/

/*===================================Document Event=======================================*/
DropDownListBTD.prototype.documentMouseDownDDL = function(e)
{
	var o = utilObj.getTargetElement();
	if (typeof(o.nameDDL) != "undefined" && o.nameDDL == this.myName)
	{
		return;
	}
	this.hideList();
};

DropDownListBTD.prototype.documentKeyDownDDL = function (e) {
	e = utilObj.getWindowEvent();
	if (e.ctrlKey || e.altKey || e.shiftKey) {
		return false;
	}
	this.isHideList = false;
	switch (e.keyCode) {
		case 38:
			this.gotoItem(true);
			break;
		case 40:
			this.gotoItem(false);
			break;
		case 27:
			this.isHideList = true;
			this.hideList();
			break;
		case 13: case 9:
			this.isHideList = true;
			if (this.oldElRow != null && this.enabledAutoCom) {
				this.clickItemDDL(this.oldElRow, e);
			}
			else if (this.oTextBox.value != this.oldValue) // No Use AutoComplete
			{
				this.oldValue = this.oTextBox.value;
				this.hideList();
				this.executeEvent(e, EventNameDDL.change);
			}
			utilObj.stopEvent();
			break;
		default:
			var self = this;
			if (!this.isTextBoxReadOnly) {
				setTimeout(function () { self.toComplete(); }, 50);
			}
			break;
	}
	return false;
};
/*===================================Document Event=======================================*/

/*===================================Element Event=======================================*/
DropDownListBTD.prototype.mouseFocusDDL = function(e)
{
	if (!this.alreadyKeyDown)
	{
		this.alreadyKeyDown = true;
		utilObj.addEvent(document, "keydown", this.whenKeyDown);
	}
	this.executeEvent(e, EventNameDDL.focus);
};

DropDownListBTD.prototype.mouseOverDDL = function(e)
{
	this.oBtn.className = "imgButtonDDL_over";
};

DropDownListBTD.prototype.mouseOutDDL = function(e)
{
	this.oBtn.className = "imgButtonDDL";
};

DropDownListBTD.prototype.mouseClickDDL = function(e) {
	if (this.isReadOnly) return;
	this.showList(e);
	this.executeEvent(e, EventNameDDL.click);
};

DropDownListBTD.prototype.textBoxKeyDownDDL = function(e)
{
	if (!this.alreadyKeyDown)
	{
		this.alreadyKeyDown = true;
		utilObj.addEvent(document, "keydown", this.whenKeyDown);
	}
	if (this.elContainerList.style.display == "none" && !this.isHideList)
	{
		this.mouseClickDDL(e);
	}
};

DropDownListBTD.prototype.textBoxBlurDDL = function(e) {
	if (this.oTextBox.value == "") {
		this.reset();
	}
	else {
		this.oTextBox.value = this.getText();
	}
	this.executeEvent(e, EventNameDDL.blur);
};

/*===================================Element Event=======================================*/

/*****************************************************************************
					Create action when execute event End
*****************************************************************************/

/*****************************************************************************
								Event Start
*****************************************************************************/

DropDownListBTD.prototype.mapEventForRow = function(elRow)
{
	var self = this;
	elRow["onclick"] = function(e)
	{
		self.clickItemDDL(elRow, e);
		e = utilObj.getWindowEvent();
		e.item = elRow.item;
		self.executeEvent(e, EventNameDDL.itemClick);
	};
	elRow["onmouseover"] = function(e)
	{
		self.mouseOverItemDDL(elRow, e);
		e = utilObj.getWindowEvent();
		e.item = elRow.item;
		self.executeEvent(e, EventNameDDL.itemMouseOver);
	};
	elRow["onmousemove"] = function(e) 
	{
		e = utilObj.getWindowEvent();
		e.item = elRow.item;
		self.executeEvent(e, EventNameDDL.itemMouseMove);
	};
	elRow["onmouseout"] = function(e) 
	{
		e = utilObj.getWindowEvent();
		e.item = elRow.item;
		self.executeEvent(e, EventNameDDL.itemMouseOut);
	};
};

DropDownListBTD.prototype.addEvent = function(eventName, func)
{
	if(this.listEvent[eventName] == null)
	{
		this.listEvent[eventName] = [];
	}
	this.listEvent[eventName].push(func);
};

DropDownListBTD.prototype.removeEvent = function(eventName, func)
{
	if(this.listEvent[eventName] == null)
	{
		return;
	}
	for (var i = 0; i < this.listEvent[eventName].length; i++)
	{
		if (func == this.listEvent[eventName][i])
		{
			this.listEvent[eventName].splice(i, 1);
			break;
		}
	}
};

DropDownListBTD.prototype.executeEvent = function(e, eventName)
{
	if (this.listEvent[eventName] != null)
	{
		for (var i = 0; i < this.listEvent[eventName].length; i++)
		{
			this.listEvent[eventName][i](e);
		}
	}
};

/*****************************************************************************
								Event End
*****************************************************************************/

/*****************************************************************************
							Private Method Start
*****************************************************************************/

DropDownListBTD.prototype.clearListItems = function()
{
	this.listData.data = [];
	while (this.oTableList.rows.length > 0)
	{
		this.oTableList.deleteRow(0);
	}
	this.oTextBox.value = "";
};

DropDownListBTD.prototype.isExistItem = function(value)
{
	var list = this.listData.data;
	var isExist = false;
	for (var i = 0; i < list.length; i++)
	{
		if (list[i][this.listData.mapField.value] == value)
		{
			isExist = true;
			break;
		}
	}
	return isExist;
};

/*======================Create List From ComboBox===========================*/
DropDownListBTD.prototype.createListFromCbo = function(oCbo) {
	this.listData = {
		mapField: {
			value: "value",
			text: "text",
			search: "text",
			display: [
				{ name: "text", field: "text", type: ColummTypeDDL.label }
			]
		},
		data: []
	};
	for (var i = 0; i < oCbo.length; i++) {
		this.listData.data.push({ value: oCbo[i].value, text: oCbo[i].text });
	}
};

DropDownListBTD.prototype.enableTextBox = function()
{
	this.isTextBoxReadOnly = false;
	this.oTextBox.readOnly = this.isTextBoxReadOnly;
};

DropDownListBTD.prototype.disableTextBox = function()
{
	this.isTextBoxReadOnly = true;
	this.oTextBox.readOnly = this.isTextBoxReadOnly;
};

DropDownListBTD.prototype.toComplete = function() {
	var isSelected = false;
	var vSearch = this.oTextBox.value.toUpperCase();
	var arrVSearch = vSearch.split(" ");
	for (var i = 0; i < this.listData.data.length; i++) {
		var elRow = this.listData.data[i].elRow;
		var arrFieldSearch = [];
		var isFound = false;
		if (typeof this.listData.mapField.search == "string") {
			arrFieldSearch.push(this.listData.mapField.search);
		}
		else {
			arrFieldSearch = this.listData.mapField.search;
		}
		var countK = 0;
		for (var k = 0; k < arrVSearch.length; k++) {
			for (var j = 0; j < arrFieldSearch.length; j++) {
				var v = this.listData.data[i][arrFieldSearch[j]];
				if (v == null) continue;
				var v = v.toUpperCase();
				if (v.indexOf(arrVSearch[k], 0) != -1) {
					countK++;
					break;
				}
			}
		}
		isFound = countK == arrVSearch.length;
		if (isFound) {
			if (!isSelected) {
				if (this.oldElRow != null) {
					this.oldElRow.className = "itemListDDL";
				}
				elRow.className = "itemListDDL_over";
				this.oldElRow = elRow;
				// this.itemSelected = this.oldElRow.item;
				isSelected = true;
			}
			elRow.style.display = "";
		}
		else {
			elRow.style.display = "none";
		}
	}
	this.calcWidth();
	//this.calcPosition();
};

DropDownListBTD.prototype.gotoItem = function(isUp) {
	var elRowTemp = this.oldElRow;
	var counter = 0;
	if (elRowTemp != null) {
		this.oldElRow.className = "itemListDDL";
		for (var i = 0; i < this.listData.data.length; i++) {
			var elRow = this.listData.data[i].elRow;
			if (elRow.style.display == "") {
				counter++;
			}
			if (elRow == elRowTemp) break;
		}
	}

	var rowIndex = 0;
	while (true) {
		if (elRowTemp != null) {
			rowIndex = elRowTemp.rowIndex;
			if ((rowIndex == 0 && isUp) || (rowIndex == this.oTableList.rows.length - 1 && !isUp)) break;

			if (isUp) {
				if (elRowTemp.previousSibling.style.display == "none") {
					elRowTemp = elRowTemp.previousSibling;
					continue;
				}
				else {
					this.oldElRow = elRowTemp.previousSibling;
					counter -= 2;
					break;
				}
			}
			else {
				if (elRowTemp.nextSibling.style.display == "none") {
					elRowTemp = elRowTemp.nextSibling;
					continue;
				}
				else {
					this.oldElRow = elRowTemp.nextSibling;
					break;
				}
			}
		}
		else {
			if (this.oTableList.rows.length > 0) {
				elRowTemp = this.oTableList.rows[0];
				if (elRowTemp.nextSibling.style.display == "none") {
					elRowTemp = elRowTemp.nextSibling;
					continue;
				}
				else {
					this.oldElRow = elRowTemp;
					break;
				}
			}
			else {
				return;
			}
		}
	}
	if (this.oldElRow != null) {
		var curentPos = counter * this.heightItem;
		var startPos = this.elContainerList.scrollTop;
		var endPos = startPos + (this.maxItem * this.heightItem);
		if (startPos > curentPos || endPos <= curentPos) {
			var scrollDown = curentPos - (this.maxItem * this.heightItem) + this.heightItem;
			this.elContainerList.scrollTop = isUp ? curentPos : (scrollDown < 0 ? 0 : scrollDown);
		}

		// this.itemSelected = this.oldElRow.item;
		this.oldElRow.className = "itemListDDL_over";
		this.oTextBox.value = this.oldElRow.item[this.listData.mapField.text];
		this.oTextBox.select();
	}
};

DropDownListBTD.prototype.calcWidth = function() {
	var sizeTableList = utilObj.getElementSize(this.oTableList);
	var w = sizeTableList.width + 17 < 170 ? 170 : sizeTableList.width;
	var maxHeight = (this.maxItem * this.heightItem);
	this.elContainerList.style.maxHeight = maxHeight + "px";
	this.elContainerList.style.overflow = "auto";

	if (sizeTableList.height > maxHeight) {
		this.oTableList.style.width = (utilObj.isEE ? w - 17 : w) + "px";
		w = w + 17;
	}
	else {
		this.oTableList.style.width = (w - 1 < 0 ? 0 : w - 1) + "px";
	}

	// Set width for container DDL
	this.elContainerList.style.width = w + "px";
};

DropDownListBTD.prototype.calcPosition = function () {
	var sizeParent = utilObj.getElementSize(this.elContainer);
	var sizeChild = utilObj.getElementSize(this.elContainerList);
	var docScroll = utilObj.getDocumentScroll();
	var pos = utilObj.getElementPositionView(this.elContainer);
	var sizeClient = utilObj.getDocument();
	if ((pos.Y + sizeParent.height + sizeChild.height - docScroll.scrollTop) > sizeClient.clientHeight) {
		pos.Y -= sizeChild.height + 2;
	}
	else {
		pos.Y += sizeParent.height - 1;
	}
	if (sizeChild.width > sizeClient.clientWidth) {
		pos.X = docScroll.scrollLeft;
	}
	else if (pos.X + sizeChild.width > sizeClient.clientWidth + docScroll.scrollLeft) {
		pos.X = sizeClient.clientWidth + docScroll.scrollLeft - sizeChild.width;
	}
	this.elContainerList.style.top = pos.Y + "px";
	this.elContainerList.style.left = pos.X + "px";
};

DropDownListBTD.prototype.showList = function(e) {
	for (var i = 0; i < this.listData.data.length; i++) {
		this.listData.data[i].elRow.style.display = "";
	}
	this.elContainerList.style.display = "block";
	this.oTableList.style.width = "0px";
	this.calcWidth();
	if (this.oldElRow != null) {
		this.elContainerList.scrollTop = this.oldElRow.rowIndex * this.heightItem;
	}
	this.elContainerList.style.top = "0px";
	this.elContainerList.style.left = "0px";
	this.calcPosition();
};

DropDownListBTD.prototype.hideList = function()
{
	if (this.elContainerList == null) return;
	this.elContainerList.style.display = "none";
	this.elContainerList.style.top = "-1000px";
	this.elContainerList.style.left = "-1000px";
	if (this.alreadyKeyDown)
	{
		this.alreadyKeyDown = false;
		utilObj.removeEvent(document, "keydown", this.whenKeyDown);
	}
};

/*****************************************************************************
							Private Method End
*****************************************************************************/

/*****************************************************************************
							Public Method Start
*****************************************************************************/
DropDownListBTD.prototype.dispose = function()
{
	this.elContainerParent.removeChild(this.elContainer);
	this.elContainerList = null;
	this.elContainer = null;
};

DropDownListBTD.prototype.reset = function()
{
	this.elContainerList.scrollTop = 0;
	if (this.oldElRow != null)
	{
		this.oldElRow.className = "itemListDDL";
	}
	this.oldElRow = this.itemSelected = null;
	this.oTextBox.value = "";
};

DropDownListBTD.prototype.reloadData = function(data) {
	if (this.oTableList != null) {
		this.listData = utilObj.cloneObject(data);
		this.maxItem = this.listData.maxItem == null ? 10 : this.listData.maxItem;
		this.elContainerList.removeChild(this.oTableList);
		this.elContainerList.style.display = "block";
		this.createList();
		this.elContainerList.style.display = "none";
	}
};

DropDownListBTD.prototype.loadListItems = function(list)
{
	this.clearListItems();
	this.listData.data = list;
	this.createTBodyList();
};

DropDownListBTD.prototype.addItem = function (item) {
	this.listData.data.push(item);	
	this.insertRow(item);
};

DropDownListBTD.prototype.removeItem = function(value)
{
	// Delete data array
	var list = this.listData.data;
	for (var i = 0; i < list.length; i++)
	{
		if (value == list[i][this.listData.mapField.value])
		{
			if (this.itemSelected != null && this.itemSelected.elRow == list[i].elRow)
			{
				this.reset();
			}
			this.oTableList.tBodies[0].removeChild(list[i].elRow);
			list.splice(i, 1);
			break;
		}
	}
};

DropDownListBTD.prototype.getItemSelected = function()
{
	return this.itemSelected;
};

DropDownListBTD.prototype.focus = function() {
	this.oTextBox.focus();
};

DropDownListBTD.prototype.getValue = function(useQuote) {
	if (this.itemSelected == null) {
		return "";
	}
	if (useQuote != null && useQuote) {
		return "'" + this.itemSelected[this.listData.mapField.value] + "'";
	}
	return this.itemSelected[this.listData.mapField.value];
};

DropDownListBTD.prototype.getText = function() {
	if (this.itemSelected == null) {
		return "";
	}
	return this.enabledAutoCom ? this.itemSelected[this.listData.mapField.text] : this.oTextBox.value;
};

DropDownListBTD.prototype.selectedValue = function (v, useQuote) {
	if (this.oTableList != null) {
		this.reset();
		var elRows = this.oTableList.rows;
		for (var i = 0; i < elRows.length; i++) {
			var isChecked = elRows[i].item[this.listData.mapField.value] == v;
			if (useQuote != null && useQuote) {
				isChecked = "'" + elRows[i].item[this.listData.mapField.value] + "'" == v;
			}
			if (elRows[i].item[this.listData.mapField.value] == v) {
				if (this.oldElRow != null) {
					this.oldElRow.className = "itemListDDL";
				}
				this.oldElRow = elRows[i];
				this.itemSelected = this.oldElRow.item;
				this.oTextBox.value = this.oldElRow.item[this.listData.mapField.text];
				this.oldElRow.className = "itemListDDL_over";
				break;
			}
		}
	}
};

DropDownListBTD.prototype.setReadOnly = function(isReadOnly) {
	this.isReadOnly = isReadOnly;
	this.oTextBox.readOnly = isReadOnly;
};

/*****************************************************************************
							Public Method End
*****************************************************************************/
