function menu(x, a, b, c, d, e)
{
	if (document.getElementById(x).style.display=='none')
	{
		//Effect.SlideDown(document.getElementById(x), {duration: 0.5});
		document.getElementById(x).style.display = '';
		if (document.getElementById(a) != null)
			document.getElementById(a).style.display = 'none';
		if (document.getElementById(b) != null)
			document.getElementById(b).style.display = 'none';
		if (document.getElementById(c) != null)
			document.getElementById(c).style.display = 'none';
		if (document.getElementById(d) != null)
			document.getElementById(d).style.display = 'none';
		if (document.getElementById(e) != null)
			document.getElementById(e).style.display = 'none';
	}
	else
		document.getElementById(x).style.display = 'none';
		//Effect.SlideUp(document.getElementById(x), {duration: 0.5});
		
	setCookie('openM', x, '1');
	setCookie('month', '', '1');
}				

function ms(x)
{
	setCookie('page', x, '1');
	//window.location.reload();
}

function clearCalendar()
{
	setCookie('m', '', '1');
	setCookie('d', '', '1');
}

function openSMenu()
{	
	setCookie('page', '', -3600);
	
	var openM = getCookie('openM');
	if (document.getElementById(openM) != null) {
		document.getElementById(openM).style.display = '';
		//setCookie('openM', '', -3600);
	}
}

function closeMenus(x, a, b, c, d, e)
{
	  document.getElementById(x).style.display = 'none';
		document.getElementById(a).style.display = 'none';
		document.getElementById(b).style.display = 'none';
		document.getElementById(c).style.display = 'none';
		document.getElementById(d).style.display = 'none';
		document.getElementById(e).style.display = 'none';
}

function listMenu(numRows, x)
{
	var i;
	for (i = 1; i <= numRows; i++) {
		if (document.getElementById(i) != null)
			document.getElementById(i).style.display = 'none';
	}
		
	if (document.getElementById(x) != null)
		document.getElementById(x).style.display = '';
}

function showErrors()
{
    if (getCookie('error') != null && getCookie('error') != "")
    {
        if (getCookie('error') != '1')
          alert("The following error(s) were encountered:\r\n " + getCookie('error').replace(/\+/g, " "));
        else
          alert("You will receive an email shortly with a key to reset your password.");
        setCookie("error", '', -3600);
    }
}

function toggleStudentDiv(show)
{
    if (show == 1) {
        document.getElementById("trSuper").style.display = '';
        document.getElementById("trSuperEmail").style.display = '';
    } else {
        document.getElementById("trSuper").style.display = 'none';
        document.getElementById("trSuperEmail").style.display = 'none';
    }
}

function checkUserFields()
{
    var clean = 1;
    var errors = "The following errors were encountered:\n";
    if (document.member.fname.value == "") {
        errors = errors + "\nFirst name cannot be blank.";
        clean = 0;
    }
    if (document.member.lname.value == "") {
        errors = errors + "\nLast name cannot be blank.";
        clean = 0;
    }
    if (document.member.address1.value == "") {
        errors = errors + "\nAddress 1 cannot be blank.";
        clean = 0;
    }
    if (document.member.city.value == "") {
        errors = errors + "\nCity cannot be blank.";
        clean = 0;
    }
    if (document.member.province.value == "") {
        errors = errors + "\nProvince cannot be blank.";
        clean = 0;
    }
    if (document.member.country.value == "") {
        errors = errors + "\nCountry cannot be blank.";
        clean = 0;
    }
    if (document.member.pcode.value == "") {
        errors = errors + "\nPostal code cannot be blank.";
        clean = 0;
    }
    if (document.member.phone1.value == "" || document.member.phone2.value == "" || document.member.phone3.value == "" || document.member.phone4.value == "") {
        errors = errors + "\nPhone number cannot be blank.";
        clean = 0;
    }
    if (document.member.username != null && document.member.username.value == "") {
        errors = errors + "\nUsername cannot be blank.";
        clean = 0;
    }
    if (document.member.password.value != document.member.password2.value) {
        errors = errors + "\nPasswords must match.";
        clean = 0;
    }
    if (document.member.type != null && (document.member.type[1].checked == 'checked' || document.member.type[1].checked == true)) {
        if (document.member.supervisor.value == "") {
            errors = errors + "\nSupervisor cannot be blank.";
            clean = 0;
        }
        if (document.member.superemail.value == "") {
            errors = errors + "\nSupervisor E-mail cannot be blank.";
            clean = 0;
        }
    }
    
    if (clean == 1) {
        document.member.submit();
    } else {
        alert(errors);
    }
}