var suggestionCache = new Array();

var obj; 

function initSuggest(fieldId) {
	obj = actb(document.getElementById(fieldId), new Array());
	/* ---- Variables ---- */
	obj.actb_timeOut = 4000; // Autocomplete Timeout in ms (-1: autocomplete never time out)
	obj.actb_lim = 5;    // Number of elements autocomplete can show (-1: no limit)
	obj.actb_firstText = true; // should the auto complete be limited to the beginning of keyword?
	obj.actb_mouse = true; // Enable Mouse Support
	obj.actb_delimiter = new Array(' ',',',';');  // Delimiter for multiple autocomplete. Set it to empty array for single autocomplete
	obj.actb_startcheck = 1; // Show widget only after this number of characters is typed in.
	/* ---- Variables ---- */

	/* --- Styles --- */
	obj.actb_bgColor = '#FFFFFF';
	obj.actb_textColor = '#000000';
	obj.actb_hColor = '#DDDDDD';
	obj.actb_fFamily = 'Verdana';
	obj.actb_fSize = '11px';
	obj.actb_hStyle = '';
	/* --- Styles --- */ 
	
	obj.actb_update_keywords = function(str) {
		var c;
		var l = str.length+1;
		
		while (--l > 0 && c == null) {
			c = suggestionCache[str.substring(0, l)];
		}
	
		if (c != null) {
			suggestionCallback(c, str, false);
		} else {
			Suggestions.getSuggestions(str, function(data) { suggestionCallback(data, str, true) } );
		}
	}
	
	function suggestionCallback(data, searchWord, store) {
		if (store) {
			suggestionCache[searchWord] = data;
		}
		obj.actb_keywords = data;
		obj.actb_filter_keywords(searchWord);
	}

}

