function jsGroupTree(){

};
jsGroupTree.CurrentSelNode=null;
$(function(){
   /*加载表单类型树*/  
   if(App.query("hideID")!="" && App.query("hideID")!=undefined)
   {
         jsGroupTree.LoadData(App.query("hideID"));
   }
   else
   {
         jsGroupTree.LoadData("");
   }
});

/*确定按钮*/
jsGroupTree.onClickConfirmBtn=function(){
   if(jsGroupTree.CurrentSelNode!=null) 
   {
          ShowWindow.opener.execScript(App.query("FormIndex"),App.query("LoadAction").replace("@str","'"+jsGroupTree.CurrentSelNode.id+"','"+jsGroupTree.CurrentSelNode.text+"'"));
          ShowWindow.close();
   }
   else
   {
          ShowWindow.close();
   }
};

/*单击树节点时触发的事件*/
jsGroupTree.SaveCurrentNode=function(item){
     jsGroupTree.CurrentSelNode=item;//用于确认按钮
};

/*双击树节点时触发的事件*/
jsGroupTree.GetUrl=function(item) {
    ShowWindow.opener.execScript(App.query("FormIndex"),App.query("LoadAction").replace("@str","'"+item.id+"','"+item.text+"'"));
    ShowWindow.close();
}


/*加载表单类型树*/
jsGroupTree.LoadData=function(currNode)
{
    try
    {
        var treeString="";
        if(currNode!="" )
        {
             treeString=GetTree("select ID,GROUPNAME as Name,PID as ParentID,0 as EndFlag from T_GROUPDEF where ID<>"+currNode,"T_GROUPDEF",0);
        }
        else
        {
             treeString=GetTree("select ID,GROUPNAME as Name,PID as ParentID,0 as EndFlag from T_GROUPDEF ","T_GROUPDEF",0);
        }
        var menudata =$.parseJSON(treeString);
        var op = { 
            data: menudata,
            nodedblclick:jsGroupTree.GetUrl,
            onnodeclick:jsGroupTree.SaveCurrentNode,
            foldtheme: "yellow",
            theme: "bbit-tree-no-lines",
            spacepic:"../../AppFrame/APICss/Shared/images/s.gif"
        };
        $("#div-left-menu-content").treeview(op);
        
        treeString=null;
        menudata=null;
        CollectGarbage();
     }
     catch(e)
     {
        alert(e.message);
     }
};



