// Self Labeled Input
// use: new Axent.SelfLabeledInput('#commentform label');
// modified: jan@propagandafabrik.de

if (Object.isUndefined(Axent)) { var Axent = { } }
Axent.SelfLabeledInput = Class.create({
initialize: function() {
    var labelSelector = arguments[0] || 'label';
    $$(labelSelector).findAll(function(l) {return (l.readAttribute('for') !== null)}).each(function(l){
        var el = $(l.readAttribute('for'));
        if (el.value.empty()) {
            l.appear({duration:0.2});
        } else {
            l.fade({duration:0.2});
        }
        el.observe('blur',function(e){
            if(Event.element(e).value == '') l.appear({duration:0.2});
        });
        el.observe('focus',function(e){
            l.fade({duration:0.2});
        });

    });    
}});

// SEARCH UI

function afterAutocompleted(text, li) {
	if(li.id){
		self.location.href=li.id;
	}else{
		$('header_search').submit();
	}
}

