/*
	call "setupBtn" on the each trigger
	the trigger's id should be the same as the associated content
	  box, with "a" prefix (e.g., "story" + "aStory")
	show the first box with "showContent('story')"
	
	requires /GS/extras.js and /GS/fx.js
 */

var showing = '', showNext = '', working = false;
function doneRelay() {
	working = false;
	EFX.onComplete = null;
}
function tagRelay() {
	EFX.onComplete = doneRelay;
	var obj = $('c'+showNext);
	if ( obj) EFX.toggleOpacity(obj.id);
	showing = showNext;
}

function showContent(x) {
	if ( x == showing || working) return;
	showNext = x;
	working = true;
	var anc = $('a'+showing);
	if ( showing != '') {
		if ( anc) setCls(anc, '');
		EFX.onComplete = tagRelay;
		EFX.toggleOpacity('c'+showing);
	} else {
		tagRelay();
	}
	anc = $('a'+x);
	if ( anc) setCls(anc, 'on');
	return false;
}

function setupBtn(btn) {
	var elt = $('a'+btn);
	if (elt) addEvent(elt,'click',Function('showContent("'+btn+'")'),true);
}