/* $Revision: 1.1.1.1 $ $Date: 2002/11/01 00:13:36 $ $Author: gdb $ */
/***********************************************************************
* ADSTAR Distributed Storage Manager (adsm)                            *
* Server Component                                                     *
*                                                                      *
* IBM Confidential                                                     *
* (IBM Confidential-Restricted when combined with the Aggregated OCO   *
* Source Modules for this Program)                                     *
*                                                                      *
* OCO Source Materials                                                 *
*                                                                      *
* 5648-020 (C) Copyright IBM Corporation 1990, 1997 (Unpublished)      *
***********************************************************************/

/***********************************************************************
* Name:
*        JSTree.js
*
* Function:
*        Provide a Dynamic tree in a web browser.
*
* Author:
*        BJ Scheid
*        Roy Tritch
*
* Status:
*        Version 3, Release 2
*
* Environment:
*        This is a PLATFORM-INDEPENDENT source file. As such it may
*        contain no dependencies on any specific operating system
*        environment or hardware platform.
*
* Public Routines:
*
* Description:
*        ...
*
* Design Notes:
*        ...
*
* Change activity:
*  10/16/2000 M Etgen - changed all image alignment to 'absmiddle' from 'middle'
*  10/16/2000 M Etgen - added IF-THEN in expandCompress() to keep the original
*        icon for the node from being changed to a folder
*  10/16/2000 M Etgen - commented out the expand/compress link on the root node
*  10/18/2000 M Etgen - removed a conditional that indicates whether a tree
*        item should be a link or not, added new conditional in place
*
*  $Log: aptree.js,v $
*  Revision 1.1.1.1  2002/11/01 00:13:36  gdb
*  My new CVS module.
*
*  Revision 1.1.1.1  2002/10/24 00:23:02  gdb
*  My new CVS module.
*
*
***********************************************************************/




/////////////////////////////////////////////////////////////
// Global Variables
/////////////////////////////////////////////////////////////

var tree_root = null;        // node to the root of the tree
var maxNodes = 0;            // total count of the nodes
var browser = 0;             // browser type
var nodeIndex = null;        // index of all the nodes in the tree
var totalWidth = 0;          // total width of the tree
var abort = null;            // Abort Url if browser doesn't support dhtml
var selected = null;         // The currently selected item
var imagePath = "./images/";    // Path to images, postpended with '/'
var expandDepth = -1;        // Depth to which we should initially expand;
                             // expand the entire tree by default
var showselect = 0;          // = 1 if we are to change icon on select
var selectedicon = "select.gif"

var selectednode = null

