function showValueList(values, valueField, titleField, displayArea, barWidth, alignRight) {
	var mappingValueField = valueField;
	var mappingTitleField = titleField;
	var topWindow = getListTopWindow();
	var bar = topWindow.document.getElementById("listBar");
	if(!bar) {
		bar = topWindow.document.createElement("div");
		bar.style.display = "none";
		bar.style.position = "absolute";
		bar.id = "listBar";
		bar.style.height = 0;
		bar.style.zIndex = 1000000;
		topWindow.document.body.insertBefore(bar, topWindow.document.body.childNodes[0]);
		bar.innerHTML = '<iframe name="listFrame" style="width:100%;height:100%"></iframe>';
		var doc = topWindow.frames["listFrame"].document;
		doc.open();
		doc.write('<html><head>');
		doc.write('</head>');
		doc.write('<body class="listbar" style="overflow-y:auto;overflow-x:hidden; margin:0px; padding:0px"><table border="0" cellpadding="3" cellspacing="0" width="100%"><tr><td></td></tr></table></body></html>');
		doc.close();
		cloneStyle(document, doc);
	}
	var table = topWindow.frames["listFrame"].document.getElementsByTagName("table")[0];
	for(var i=table.rows.length-1; i>=0; i--) {
		table.deleteRow(i);
	}
	if(values.substring(values.length - 1)=='\0') {
		values = values.substring(0, values.length - 1);
	}
	values = values.split("\0");
	for(var i=0; i<values.length && values[i]!=""; i++) { 
		var item = table.insertRow(-1).insertCell(-1);
		item.className = "listnormal";
		item.noWrap = true;
		var itemValues = values[i].split("|");
		item.id = itemValues[itemValues.length - 1];
		item.innerHTML = itemValues[0]; 
		item.style.height = "18px";
		if(mappingTitleField) {
			if(mappingTitleField.style.fontFamily) {
				item.style.fontFamily = mappingTitleField.style.fontFamily;
			}
			if(mappingTitleField.style.fontSize) {
				item.style.fontSize = mappingTitleField.style.fontSize;
			}
		}
		item.onmousedown = function() {
			getListTopWindow().document.getElementById("listBar").style.display = "none";
			if(mappingValueField) {
				mappingValueField.value = this.id;
			}
			if(mappingTitleField) {
				mappingTitleField.value = this.innerHTML;
			}
			try {
				if(mappingValueField) {
					mappingValueField.onchange();
				}
			}
			catch(e) {
			
			}
			try {
				if(mappingTitleField) {
					mappingTitleField.onchange();
				}
			}
			catch(e) {
			
			}
		}
		item.onmouseover = function() {
			this.className = "listover";
		}
		item.onmouseout = function() {
			this.className = "listnormal";
		}
	}
	if(!barWidth || barWidth<0 || barWidth==0) {
		barWidth = displayArea.offsetWidth;
	}
	var pos = getElementAbsolutePosition(displayArea);
	bar.style.left = alignRight ? pos.left + displayArea.offsetWidth - barWidth : pos.left;
	bar.style.top = pos.top + displayArea.offsetHeight - 1;
	bar.style.width = barWidth;
	bar.style.display = "";
	bar.style.overflow = "auto";
	bar.style.height = table.offsetHeight + 3 > 160 ? 160 : table.offsetHeight + 3;
	topWindow.frames["listFrame"].document.body.scrollTop = 0;
	currentAlignRight = alignRight;
	table.width = topWindow.frames["listFrame"].document.body.clientWidth;
	topWindow.frames["listFrame"].document.body.onblur = function() {
		getListTopWindow().document.getElementById("listBar").style.display = "none";
	}
	topWindow.frames["listFrame"].document.body.focus();
	window.attachEvent("onunload", function(){try{topWindow.document.getElementById("listBar").style.display = "none";}catch(e){}});
}
function getElementAbsolutePosition(obj) { 
	var pos = new Object();
	pos.left = 0;
	pos.top = 0;
	while(true) {
		if(obj.tagName=="BODY" || obj.tagName=="HTML") {
			if(!obj.ownerDocument.parentWindow.frameElement || obj.ownerDocument.parentWindow.frameElement.id=="dialogBody") {
				break;
			}
			pos.left -= obj.scrollLeft;
			pos.top -= obj.scrollTop;
			obj = obj.ownerDocument.parentWindow.frameElement;
		}
		pos.left += obj.offsetLeft;
		pos.top += obj.offsetTop;
		obj = obj.offsetParent;
	}
	return pos;
}
function setDropDownItems(fieldName, itemsText) {
	var dropDownButton = document.getElementById("table" + fieldName).rows[0].cells[1];
	dropDownButton.onclick = function() {
		showValueList(itemsText, document.getElementsByName(fieldName)[0], document.getElementsByName(fieldName)[0], document.getElementById('table' + fieldName));
	}
}
function getListTopWindow() {
	var topWindow = window;
	while(topWindow!=window.top && topWindow.frameElement && topWindow.frameElement.id!="dialogBody") {
		topWindow = topWindow.frameElement.ownerDocument.parentWindow;
	}
	return topWindow;
}
