var labels = ["yes", "no"];

(function () {
    for(var i =0; i<labels.length; i++){
        var lbl = document.createElement("label");
        var checkbox = document.createElement("input");
        checkbox.type="checkbox";
        checkbox.id="checkbox"+i;
        lbl.setAttribute("tabindex","1");
        lbl.innerHTML=lbl.innerHTML+labels[i];
        lbl.addEventListener("keydown", function(e){
            if(e.which ===13 || e.which===32){
                this.click();
            }
        });
        checkbox.addEventListener("change", function(){
            checkAllChecks();
        });
        lbl.appendChild(checkbox);
        document.querySelector(".container").appendChild(lbl);
    }
    vleOpen();
})();

function checkAllChecks(){
    var whichChecked=[];
    var checkboxes=document.querySelectorAll("input[type='checkbox']");
    for(var i=0; i<checkboxes.length; i++){
        var curr={};
        curr[checkboxes[i].id]=checkboxes[i].checked;
        whichChecked.push(curr);
        checkboxes[i].parentNode.removeAttribute("class");
        if(checkboxes[i].checked) {
            checkboxes[i].parentNode.setAttribute("class","highlighted");
        }
    }
    vleSave(whichChecked);
}