/////////////////////////////////////////////////////////////
// Define a tree node
//
// Inputs:
//   icon - name of the icon eg. /file/btn.gif
//   content - node or foler content (can be HTML text)
//   link - link for the name and icon
//   parent - parent node
//   id - id assigned to the node
/////////////////////////////////////////////////////////////
function TreeNode(icon, content, link, parent, id, level, is_selectable,NodValue)
{
   // Class Variables
   this.value = NodValue;        // Node Value
   this.browser = 0;             // Browser Type
   this.icon = icon;             // Content Icon
   this.link = link;             // Content Link
   this.level = level;           // Nodes Level wrt root node
   this.content = content;       // Content to be displayed
   this.parent = parent;         // Parent TreeNode
   this.children = new Array;    // Children of the current TreeNode
   this.childCount = 0;          // Number of children of this TreeNode
   this.id = id;                 // TreeNode Id number
   this.layer = null;            // Layer refering to the content displayed
   this.width = 0;               // Width of the layer
   this.height = 0;              // Height of the layer
   this.expanded = false;        // Are the children visible
   this.visible = false;         // Is the node itself visiable
   this.PSrc = null;             // Plus icon source url
   this.MSrc = null;             // Minus icon source url
   this.button = null;           // Browser image object to the PM button
   this.img = null;              // Browser image object to the icon
   this.selectable = is_selectable; // Item is Selectable?


   // Class Methods
   this.displayTree = displayTree;
   this.layout = JSTree_Layout;

}
/////////////////////////////////////////////////////////////
// initalize()
//   Display the inital state of the tree.
//
// Inputs:
//   None.
// Output:
//   Tree is displayed in the browser.
// Notes:
//   The tree has already been built by the setTreeRoot and
//   addTreeNode methods.
/////////////////////////////////////////////////////////////
function initialize()
{

   var node = tree_root;

// quickly return to prevent error messages being displayed.
   if (node == null)
      return;

// setup the node index for faster access to tree members
   nodeIndex = new Array();
   createNodeIndex(node);
   top.header.tmptreecontent.length = nodeIndex.length;

// set the document node to the tree root
   document.node = tree_root;

// In Netscape create a layer that is big enough for all
// nodes to be displayed.  This is to force the scrollbars
// to appear since Netscape is not as dynamic as IE when it
// comes to scrollbars

   if (node.browser == 1) {
      var k;

// Find the maximum width of the tree...
      for (k = 0; k < nodeIndex.length; k++) {//alert("cccccccccccccccccccc1");
         var ndWidth = (nodeIndex[k].content.length * 7) + (22 * nodeIndex[k].level);
         if (ndWidth > totalWidth)
            totalWidth = ndWidth;
      }

// The total height is the number node multiplied by the
// number of icons plus some rubber chicken number.
      var totalHeight = (nodeIndex.length * 22) + 20;


      document.write("<layer ID='Sizer' visibility='show' width="+totalWidth+" height="+totalHeight+" Z-INDEX=0>Please wait...</LAYER>");
      iFontSize = 11;
   }
   else {
      iFontSize = 10;
   }

// align the current tree state with what we have saved
   treeCheck();


// display the tree
   displayTree(node, "", false, true, 1);

// flesh out the tree to its prior state
   refreshCheck();

// Expose the root unless depth was set to 0
   if ( expandDepth != null && expandDepth != 0 ) {
      node.visible = true;
      if (browser == 1)
         node.layer.visibility="show";
      else
         document.all["Item0"].style.display="block";

      node.expanded = true;

// Show's Roots Children
      expandChildren(node, expandDepth);
   }

// layout all the created layer in Netscape
   if (node.browser == 1) {
      node.layout();
   }

// Added to hide the --Please Wait...-- text inserted into Sizer for NS
   expandDepth = null;
   if (node.browser == 1) {
        document.Sizer.visibility="hide";
        }


// Increment the counter for the number of tree refresh instances
   top.header.treecounter = top.header.treecounter + 1;
}



/////////////////////////////////////////////////////////////
// createNodeIndex()
//   Create an index of all the nodes in the tree to speedup
//   lookup work.
//
// Inputs:
//   The root of the tree.
// Output:
//   The nodeIndex is created.
/////////////////////////////////////////////////////////////
function createNodeIndex(node)
{

   nodeIndex[node.id] = node;

   /*----- First time through, register the content with the id -----*/

   top.header.tmptreecontent[node.id] = node.content;

   if (top.header.treecounter == 0) {
        top.header.treecontent[node.id] = node.content;
        top.header.treeopen[node.id] = 1;
       }

  /*----------------------------------------------------------------*/


   var i;
   for (i = 0; i < node.childCount; i++) {//alert("cccccccccccccccccccc2");
      createNodeIndex(node.children[i]);
   }
}



