/* =============================================================================
$Id: expander.js 6176 2007-04-30 10:37:29Z howardb $
$Date: 2007-04-30 11:37:29 +0100 (Mon, 30 Apr 2007) $
$Revision: 6176 $
$Author: howardb $
Copyright (c) 2005 Conchango Ltd. All rights reserved.
Web Application Version: [BUILD_16.07.32_2_071011]
Release Date: [12-October-2007]
============================================================================= */
var Expander =
{
	_open: null, //ID of open element

	changeState: function(e)
	{
		// Check if another section is open and close it
		if (e.id != this._open && null != this._open)
			this.changeState($(this._open));

		var className = e.parentNode.className;
		var innerHTML = e.innerHTML

		//switch class oncontaining element
		e.parentNode.className = (-1 != className.indexOf("expanded"))?
			"":
			"expanded";

		//swap hide/show text
		e.innerHTML = (-1 != innerHTML.indexOf("Show")) ?
			innerHTML.replace(/Show/,"Hide"):
			innerHTML.replace(/Hide/,"Show");

		//if openning a section store it's ID
		if ("" != e.parentNode.className)
			this._open=e.id;
		else
			this._open=null;

		//deselect link
		if (e.blur)
			e.blur();

		//return false to stop link firing
		return false;
	}
}