anchor.diff:     // alert(id +"-"+$("ul#"+ulTagId).parents('li:eq(0)').size());
      // }
       if ($("ul#"+ulTagId).parents('li:eq(0)').size() == 0) {
  -      tdTag1 = $('<td></td>').html(getResearchAreaCode(name));
  +      // TODO : this is the second level, the children of '000001'
  +      tdTag1 = $('<td></td>').html("000001");
  +      //tdTag1 = $('<td></td>').html(getResearchAreaCode(name));
         //alert(getResearchAreaDescription(name));
       } else {
          // alert($("ul#"+ulTagId).parents('li:eq(0)').children('a:eq(0)').size());
  
positive.code:                       removedNode = $(liId).clone(true);
                        //removedNode = $(liId); // this will not work because event also lost
                        //alert("Remove node "+removedNode.attr("id"));
                        alert ($(liId).parents('li:eq(0)').children('a:eq(0)').text());
                        sqlScripts = sqlScripts +"#;#"+getDeleteClause(getResearchAreaCode(removedNode.children('a:eq(0)').text()), getResearchAreaCode($(liId).parents('li:eq(0)').children('a:eq(0)').text()));
                        $(liId).remove();
                        alert (sqlScripts);
                        cutNode=null;
  
negative.code:        return false;
        }); 
              
              
              
       $("#add0").click(function(){    
       // click 'add' for 000001
            alert ("top add");
         
         
                   var trNode = $(this).parents('tr:eq(0)');
            //alert(trNode.children('td:eq(1)').children('input:eq(0)').attr("value")+"-"+trNode.children('td:eq(2)').children('input:eq(0)').attr("value"));
  
           if (trNode.children('td:eq(1)').children('input:eq(0)').attr("value") == "") {
             alert("must enter research area code");
           } else if (trNode.children('td:eq(2)').children('input:eq(0)').attr("value") == "") {
             alert("must enter research area");
           } else {
           
           // check if code exists
               var raExist
               $.ajax({
                   url: 'researchAreas.do',
                   type: 'GET',
                   dataType: 'html',
                   data:'researchAreaCode='+trNode.children('td:eq(1)').children('input:eq(0)').attr("value")+'&addRA=Y',
                   cache: false,
                   async: false,
                   timeout: 1000,
                   error: function(){
                      alert('Error loading XML document');
                   },
                   success: function(xml){
                      $(xml).find('h3').each(function(){
                         raExist = $(this).text();
                      //alert(raExist);
          
                       });
                    }
                 });   // end ajax  
           
           
             if (raExist == 'false') {
                 var ulTag = $("#example");
                                                            
                 var item_text = trNode.children('td:eq(1)').children('input:eq(0)').attr("value") +" : "+trNode.children('td:eq(2)').children('input:eq(0)').attr("value");
                 var listitem = setupListItem(item_text);
                 //alert(listitem.html());
              // need this ultag to force to display folder.
              var childUlTag = $('<ul></ul>').attr("id","ul"+i);
              childUlTag.appendTo(listitem);
                 listitem.appendTo(ulTag);
                 //alert("ultagid "+ulTag.attr("id").substring(2));
                 // force to display folder icon
                 $("#example").treeview({
                     add: listitem
                 // toggle: function() {
                 //   var subul=this.getElementsByTagName("ul")[0]
                 //   if (subul.style.display=="block")
                 //      alert("You've opened this Folder!")
                 //   } 
                 });
                 
                 // apend to sqlScripts
                 sqlScripts = sqlScripts +"#;#"+getInsertClause(trNode.children('td:eq(1)').children('input:eq(0)').attr("value"), '000001', trNode.children('td:eq(2)').children('input:eq(0)').attr("value"));
                 //alert("sqlScripts = "+sqlScripts);
              }  else {
                   alert ("Research Area Code already exist");
              }
             };                                
         
          
         return false;
        }); // add0 
              
           
    // }); // $(document).ready
  
  