	var arr = new Array()
	var paths_arr = new Array()
	var focused = false;
	
	Array.prototype.get_matches = function ( obj, case_sensitive ) {
		var ret = new Array();
		var len = this.length;
		case_obj = (!case_sensitive ? obj.toLowerCase() : obj);
		
		for ( var x = len -1; x > -1; x-- ) 
		{
			str = String(this[x]);
			if (!case_sensitive)
				test_str = str.toLowerCase();
			else
				test_str = str;

			if (test_str.indexOf(case_obj) != -1)
			{
				ret.push(str);
			}
		}
		return ret.reverse();
	}

	Array.prototype.in_array = function ( obj ) {
		var len = this.length;
		for ( var x = 0 ; x < len ; x++ ) {
			if ( this[x] == obj ) 
				return x;
		}
		return -1;
	}

	function setup_list( list )
	{
		for ( var x = 0 ; x < list.length ; x++ ) {
			arr.push(list[x]);
		}
		//alert(arr.length);
	}
	
	function setup_paths( list )
	{
		for ( var x = 0 ; x < list.length ; x++ ) {
			paths_arr.push(list[x]);
		}
		//alert(paths_arr.length);
	}
	/*onKeyDown=try{
					kc = event.keyCode; obj = getElementById(\'sel\');
					if(kc == 40) {obj.selectedIndex++;}
					else if(kc == 38) {obj.selectedIndex--;}
					else if(kc == 13) {this.value = obj.options[obj.selectedIndex].value;}
				}catch(x){}
	onKeyUp=try {kc = event.keyCode ; if((kc != 38) && (kc != 40) && (kc != 13)) { if((kc != 27)) relist(this.value, \'sel\'); else sel.style.display=\'none\';}} catch(x){relist(this.value, \'sel\');}
	*/
	function relist(str,tgt)
	{
		obj = document.getElementById(tgt);
		if(str.length > 0)
		{
			obj.options.length=0;
			matches = arr.get_matches( str, false );
			var num_matches = matches.length;
			default_selected = false; //set the first item to selected
			if(num_matches == 0)
			{
				//obj.options[0] = new Option("No matches found.", -1, false, true);
				//obj.disabled = 'true';
				//obj.size = 1
				obj.style.display = 'none';
			}
			else
			{
				obj.disabled = '';
				for ( var x=0; x<num_matches; x++ ) 
				{
					obj.options[x]=new Option(matches[x], matches[x], false, default_selected);
					default_selected = false;
				}
				if (num_matches == 1)
					obj.size = 2;
				else if(num_matches < 10)
					obj.size = num_matches;
				else
					obj.size = 10;
			}
			if (num_matches > 0)
				obj.style.display = '';
		}
		else
		{
			obj.style.display = 'none';
		}
		
		//for (x = 0; x<obj.options.length; x++)
			//alert(obj.options[x].value);
	}

	function resolve_location(str)
	{
		var found;
		
		for (i=0; i<arr.length; i++)
		{
			if (arr[i] == str)
			{
				found = i;
				break;
			}
		}
		
		window.location = paths_arr[found];
	}
	
	function doOnKeyDown(e)
	{
		try{
			kc = e.keyCode;
			obj = document.getElementById('sel');
			if(kc == 40) {
				obj.selectedIndex++;
				document.getElementById('search_string').value = obj.value;
			} else if(kc == 38) {
				obj.selectedIndex--;
				document.getElementById('search_string').value = obj.value;
			}/*else if(kc == 13) {
				if(obj.selectedIndex != -1){
					resolve_location(obj.value);
					return false;
				}else
					this.form.submit();
			}*/
		}catch(x){}
	}
	
	function doOnKeyUp(e)
	{
		try {
			kc = e.keyCode;
			obj = document.getElementById('sel');
			if((kc != 38) && (kc != 40) && (kc != 13))
			{
				if(kc != 27)
					relist(get('search_string').value, 'sel');
				else
					get('sel').style.display='none';
			} else if(kc == 13) {
				if(obj.selectedIndex != -1){
					resolve_location(obj.value);
					return false;
				}else
					this.form.submit();
			}
		} catch(x){
			relist(get('search_string').value, 'sel');
			}
	}