/////////////////////////////////////////////////////////////
// displayTree()
//   display the tree built in memory
//
// Inputs:
//   node - the node to show
//   spacer - html text spacer
//   lastNode - boolean flag inidcating last child
//   root - is this node the root node.
// Outputs:
//   The tree is displayed to the browser's window
/////////////////////////////////////////////////////////////
function displayTree(node, spacer, lastnode, root, level)
{
// Build the item layer --- added quotes around 'none' to keep Opera happy

   if (node.browser == 1)
      document.write("<layer id=Item"+node.id+" visibility=hide width="+totalWidth+" z-index=1>");
   else {
         document.write("<div id=Item"+node.id+"  style={display:'none'}  nowrap>");

    }
// Add the spacer to the item

   if (!root)
      document.write(spacer);

// Set the node's layer
   if (node.browser == 1)
      node.layer = document.layers["Item"+node.id];
   else
      node.layer = document.all["Item"+node.id];


// Determine what or if plus-minus buttons are needed.

   if (node.childCount >0) {
      if (!root) {
         // add the appropriate  buttons
         if (lastnode) {
            if (showExpanders) {
               node.PSrc = imagePath + "lplus20.gif";
               node.MSrc = imagePath + "lminus20.gif";
            }
            else {
               node.PSrc = imagePath + "blank20.gif";
               node.MSrc = imagePath + "blank20.gif";
            }
            if ( expandDepth == null || expandDepth < 0 || level <= expandDepth )
               useSrc = node.MSrc;
            else
               useSrc = node.PSrc;

            document.write("<a onclick='expandCompressNode("+this.id+");return false' href='javascript:expandCompressNode("+this.id+");'>");
            document.write("<img src='"+ useSrc +"' name='PM"+node.id+"'  align='absmiddle' border=0>");
            document.write("<img src="+node.icon+" name='icon" + node.id +"'   align='texttop'  border=0>");
            document.write("</A>");
            spacer += "<img src=" + imagePath + "blank20.gif  align='absmiddle'  border=0>";
         }
         else {
            if (showExpanders) {
               node.PSrc = imagePath + "tplus20.gif";
               node.MSrc = imagePath + "tminus20.gif";
            }
            else {
               node.PSrc = imagePath + "blank20.gif";
               node.MSrc = imagePath + "blank20.gif";
            }
            if ( expandDepth == null || expandDepth < 0 || level <= expandDepth )
               useSrc = node.MSrc;
            else
               useSrc = node.PSrc;

            document.write("<a onclick='expandCompressNode("+node.id+");return false' href='javascript:expandCompressNode("+node.id+")'>");
            document.write("<img src='"+ useSrc +"' name='PM"+node.id+"'  align='absmiddle' border=0>");
            document.write("<img src="+node.icon+" name='icon" + node.id + "'    align='texttop'  border=0>");

            document.write("</A>");
            if (showExpanders)
               spacer += "<img src=" + imagePath + "vbar20.gif  align='absmiddle'  border=0>";
            else
               spacer += "<img src=" + imagePath + "blank20.gif  align='absmiddle'  border=0>";
         }  // end if lastnode

         // Set the node button to the appropate browser image object

         if (node.browser == 1)
            node.button = node.layer.document.images['PM'+node.id];
         else
            node.button = document.all['PM'+node.id];
      }  // if (!root)
      else
          // if it IS the root
         //spixley added the else to get the image to show up
      {
//         M Etgen commented out the link on the root icon cause don't need that to expand-compress
//         document.write("<a onclick='expandCompressNode("+node.id+");return false' href='javascript:expandCompressNode("+node.id+")'>");
         document.write("<img src="+node.icon+" name='icon" + node.id + "'    align='absmiddle' border=0 >");
//         document.write("</A>");
      }

      // Write the content of the node out

      if (node.selectable) {
         if (showselect)
            document.write("&nbsp;<a href=\"" + ebs(node.link) + "; Sel(" + node.id + ")\">");
         else
            document.write("&nbsp;<a href=\"" + ebs(node.link) + "\">");
      }
      else {
         document.write("&nbsp;")
      }

      document.write(node.content);

      if (node.selectable)  {
         document.write( "</a>" );
      }


      // Set the node icon to the appropriate browser image object
      if (node.browser == 1)
         node.img = node.layer.document.images['icon'+node.id];
      else
         node.img = document.all['icon'+node.id];

      // Close the item layer

      if (node.browser == 1)
         document.write("</layer>");
      else
         document.write("</div>");

      // Loop around all the children and add them
      for (var i = 0; i < node.childCount; i++) {//alert("cccccccccccccccccccc3");
         var lstnode = false;
         if (i == (node.childCount -1))
            lstnode = true;
         node.children[i].displayTree(node.children[i], spacer, lstnode, false, level+1);
      }
   } // end if( has children)
   else {
      // Add node without childern, note spacer does not change
      if (showExpanders) {
         if (lastnode)
            document.write("<img src=" + imagePath + "lbar20.gif " + "  align='absmiddle' border=0>");
         else
            document.write("<img src=" + imagePath + "tbar20.gif " + "  align='absmiddle' border=0>");
      }
      else
         document.write("<img src=" + imagePath + "blank20.gif " + "  align='absmiddle' border=0>");


      // Write the content of the node out

      if (node.selectable) {
         if (showselect)
            document.write("<a href=\"" + ebs(node.link) + "; Sel(" + node.id + ")\">");
         else
            document.write("<a href=\"" + ebs(node.link) + "\">");
      }
      document.write("<img src="+node.icon+" name='icon" + node.id + "'   align='texttop'  border=0  >");

      if (node.selectable)
         document.write( "</a>" );


      if (node.selectable) {
         if (showselect)
            document.write("&nbsp;<a href=\"" + ebs(node.link) + "; Sel(" + node.id + ")\">");
         else
            document.write("&nbsp;<a href=\"" + ebs(node.link) + "\">");
      }
      else {
         document.write("&nbsp;")
      }

      document.write(node.content);

      if (node.selectable)  {
         document.write( "</a>" );
      }


      if (node.browser == 1)
         node.img = node.layer.document.images['icon'+node.id];
      else
         node.img = document.all['icon'+node.id];

      // Close the item layer

      if (node.browser == 1)
         document.write("</layer>");
      else
         document.write("</div>");

   } // end else (has no children)


   if (node.browser == 2) {
       if (node.parent != tree_root) {
          document.all["Item"+node.id].style.display = "none";
       }

   }

}



