Can someone please help with this code? It all works correctly except that checkbox JKL pop-up only works if checkbox DEF is checked and when you uncheck checkbox JKL the pop-up pops up a second time.

Code:
<script type="text/javascript">
$('input[type=checkbox]').change(function() { 
    // get id of the current clicked element 
    var id = $(this).attr('id'); 
    // find elements with classname 'parent-<id>' and (un)check them 
    var children = $('.parent-' + id).attr('checked', $(this).attr('checked')); 
}); 

function toggleMe(a){
  var e=document.getElementById(a);
  if(!e)return true;
  if(e.style.display=="none"){
    e.style.display="block";
  } else {
    elms=e.getElementsByTagName("INPUT");
    for(var i=elms.length;i--;){
	if(elms[i].name=="chk1" || elms[i].name=="chk2" || elms[i].name=="chk3" || elms[i].name=="chk4")
	     elms[i].checked=false;
    }
    e.style.display="none";
  }
  return true;
}
</script>
</head>
<body>
<form name='f1' action='#'>
<h2 align="center">Request Form</h2><br>
<br>
<br>
 <br>
Please check what you want.<br><br>

<input id="s1" type="checkbox" onclick="return toggleMe('para1')" value="1">1
<br>
<div id="para1" style="display:none">
&nbsp;&nbsp;&nbsp;<input id="chk1" type="checkbox" class="parent-s1" name="chk1"/>
  <label for="chk1">ABC</label><br>
&nbsp;&nbsp;&nbsp;<input id="chk2" type="checkbox" class="parent-s1" name="chk2" onclick="newPage('http://www.yourPopUppageDEF.com')"> DEF
</script>
<br>
</div>
<input id="s2" type="checkbox" onclick="return toggleMe('para2')" value="2">2
<br>
<div id="para2" style="display:none">
&nbsp;&nbsp;&nbsp;<input id="chk3" type="checkbox" class="parent-s2" name="chk3"/>
  <label for="chk2">GHI</label><br>
&nbsp;&nbsp;&nbsp;<input id="chk4" type="checkbox" class="parent-s2" name="chk4" onclick="newPage('http://www.yourPopUppageJKL.com')"> JKL
</div>
<script type = "text/javascript">
function newPage(page) {
if (document.getElementById("chk2","chk4").checked) {  
OpenWin = this.open(page,"CtrlWindow","top=80,left=100,screenX=100,screenY=80,width=550,height=460,toolbar=no,menubar=no,location=no, scrollbars=no,resizable=yes");
return false;
}
}
</script>
<script type = "text/javascript">
function Cb2Rb( setRef )
{
 this.boxGroup = setRef;

 for( var i=0, len=setRef.length; i<len; i++ )
  setRef[ i ].onclick=( function(inst, namex){return function(){inst.scan(namex)}} )(this, i);

 this.scan=function(index)
 {
  if( this.boxGroup[ index ].checked )
   for(var i=0, g=this.boxGroup, len=g.length; i<len; i++)
    if( i != index )
     g[i].checked = false;
 }
}

new Cb2Rb( document.forms.f1.chk2 ),( document.forms.f1.chk4 );

</script>
<script type='text/javascript'>
function sub_delete{ 
        if (typeof document.checks.chk.length === 'undefined') { 
   /*then there is just one checkbox with the name 'chk' no array*/ 
        if (document.checks.chk.checked == true ) 
                            { 
                                document.checks.submit(); 
                                return 0; 
                            }    
    }else{ 
  /*then there is several checkboxs with the name 'chk' making an array*/ 
        for(var i = 0, max = document.checks.chk.length; i < max; i++){ 
            if (document.checks.chk[i].checked == true ) 
                            { 
                                document.checks.submit(); 
                                return 0; 
                            } 
 
        } 
    } 
    }//sub_delete end 
</script>
<script type='text/javascript'>
$('input[class*="parent"]').change(function(){ 
    var cls = '.' + $(this).attr('class') + ':checked'; 
    var len = $(cls).length; 
    var parent_id = '#' + $(this).attr('class').split('-')[1]; 
 
    // 3. Check parent if at least one child is checked 
    if(len) { 
        $(parent_id).attr('checked', true); 
    } else { 
        // 2. Uncheck parent if all childs are unchecked. 
        $(parent_id).attr('checked', false); 
    } 
}); 
</script>