<input type="button" onclick="changeBoxes(1)" value="select all" />
<input type="button" onclick="changeBoxes(-1)" value="invertselection" />
<input type="button" onclick="changeBoxes(0)" value="select none" />
for(var i=0;i<elms.length;i++){
if(elms[i].type!='checkbox'){continue;}
elms[i].checked=action<0?(elms[i].checked?0:1):action;
}