function SelectInfo (who)
{
	var id = who.id;
	var name = id.substring (0, id.length - 1);
	var n = id.substring (id.length - 1);
	
	for (var c = 1; ; c++)
	{
		var label = document.getElementById (name + c);
		var info = document.getElementById (name + c + 'info');
		if (!label || !info) break;

		if (id == label.id)
		{
			label.className = 'item selected';
			info.className = 'visible';
		}
		else
		{
			label.className = 'item';
			info.className = 'invisible';
		}
	}
}

function NoIWillNot (who)
{
	var Viewport = document.getElementById ('Viewport');
	if (Viewport) Viewport.style.visibility = 'hidden';

	var NoButton = document.getElementById ('NoButton');
	if (NoButton) NoButton.style.visibility = 'hidden';
}

function YesIWill()
{
	var Viewport = document.getElementById ('Viewport');
	if (Viewport) Viewport.style.visibility = 'visible';

	var UserForm = document.getElementById ('UserForm');
	if (UserForm) UserForm.className = 'visible';

	var NoButton = document.getElementById ('NoButton');
	if (NoButton) NoButton.style.visibility = 'hidden';

	var YesButton = document.getElementById ('YesButton');
	if (YesButton) YesButton.style.visibility = 'hidden';

	document.location.href = '#yes-i-will-come';
}

function TogglePayOptions (who)
{
	var PayOptions = document.getElementById ('PayOptions');
	if (PayOptions) PayOptions.style.visibility = who.checked ? 'visible' : 'hidden';
}

function ToggleTalk (who)
{
	var TalkFields = document.getElementById ('TalkFields');
	if (TalkFields) TalkFields.className = who.checked ? 'visible' : 'invisible';

	var PayFields = document.getElementById ('PayFields');
	if (PayFields) PayFields.className = !who.checked ? 'visible' : 'invisible';
}

function FormSubmit()
{
	var MainForm = document.getElementById ('MainForm');
	if (MainForm) MainForm.submit();
}

function WantAttend (who)
{
	var id = who.id;
	var n = id.substring (id.length - 1);

	var Prewant = document.getElementById ('Prewant' + n);
	var Attend = document.getElementById ('Attend' + n);
	if (!Prewant || !Attend) return;

	Prewant.checked = who.checked;
	Attend.checked = who.checked;
}

function OrgSwap()
{
	if (Math.random() >= 0.5)
	{
		var org1 = document.getElementById ('org1');
		var org2 = document.getElementById ('org2');

		if (org1 && org2)
		{
			document.title  += '.';
			var html = org2.innerHTML;
			org2.innerHTML = org1.innerHTML;
			org1.innerHTML = html;
		}
	}
}

