function _NlLov() {
	this.__AutoComplete = new Array();
	this.__AutoComplete_findTime = null;
	this.__LOVS = new Array();

	this.isIE = document.all ? true : false;
	this.isGecko = navigator.userAgent.toLowerCase().indexOf('gecko') != -1;
	this.isOpera = navigator.userAgent.toLowerCase().indexOf('opera') != -1;

	this.dropdown_offsetWidth = 0;
	this.dropdown_offsetX = 0;

	this.divCod_offsetWidth = -3;
	this.divCod_offsetMarginRight = 7;
	this.divDesc_offsetWidth = 0;

	if (BrowserDetect.browser == "Firefox") {
		this.dropdown_offsetWidth = -2;
		this.dropdown_offsetX = 0;

		this.divCod_offsetWidth = -8;
		this.divCod_offsetMarginRight = 12;
	} else if (BrowserDetect.browser == "Chrome") {
		this.dropdown_offsetWidth = -2;

		this.divCod_offsetWidth = -8;
		this.divCod_offsetMarginRight = 16;
	}

	this.docEvent = false;
}

_NlLov.prototype = {
	__AutoComplete : null,
	__AutoComplete_findTime : null,
	isIE : false,
	isGecko : false,
	isOpera : false,
	docEvent : false,
	__LOVS : null,

	create : function(_idLov, _numSeq, _desPagina, _parEsp, _indTabela, _tipLov) {
		var _numMaxItens = 8;

		var _divFind = document.getElementById(_idLov + '_divJSFind');

		var _grid = _divFind.previousSibling;

		var _btnFind = NlUtil.findElement(_grid, _idLov, _idLov + '_btnFind');
		var _btnClear = NlUtil.findElement(_grid, _idLov, _idLov + '_btnClear');
		var _btnMasc = NlUtil.findElement(_grid, _idLov, _idLov + '_btnMasc');
		var _btnComment = NlUtil.findElement(_grid, _idLov,
				_idLov + '_btnComment');
		var _txtCod = NlUtil.findElement(_grid, _idLov, _idLov + '_txtCod');
		var _txtDesc = NlUtil.findElement(_grid, _idLov, _idLov + '_txtDesc');

		this.__LOVS[_grid.id.substring(0, _grid.id.indexOf('_grid'))] = {
			'tipLov' : _tipLov
		};

		if (_txtDesc != null && _tipLov != 1) {
			var id = _txtDesc.id;
			this.__AutoComplete[id] = {
				'data' : new Array(),
				'idLov' : _idLov,
				'txtDesc' : _txtDesc,
				'txtCod' : _txtCod,
				'dropdown' : null,
				'highlighted' : null,
				'numSeq' : _numSeq,
				'desPagina' : _desPagina,
				'parEsp' : _parEsp,
				'indTabela' : _indTabela,
				'maxitems' : _numMaxItens,
				'firstItemShowing' : 0,
				'lastItemShowing' : (_numMaxItens - 1),
				'ctrlTempo' : 0,
				'selected' : false,
				'txtDesc.initValue' : _txtDesc.value
			};

			// Eventos txt descrição
			_txtDesc.onkeydown = function(e) {
				return NlLov.autoComplete_KeyDown(this.getAttribute('id'), e);
			}

			_txtDesc.onkeyup = function(e) {
				return NlLov.autoComplete_KeyUp(this.getAttribute('id'), e);
			}

			_txtDesc.ondblclick = function() {
				window.clearTimeout(NlLov.__AutoComplete_findTime);
				NlLov.autoComplete_find(this.getAttribute('id'));
			}
			_txtDesc.onclick = function(e) {
				if (!e)
					e = window.event;
				e.cancelBubble = true;
				e.returnValue = false;
			}

			if (_tipLov == 3) {
				// Busca qnd ganha o foco
				_txtDesc.onfocus = function() {
					window.clearTimeout(NlLov.__AutoComplete_findTime);
					NlLov.autoComplete_find(this.getAttribute('id'), true);
				}
			}

			this.autoComplete_CreateDropdown(id);

			// Prevent select dropdowns showing thru
			if (this.isIE) {
				this.__AutoComplete[id]['iframe'] = document
						.createElement('iframe');
				this.__AutoComplete[id]['iframe'].id = id + '_iframe';
				this.__AutoComplete[id]['iframe'].style.position = 'absolute';
				this.__AutoComplete[id]['iframe'].style.top = '0px';
				this.__AutoComplete[id]['iframe'].style.left = '0px';
				this.__AutoComplete[id]['iframe'].style.width = '0px';
				this.__AutoComplete[id]['iframe'].style.height = '0px';
				this.__AutoComplete[id]['iframe'].style.zIndex = '98';
				this.__AutoComplete[id]['iframe'].style.visibility = 'hidden';
				this.__AutoComplete[id]['txtDesc'].parentNode.insertBefore(
						this.__AutoComplete[id]['iframe'],
						this.__AutoComplete[id]['txtDesc']);
			}

			if (!this.docEvent) {
				// Hides the dropdowns when document clicked
				var docClick = function() {
					for (id in NlLov.__AutoComplete) {
						NlLov.autoComplete_HideDropdown(id);
					}
				}

				if (document.addEventListener) {
					document.addEventListener('click', docClick, false);
				} else if (document.attachEvent) {
					document.attachEvent('onclick', docClick, false);
				}
				this.docEvent = true;
			}
		} else if (_txtDesc != null) {
			// Remove do array caso já exista (ocorre quando é alterado o tipo
			// dinamicamente na tela, teste da lov do usuario)
			if (this.__AutoComplete[_txtDesc.id] != null) {
				this.__AutoComplete = removeArrayKey(this.__AutoComplete,
						_txtDesc.id);
			}
			_txtDesc.oldValue = _txtDesc.value;
			_txtDesc.onkeydown = function(e) {
				return NlLov.enterEsc_KeyDown(this, e, _idLov, 'desc');
			}
		}

		// Tira o tab index
		if (_txtCod != null) {
			if (_tipLov != 1) {
				_txtCod.tabIndex = -1;
			}
			_txtCod.oldValue = _txtCod.value;
			_txtCod.onkeydown = function(e) {
				return NlLov.enterEsc_KeyDown(this, e, _idLov, 'cod');
			}
		}
		if (_btnFind != null) {
			_btnFind.tabIndex = -1;
		}
		if (_btnClear != null) {
			_btnClear.tabIndex = -1;
		}
		if (_btnMasc != null) {
			_btnMasc.tabIndex = -1;
		}
		if (_btnComment != null) {
			_btnComment.tabIndex = -1;
		}
	},

	change : function(campoValue, idLov, tipo) {
		changeFunc = function() {
			var btnFind = NlUtil.findElement(campoValue, idLov,
					idLov + '_btnFind');
			var hidAux = NlUtil.findElement(campoValue, idLov,
					idLov + '_hidAux');

			var id = campoValue.id;

			if (tipo == 'desc') {
				if (NlLov.__AutoComplete[id]
						&& NlLov.__AutoComplete[id]['selected']) {
					return;
				}
			}

			hidAux.value = tipo;

			if (campoValue.value != '') {
				if (tipo == 'desc' && NlLov.__AutoComplete[id]) {
					NlLov.__AutoComplete[id]['txtDesc'].value = NlLov.__AutoComplete[id]['txtDesc.initValue'];
				} else {
					btnFind.click();
				}
			} else {
				var btnClear = NlUtil.findElement(campoValue, idLov,
						idLov + '_btnClear');
				if (btnClear != null) {
					btnClear.click();
				}
			}
		};
		if (tipo == 'desc') {
			window.setTimeout(changeFunc, 100);
		} else {
			changeFunc();
		}
	},

	autoComplete_CreateDropdown : function(id) {
		this.__AutoComplete[id]['dropdown'] = document.createElement('div');
		this.__AutoComplete[id]['dropdown'].className = 'autocomplete';

		this.__AutoComplete[id]['txtDesc'].parentNode.insertBefore(
				this.__AutoComplete[id]['dropdown'],
				this.__AutoComplete[id]['txtDesc']);

		// Position it
		this.__AutoComplete[id]['dropdown'].style.zIndex = '99';
		this.__AutoComplete[id]['dropdown'].style.visibility = 'hidden';
	},

	autoComplete_HideAll : function() {
		for (id in this.__AutoComplete) {
			this.autoComplete_HideDropdown(id);
		}
	},

	autoComplete_HideDropdown : function(id) {
		if (this.__AutoComplete[id]['iframe']) {
			this.__AutoComplete[id]['iframe'].style.visibility = 'hidden';
		}

		this.__AutoComplete[id]['dropdown'].style.visibility = 'hidden';
		this.__AutoComplete[id]['highlighted'] = null;
	},

	autoComplete_SetData : function(id, data) {
		this.__AutoComplete[id]['data'] = data;
	},

	autoComplete_ShowDropdown : function(id) {
		this.autoComplete_HideAll();

		var value = this.__AutoComplete[id]['txtDesc'].value;
		var _data = this.__AutoComplete[id]['data'];

		var numItems = this.__AutoComplete[id]['dropdown'].childNodes.length;
		var widthCod = 0;
		var alignCod = null;
		if (this.__AutoComplete[id]['txtCod'] != null) {
			// widthCod = this.__AutoComplete[id]['txtCod'].offsetWidth;
			// alignCod = this.__AutoComplete[id]['txtCod'].style.textAlign;
		}
		var widthDesc = this.__AutoComplete[id]['txtDesc'].offsetWidth;
		var widthDrop = widthCod + widthDesc;

		var newDiv = null;
		var newDivCod = null;
		var newDivDesc = null;
		var textCod = null;
		var textDesc = null;

		// Remove all child nodes from dropdown
		while (this.__AutoComplete[id]['dropdown'].childNodes.length > 0) {
			this.__AutoComplete[id]['dropdown']
					.removeChild(this.__AutoComplete[id]['dropdown'].childNodes[0]);
		}

		// No matches?
		if (_data.length == 0) {
			this.autoComplete_HideDropdown(id);
			return;
		}

		// Add data to the dropdown layer
		for (i = 0; i < _data.length; ++i) {
			newDiv = document.createElement('div');
			newDiv.className = 'autocomplete_item'; // Don't use setAttribute()
			newDiv.setAttribute('id', 'autocomplete_item_' + i);
			newDiv.setAttribute('index', i);
			newDiv.style.zIndex = '99';

			// Scrollbars are on display ?
			newDiv.style.width = (widthDrop + 100) + 'px';

			newDiv.onmouseover = function() {
				NlLov.autoComplete_HighlightItem(id, new Number(this
						.getAttribute('index')));
			};
			newDiv.onclick = function() {
				NlLov.autoComplete_SetValue(id);
				NlLov.autoComplete_HideDropdown(id);
			}

			if (widthCod > 0) {
				newDivCod = document.createElement('div');
				newDivCod.className = 'autocomplete_item_cod';
				newDivCod.style.width = (widthCod + this.divCod_offsetWidth) + 'px';
				newDivCod.style.textAlign = alignCod;
				newDivCod.style.marginRight = this.divCod_offsetMarginRight + 'px';
				newDiv.appendChild(newDivCod);
			}

			newDivDesc = document.createElement('div');
			newDivDesc.className = 'autocomplete_item_desc';
			newDivDesc.style.width = (widthDesc + this.divDesc_offsetWidth) + 'px';
			newDiv.appendChild(newDivDesc);

			// if (this.__AutoComplete[id]['indTabela']) {
			// textCod = document.createTextNode(_data[i].campo1);
			// textDesc = document.createTextNode(_data[i].campo2);
			// } else {
			textCod = document.createTextNode(_data[i].campo2);
			textDesc = document.createTextNode(_data[i].campo1);
			// }

			newDivDesc.appendChild(textDesc);
			if (widthCod > 0) {
				newDivCod.appendChild(textCod);
			}

			this.__AutoComplete[id]['dropdown'].appendChild(newDiv);
		}

		this.__AutoComplete[id]['itemHeight'] = newDiv.offsetHeight;

		// Too many items?
		if (_data.length > this.__AutoComplete[id]['maxitems']) {
			this.__AutoComplete[id]['dropdown'].style.height = (this.__AutoComplete[id]['maxitems'] * this.__AutoComplete[id]['itemHeight']) + 'px';
		} else {
			this.__AutoComplete[id]['dropdown'].style.height = '';
		}

		/**
		 * Set left/top in case of document movement/scroll/window resize etc
		 */
		var _pos;
		// if (this.__AutoComplete[id]['txtCod'] == null) {
		_pos = elementPosition(this.__AutoComplete[id]['txtDesc']);
		// } else {
		// _pos = elementPosition(this.__AutoComplete[id]['txtCod']);
		// }

		this.__AutoComplete[id]['dropdown'].style.left = (_pos.x + this.dropdown_offsetX) + 'px';
		this.__AutoComplete[id]['dropdown'].style.width = (widthDrop + this.dropdown_offsetWidth) + 'px';
		// this.__AutoComplete[id]['dropdown'].style.width = widthDrop + 'px';

		this.__AutoComplete[id]['dropdown'].style.top = (_pos.y + this.__AutoComplete[id]['txtDesc'].offsetHeight) + 'px';

		// Show the iframe for IE
		if (this.isIE) {
			this.__AutoComplete[id]['iframe'].style.top = this.__AutoComplete[id]['dropdown'].style.top;
			this.__AutoComplete[id]['iframe'].style.left = this.__AutoComplete[id]['dropdown'].style.left;
			this.__AutoComplete[id]['iframe'].style.width = this.__AutoComplete[id]['dropdown'].offsetWidth;
			this.__AutoComplete[id]['iframe'].style.height = this.__AutoComplete[id]['dropdown'].offsetHeight;
			this.__AutoComplete[id]['iframe'].style.visibility = 'visible';
		}

		// Show dropdown
		this.__AutoComplete[id]['dropdown'].style.visibility = 'visible';

		// If now showing less items than before, reset the highlighted value
		if (this.__AutoComplete[id]['dropdown'].childNodes.length != numItems) {
			this.__AutoComplete[id]['highlighted'] = null;
		}
	},

	autoComplete_HighlightItem : function(id, index) {
		if (this.__AutoComplete[id]['dropdown'].childNodes[index]) {
			for ( var i = 0; i < this.__AutoComplete[id]['dropdown'].childNodes.length; ++i) {
				if (this.__AutoComplete[id]['dropdown'].childNodes[i].className == 'autocomplete_item_highlighted') {
					this.__AutoComplete[id]['dropdown'].childNodes[i].className = 'autocomplete_item';
				}
			}

			this.__AutoComplete[id]['dropdown'].childNodes[index].className = 'autocomplete_item_highlighted';
			this.__AutoComplete[id]['highlighted'] = index;
		}
	},

	autoComplete_Highlight : function(id, index) {
		// Out of bounds checking
		if (index == 1
				&& this.__AutoComplete[id]['highlighted'] == this.__AutoComplete[id]['dropdown'].childNodes.length - 1) {
			this.__AutoComplete[id]['dropdown'].childNodes[this.__AutoComplete[id]['highlighted']].className = 'autocomplete_item';
			this.__AutoComplete[id]['highlighted'] = null;
		} else if (index == -1 && this.__AutoComplete[id]['highlighted'] == 0) {
			this.__AutoComplete[id]['dropdown'].childNodes[0].className = 'autocomplete_item';
			this.__AutoComplete[id]['highlighted'] = this.__AutoComplete[id]['dropdown'].childNodes.length;
		}

		// Nothing highlighted at the moment
		if (this.__AutoComplete[id]['highlighted'] == null) {
			this.__AutoComplete[id]['dropdown'].childNodes[0].className = 'autocomplete_item_highlighted';
			this.__AutoComplete[id]['highlighted'] = 0;
		} else {
			if (this.__AutoComplete[id]['dropdown'].childNodes[this.__AutoComplete[id]['highlighted']]) {
				this.__AutoComplete[id]['dropdown'].childNodes[this.__AutoComplete[id]['highlighted']].className = 'autocomplete_item';
			}

			var newIndex = this.__AutoComplete[id]['highlighted'] + index;

			if (this.__AutoComplete[id]['dropdown'].childNodes[newIndex]) {
				this.__AutoComplete[id]['dropdown'].childNodes[newIndex].className = 'autocomplete_item_highlighted';

				this.__AutoComplete[id]['highlighted'] = newIndex;
			}
		}
	},

	autoComplete_SetValue : function(id) {
		this.__AutoComplete[id]['selected'] = true;
		var _item = this.__AutoComplete[id]['data'][this.__AutoComplete[id]['highlighted']];
		var _elem = this.__AutoComplete[id]['txtDesc'];
		this.autoComplete_HideDropdown(id);

		if (this.__AutoComplete[id]['indTabela']) {
			text = _item.campo2;
		} else {
			text = _item.campo1;
		}
		_elem.value = text;
		var idLov = this.__AutoComplete[id]['idLov'];
		var hidAux = NlUtil.findElement(_elem, idLov, idLov + '_hidAux');
		if (this.__AutoComplete[id]['numSeq'] == 247) {
			hidAux.value = 'auto:' + _item.campo2;
		} else {
			hidAux.value = 'auto:' + _item.rowid;
		}

		var btnFind = NlUtil.findElement(_elem, idLov, idLov + '_btnFind');
		btnFind.click();
	},

	autoComplete_ScrollCheck : function(id) {
		// Scroll down, or wrapping around from scroll up
		if (this.__AutoComplete[id]['highlighted'] > this.__AutoComplete[id]['lastItemShowing']) {
			this.__AutoComplete[id]['firstItemShowing'] = this.__AutoComplete[id]['highlighted']
					- (this.__AutoComplete[id]['maxitems'] - 1);
			this.__AutoComplete[id]['lastItemShowing'] = this.__AutoComplete[id]['highlighted'];
		}

		// Scroll up, or wrapping around from scroll down
		if (this.__AutoComplete[id]['highlighted'] < this.__AutoComplete[id]['firstItemShowing']) {
			this.__AutoComplete[id]['firstItemShowing'] = this.__AutoComplete[id]['highlighted'];
			this.__AutoComplete[id]['lastItemShowing'] = this.__AutoComplete[id]['highlighted']
					+ (this.__AutoComplete[id]['maxitems'] - 1);
		}

		this.__AutoComplete[id]['dropdown'].scrollTop = this.__AutoComplete[id]['firstItemShowing']
				* this.__AutoComplete[id]['itemHeight'];
	},

	autoComplete_KeyDown : function(id, event) {
		if (window.event) {
			event = window.event;
		}
		var keyCode = event.keyCode;

		switch (keyCode) {
		// Return/Enter
		case 13:
			if (this.__AutoComplete[id]['highlighted'] != null) {
				NlLov.autoComplete_SetValue(id);
			}
			break;

		// Escape
		case 27:
			if (NlLov.autoComplete_isVisible(id)) {
				NlLov.autoComplete_HideDropdown(id);
			} else {
				NlLov.__AutoComplete[id]['txtDesc'].value = NlLov.__AutoComplete[id]['txtDesc.initValue'];
			}
			event.returnValue = false;
			event.cancelBubble = true;
			break;

		// Tab
		case 9:
			if (NlLov.autoComplete_isVisible(id)) {
				NlLov.autoComplete_HideDropdown(id);
			}
			return;
			break;

		// Up arrow
		case 38:
			if (!NlLov.autoComplete_isVisible(id)) {
				window.clearTimeout(this.__AutoComplete_findTime);
				NlLov.autoComplete_find(id);
			} else {
				NlLov.autoComplete_Highlight(id, -1);
				NlLov.autoComplete_ScrollCheck(id, -1);
			}
			return false;
			break;

		// Down arrow
		case 40:
			if (!NlLov.autoComplete_isVisible(id)) {
				window.clearTimeout(this.__AutoComplete_findTime);
				NlLov.autoComplete_find(id);
			} else {
				NlLov.autoComplete_Highlight(id, 1);
				NlLov.autoComplete_ScrollCheck(id, 1);
			}
			return false;
			break;
		}
	},

	autoComplete_KeyUp : function(id, event) {
		if (window.event) {
			event = window.event;
		}
		var k = event.keyCode;

		if ((k == 9) || (k == 13) || (k >= 16 && k <= 20)
				|| (k >= 35 && k <= 40) || (k == 44) || (k == 45) || (k == 144)
				|| (k == 145) || (k >= 112 && k <= 123))
			return;

		switch (k) {
		case 27:
			NlLov.autoComplete_HideDropdown(id);
			event.returnValue = false;
			event.cancelBubble = true;
			break;
		default:
			if (NlLov.__AutoComplete[id]['txtDesc'].value.length < getQtdLetrasLovAutoComplete()) {
				NlLov.__AutoComplete[id]['ultimaBusca'] = null;
			}
			window.clearTimeout(this.__AutoComplete_findTime);
			this.__AutoComplete_findTime = window.setTimeout(function() {
				NlLov.autoComplete_find(id);
			}, getTimeOutLovAutoComplete());
			break;
		}
	},

	autoComplete_isVisible : function(id) {
		return this.__AutoComplete[id]['dropdown'].style.visibility == 'visible';
	},

	autoComplete_find : function(id, _force) {
		if (NlLov.__AutoComplete[id]['txtDesc'].value.length >= getQtdLetrasLovAutoComplete()
				|| _force) {
			if (!NlLov.autoComplete_isVisible(id)) {
				NlLov.__AutoComplete[id]['ultimaBusca'] = null;
			}
			if (NlLov.__AutoComplete[id]['ultimaBusca'] != NlLov.__AutoComplete[id]['txtDesc'].value) {
				NlLov.__AutoComplete[id]['ultimaBusca'] = NlLov.__AutoComplete[id]['txtDesc'].value;
				UiLovBacking.findDwr(getNlSessionId(),
						NlLov.__AutoComplete[id]['idLov'], id,
						NlLov.__AutoComplete[id]['numSeq'],
						NlLov.__AutoComplete[id]['desPagina'],
						NlLov.__AutoComplete[id]['txtDesc'].value,
						NlLov.__AutoComplete[id]['parEsp'],
						NlLov.__AutoComplete[id]['indTabela'], new Date()
								.getTime(), {
							callback : NlLov.autoComplete_findResponse
						});
			}
		} else {
			NlLov.__AutoComplete[id]['ultimaBusca'] = null;
		}
	},

	autoComplete_findResponse : function(_retorno) {
		if (_retorno != null) {
			var id = _retorno.autoCompleteId;
			if (!NlLov.__AutoComplete[id]['selected']) {
				if (_retorno.ctrlTempo > NlLov.__AutoComplete[id]['ctrlTempo']) {
					NlLov.__AutoComplete[id]['ctrlTempo'] = _retorno.ctrlTempo;
					NlLov.autoComplete_SetData(id, _retorno.lista);
					NlLov.autoComplete_ShowDropdown(id);
					NlLov.autoComplete_ScrollCheck(id, 1);
				}
			}
		}
	},

	autoComplete_findError : function(errorString, exception) {
		alert(errorString);
	},

	open : function(idLov) {
		var btnFind = nl$(idLov + '_btnFind');
		var hidAux = nl$(idLov + '_hidAux');
		hidAux.value = 'desc';
		btnFind.click();
	},

	enterEsc_KeyDown : function(_txt, event, _idLov, _tipo) {
		if (window.event) {
			event = window.event;
		}
		var keyCode = event.keyCode;

		if (keyCode == 27) {
			_txt.value = _txt.oldValue;
		} else if (keyCode == 13) {
			_preventDefault(event);

			var hidAux = NlUtil.findElement(_txt, _idLov, _idLov + '_hidAux');

			hidAux.value = _tipo;

			var btnFind = NlUtil.findElement(_txt, _idLov, _idLov + '_btnFind');

			fireClick(btnFind, event);
		}
	},

	createNota : function(_idLov) {
		var _divFind = document.getElementById(_idLov + '_divJSFind');
		var _grid = _divFind.previousSibling;

		var _txtNota_numNota = NlUtil.findElement(_grid, _idLov,
				_idLov + '_txtNota_numNota');
		var _txtNota_codSerie = NlUtil.findElement(_grid, _idLov,
				_idLov + '_txtNota_codSerie');
		var _txtNota_numSeq = NlUtil.findElement(_grid, _idLov,
				_idLov + '_txtNota_numSeq');
		var _txtNota_codMaq = NlUtil.findElement(_grid, _idLov,
				_idLov + '_txtNota_codMaq');

		if (_txtNota_numNota != null) {
			_txtNota_numNota.oldValue = _txtNota_numNota.value;
			_txtNota_numNota.onkeydown = function(e) {
				return NlLov.enterEsc_KeyDown(this, e, _idLov, 'cod');
			}
		}
		if (_txtNota_codSerie != null) {
			_txtNota_codSerie.oldValue = _txtNota_codSerie.value;
			_txtNota_codSerie.onkeydown = function(e) {
				return NlLov.enterEsc_KeyDown(this, e, _idLov, 'cod');
			}
		}
		if (_txtNota_numSeq != null) {
			_txtNota_numSeq.oldValue = _txtNota_numSeq.value;
			_txtNota_numSeq.onkeydown = function(e) {
				return NlLov.enterEsc_KeyDown(this, e, _idLov, 'cod');
			}
		}
		if (_txtNota_codMaq != null) {
			_txtNota_codMaq.oldValue = _txtNota_codMaq.value;
			_txtNota_codMaq.onkeydown = function(e) {
				return NlLov.enterEsc_KeyDown(this, e, _idLov, 'cod');
			}
		}

		var _btnFind = NlUtil.findElement(_grid, _idLov, _idLov + '_btnFind');
		var _btnClear = NlUtil.findElement(_grid, _idLov, _idLov + '_btnClear');

		if (_btnFind != null) {
			_btnFind.tabIndex = -1;
		}
		if (_btnClear != null) {
			_btnClear.tabIndex = -1;
		}
	},

	createAc : function(_idLov) {
		var _divFind = document.getElementById(_idLov + '_divJSFind');
		var _grid = _divFind.previousSibling;

		var _txtAC_numCod = NlUtil.findElement(_grid, _idLov,
				_idLov + '_txtAC_numCod');
		var _txtAC_numSeq = NlUtil.findElement(_grid, _idLov,
				_idLov + '_txtAC_numSeq');
		var _txtAC_codMaq = NlUtil.findElement(_grid, _idLov,
				_idLov + '_txtAC_codMaq');

		if (_txtAC_numCod != null) {
			_txtAC_numCod.oldValue = _txtAC_numCod.value;
			_txtAC_numCod.onkeydown = function(e) {
				return NlLov.enterEsc_KeyDown(this, e, _idLov, 'cod');
			}
		}
		if (_txtAC_numSeq != null) {
			_txtAC_numSeq.oldValue = _txtAC_numSeq.value;
			_txtAC_numSeq.onkeydown = function(e) {
				return NlLov.enterEsc_KeyDown(this, e, _idLov, 'cod');
			}
		}
		if (_txtAC_codMaq != null) {
			_txtAC_codMaq.oldValue = _txtAC_codMaq.value;
			_txtAC_codMaq.onkeydown = function(e) {
				return NlLov.enterEsc_KeyDown(this, e, _idLov, 'cod');
			}
		}

		var _btnFind = NlUtil.findElement(_grid, _idLov, _idLov + '_btnFind');
		var _btnClear = NlUtil.findElement(_grid, _idLov, _idLov + '_btnClear');

		if (_btnFind != null) {
			_btnFind.tabIndex = -1;
		}
		if (_btnClear != null) {
			_btnClear.tabIndex = -1;
		}
	},

	changeNtAc : function(campoValue, idLov) {
		var btnFind = NlUtil.findElement(campoValue, idLov, idLov + '_btnFind');
		var hidAux = NlUtil.findElement(campoValue, idLov, idLov + '_hidAux');

		if (campoValue.value != '') {
			hidAux.value = 'cod';
			btnFind.click();
		} else {
			var btnClear = NlUtil.findElement(campoValue, idLov,
					idLov + '_btnClear');
			if (btnClear != null) {
				btnClear.click();
			}
		}

	}

}

function removeArrayKey(arrayName, key) {
	var x;
	var tmpArray = new Array();
	for (x in arrayName) {
		if (x != key) {
			tmpArray[x] = arrayName[x];
		}
	}
	return tmpArray;
}

var NlLov = new _NlLov();

