home *** CD-ROM | disk | FTP | other *** search
/ 207.233.110.77 / 207.233.110.77.tar / 207.233.110.77 / gcampbell / outline.js < prev    next >
Text File  |  2011-07-26  |  3KB  |  123 lines

  1. <!--
  2. // See KB article about changing this dynamic HTML
  3.     function getControlTag(src)
  4.     {
  5.         TRok = false
  6.         while ("HTML" != src.tagName)
  7.         {
  8.             if ("IMG" == src.tagName || "FONT" == src.tagName || "A" == src.tagName || "TD" == src.tagName)
  9.                 TRok = true
  10.             if ("LI" == src.tagName)
  11.                 return src
  12.             if ("TR" == src.tagName)
  13.             {
  14.                 if(TRok)
  15.                     return src
  16.                 return null
  17.             }
  18.             src = src.parentElement
  19.         }
  20.         return null
  21.     }
  22.     function dynOutlineEnabled(src)
  23.     {
  24.         while ("BODY" != src.tagName)
  25.         {
  26.             table = "TABLE" == src.tagName;
  27.             if(table && src.getAttribute("border", false) != "0")
  28.                 return false;
  29.             if("OL" == src.tagName || "UL" == src.tagName || table)
  30.             {
  31.                 if(null != src.getAttribute("nodynamicoutline", false))
  32.                     return false
  33.                 if(null != src.getAttribute("dynamicoutline", false))
  34.                     return true
  35.                 if(mac > 0)
  36.                 {
  37.                     var at = src.outerHTML.indexOf("dynamicoutline")
  38.                     if(at > 0)
  39.                     {
  40.                         var gt = src.outerHTML.indexOf(">")
  41.                         if(at < gt)
  42.                             return true
  43.                     }
  44.                 }
  45.             }
  46.             src = src.parentElement
  47.         }
  48.         return false
  49.     }
  50.     function initCollapse(src)
  51.     {
  52.         while ("BODY" != src.tagName)
  53.         {
  54.             table = "TABLE" == src.tagName;
  55.             if(table && src.getAttribute("border", false) != "0")
  56.                 return false;
  57.             if("OL" == src.tagName || "UL" == src.tagName || table)
  58.             {
  59.                 if(null != src.getAttribute("initcollapsed", false))
  60.                     return true
  61.             }
  62.             src = src.parentElement
  63.         }
  64.         return false
  65.     }
  66.     function containedIn(src, dest)
  67.     {
  68.         if ("!" == src.tagName)
  69.             return true
  70.         src = getControlTag(src)
  71.         if (src == dest)
  72.             return true
  73.         return false
  74.     }
  75.     function initOutline()
  76.     {
  77.         var ms = navigator.appVersion.indexOf("MSIE");
  78.         mac = navigator.appVersion.indexOf("Macintosh");
  79.         ie4 = (ms>0) && (parseInt(navigator.appVersion.substring(ms+5, ms+6)) >= 4);
  80.         if(!ie4)
  81.             return;
  82.         listTags = new Array()
  83.         listTags[0]="UL"
  84.         listTags[1]="OL"
  85.         listTags[2]="TABLE"
  86.         for(j=0;j<listTags.length;j++)
  87.         {
  88.             tagName=listTags[j]
  89.             coll=document.all.tags(tagName)
  90.             for(i=0; i<coll.length; i++)
  91.             {
  92.                 if(dynOutlineEnabled(coll[i].parentElement))
  93.                 {
  94.                     if(initCollapse(coll[i]))
  95.                         coll[i].style.display="none"
  96.                 }
  97.             }
  98.         }        
  99.     }   
  100.     function dynOutline()
  101.     {
  102.         var ms = navigator.appVersion.indexOf("MSIE");
  103.         ie4 = (ms>0) && (parseInt(navigator.appVersion.substring(ms+5, ms+6)) >= 4);
  104.         if(!ie4)
  105.             return;
  106.         var src = event.srcElement
  107.         src = getControlTag(src)
  108.         if (null == src)
  109.             return
  110.         if (!dynOutlineEnabled(src))
  111.             return
  112.         var idx = src.sourceIndex+1
  113.         while (idx < document.all.length && containedIn(document.all[idx], src))
  114.         {
  115.             srcTmp = document.all[idx]
  116.             tag = srcTmp.tagName
  117.             if ("UL" == tag || "OL" == tag || "TABLE" == tag)
  118.                 srcTmp.style.display = srcTmp.style.display == "none" ? "" : "none"
  119.             idx++;
  120.         }
  121.     }
  122. //-->
  123.