/////////////////////////////////////////////////////////////
// addItem()
//   Add an item to the tree
// Inputs:
//   parent - parent node
//   icon - name of the icon eg. ./file/btn.gif
//   content - node or folder content (can be HTML text)
//   link - link for the name and icon
// Output:
//   The tree node that has been created.
/////////////////////////////////////////////////////////////
function addItem(parent, icon, content, link, NodValue)
{  alert("bbbbbbbbbbbbbbbbb");
   var selectable = true;
//  if(tree_root == null)
//    //alert("ERROR:\n Adding nodes to a null tree.\n"+ "Define the root first with addRoot().");

   if (parent == null) {
      // assume that a null parent infers adding to the root node
      // //alert("parent is root")
      parent = tree_root;
  }

//  M Etgen removed the following line in favor of: "if [link==null]"
//   if (addItem.arguments.length > 4 && addItem.arguments[4] == 0) {

if (link == "") {
      selectable = false;
}

   var tempNode = new TreeNode(icon, content, link, parent, maxNodes++, parent.level + 1, selectable,NodValue);
   tempNode.browser = browser;

   parent.children[parent.childCount++] = tempNode;

   return tempNode;
}

/////////////////////////////////////////////////////////////
// addRoot()
//   Set the root of the tree to be constructed
// Inputs:
//   parent - parent node
//   icon - name of the icon eg. ./file/btn.gif
//   content - node or foler content (can be HTML text)
//   link - link for the name and icon
// Output:
//   The root tree node that has been created.
/////////////////////////////////////////////////////////////
function addRoot(icon, content, link, NodValue)
{
   // Determine the browser type
   // Browser Types:
   // 0 - Not supported
   // 1 - Netscape Communicator
   // 2 - IE 4.0
   var browserVer = parseInt(navigator.appVersion);
   var browserNam = navigator.appName;
   var selectable = true;


   if (browserNam == "Netscape") {
   if  ((browserVer >= 4) && (browserVer < 5)) {
            browser = 1;
   }
   else { browser = 2 }
   }
   else if (browserVer >= 4)
      browser = 2;
   else
   {
      document.location = abort;
      browser = 0;
      tree_root = null;
      return null;
   }


   if (addRoot.arguments.length > 3 && addRoot.arguments[3] == 0)
      selectable = false;

   // create a new node and set that as the root.
   var tempNode = new TreeNode(icon, content, link, null, maxNodes++, 1, selectable, NodValue);
   tempNode.browser = browser;

   tree_root = tempNode;
   return tempNode;
}

