document.addEvent('domready', function() {
 
	/**
	 * Simple example, backend returns a list of <li> elements,
	 * processed by Autocompleter.Request.HTML.
	 */
	var inputWord = $('demo-word');
 
	// Our instance for the element with id "demo-word2"
	new Autocompleter.Request.HTML(inputWord, 'searchfeed.php', {
		'indicatorClass': 'autocompleter-loading',
		'className': 'autocompleter-choices',
		'postData': {
			'extended': '1' // send additional POST data, check the PHP code
		},
		'injectChoice': function(choice) {

			if (choice.getFirst() != null){
				var newText = choice.getFirst();

				choice.inputValue = newText.innerHTML.replace(/(<([^>]+)>)/ig,"").replace("&amp;","and").replace("Click here to view",""); 

				this.addChoiceEvents(choice);
			}
		}
	});
	
	//do we have a second search option?
	if ($('demo-word2')){
		
		var inputWord2 = $('demo-word2');
		
		new Autocompleter.Request.HTML(inputWord2, 'searchfeed.php', {
			'indicatorClass': 'autocompleter-loading',
			'className': 'mainsearch-choices',
			'postData': {
				'extended': '1' // send additional POST data, check the PHP code
			},
			'width': '327',
			'injectChoice': function(choice) {
	
				if (choice.getFirst() != null){
					var newText = choice.getFirst();
	
					choice.inputValue = newText.innerHTML.replace(/(<([^>]+)>)/ig,"").replace("&amp;","and").replace("Click here to view",""); 
	
					this.addChoiceEvents(choice);
				}
			}
		});
		
	}
	
	
});