function
OnTreeClick(evt)
{
var src = window.event !=
window.undefined ? window.event .srcElement : evt.target;
var isChkBoxClick =
(src.tagName.toLowerCase() == "input"
&& src.type == "checkbox");
if(isChkBoxClick)
{
var parentTable =
GetParentByTagName("table", src);
var nxtSibling =
parentTable.nextSibling;
if(nxtSibling &&
nxtSibling.nodeType == 1)//check if nxt sibling is
not null & is an element node
{
if(nxtSibling.tagName.toLowerCase()
== "div") //if
node has children
{
//check or uncheck children at all levels
CheckUncheckChildren(parentTable.nextSibling, src.checked);
}
}
//check or uncheck parents at all levels
CheckUncheckParents(src, src.checked);
}
}
function
CheckUncheckChildren(childContainer, check)
{
var childChkBoxes =
childContainer.getElementsByTagName("input");
var childChkBoxCount =
childChkBoxes.length;
for(var i = 0; i<childChkBoxCount; i++)
{
childChkBoxes[i].checked = check;
}
}
function
CheckUncheckParents(srcChild, check)
{
var parentDiv =
GetParentByTagName("div",
srcChild);
var parentNodeTable =
parentDiv.previousSibling;
if(parentNodeTable)
{
var checkUncheckSwitch;
var isAllSiblingsChecked =
AreAllSiblingsChecked(srcChild);
if(check) //checkbox checked
{
if(isAllSiblingsChecked)
checkUncheckSwitch = true;
else
return; //do not need to check parent if any(one or more) child not
checked
}
else //checkbox unchecked
{
checkUncheckSwitch=isAllSiblingsChecked; //make sure no child element is selected
}
var inpElemsInParentTable
= parentNodeTable.getElementsByTagName("input");
if(inpElemsInParentTable.length
> 0)<