/////////////////////////////////////////////////////////////
// setAbort()
//   Set the url to abort to if browser dosen't support dhtml
//
// Inputs:
//   url - url to abort to if browser does not support Dynamic
//         html.
// Output:
//   golbal abort command is set
/////////////////////////////////////////////////////////////
function setAbort(url)
{
   abort = url;
}

function setImagePath(path)
{
   imagePath = path;
}

function setExpandDepth(iDepth)
{
   if ( iDepth != null && iDepth >= 0 )
      expandDepth = iDepth;
}

function setShowExpanders (sExpand)
{
   showExpanders = sExpand;
}

/////////////////////////////////////////////////////////////
// expandChildren()
//   Expand the chlidren of the node by making the chlidren
//   nodes visable.
//
// Inputs:
//   node - the node to be expanded
//   depth - the absolute depth to which to expand (optional)
//           null:  expand leaves if previously expanded
//           < 0 :  forcefully expand entire tree
//           > 0 :  forcefully expand tree n levels from root
// Output:
//   None.
/////////////////////////////////////////////////////////////
function expandChildren(node,depth)
{
   var i;
   if ( depth )
      depth--;

   node.expanded = true;

   //if(node.browser == 2) {
      if (top.header.treeopen)
         top.header.treeopen[node.id] = 0
   //}

   for (i = 0; i < node.childCount; i++)
   {//alert("cccccccccccccccccccc4");
      var cnode = node.children[i];

      // show the layers of this node
      if (cnode.browser == 1) {
         document.layers['Item'+cnode.id].visibility="show";
      }
      else  {
         document.all["Item"+cnode.id].style.display = "block";
      }
      cnode.visible = true;

      // open up any previouly open children

      if ( depth == null && cnode.expanded )
         expandChildren(cnode);
      else
      {
         if (depth != null && depth != 0 )
            expandChildren(cnode,depth);
      }

   }

}

/////////////////////////////////////////////////////////////
// expandCompressNode()
//   Event Handler for the Plus-Minus buttons.  This procedure
//   will either expand a node or compress a node depending on
//   the current state of node.
//
// Inputs:
//   id - the id number of the node of which created the event
// Output:
//   None.
/////////////////////////////////////////////////////////////
function expandCompressNode(id)
{
   var node = nodeIndex[id];
   alert("aaa111");
   // determine the current state of the node
   if (!node.expanded)
   {
      // Expand the node
      node.button.src = node.MSrc;
      // added by M Etgen to keep the function
      // from replacing the non-folder icon with a folder

      if (node.icon == imagePath +  folder["close"]) {
   node.img.src = imagePath + folder["open"];
   }
      else {
   node.img.src = node.icon
   }
     // end of addition by M Etgen
      node.expanded = true;


      // Show all the children
      expandChildren(node);
   }
   else
   {
      //Compress the node
      node.button.src = node.PSrc;
      // added by M Etgen to keep the function
      // from replacing the non-folder icon with a folder
      if (node.icon == imagePath + folder["open"]) {
   node.img.src = imagePath + folder["close"];
   }
      else {
   node.img.src = node.icon
   }
     // end of addition by M Etgen

      node.expanded = false;


      // Hide all the Children
      compressChildren(node);
   }

   if (node.browser == 1)
      node.layout();

}

