function toggleSignup(type, action) {
	if (action == "on") {
	    document.getElementById("account_type").value = type;
	    document.getElementById("signup_form").style.display = "block";
	    document.getElementById("signup_info").style.display = "none";
		if (type == "HOMEBASE") {
			document.getElementById("signup_form_instructions").innerHTML = "Parents, to sign up, please fill in the information below:";
			document.getElementById("user_id_label").innerHTML = "Parent User ID * :";
			document.getElementById("password_label").innerHTML = "Parent Password * :";
			document.getElementById("password_confirm_label").innerHTML = "Re-type Parent Password * :";
		}
		if (type == "COUNSELOR") { 
		    document.getElementById("signup_form_instructions").innerHTML = "Teachers, to sign up, please fill in the information below:";
			document.getElementById("user_id_label").innerHTML = "Teacher User ID * :";
			document.getElementById("password_label").innerHTML = "Teacher Password * :";
			document.getElementById("password_confirm_label").innerHTML = "Re-type Teacher Password * :";	
        }
		if (type == "SURVEYOR") { 
		    document.getElementById("signup_form_instructions").innerHTML = "Students, to sign up, please fill in the information below (if you are unsure of anything please call a parent or teacher to help you):"; 
			document.getElementById("user_id_label").innerHTML = "Student User ID * :";
			document.getElementById("password_label").innerHTML = "Student Password * :";
			document.getElementById("password_confirm_label").innerHTML = "Re-type Student Password * :";
		}
	} else {
	    document.getElementById("signup_form").style.display = "none";
	    document.getElementById("signup_info").style.display = "block";
		document.getElementById("user_user_id").value = "";
		document.getElementById("user_password").value = "";
		document.getElementById("user_password_confirmation").value = "";
		document.getElementById("user_email").value = "";
	}
}


function newManagementAccountValidation (frm)
{
    var err = "";

    for (var i = 0; i < frm.elements.length; i++) {
		var txt;
		if (frm[i].id == "users_user_id") txt = "User ID";
		if (frm[i].id == "users_password") txt = "Password";
		if (frm[i].id == "users_password_confirmation") txt = "Password confirmation";
		if (frm[i].id == "users_email") txt = "Email";
		if (frm[i].id == "users_first_name") txt = "First name";
		if (frm[i].id == "users_last_name") txt = "Last name";
		if (frm[i].id == "users_public_alias") txt = "Public alias";
		if (frm[i].id == "users[dob]") txt = "Birth date";
        err += frm[i].value == "" ? "<br/>" + txt + " cannot be blank." : "";
    }

    if (document.getElementById('users_password').value != document.getElementById('users_password_confirmation').value) {
		err += "<br/>User passwords must match.";
	}
	
	if (document.getElementById('account_type_homebase')) {
		if (!document.getElementById('account_type_homebase').checked
			&& !document.getElementById('account_type_counselor').checked
			 && !document.getElementById('account_type_depot').checked
			  && !document.getElementById('account_type_professor').checked
			   && !document.getElementById('account_type_admin').checked) {
            err += "<br/>You must select at least one account type.";
		}
        if (document.getElementById('account_type_homebase').checked && document.getElementById('account_type_counselor').checked) {
			err += "<br/>Cannot select both HOMEBASE and COUNSELOR.";
		}
	}
	
	if (!document.getElementById('gender_female').checked && !document.getElementById('gender_male').checked) {
		err += "<br/>You must select a gender.";
	}

    if (err != "") {
        document.getElementById('new_account_error').innerHTML = "<b>Before you can continue you must clear up the following errors:</b><br/>" + err;
        return false;
    }
	return true;
}

function getAccountType(elt) 
{
	var inps = elt.parentNode.getElementsByTagName('input');
	var acc = "";
	for (var i = 0; i < inps.length; i++) {
	    if (inps[i].checked) {
		    acc += inps[i].value + ":";	
		}
	}
	document.getElementById('account_type').value = acc.substring(0, acc.length - 1);
}