function actCMB(obj,ca){
	/* ---- Public Variables ---- */
	this.actCMB_timeOut = -1; // Autocomplete Timeout in ms (-1: autocomplete never time out)
	this.actCMB_lim = 4;    // Number of elements autocomplete can show (-1: no limit)
	this.actCMB_firstText = false; // should the auto complete be limited to the beginning of keyword?
	this.actCMB_mouse = true; // Enable Mouse Support
	this.actCMB_delimiter = new Array(';',',');  // Delimiter for multiple autocomplete. Set it to empty array for single autocomplete
	this.actCMB_startcheck = 1; // Show widget only after this number of characters is typed in.
	/* ---- Public Variables ---- */

	/* --- Styles --- */
	this.actCMB_bgColor = '#339966';
	this.actCMB_textColor = '#000000';
	this.actCMB_hColor = '#ffff66';
	this.actCMB_fFamily = 'Verdana';
	this.actCMB_fSize = '11px';
	this.actCMB_hStyle = 'text-decoration:underline;font-weight:bold';
	/* --- Styles --- */

	/* ---- Private Variables ---- */
	var actCMB_delimwords = new Array();
	var actCMB_cdelimword = 0;
	var actCMB_delimchar = new Array();
	var actCMB_display = false;
	var actCMB_pos = 0;
	var actCMB_total = 0;
	var actCMB_curr = null;
	var actCMB_rangeu = 0;
	var actCMB_ranged = 0;
	var actCMB_bool = new Array();
	var actCMB_pre = 0;
	var actCMB_toid;
	var actCMB_tomake = false;
	var actCMB_getpre = "";
	var actCMB_mouse_on_list = 1;
	var actCMB_kwcount = 0;
	var actCMB_caretmove = false;
	this.actCMB_keywords = new Array();
	/* ---- Private Variables---- */
	
	this.actCMB_keywords = ca;
	var actCMB_self = this;

	actCMB_curr = obj;
	
	addEvent(actCMB_curr,"focus",actCMB_setup);
	addEvent(actCMB_curr,"keypress",actCMB_setup);
	function actCMB_setup(){
		addEvent(document,"keydown",actCMB_checkkey);
		addEvent(actCMB_curr,"blur",actCMB_clear);
		addEvent(document,"keypress",actCMB_keypress);
	}

	function actCMB_clear(evt){
		if (!evt) evt = event;
		removeEvent(document,"keydown",actCMB_checkkey);
		removeEvent(actCMB_curr,"blur",actCMB_clear);
		removeEvent(document,"keypress",actCMB_keypress);
		actCMB_removedisp();
	}
	function actCMB_parse(n){
		if (actCMB_self.actCMB_delimiter.length > 0){
			var t = actCMB_delimwords[actCMB_cdelimword].trim().addslashes();
			var plen = actCMB_delimwords[actCMB_cdelimword].trim().length;
		}else{
			var t = actCMB_curr.value.addslashes();
			var plen = actCMB_curr.value.length;
		}
		var tobuild = '';
		var i;

		if (actCMB_self.actCMB_firstText){
			var re = new RegExp("^" + t, "i");
		}else{
			var re = new RegExp(t, "i");
		}
		var p = n.search(re);
				
		for (i=0;i<p;i++){
			tobuild += n.substr(i,1);
		}
		tobuild += "<font style='"+(actCMB_self.actCMB_hStyle)+"'>"
		for (i=p;i<plen+p;i++){
			tobuild += n.substr(i,1);
		}
		tobuild += "</font>";
			for (i=plen+p;i<n.length;i++){
			tobuild += n.substr(i,1);
		}
		return tobuild;
	}
	function actCMB_generate(){
		if (document.getElementById('tat_table')){ actCMB_display = false;document.body.removeChild(document.getElementById('tat_table')); } 
		if (actCMB_kwcount == 0){
			actCMB_display = false;
			return;
		}
		a = document.createElement('table');
		a.cellSpacing='1px';
		a.cellPadding='2px';
		a.style.position='absolute';
		a.style.top = eval(curTop(actCMB_curr) + actCMB_curr.offsetHeight) + "px";
		a.style.left = curLeft(actCMB_curr) + "px";
		a.style.backgroundColor=actCMB_self.actCMB_bgColor;
		a.id = 'tat_table';
		document.body.appendChild(a);
		var i;
		var first = true;
		var j = 1;
		if (actCMB_self.actCMB_mouse){
			a.onmouseout = actCMB_table_unfocus;
			a.onmouseover = actCMB_table_focus;
		}
		var counter = 0;
		for (i=0;i<actCMB_self.actCMB_keywords.length;i++){
			if (actCMB_bool[i]){
				counter++;
				r = a.insertRow(-1);
				if (first && !actCMB_tomake){
					r.style.backgroundColor = actCMB_self.actCMB_hColor;
					first = false;
					actCMB_pos = counter;
				}else if(actCMB_pre == i){
					r.style.backgroundColor = actCMB_self.actCMB_hColor;
					first = false;
					actCMB_pos = counter;
				}else{
					r.style.backgroundColor = actCMB_self.actCMB_bgColor;
				}
				r.id = 'tat_tr'+(j);
				c = r.insertCell(-1);
				c.style.color = actCMB_self.actCMB_textColor;
				c.style.fontFamily = actCMB_self.actCMB_fFamily;
				c.style.fontSize = actCMB_self.actCMB_fSize;
				c.innerHTML = actCMB_parse(actCMB_self.actCMB_keywords[i]);
				c.id = 'tat_td'+(j);
				c.setAttribute('pos',j);
				if (actCMB_self.actCMB_mouse){
					c.style.cursor = 'pointer';
					c.onclick=actCMB_mouseclick;
					c.onmouseover = actCMB_table_highlight;
				}
				j++;
			}
			if (j - 1 == actCMB_self.actCMB_lim && j < actCMB_total){
				r = a.insertRow(-1);
				r.style.backgroundColor = actCMB_self.actCMB_bgColor;
				c = r.insertCell(-1);
				c.style.color = actCMB_self.actCMB_textColor;
				c.style.fontFamily = 'verdana';
				c.style.weight="bolder"; 
				c.style.fontSize = actCMB_self.actCMB_fSize;
				c.align='center';
				replaceHTML(c,'+'); // DOWN
				if (actCMB_self.actCMB_mouse){
					c.style.cursor = 'pointer';
					c.onclick = actCMB_mouse_down;
				}
				break;
			}
		}
		actCMB_rangeu = 1;
		actCMB_ranged = j-1;
		actCMB_display = true;
		if (actCMB_pos <= 0) actCMB_pos = 1;
	}
	function actCMB_remake(){
		document.body.removeChild(document.getElementById('tat_table'));
		a = document.createElement('table');
		a.cellSpacing='1px';
		a.cellPadding='2px';
		a.style.position='absolute';
		a.style.top = eval(curTop(actCMB_curr) + actCMB_curr.offsetHeight) + "px";
		a.style.left = curLeft(actCMB_curr) + "px";
		a.style.backgroundColor=actCMB_self.actCMB_bgColor;
		a.id = 'tat_table';
		if (actCMB_self.actCMB_mouse){
			a.onmouseout= actCMB_table_unfocus;
			a.onmouseover=actCMB_table_focus;
		}
		document.body.appendChild(a);
		var i;
		var first = true;
		var j = 1;
		if (actCMB_rangeu > 1){
			r = a.insertRow(-1);
			r.style.backgroundColor = actCMB_self.actCMB_bgColor;
			c = r.insertCell(-1);
			c.style.color = actCMB_self.actCMB_textColor;
			c.style.fontFamily = 'verdana';
			c.style.weight="bolder";
			c.style.fontSize = actCMB_self.actCMB_fSize;
			c.align='center';
			replaceHTML(c,'-'); // UP
			if (actCMB_self.actCMB_mouse){
				c.style.cursor = 'pointer';
				c.onclick = actCMB_mouse_up;
			}
		}
		for (i=0;i<actCMB_self.actCMB_keywords.length;i++){
			if (actCMB_bool[i]){
				if (j >= actCMB_rangeu && j <= actCMB_ranged){
					r = a.insertRow(-1);
					r.style.backgroundColor = actCMB_self.actCMB_bgColor;
					r.id = 'tat_tr'+(j);
					c = r.insertCell(-1);
					c.style.color = actCMB_self.actCMB_textColor;
					c.style.fontFamily = actCMB_self.actCMB_fFamily;
					c.style.fontSize = actCMB_self.actCMB_fSize;
					c.innerHTML = actCMB_parse(actCMB_self.actCMB_keywords[i]);
					c.id = 'tat_td'+(j);
					c.setAttribute('pos',j);
					if (actCMB_self.actCMB_mouse){
						c.style.cursor = 'pointer';
						c.onclick=actCMB_mouseclick;
						c.onmouseover = actCMB_table_highlight;
					}
					j++;
				}else{
					j++;
				}
			}
			if (j > actCMB_ranged) break;
		}
		if (j-1 < actCMB_total){
			r = a.insertRow(-1);
			r.style.backgroundColor = actCMB_self.actCMB_bgColor;
			c = r.insertCell(-1);
			c.style.color = actCMB_self.actCMB_textColor;
			c.style.fontFamily = 'verdana';
			c.style.fontSize = actCMB_self.actCMB_fSize;
			c.align='center';
			replaceHTML(c,'+'); // DOWN
			if (actCMB_self.actCMB_mouse){
				c.style.cursor = 'pointer';
				c.onclick = actCMB_mouse_down;
			}
		}
	}
	function actCMB_goup(){
		if (!actCMB_display) return;
		if (actCMB_pos == 1) return;
		document.getElementById('tat_tr'+actCMB_pos).style.backgroundColor = actCMB_self.actCMB_bgColor;
		actCMB_pos--;
		if (actCMB_pos < actCMB_rangeu) actCMB_moveup();
		document.getElementById('tat_tr'+actCMB_pos).style.backgroundColor = actCMB_self.actCMB_hColor;
		if (actCMB_toid) clearTimeout(actCMB_toid);
		if (actCMB_self.actCMB_timeOut > 0) actCMB_toid = setTimeout(function(){actCMB_mouse_on_list=0;actCMB_removedisp();},actCMB_self.actCMB_timeOut);
	}
	function actCMB_godown(){
		if (!actCMB_display) return;
		if (actCMB_pos == actCMB_total) return;
		document.getElementById('tat_tr'+actCMB_pos).style.backgroundColor = actCMB_self.actCMB_bgColor;
		actCMB_pos++;
		if (actCMB_pos > actCMB_ranged) actCMB_movedown();
		document.getElementById('tat_tr'+actCMB_pos).style.backgroundColor = actCMB_self.actCMB_hColor;
		if (actCMB_toid) clearTimeout(actCMB_toid);
		if (actCMB_self.actCMB_timeOut > 0) actCMB_toid = setTimeout(function(){actCMB_mouse_on_list=0;actCMB_removedisp();},actCMB_self.actCMB_timeOut);
	}
	function actCMB_movedown(){
		actCMB_rangeu++;
		actCMB_ranged++;
		actCMB_remake();
	}
	function actCMB_moveup(){
		actCMB_rangeu--;
		actCMB_ranged--;
		actCMB_remake();
	}

	/* Mouse */
	function actCMB_mouse_down(){
		document.getElementById('tat_tr'+actCMB_pos).style.backgroundColor = actCMB_self.actCMB_bgColor;
		actCMB_pos++;
		actCMB_movedown();
		document.getElementById('tat_tr'+actCMB_pos).style.backgroundColor = actCMB_self.actCMB_hColor;
		actCMB_curr.focus();
		actCMB_mouse_on_list = 0;
		if (actCMB_toid) clearTimeout(actCMB_toid);
		if (actCMB_self.actCMB_timeOut > 0) actCMB_toid = setTimeout(function(){actCMB_mouse_on_list=0;actCMB_removedisp();},actCMB_self.actCMB_timeOut);
	}
	function actCMB_mouse_up(evt){
		if (!evt) evt = event;
		if (evt.stopPropagation){
			evt.stopPropagation();
		}else{
			evt.cancelBubble = true;
		}
		document.getElementById('tat_tr'+actCMB_pos).style.backgroundColor = actCMB_self.actCMB_bgColor;
		actCMB_pos--;
		actCMB_moveup();
		document.getElementById('tat_tr'+actCMB_pos).style.backgroundColor = actCMB_self.actCMB_hColor;
		actCMB_curr.focus();
		actCMB_mouse_on_list = 0;
		if (actCMB_toid) clearTimeout(actCMB_toid);
		if (actCMB_self.actCMB_timeOut > 0) actCMB_toid = setTimeout(function(){actCMB_mouse_on_list=0;actCMB_removedisp();},actCMB_self.actCMB_timeOut);
	}
	function actCMB_mouseclick(evt){
		if (!evt) evt = event;
		if (!actCMB_display) return;
		actCMB_mouse_on_list = 0;
		actCMB_pos = this.getAttribute('pos');
		actCMB_penter();
		exeLocal(cmbVAL);
	}
	function actCMB_table_focus(){
		actCMB_mouse_on_list = 1;
	}
	function actCMB_table_unfocus(){
		actCMB_mouse_on_list = 0;
		if (actCMB_toid) clearTimeout(actCMB_toid);
		if (actCMB_self.actCMB_timeOut > 0) actCMB_toid = setTimeout(function(){actCMB_mouse_on_list = 0;actCMB_removedisp();},actCMB_self.actCMB_timeOut);
	}
	function actCMB_table_highlight(){
		actCMB_mouse_on_list = 1;
		document.getElementById('tat_tr'+actCMB_pos).style.backgroundColor = actCMB_self.actCMB_bgColor;
		actCMB_pos = this.getAttribute('pos');
		while (actCMB_pos < actCMB_rangeu) actCMB_moveup();
		while (actCMB_pos > actCMB_ranged) actCMB_movedown();
		document.getElementById('tat_tr'+actCMB_pos).style.backgroundColor = actCMB_self.actCMB_hColor;
		if (actCMB_toid) clearTimeout(actCMB_toid);
		if (actCMB_self.actCMB_timeOut > 0) actCMB_toid = setTimeout(function(){actCMB_mouse_on_list = 0;actCMB_removedisp();},actCMB_self.actCMB_timeOut);
	}
	/* ---- */

	function actCMB_insertword(a){
		if (actCMB_self.actCMB_delimiter.length > 0){
			str = '';
			l=0;
			for (i=0;i<actCMB_delimwords.length;i++){
				if (actCMB_cdelimword == i){
					prespace = postspace = '';
					gotbreak = false;
					for (j=0;j<actCMB_delimwords[i].length;++j){
						if (actCMB_delimwords[i].charAt(j) != ' '){
							gotbreak = true;
							break;
						}
						prespace += ' ';
					}
					for (j=actCMB_delimwords[i].length-1;j>=0;--j){
						if (actCMB_delimwords[i].charAt(j) != ' ') break;
						postspace += ' ';
					}
					str += prespace;
					str += a;
					l = str.length;
					if (gotbreak) str += postspace;
				}else{
					str += actCMB_delimwords[i];
				}
				if (i != actCMB_delimwords.length - 1){
					str += actCMB_delimchar[i];
				}
			}
			actCMB_curr.value = str;
			setCaret(actCMB_curr,l);
		}else{
			actCMB_curr.value = a;
		}
		actCMB_mouse_on_list = 0;
		actCMB_removedisp();
	}
	function actCMB_penter(){
		if (!actCMB_display) return;
		actCMB_display = false;
		var word = '';
		var c = 0;
		for (var i=0;i<=actCMB_self.actCMB_keywords.length;i++){
			if (actCMB_bool[i]) c++;
			if (c == actCMB_pos){
				word = actCMB_self.actCMB_keywords[i];
				break;
			}
		}
		actCMB_insertword(word);
		l = getCaretStart(actCMB_curr);
	}
	function actCMB_removedisp(){
		if (actCMB_mouse_on_list==0){
			actCMB_display = 0;
			if (document.getElementById('tat_table')){ document.body.removeChild(document.getElementById('tat_table')); }
			if (actCMB_toid) clearTimeout(actCMB_toid);
		}
	}
	function actCMB_keypress(e){
		if (actCMB_caretmove) stopEvent(e);
		return !actCMB_caretmove;
	}
	function actCMB_checkkey(evt){
		if (!evt) evt = event;
		a = evt.keyCode;
		caret_pos_start = getCaretStart(actCMB_curr);
		actCMB_caretmove = 0;
		switch (a){
			case 38:
				actCMB_goup();
				actCMB_caretmove = 1;
				return false;
				break;
			case 40:
				actCMB_godown();
				actCMB_caretmove = 1;
				return false;
				break;
			case 13: case 9:
				if (actCMB_display){
					actCMB_caretmove = 1;
					actCMB_penter();
					exeLocal(cmbVAL);
					return false;
				}else{
					return true;
				}
				break;
			default:
				setTimeout(function(){actCMB_tocomplete(a)},50);
				break;
		}
	}

	function actCMB_tocomplete(kc){
		if (kc == 38 || kc == 40 || kc == 13) return;
		var i;
		if (actCMB_display){ 
			var word = 0;
			var c = 0;
			for (var i=0;i<=actCMB_self.actCMB_keywords.length;i++){
				if (actCMB_bool[i]) c++;
				if (c == actCMB_pos){
					word = i;
					break;
				}
			}
			actCMB_pre = word;
		}else{ actCMB_pre = -1};
		
		if (actCMB_curr.value == ''){
			actCMB_mouse_on_list = 0;
			actCMB_removedisp();
			return;
		}
		if (actCMB_self.actCMB_delimiter.length > 0){
			caret_pos_start = getCaretStart(actCMB_curr);
			caret_pos_end = getCaretEnd(actCMB_curr);
			
			delim_split = '';
			for (i=0;i<actCMB_self.actCMB_delimiter.length;i++){
				delim_split += actCMB_self.actCMB_delimiter[i];
			}
			delim_split = delim_split.addslashes();
			delim_split_rx = new RegExp("(["+delim_split+"])");
			c = 0;
			actCMB_delimwords = new Array();
			actCMB_delimwords[0] = '';
			for (i=0,j=actCMB_curr.value.length;i<actCMB_curr.value.length;i++,j--){
				if (actCMB_curr.value.substr(i,j).search(delim_split_rx) == 0){
					ma = actCMB_curr.value.substr(i,j).match(delim_split_rx);
					actCMB_delimchar[c] = ma[1];
					c++;
					actCMB_delimwords[c] = '';
				}else{
					actCMB_delimwords[c] += actCMB_curr.value.charAt(i);
				}
			}

			var l = 0;
			actCMB_cdelimword = -1;
			for (i=0;i<actCMB_delimwords.length;i++){
				if (caret_pos_end >= l && caret_pos_end <= l + actCMB_delimwords[i].length){
					actCMB_cdelimword = i;
				}
				l+=actCMB_delimwords[i].length + 1;
			}
			var ot = actCMB_delimwords[actCMB_cdelimword].trim(); 
			var t = actCMB_delimwords[actCMB_cdelimword].addslashes().trim();
		}else{
			var ot = actCMB_curr.value;
			var t = actCMB_curr.value.addslashes();
		}
		if (ot.length == 0){
			actCMB_mouse_on_list = 0;
			actCMB_removedisp();
		}
		if (ot.length < actCMB_self.actCMB_startcheck) return this;
		if (actCMB_self.actCMB_firstText){
			var re = new RegExp("^" + t, "i");
		}else{
			var re = new RegExp(t, "i");
		}

		actCMB_total = 0;
		actCMB_tomake = false;
		actCMB_kwcount = 0;
		for (i=0;i<actCMB_self.actCMB_keywords.length;i++){
			actCMB_bool[i] = false;
			if (re.test(actCMB_self.actCMB_keywords[i])){
				actCMB_total++;
				actCMB_bool[i] = true;
				actCMB_kwcount++;
				if (actCMB_pre == i) actCMB_tomake = true;
			}
		}

		if (actCMB_toid) clearTimeout(actCMB_toid);
		if (actCMB_self.actCMB_timeOut > 0) actCMB_toid = setTimeout(function(){actCMB_mouse_on_list = 0;actCMB_removedisp();},actCMB_self.actCMB_timeOut);
		actCMB_generate();
	}
	return this;
}