
function changeClear() {
	document.getElementById('codeid').value = '';
	changeAC();
}

function changeAC() {
	$("#codeid").unautocomplete();
	
	$("#codeid2").autocomplete(stocks, {
					minChars : 0,
					width : 150,
					matchContains : "word",
					autoFill : false,
					formatItem : function(row, i, max) {
						return row.name + "  " + row.value;
					},
					formatMatch : function(row, i, max) {
						return row.name + " " + row.value;
					},
					formatResult : function(row) {
						return row.value;
					}
				});
	
	if(document.getElementById('indextype')){
		if (document.getElementById('indextype').value == 'stock') {
	
			$("#codeid").autocomplete(stocks, {
						minChars : 0,
						width : 150,
						matchContains : "word",
						autoFill : false,
						formatItem : function(row, i, max) {
							return row.name + "  " + row.value;
						},
						formatMatch : function(row, i, max) {
							return row.name + " " + row.value;
						},
						formatResult : function(row) {
							return row.value;
						}
					});
	
		} else if (document.getElementById('indextype').value == 'fund') {
	
			$("#codeid").autocomplete(funds, {
						minChars : 0,
						width : 150,
						matchContains : "word",
						autoFill : false,
						formatItem : function(row, i, max) {
							return row.name + "  " + row.value;
						},
						formatMatch : function(row, i, max) {
							return row.name + " " + row.value;
						},
						formatResult : function(row) {
							return row.value;
						}
					});
	
		}
	}
}

changeAC();
