function FormValidate(o)
{
	if (o.username.value == "") {alert("Create a username."); o.username.select(); return false;}
	if (o.password.value == "") {alert("Enter your password."); o.password.select(); return false;}
	if (o.firstName.value == "") {alert("Enter your first name."); o.firstName.select(); return false;}
	if (o.lastName.value == "") {alert("Enter your last name."); o.lastName.select(); return false;}
	if (o.email.value == "") {alert("Enter your email address."); o.email.select(); return false;}
	if (o.birthDate[0].options[o.birthDate[0].selectedIndex].value == "0") {alert("Select the month your were born."); o.birthDate[0].focus(); return false;}
	if (o.birthDate[1].options[o.birthDate[1].selectedIndex].value == "0") {alert("Select the day your were born."); o.birthDate[1].focus(); return false;}
	if (o.birthDate[2].options[o.birthDate[2].selectedIndex].value == "0") {alert("Select the year your were born."); o.birthDate[2].focus(); return false;}
	if (o.gender[0].checked == false && o.gender[1].checked == false) {alert("Select your gender."); o.gender[0].focus(); return false;}
	if (o.country.options[o.country.selectedIndex].value == "0") {alert("Select a country."); o.country.focus(); return false;}
	if (o.state.options[o.state.selectedIndex].value == "0") {alert("Select a state."); o.state.focus(); return false;}
	if (o.city.options[o.city.selectedIndex].text == "") {alert("Select a city."); o.city.focus(); return false;}
	if (o.legal.checked == false) {alert("You must agree to the 'Terms of Use' and 'Privacy Policy'."); o.legal.focus(); return false;}
	if (o.misconduct.checked == false) {alert("You must promise to never post profanities, pornographic content, advertisements, threats, or derogatory statements."); o.misconduct.focus(); return false;}
	if (o.secCode != null) {if (o.secCode.value == "" || o.secCode.value == "Type code here...") {alert("Enter the security code."); o.secCode.focus(); return false;}}
	return true;
}

function HideAll(o)
{
	var a = "explainUsername,explainPassword,explainName,explainEmail,explainBirthday,explainLocation".split(",");
	for (var i = 0; i < a.length; i++)
	{
		document.getElementById(a[i]).style.display = "none";
	}
	
	if (o.toUpperCase() != "FALSE")
		document.getElementById(o).style.display = "block";
}

function UsernameAvailable(o)
{
	if (o.value != "")
	{
		var x = AjaxGet("http://www.debate.org/join/username/?u=" + escape(o.value), false, true);
		
		if (x.toLowerCase() == "true")
		{
			alert("The username you have entered is already taken. Please enter a different username.");
			o.select();
		}
		else
		{
			alert("The username you have entered is available.");
			document.getElementById("checkAvail").style.display = "none";
		}
	}
}

function UsernameAvailableButton(u, b)
{
	b.style.display = (u.value == "") ? "none" : "block";
}