/////////////////////////////////////////////////////////////
// compressChildren()
//   Compress the chlidren of the node by hiding its chlidren
//   nodes.
//
// Inputs:
//   node - the node to be compressed
// Output:
//   None.
/////////////////////////////////////////////////////////////
function compressChildren(node)
{
   var i;

   //if(node.browser == 2) {
      if (top.header.treeopen)
         top.header.treeopen[node.id] = 1
   //}

   for (i = 0; i < node.childCount; i++)
   {//alert("cccccccccccccccccccc5");
      var cnode = node.children[i];

      // Handle the different browser cases
      if (cnode.browser == 1) {
         document.layers['Item'+cnode.id].visibility="hide";
      }
      else  {
         document.all["Item"+cnode.id].style.display = "none";
      }
      // update the node visible flag
      cnode.visible = false;

      // close up the child's children
      if (cnode.childCount > 0)
         compressChildren(cnode);
   }
}

/////////////////////////////////////////////////////////////
// JSTree_Layout()
//   Layout the layers of the tree one after another.
//
// Inputs:
//   None.  Uses document.layers to do the layout.
// Output:
//   A Laid out tree.
// Note:
//   This function is only needed for Netscape.
/////////////////////////////////////////////////////////////
function JSTree_Layout()
{
   var docLayers;

   // extract the layers of the document
   docLayers = document.layers;

   // initalize position and loop variables
   var i = 0;
   var posY = docLayers[i].pageY + docLayers[i].document.height;

   for (i = 1; i < docLayers.length; i++)
   {//alert("cccccccccccccccccccc6");
      // don't layout a hidden layer
      if (docLayers[i].visibility != "hide")
      {
         // set the location of the layer
         docLayers[i].moveTo(docLayers[i].x, posY);
         posY += docLayers[i].document.height;
      }
   }
}

function Sel(id)
{
   var node = nodeIndex[id];

   if (selected != null)
      selected.img.src = selected.icon;

   selected = node;
   selected.img.src = imagePath + selectedicon;

   var node_ptr = selected.parent;
   var need_refresh = false;

   while (node_ptr && node_ptr != tree_root)
   {  //alert("cccccccccccccccccccc20");
      if (!node_ptr.expanded)
      {
         node_ptr.button.src = node_ptr.MSrc;
         expandChildren(node_ptr);
         node_ptr = node_ptr.parent;
         need_refresh = true;
      }
      else
         break;
   }

   if (need_refresh && node.browser == 1)
      node.layout();

//--------------------- set cookie and parent window layer ----------------------------
   var expDays = 30;
   var exp = new Date(); 
   exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
   SetCookie('selTzzName', selected.content, exp);
   SetCookie('selTzzbm', selected.value, exp);
   parent.selTzzBm=selected.value;
   parent.selTzzName=selected.content;
   parent.setTzzName(selected.content);

}

// browsers parse (and unescape) the href in the processing
// of an onclick.  By the time str gets to our callback,
// it is escaped again.  This ensures our callback gets a
// string with escaped backslashes.

function ebs(str)
{
   if (!str || str == null)
      return("");

   return(str.replace(/\\/g, "\\\\"));
}



/////////////////////////////////////////////////////////////
// searchNode(node,tvalue)
//   find the node which node.value=tvalue 
/////////////////////////////////////////////////////////////
/*
var searchFlag=true;
function searchNode(node,tvalue)
{
//   g=h;
   if(searchFlag==false||node==null)
   {
      return;
   }
   
//   //alert(node.content);   
   if(node.value==tvalue)
   {
      Sel(node.id)
//      //alert(node.id);
      searchFlag=false;
   }
   var i;
   for (i = 0; i < node.childCount; i++)
   {//alert("cccccccccccccccccccc7");
      var cnode = node.children[i];
//      //alert(node.content);
      searchNode(cnode,tvalue);
   }
}
*/
function searchNode(node,tvalue)
{
   if(node.value==tvalue)
   {
      Sel(node.id);
//	  //alert(node.content);
      parent.setLayer("<h1><font size='3' color='#009966'>"+node.content+"</font></h1>",'TzzNameLayer');	  
      return true;
   }
   else
   {
      var i;
      for (i = 0; i < node.childCount; i++)
      {//alert("cccccccccccccccccccc8");
         var cnode = node.children[i];
         
         if( searchNode(cnode,tvalue))
         {
            return true;
         }
      }
      return false;
   }   
}


