addLoadEvent(function() {
	var feat = $('subscribe');

	sub_dts = feat.getElementsByTagName('dt');
	sub_dds = feat.getElementsByTagName('dd');

	for (var i = 0; i < sub_dts.length; i++) {
		var subrotator = new SubRotator(sub_dts[i], sub_dds[i]);
	}
});


function SubRotator(trigger, tgt) {
	this.isVisible = false;
	this.shouldBeVisible = false;
	this.inTransit = false;

	this.trigger = trigger;
	this.tgt = tgt;
	
	trigger._rotator = this;
	tgt._rotator = this;

	Element.hide(tgt);
	tgt.className = 'current';

	trigger.onmouseover = function() {
		this._rotator.show();
	}

	trigger.onmouseout = function() {
		this._rotator.hide();
	}
}

SubRotator.prototype.show = function() {
	this.shouldBeVisible = true;
	if (this.inTransit) return;

	this.isVisible = true;
	this.inTransit = true;
        new Effect.Appear(this.tgt, {afterFinish: subTransDone});
}

SubRotator.prototype.hide = function() {
	this.shouldBeVisible = false;
	if (this.inTransit) return;

	this.isVisible = false;
	this.inTransit = true;
        new Effect.Fade(this.tgt, {afterFinish: subTransDone});
}

SubRotator.prototype.transDone = function() {
	this.inTransit = false;

	if (this.shouldBeVisible && !this.isVisible) {
		this.show();		
	} else if (!this.shouldBeVisible && this.isVisible) {
		this.hide();
	}
}

function subTransDone(obj) {
        obj.element._rotator.transDone();
}
