/**************************************************************************************************/
// STUFF FOR WHEN THE PAGE LOADS

function loadMe() {

	// Hide the "secondary" lists by default.
	$$('ul.secondary').invoke('hide');

	// Register some event handlers.
	Behaviour.register({

		// All links with a classname of "more".
		'a.more' : function(e) {
			e.onclick = function() {
				var div_id = this.parentNode.parentNode.id;
				var secondary = $$('#' + div_id + ' ul.secondary')[0];

				if (secondary.visible()) {
					BlindShut(secondary);
					e.innerHTML = 'More &raquo;';
				}
				else {
					BlindOpen(secondary);
					e.innerHTML = '&laquo; Less';
				}

				return false;
			}
		},

		// An element with an id of expand
		'#expand' : function(e) {
			e.onclick = function() {
				$$('ul.secondary').each(function(e, iter) {
					$$('a.more').each(function(elem) {
						elem.innerHTML = '&laquo; Less';
					});
					if (!e.visible()) BlindOpen(e);
				});
				return false;
			}
		},

		// An element with an id of collapse
		'#collapse' : function(e) {
			e.onclick = function() {
				$$('ul.secondary').each(function(e, iter) {
					$$('a.more').each(function(elem) {
						elem.innerHTML = 'More &raquo;';
					});
					if (e.visible()) BlindShut(e);
				});
				return false;
			}
		}
	});
};


/**************************************************************************************************/
// EFFECTS

function BlindOpen(id, opt) {
	opt = (opt) ? opt:{};
	opt.duration = (opt.duration) ? opt.duration : 0.5;
	new Effect.BlindDown(id, opt);
	new Effect.Appear(id, opt);
};

function BlindShut(id, opt) {
	opt = (opt) ? opt:{};
	opt.duration = (opt.duration) ? opt.duration : 0.5;
	new Effect.BlindUp(id, opt);
	new Effect.Fade(id, opt);
};

