/***********************************************************
* gameui.js                                        by Ralp *
*   There is not much interface to this game: just         *
*   clicking squares, undo, or the Level menu.             *
*   Appropriately, that's all that is here!                *
***********************************************************/

/* TODO: push and unpush should probably be zipped up into one function
 *       likewise for toggle and untoggle */
function push() {
    var x = parseInt(this.id.charAt(1));
    var y = parseInt(this.id.charAt(2));
    if ( isClickable[ board[x][y] ] ) {
        clicks++;
        setText("score", "Clicks: "+clicks);
        toggle(x,y);
        toggle(x-1,y);
        toggle(x+1,y);
        toggle(x,y-1);
        toggle(x,y+1);
        lastClick=this;
        enableButton("undolink");
        if (checkVictory()) youWin();
    }
}
function unpush(click) {
    if (click != null) {
        var x = parseInt(click.id.charAt(1));
        var y = parseInt(click.id.charAt(2));
        clicks--;
        setText("score", "Clicks: "+clicks);
        untoggle(x,y);
        untoggle(x-1,y);
        untoggle(x+1,y);
        untoggle(x,y-1);
        untoggle(x,y+1);
        lastClick=null;
        disableButton("undolink");
    }
}

function toggleLevMenu() {
    if (getId("levmenucontainer").getAttribute("class") == "hidden")
        show("levmenucontainer");
    else
        hide("levmenucontainer");
}
