home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 November / pcwk_11_98a.iso / Wtestowe / Money99 / money99.1 / MnyTrial.chm / htm / moneyhlp.js < prev    next >
Text File  |  1998-07-25  |  3KB  |  108 lines

  1. function checkParent(src,dest)
  2. {
  3.     //Search for a specific parent of the current element.
  4.     while(src !=null)
  5.     {
  6.         if(src.tagName == dest)
  7.         {
  8.             return src;
  9.         }
  10.         src = src.parentElement;
  11.     }
  12.     return null;
  13. }
  14.  
  15. //Generic Display code
  16. function outline2()
  17. {
  18.     //Expand or collapse if a list item is clicked.
  19.     var open = event.srcElement;
  20.  
  21.     //Verify that the tag which was clicked was either the 
  22.     //trigger tag or nested within a trigger tag.
  23.     var el = checkParent(open,"A");
  24.     if(null != el)
  25.     {    
  26.         var incr=0;
  27.         var elmPos = 0;
  28.         var parentSpan;
  29.         var fBreak
  30.  
  31.         //Get the position of the element which was clicked
  32.         elemPos = window.event.srcElement.sourceIndex;
  33.  
  34.         //Search for a SPAN tag
  35.         for (parentSpan = window.event.srcElement.parentElement;
  36.             parentSpan!=null;
  37.             parentSpan = parentSpan.parentElement) 
  38.         {
  39.             //test if already at a span tag 
  40.             if (parentSpan.tagName=="SPAN") 
  41.             {
  42.                 incr=1;
  43.                 break;
  44.             }
  45.             
  46.             //Test if the tag clicked was in a body tag or in any of the possible kinds of lists
  47.             //we perform this test because nested lists require special handling
  48.             if (parentSpan.tagName=="BODY" || parentSpan.tagName=="UL" || parentSpan.tagName=="OL") 
  49.             {
  50.                 //Determine where the span to be expanded is.  
  51.                 for (incr=1; (elemPos+incr) < document.all.length; incr++)
  52.                 {    
  53.                     //verify we are at an expandable Div tag
  54.                     if(document.all(elemPos+incr).tagName=="SPAN" && 
  55.                     (document.all(elemPos+incr).className=="expanded" ||
  56.                      document.all(elemPos+incr).className=="collapsed"))
  57.                     {
  58.                         fBreak=1;
  59.                         break;
  60.                     }
  61.                     //If the next tag following the list item (li) is another 
  62.                     //list item(li) return in order to prevent accidentally opening
  63.                     //the next span in the list
  64.                     else if(document.all(elemPos+incr).tagName=="LI")
  65.                     {
  66.                         return;
  67.                     }
  68.                 }
  69.             }
  70.             //determine if we need to break out of the while loop (kind of a kludge since theres no goto in javascript)
  71.             if(fBreak==1)
  72.             {
  73.                 break;
  74.             }
  75.         }
  76.  
  77.     }
  78.     else
  79.     {
  80.         return;
  81.     }
  82.  
  83.     //Now that we've identified the span, expand or collapse it
  84.     if(document.all(elemPos+incr).className=="collapsed")
  85.     {
  86.         document.all(elemPos+incr).className="expanded";
  87.     }
  88.     else if(document.all(elemPos+incr).className=="expanded")
  89.     {
  90.         document.all(elemPos+incr).className="collapsed";
  91.     }
  92.     else
  93.     {
  94.         return;
  95.     }
  96.     event.cancelBubble = true;
  97. }
  98.  
  99.  
  100.  
  101. //function positionDivs() {
  102. //        if (idBodyDiv.style.pixelHeight > 0) {
  103. //            idBodyDiv.style.height = document.body.offsetHeight - idHeaderDiv.offsetHeight - 5
  104. //        }
  105. //        window.status = idBodyDiv.style.height
  106. //    }
  107. //    window.onresize = positionDivs
  108.