function toggleEnabled(){
    var elem = document.getElementById("username");
    if (elem != null)
    {
        // toggle the disabled status
        elem.disabled = !elem.disabled;
    }else{
        elem.disabled = "disabled";
    }
}
function openPWDiv(){
    document.getElementById("lostpassdiv").style.display="block";
}
function optOut(opt) {
    if (opt=='mm') {
        document.forms[0].hlogout.value="menu";
        document.forms[0].submit();
    }
    if (opt=='hp') {
        document.forms[0].hlogout.value="logout";
        document.forms[0].submit();
    }
}
function chk4New($id) {
    if ($id=="") {
        document.getElementById("primemail").style.visibility="hidden";
        document.getElementById("primemaillabel").style.visibility="hidden";
    }else{
        document.getElementById("displayPass").style.display="none";
        document.getElementById("username").disabled="disabled";
        document.getElementById("updateprimaryemail").checked="";
    }
}
function valLoginForm() {
    var valid = true;
    if (document.forms[0].username.value=="") {
        document.getElementById("UName").style.color="red";
        valid = false;
    }else{
        document.getElementById("UName").style.color="black";
    }
    if (document.forms[0].password.value=="") {
        document.getElementById("PWord").style.color="red";
        valid = false;
    }else{
        document.getElementById("PWord").style.color="black";
    }
    if (valid==true) {
        document.forms[0].hsubmit.value = "Login"
        document.forms[0].submit();
    }else{
        document.getElementById("errmsg").innerHTML =  "Please fill in all fields before submitting."
        document.getElementById("errmsg").style.color="red";
        document.getElementById("errmsg").style.fontFamily="verdana";

    //window.location.hash = "section1";;
    }
}
function valAdminForm(id) {
    var valid = true;
    var errmsg = "";
    if (document.forms[0].username.value=="") {
        document.getElementById("PUser").style.color="red";
        valid = false; 
    }else{
        document.getElementById("PUser").style.color="black";
    }
    if (id=='') {
        if (document.forms[0].password.value=="") {
            document.getElementById("PWord").style.color="red"; 
            valid = false; 
        }else{
            document.getElementById("PWord").style.color="black";
        }
        if (document.forms[0].password2.value=="") {
            document.getElementById("PWord2").style.color="red"; 
            valid = false; 
        }else{
            document.getElementById("PWord2").style.color="black";
        }
        if (document.forms[0].password.value!=document.forms[0].password2.value){
            document.getElementById("PWord").style.color="red"; 
            document.getElementById("PWord2").style.color="red";
            errmsg = "Passwords do not match.<br> " ;
            document.forms[0].password.value="";
            document.forms[0].password2.value="";
            valid = false; 
        }
    }
    if (document.forms[0].studentname.value=="") {
        document.getElementById("SName").style.color="red"; 
        valid = false; 
    }else{
        document.getElementById("SName").style.color="black";
    }
	    
		
		if (document.forms[0].studentlastname.value=="") {
        document.getElementById("SLName").style.color="red"; 
        valid = false; 
    }else{
        document.getElementById("SLName").style.color="black";
    }
	
	
    if (document.forms[0].address.value=="") {
        document.getElementById("SAddr").style.color="red";
        valid = false; 
    }else{
        document.getElementById("SAddr").style.color="black";
    }
    if (document.forms[0].city.value=="") {
        document.getElementById("SCity").style.color="red"; 
        valid = false; 
    }else{
        document.getElementById("SCity").style.color="black";
    }
    if (document.forms[0].state.value=="") {
        document.getElementById("SState").style.color="red"; 
        valid = false; 
    }else{
        document.getElementById("SState").style.color="black";
    }
    if (document.forms[0].zipcode.value=="") {
        document.getElementById("SZip").style.color="red"; 
        valid = false; 
    }else{
        document.getElementById("SZip").style.color="black";
    }
    if (document.forms[0].telephone.value=="") {
        document.getElementById("STel").style.color="red";
        valid = false; 
    }else{
        document.getElementById("STel").style.color="black";
    }
    if (document.forms[0].dobmonth.value=="") {
        document.getElementById("SDob").style.color="red"; 
        valid = false; 
    }else{
        document.getElementById("SDob").style.color="black";
    }
    if (document.forms[0].dobday.value=="") {
        document.getElementById("SDob").style.color="red"; 
        valid = false; 
    }else{
        document.getElementById("SDob").style.color="black";
    }
    if (document.forms[0].dobyear.value=="") {
        document.getElementById("SDob").style.color="red"; 
        valid = false; 
    }else{
        document.getElementById("SDob").style.color="black";
    }
    if (document.forms[0].emailadult.value=="") {
        document.getElementById("SAdult").style.color="red"; 
        valid = false; 
    }else{
        document.getElementById("SAdult").style.color="black";
    }
    if ((document.forms[0].highschool.value=="") && (document.forms[0].middleschool.value=="")) {
        document.getElementById("SHigh").style.color="red"; 
        valid = false; 
    }else{
        document.getElementById("SHigh").style.color="black";
    }
    if (document.forms[0].graduatingyear.value=="Select Year") {
        document.getElementById("SGrad").style.color="red"; 
        valid = false; 
    }else{
        document.getElementById("SGrad").style.color="black";
    }

    if (valid==true) {
        document.forms[0].huser.value = document.forms[0].username.value;
        document.forms[0].hsubmit.value = "save";
        document.forms[0].submit();
    }else{
        document.getElementById("errmsg").innerHTML = errmsg + "Please fill in all red fields."
        document.getElementById("errmsg").style.color="red";
        document.getElementById("errmsg").style.fontWeight="bold";
        document.getElementById("errmsg").style.fontFamily="verdana";

        window.location.hash = "section1";;
    }
}

