/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

function getSelectionId(text, li) {
	var lis = document.getElementsByTagName('li');
	for(var i=0;i<lis.length;i++){
		if(lis[i].className=="selected"){
			if (lis[i].childNodes[0].href)
				window.location = lis[i].childNodes[0].href;
		}
		
	}
}


window.onload = function(){
    new Ajax.Autocompleter("search", "autocomplete_choices", "/pages/search", {
      afterUpdateElement : getSelectionId
    });

	if ($('arr_content')){
		Event.observe('arr_left', 'click', function(event){
			var children = $('arr_content').childElements();
			var i = 6;
			for (var n = children.length-1; n >= 0; n--){
				if(children[n].positionedOffset){
					var dx = children[n].positionedOffset().left + $('arr_content').positionedOffset().left;
					if ( dx < 0){
						if (--i == 0 || n == 0){
							new Effect.Move('arr_content', { x: -dx, y: 0, mode: 'relative' });
							break;
						}							
					}
				}
			}
		});
		Event.observe('arr_right', 'click', function(event){
			var children = $('arr_content').childElements();
			var i = 6;
			for (n in children){
				if(children[n].positionedOffset){
					var dx = children[n].positionedOffset().left + $('arr_content').positionedOffset().left;
					if ( dx > 0){
						if (--i == 0){
							new Effect.Move('arr_content', { x: -dx, y: 0, mode: 'relative' });
							break;
						}							
					}
				}
			}
		});
	}

}