// JavaScript Document

function toggleUsername() {
    if (document.getElementById("memberLoginUsernameText").style.display == "block") {
      document.getElementById("memberLoginUsernameText").style.display = "none";
      document.getElementById("memberLoginUsername").style.display = "block";
      document.getElementById("memberLoginUsername").focus();
	}
    else if (document.getElementById("memberLoginUsername").style.display == "block" && document.getElementById("memberLoginUsername").value == "") {
	  if (document.getElementById("memberLoginUsernameText").style.color = "red")
	    document.getElementById("memberLoginUsernameText").style.color="gray";
      document.getElementById("memberLoginUsername").blur();
      document.getElementById("memberLoginUsername").style.display = "none";
      document.getElementById("memberLoginUsernameText").style.display = "block";
	}
}

function togglePassword() {
    if (document.getElementById("memberLoginPasswordText").style.display == "block") {
      document.getElementById("memberLoginPasswordText").style.display = "none";
      document.getElementById("memberLoginPassword").style.display = "block";
      document.getElementById("memberLoginPassword").focus();
	}
    else if (document.getElementById("memberLoginPassword").style.display == "block" && document.getElementById("memberLoginPassword").value == "") {
	  if (document.getElementById("memberLoginPasswordText").style.color = "red")
	    document.getElementById("memberLoginPasswordText").style.color="gray";
      document.getElementById("memberLoginPassword").blur();
      document.getElementById("memberLoginPassword").style.display = "none";
      document.getElementById("memberLoginPasswordText").style.display = "block";
	}
}

function submitMemberLoginForm() {
	var loginType = "";
    var submittedUsername = document.MemberLogin.memberLoginUsername.value;
	var submittedPassword = document.MemberLogin.memberLoginPassword.value;
    var submittedDomain = document.MemberLogin.memberLoginDomain.value;
	
	// My Account...
    if (document.getElementById("memberLoginMyAccount") != null && document.getElementById("memberLoginMyAccount").checked) 
	  loginType = "MyAccount";
	// Web Mail...
	else if (document.getElementById("memberLoginWebMail") != null && document.getElementById("memberLoginWebMail").checked) 
      loginType = "WebMail";
	
    if (submittedUsername != null && submittedUsername != "") {
      switch (loginType) {
	    case 'MyAccount' : document.GippsNetMyAccount.loginuser.value = submittedUsername + submittedDomain; break; 
        case 'WebMail'   : document.GippsNetWebMail.login_username.value = submittedUsername + submittedDomain; break; 
		default          : alert("Please select a valid account login type...");
	  }
	} else {
	  document.getElementById("memberLoginUsernameText").style.color="red";
	  // alert("Please provide your username...");
	  return false;
    } 
    if (submittedPassword != null && submittedPassword != "") {
      switch (loginType) {
	    case 'MyAccount' : document.GippsNetMyAccount.password.value = submittedPassword; break; 
        case 'WebMail'   : document.GippsNetWebMail.secretkey.value = submittedPassword; break; 
	    default          : alert("Please select a valid account login type...");
	  }
    } else {
	  document.getElementById("memberLoginPasswordText").style.color="red";
	  // alert("Please provide your password...");
	  return false;
	}

    switch (loginType) {
	  case 'MyAccount' : document.GippsNetMyAccount.submit(); break; 
      case 'WebMail'   : document.GippsNetWebMail.submit(); break; 
	  default          : alert("Please select a valid account login type...");
	}
	return false;
}


