var x; 
function apply() {
    if (x = 1) {
        alert("show");
        document.getElementById("nav").style.display = "inline";
        var x = 2;
    } else {
        alert("hide");
        document.getElementById("nav").style.display = "none";
        var x = 1;
    }
}
function hide() {
    document.getElementById("nav").style.display = "none";
    x = 1;
    alert(x)
}
I am having some trouble with this piece of code. I use the function hide onload and have function apply linked to a button click.
 
     
     
    