var checkCount = Array;
  
function checkbox_limit(obj, name, limit) {

  if(isNaN(checkCount[name])) {
    checkCount[name] = 0;
  }
  if(obj.checked){
    checkCount[name]=checkCount[name]+1
  }else{
    checkCount[name] = checkCount[name] - 1
  }
  
  if (checkCount[name]>limit){
    obj.checked=false
    checkCount[name]=checkCount[name]-1
    alert('Please limit selections to '  + limit);
  }
}
