document.observe("dom:loaded", function() {
	if($('suche'))
	{
		$('suche').insert({after: '<span id="indicator1" style="display:none;position:absolute;right:48px;top:12px;"><img src="/media/images/chrome/load.gif" alt="Working..." /></span>'});
		$('suche').insert({after: '<div id="suggests"></div>'});
		$('suche').setAttribute('autocomplete', 'off');
		new Ajax.Autocompleter('suche', 'suggests', '/shop/suchwort/?location=' + encodeURI(window.location.pathname), {
			//parameters:'isajax=1&suggest=1&location='+window.location.pathname+'&kategorie_suche='+$F('kategorie_suche'),
			// callback: function(){alert('hier');},
			afterUpdateElement: function(e){e.up('form').submit();}
			//indicator: 'indicator1',
			
		});
		 // + encodeURI(window.location.pathname)
		 /*
		new Ajax.Autocompleter('suche', 'suggests', '/bilddatenbank/suchwort/', {
		callback: function(e){alert($('suggests').getStyle())}
		});
		 */
	}
	/*
	if($('kategorie_suche'))
	{
		$('kategorie_suche').observe('change', function(event){
			Event.element(event).up('form').submit();
		});
	}*/

	if($('changewebcontainer'))
	{
		
		open = true;
		var div = 'edit_container';
		
		var objBody = $$('body')[0];
		
		objBody.appendChild(Builder.node('div',{id:'overlay'}));
		
		//if($('schlagwort_id'))
		//	tlist2 = new FacebookList('schlagwort_id', 'schlagwort-auto',{fetchFile:'/admin/schlagwort/get', setFile:'/admin/schlagwort/set'});
		
		var arrayPageScroll = document.viewport.getScrollOffsets();
		var Top = arrayPageScroll[1] + (document.viewport.getHeight() / 10);
		var Left = arrayPageScroll[0];
		$(div).setStyle({ top: Top + 'px', left: Left + 'px' });
		$('edit_container').observe('click', (function(event) { if (event.element().id == 'edit_container') closechange(div) }));
		
		// stretch overlay to fill page and fade in
		var arrayPageSize = getPageSize();
		$('overlay').setStyle({ width: arrayPageSize[0] + 'px', height: arrayPageSize[1] + 'px', opacity: 0.8});
		$('overlay').observe('click', (function() { closechange(div) }));		
	}

	adddatepicker();
});