/* Expandable Content (see README for usage)
 * $Id: expandable.js 801 2004-12-12 02:19:26Z ling $
 */

var ec_ok = document.getElementById? true : false;

// [Private] Toggle the 'display' property of id
// f: 1 (force visible), 0 (force invisible), none (toggle)
function ec_toggle_display (id, f) {
	var item = document.getElementById(id);
	if (item) {
		var v = f? 1 : ((f==0)? 0 : (item.style.display == 'none'));
		item.style.display = v? '' : 'none';
	}
}

// [Private] Toggle the show/hide class of id
function ec_toggle_class (id, f) {
	var item = document.getElementById(id);
	if (item) {
		var v = f? 1 : ((f==0)? 0 : (item.className == 'ec_hide'));
		item.className = v? 'ec_show' : 'ec_hide';
	}
}

// [Public] Toggle the whole set.
// id: the content part; id+'_show', id+'_hide': the prompt parts
function ec_toggle (id) {
	if (!ec_ok) return;
	ec_toggle_display(id);
	ec_toggle_display(id+'_show');
	ec_toggle_display(id+'_hide');
}

// [Public] Write the prompt in a pair of brackets.
function ec_prompt (id, show, hide) {
	if (!ec_ok) return;
	if (typeof(show) != "string") show = "show";
	if (typeof(hide) != "string") hide = "hide";

	document.write('<SPAN class="ec_prompt">[' +
	'<A href="javascript:ec_toggle(\''+id+'\')">' +
	'<SPAN id="'+id+'_show" class="ec_show">'+show+'</SPAN>' +
	'<SPAN id="'+id+'_hide" class="ec_hide">'+hide+'</SPAN>' +
	'</A>]</SPAN>');
	ec_toggle_display(id+'_show', 0);
}

// [Public] Write a clickable title
function ec_title (id, prefix, show, hide) {
	if (!ec_ok) { document.writeln(prefix); return; }
	if (typeof(show) != "string") show = "&raquo;";
	if (typeof(hide) != "string") hide = "";

	document.write('<A href="javascript:ec_toggle(\''+id+'\')">' +
	prefix + '<SPAN class="ec_prompt">' +
	'<SPAN id="'+id+'_show" class="ec_show">&nbsp;'+show+'</SPAN>' +
	'<SPAN id="'+id+'_hide" class="ec_hide">&nbsp;'+hide+'</SPAN>' +
	'</SPAN></A>');
	ec_toggle_display(id+'_show', 0);
}

function ec_expand_all () {
}
