function showGlossaryText(e) {
	var targ = Event.element(e);
	Event.stop(e);

	var item = $(targ.href.replace(/^.+\#/,""));
	function hideItem(thing) {
		new Effect.Fade(thing, { duration: .35 });
	}
	$$('.popupBox').each(function (button) {
		if (button != item) {
			hideItem(button);
		}
	});
	if (!item.visible()) {
		var top = Event.pointerY(e) - targ.up('.main').offsetTop - 25;
		var left = Event.pointerX(e) - targ.up('.main').offsetLeft - 150;
		item.style.top = top + "px";
		item.style.left = (left > 0 ? left : 0) + "px";
		new Effect.Appear(item, { duration: 0.35, to: .95 })
	} else {
		hideItem(item);
	}
}

PlanCalculator = {
	initialized: false,
	pricePerUser: 8,
	storagePerUser: 0.25,
	pricePerGB: 2,
	totalField: null,
	fields: [],
	calculate: function() {
		var total = 0;
		var users = 0;
		var storage = 0;
		var extraStorage = 0;
		users = parseInt($('planNumberOfUsers').value, 10);
		if (users < 3) {
			users = 3;
		}
		total += users * PlanCalculator.pricePerUser;
		extraStorage = parseInt($('planExtraStorage').value, 10);
		storage = (users * PlanCalculator.storagePerUser) + extraStorage;
		total += extraStorage * PlanCalculator.pricePerGB;
		total += parseInt($('planExtraDomain').value, 10);
		total += parseInt($('planExtraIP').value, 10);
		if (isNaN(total) || isNaN(users) || isNaN(storage) || users < 1) {
			total = '<big><strong>Unknown</strong></big>';
		} else {
			total = '<small>USD</small> <big><strong>$' + total + '</strong></big><br />(includes ' +
				storage + ' GB of storage)';
		}
		PlanCalculator.totalField.update(total);
	},
	open: function() {
		new Effect.Appear('planCalculatorBox', {
			duration: .3,
			afterFinish: function() {
				$('planNumberOfUsers').focus();
			}
		});
		return false;
	},
	initialize: function() {
		PlanCalculator.totalField = $('planEstimateTotal');
		if (!PlanCalculator.totalField) return;
		PlanCalculator.fields = $$('.planCalculatorField');
		if (!PlanCalculator.fields) return;
		PlanCalculator.fields.invoke('observe', 'change', PlanCalculator.calculate);
		PlanCalculator.fields.invoke('observe', 'keyup', PlanCalculator.calculate);
		PlanCalculator.initialized = true;
	}
};

Event.observe(window, 'load', function() {
	PlanCalculator.initialize();
	if (PlanCalculator.initialized) {
		PlanCalculator.calculate();
	 	window.setTimeout(function() { new Effect.Appear('calculatorLinkBox', { duration: .5 }) }, 500);
	}
});

