function hideOrUnhideMB(elem){ var elemToHide = getElementsByIdStartsWith(elem.parentNode.parentNode.parentNode, 'div', elem.name + '_p'); if (elemToHide != null){ if (elem.checked){ elemToHide.style.display = 'none'; } else{ elemToHide.style.display = 'block'; } } } function getElementsByIdStartsWith(container, selectorTag, suffix) { var myPosts = container.getElementsByTagName(selectorTag); for (var i = 0; i < myPosts.length; i++) { if (myPosts[i].id != null){ if (myPosts[i].id.indexOf(suffix, 0)>0){ return myPosts[i]; } } } return null; }