function onloadQueue(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
		} else {
			window.onload = function() {
				if (oldonload) {
					oldonload();
					}
				func();
				}
			}
	}

Ajax.Autocompleter.prototype.updateChoices =  function (choices) {

	if (!this.changed && this.hasFocus) {
		this.update.innerHTML = '<ul></ul>';

		response = choices.evalJSON();
	
		if (response) {
			var i = 0;
			this.choicesJSON = $H(response).values();
			$H(response).values().each((function (suggestion) {
				i++;
				if (i == $H(response).values().size()) {
					this.update.down('ul').insert((new Template('<li class="last">#{suggestion}</li>')).evaluate({suggestion: suggestion.titlu}));
					} else if (i == 1) {
						this.update.down('ul').insert((new Template('<li class="first">#{suggestion}</li>')).evaluate({suggestion: suggestion.titlu}));
						} else {
							this.update.down('ul').insert((new Template('<li>#{suggestion}</li>')).evaluate({suggestion: suggestion.titlu}));
							}
				}).bind(this));
			}

		Element.cleanWhitespace(this.update);
		Element.cleanWhitespace(this.update.down());

		if (this.update.firstChild && this.update.down().childNodes) {
			this.entryCount = this.update.down().childNodes.length;
			for (var i = 0; i < this.entryCount; i++) {
				var entry = this.getEntry(i);
				entry.autocompleteIndex = i;
				this.addObservers(entry);
				}
			} else { 
				this.entryCount = 0;
				}

		this.stopIndicator();
		this.index = 0;

		if (this.entryCount == 1 && this.options.autoSelect) {
			this.selectEntry();
			this.hide();
			} else {
				this.render();
				}
		}
	}

Ajax.Autocompleter.prototype.markPrevious = function() {
	if(this.index > 0) {
		this.index--;
		} else {
			this.index = this.entryCount-1;
			}
	}

Ajax.Autocompleter.prototype.markNext = function() {
	if (this.index < this.entryCount-1) {
		this.index++;
		} else {
			this.index = 0;
			}
	}

onloadQueue(function () {
	if ($$('#scroller .slide').size() > 1) {
		var carousel = new Carousel($('scroller'), $$('.slide'), $$('#showcase a.navigational'), {auto: true, duration: 0.5, frequency: 3, controlClassName: 'navigational'});
		} else {
			$$('#showcase a.navigational').invoke('hide');
			}
	if ($$('#scroller-posturi .post').size() > 1) {
		var carousel_posturi = new Carousel($('scroller-posturi'), $$('.post'), false, {auto: true, duration: 0.5, frequency: 4});
		}
	});