//================================================================
//                                 
//================================================================

/*
function clk(targetFrame, sPath)
{
  targetFrame.location= sPath;
}
*/
function clk(SelValue,SelName)
{
//  targetFrame.location= sPath;
    searchNode(root,SelValue);
}



function refreshCheck(){

   for (j=0; j < top.header.treecontent.length; j++) {
//alert("cccccccccccccccccccc9");
      if (top.header.treeopen[j] == 0) {

        var thisnode = nodeIndex[j];
        if (thisnode.button){thisnode.button.src = thisnode.MSrc;}

         if (thisnode.icon == imagePath +  folder["close"]) {
          thisnode.img.src = imagePath + folder["open"];
           }
         else {
           thisnode.img.src = thisnode.icon
           }

         thisnode.expanded = true;

         expandChildren(thisnode);
      }
    }

}


function treeCheck(){
        var odiff, j, k, m, transnum;
        odiff = top.header.tmptreecontent.length - top.header.treecontent.length;
        if (odiff > 0){larger = top.header.tmptreecontent.length}
        else {larger = top.header.treecontent.length}


                    if (odiff == 0) {
                        /*------- user just changed label for node or something -----------*/

                        for (j=0; j < top.header.tmptreecontent.length; j++) {//alert("cccccccccccccccccccc11");
                                if (top.header.treecontent[j] != top.header.tmptreecontent[j]) {
                                        top.header.treecontent[j] = top.header.tmptreecontent[j];
                                }
                        }
                    }
                    if (odiff < 0) {
                        /*------- user removed something -----------*/

                        for (j=0; j < top.header.treecontent.length; j++) {//alert("cccccccccccccccccccc12");
                                                        if (top.header.treecontent[j] != top.header.tmptreecontent[j]) {

                                        for (m = 0; m < larger; m++) {
//alert("cccccccccccccccccccc13");
                                                        top.header.treecontent[m + j] = top.header.treecontent[m + j + 1];
                                                        top.header.treeopen[m + j] = top.header.treeopen[m + j + 1];

                                        }

                                        top.header.treecontent.length = (top.header.tmptreecontent.length - odiff) - 1;
                                        top.header.treeopen.length = (top.header.tmptreecontent.length - odiff) - 1;

                                        break;
                                }
                        }
                        treeCheck();
                    }

                    if (odiff > 0) {
                        /*------- user added something -----------*/

                        for (j=0; j < top.header.tmptreecontent.length; j++) {//alert("cccccccccccccccccccc14");
                                if (top.header.treecontent[j] != top.header.tmptreecontent[j]) {
                                        var start = j;

                                        for (k = top.header.treecontent.length - 1; k > j-1; k--) {//alert("cccccccccccccccccccc15");
                                                top.header.treecontent[k + 1] = top.header.treecontent[k];
                                                top.header.treeopen[k + 1] = top.header.treeopen[k];
                                        }
                                        ////alert(top.header.treecontent[j]+" is being added");
                                        top.header.treecontent[j] = top.header.tmptreecontent[j];
                                        top.header.treeopen[j] = 1;


                                        break;
                                }
                        }
                        treeCheck();
                    }
}


function processIndicator (filename) {
   top.detail.document.clear()
   top.detail.document.open()
   top.detail.document.write("<%@ page language=\"java\" %>")
//   top.detail.document.write("<%@ taglib uri=\"/WEB-INF/struts.tld\" prefix=\"struts\" %>")
   top.detail.document.write("<html><body onload=\"location='" + filename + "'\">")
   top.detail.document.write("<div style=\"position=absolute;left=40%;top=40%;font-family:sans-serif;font-size:200%;color:#CCCCCC;font-weight:bold\">Loading.....</div>")
   top.detail.document.write("</body></html>")
   top.detail.document.close()
   }



