// funds lookup
var fundLookup = new Suggest();  
var searchString = ""; 
var _fundSelectorLanguage = "en";

function getData(qry) {
	if (qry) {
		searchString = trimStr(qry);
		if (searchString.length>=2) {
			
			DWREngine._execute(_cfscriptLocation, null, 'getFundList', searchString,'',_fundSelectorLanguage, getFundDataResult);
		}
	}
}
			
function getFundDataResult(dataArray)	{
	var key = Array();
	var value0 = Array();
	var value1 = null;
	var value2 = null;
	
	for (i=0; i < dataArray.length; i++) {
		key[i] = trimStr(dataArray[i]['KEY']);
		value0[i] = trimStr(dataArray[i]['VALUE']);
		
	}		
			
	
	strQuery = selectedSuggestObject.name + '.showQueryDiv("' + searchString + '", key , value0,value1,value2)';
	eval (strQuery);
}

			
function itemSelectionListener(result) {
	//use this function to set the hidden field with key value..
	var theForm = getForm('donationForm');
	if (!theForm) return false;

	if (trimStr(theForm.vOtherProductCode.value)!="") {
		theForm.vProductCode.value=theForm.vOtherProductCode.value;
		theForm.action.value="confirmAmount";
		theForm.submit();
	}
}

function initFundLookUp() {
	if (getEltById('fldFundLookup')) {
		fundLookup.setListStyle("listStyle");
		fundLookup.setListItemStyle("listItemStyle");
		fundLookup.setListItemKey("listItemKey");
		fundLookup.setListItemValue("listItemValue");
		fundLookup.setListWidth("280px");	
	
		fundLookup.setSelectionListener(itemSelectionListener);
    	fundLookup.setShowKey(false);
    	fundLookup.setQueryFieldHolds(3); //0 - Key, 1 = Value  , 2 - Both Key and value
    	fundLookup.setMinCharToStartSearch(2);
    
		onSuggestFieldFocus(fundLookup);
		fundLookup.InitQueryCode('fundLookup','fldFundLookup');
		fundLookup.InitQueryCode2('vOtherProductCode',null,null);
	}
}	





