<!--
function getTagElementsByAttribute(tag, name, value)
{   
    var arr = new Array(); 
    var elem = document.getElementsByTagName(tag);
    if(elem!=null)
    {   
        if(name!='')
        {
            for(i = 0,iarr = 0; i < elem.length; i++) {
                var att = elem[i].getAttribute(name);
                if(att!=null && att == value) {
                     arr[iarr] = elem[i];
                     iarr++;
                }
            }
        }
        else
        {
            arr=elem;
        }
    }
    return arr;
}
function openMenu(id,img)
{    
    var obj=document.getElementById(id);
    if(obj!=null && obj.getAttribute('typeId')!=null && obj.getAttribute('child')!=null)
    {
        if(obj.getAttribute('child')=='open')
        {
            obj.setAttribute('child','close');
            img.src="/Admin/Images/expand.gif";
            changeMenu(obj.getAttribute('typeId'),'close');
        }
        else if(obj.getAttribute('child')=='close')
        {
            obj.setAttribute('child','open');
            img.src="/Admin/Images/collapse.gif";
            changeMenu(obj.getAttribute('typeId'),'open');
        }    
    }
}
function initMenu(id,child)
{      
    var tid=id;
    if(tid!=0 && tid!='0' && tid!='')
    {        
        while(tid!=0 && tid!='0' && tid!='')
        {
            objs=getTagElementsByAttribute('tr','typeId',tid);
            
            if(objs!=null && objs.length==1)
            {
                if(objs[0].getAttribute('child')!=null && objs[0].getAttribute('child')=='close')
                {
                    objs[0].setAttribute('child','open');
                    objs[0].style.display='';
                    var img=document.getElementById('PPFOR_img_' + tid);
                    if(img!=null) img.src="/Admin/Images/collapse.gif";
                    if(objs[0].getAttribute('name')!=null)
                    {
                        var oobjs=getTagElementsByAttribute('tr','name',objs[0].getAttribute('name'));
                        if(oobjs!=null)
                        {
                            for(j=0;j<oobjs.length;j++) oobjs[j].style.display='';
                        }
                        tid=objs[0].getAttribute('name').replace('PPFOR_parent_','');
                    }
                    else
                    {
                        tid='0';
                    }
                }
                else
                {
                    break;
                }
            }
            else
            {
                break;
            }
        }
    }
    changeMenu(id,child);    
}
function changeMenu(id,child)
{
    var objs=getTagElementsByAttribute('tr','name','PPFOR_parent_' + id);
    
    if(objs!=null && objs.length>0)
    {
        for(var index=0; index<objs.length;index++)
        {            
            var obj=objs[index];
            if(obj!=null && obj.getAttribute('name')!=null && obj.getAttribute('typeId')!=null && obj.getAttribute('child')!=null)
            {
                if(child=='close' && obj.getAttribute('name')!='0')
                {
                    obj.style.display='none';
                    changeMenu(obj.getAttribute('typeId'),'close');                        
                }
                else if(child=='open')
                {
                    obj.style.display='';
                    changeMenu(obj.getAttribute('typeId'),obj.getAttribute('child'));  
                }
            }
        }            
    }
    else if(id!='0')
    {
        var img=document.getElementById('PPFOR_img_' + id);
        if(img!=null) img.src="/Admin/Images/nochild.gif";
    }
}
function changeSubMenu(checked,belongType)
{
    var objs=getTagElementsByAttribute('input','belongType',belongType);
    
    if(objs!=null && objs.length>0){
        checked=checked||false;      
        var rowId='';
        for(var i=0;i<objs.length;i++){
            if(objs[i].type=='checkbox'){
                objs[i].checked=checked;
                rowId=objs[i].getAttribute('rowId')||'0';               
                onRowCheckColorChange(document.getElementById("PPFOR_rows_" + rowId),rowId,checked);
                changeSubMenu(checked,objs[i].getAttribute('typeId')||'');               
            }
        }        
    }
}
-->
