function SwatDisclosure(id, open)
{
	this.image = document.getElementById(id + '_img');
	this.input = document.getElementById(id + '_input');
	this.div = document.getElementById(id);
	this.animate_div = this.div.firstChild.nextSibling.firstChild;

	// prevent closing during opening animation and vice versa
	this.semaphore = false;

	// get initial state
	if (this.input.value.length) {
		// remembered state from post values
		if (this.input.value == 'opened') {
			this.open();
		} else {
			this.close();
		}
	} else {
		// initial display
		if (open) {
			this.open();
		} else {
			this.close();
		}
	}
}

SwatDisclosure.open_text = 'open';
SwatDisclosure.close_text = 'close';

SwatDisclosure.prototype.toggle = function()
{
	if (this.opened) {
		this.closeWithAnimation();
	} else {
		this.openWithAnimation();
	}
}

SwatDisclosure.prototype.close = function()
{
	YAHOO.util.Dom.removeClass(this.div, 'swat-disclosure-control-opened');
	YAHOO.util.Dom.addClass(this.div, 'swat-disclosure-control-closed');

	this.semaphore = false;

	this.image.src = 'packages/swat/images/swat-disclosure-closed.png';
	this.image.alt = SwatDisclosure.open_text;
	this.input.value = 'closed';

	this.opened = false;
}

SwatDisclosure.prototype.closeWithAnimation = function()
{
	if (this.semaphore)
		return;

	this.animate_div.style.overflow = 'hidden';
	this.animate_div.style.height = '';
	var attributes = { height: { to: 0 } }; 
	var animation = new YAHOO.util.Anim(this.animate_div, attributes, 0.25,
		YAHOO.util.Easing.easingIn); 

	this.semaphore = true;
	animation.onComplete.subscribe(SwatDisclosure.handleClose, this);
	animation.animate();

	this.image.src = 'packages/swat/images/swat-disclosure-closed.png';
	this.image.alt = SwatDisclosure.open_text;
	this.input.value = 'closed';
	this.opened = false;
}

SwatDisclosure.prototype.open = function()
{
	YAHOO.util.Dom.removeClass(this.div, 'swat-disclosure-control-closed');
	YAHOO.util.Dom.addClass(this.div, 'swat-disclosure-control-opened');

	this.semaphore = false;

	this.image.src = 'packages/swat/images/swat-disclosure-open.png';
	this.image.alt = SwatDisclosure.close_text;
	this.input.value = 'opened';
	this.opened = true;
}

SwatDisclosure.prototype.openWithAnimation = function()
{
	if (this.semaphore)
		return;

	YAHOO.util.Dom.removeClass(this.div, 'swat-disclosure-control-closed');
	YAHOO.util.Dom.addClass(this.div, 'swat-disclosure-control-opened');

	// get display height
	this.animate_div.parentNode.style.overflow = 'hidden';
	this.animate_div.parentNode.style.height = '0';
	this.animate_div.style.visibility = 'hidden';
	this.animate_div.style.overflow = 'hidden';
	this.animate_div.style.display = 'block';
	this.animate_div.style.height = '';
	var height = this.animate_div.offsetHeight;
	this.animate_div.style.height = '0';
	this.animate_div.style.visibility = 'visible';
	this.animate_div.parentNode.style.height = '';
	this.animate_div.parentNode.style.overflow = 'visible';
	
	var attributes = { height: { to: height, from: 0 } }; 
	var animation = new YAHOO.util.Anim(this.animate_div, attributes, 0.5,
		YAHOO.util.Easing.easeOut); 

	this.semaphore = true;
	animation.onComplete.subscribe(SwatDisclosure.handleOpen, this);
	animation.animate();

	this.image.src = 'packages/swat/images/swat-disclosure-open.png';
	this.image.alt = SwatDisclosure.close_text;
	this.input.value = 'opened';
	this.opened = true;
}

SwatDisclosure.handleClose = function(type, args, disclosure)
{
	YAHOO.util.Dom.removeClass(disclosure.div,
		'swat-disclosure-control-opened');

	YAHOO.util.Dom.addClass(disclosure.div, 'swat-disclosure-control-closed');
	disclosure.semaphore = false;
}

SwatDisclosure.handleOpen = function(type, args, disclosure)
{
	// allow font resizing to work again
	disclosure.animate_div.style.height = '';

	// re-set overflow to visible for styles that might depend on it
	disclosure.animate_div.style.overflow = 'visible';

	disclosure.semaphore = false;
}

@@ -1576,38 +1576,28 @@
 e.subscribe(
-SwatDisclosure
+this
 .handleClose
@@ -1598,24 +1598,30 @@
 eClose, this
+, true
 );%0A%09animatio
@@ -3171,30 +3171,20 @@
 bscribe(
-SwatDisclosure
+this
 .handleO
@@ -3192,16 +3192,22 @@
 en, this
+, true
 );%0A%09anim
@@ -3401,24 +3401,34 @@
 tDisclosure.
+prototype.
 handleClose 
@@ -3438,38 +3438,16 @@
 unction(
-type, args, disclosure
 )%0A%7B%0A%09YAH
@@ -3474,26 +3474,18 @@
 ass(
-disclosure
+this
 .div,
-%0A%09%09
+ 
 'swa
@@ -3515,17 +3515,16 @@
 ened');%0A
-%0A
 %09YAHOO.u
@@ -3540,26 +3540,20 @@
 ddClass(
-disclosure
+this
 .div, 's
@@ -3586,26 +3586,20 @@
 sed');%0A%09
-disclosure
+this
 .semapho
@@ -3628,16 +3628,26 @@
 closure.
+prototype.
 handleOp
@@ -3664,30 +3664,8 @@
 ion(
-type, args, disclosure
 )%0A%7B%0A
@@ -3703,26 +3703,20 @@
  again%0A%09
-disclosure
+this
 .animate
@@ -3807,26 +3807,20 @@
  on it%0A%09
-disclosure
+this
 .animate
@@ -3854,26 +3854,20 @@
 ble';%0A%0A%09
-disclosure
+this
 .semapho

remove static animation complete events in favour of prototyped methods.