window.onload = function(){
	$$('.external').addEvent('click', function(ev){
			window.open(this.href); new Event(ev).stop(); return; });
	
	$$('.search').addEvent('click', function(ev){
		new Event(ev).stop();
		$('search').value='';
	});
	
	var searchInput = $('search');
  
	// A simple spinner div, display-toggled during request
	var indicator = new Element('div', {
	    'class': 'autocompleter-loading',
	    'styles': {'display': 'none'}
	}).injectAfter(searchInput); // appended after the input
	 
	var completer = new Autocompleter.Ajax.Xhtml(searchInput, BASEURL+'system/assets/ajax/auto.php', {
	  'delay': 50,
		'minLength': 1,
		'postData': {html: 1},
		'indicator': indicator,
		'injectChoice': function(choice) {
			// we get the text from the first child, default would be the element-text itself
			var value = choice.getFirst().innerHTML;
			// holds the internal value
			choice.inputValue = value;
			// same here, we mark the text for the first child
			this.addChoiceEvents(choice).getFirst().setHTML(this.markQueryValue(value));
		},
		/*'selectMode': 'pick',*/
		'selectFirst': false,
		'inheritWidth':false
	});

}
