(function () {
var nodes = document.test.getElementsByTagName('input');
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].type == 'checkbox') {
nodes[i].onclick = function (e) {
e = e || window.event;
if ((function () {
var x = 0;
for (var z = 0; z < nodes.length; z++) {
if (nodes[z].checked) {
x++;
}
}
return x;
})() > 2) {
e.preventDefault(),
e.returnValue = false;
}
}
}
}
})();