if (getCookie("username") != null) {
    if(document.getElementById("j_username")){
        document.getElementById("j_username").value = getCookie("username");
    }
    if(document.getElementById("j_password")){
        document.getElementById("j_password").focus();
    }
    
} 
else {
    if(document.getElementById("j_username")){
        document.getElementById("j_username").focus();
    }
}

function saveUsername(theForm) {
    var expires = new Date();
    expires.setTime(expires.getTime() + 24 * 30 * 60 * 60 * 1000); // sets it for approx 30 days.
    setCookie("username",theForm.j_username.value,expires,"<c:url value="/"/>");
}
