document.observe('dom:ready',function(){initExpanders();});

function initExpanders(){
	$$('a.expander:not([class~=processed])').each(function(a){initExpander(a);});	
}

function initExpander(a){
	a = $(a).addClassName('processed');
	var target = a.previous('div.expander-target');	
	target.hide();
	a.observe('click',function(){toggleExpander(a,target);});
	a.onclick = function(){return false;}
}
function toggleExpander(a,target){
	if (a.hasClassName('expanded')){
		a.removeClassName('expanded');
		a.update($(a).initial);
	} else {
		$(a).initial = a.innerHTML;
		a.addClassName('expanded');
		a.update('Close');
	}
	Effect.toggle(target,'blind');
}
