home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2006 June / PCpro_2006_06.ISO / files / mstools / EducationPack.msi / product.cab / EquationWriterHelpfile / tap.js < prev   
Encoding:
Text File  |  2005-07-01  |  3.1 KB  |  144 lines

  1. window.onload=initExpandos;
  2. String.prototype.ltrim = function () { return this.replace(/^ */,"");}
  3. String.prototype.rtrim = function () { return this.replace(/ *$/,"");}
  4. String.prototype.trim  = function () { return this.ltrim().rtrim(); }
  5.  
  6.  
  7. function mouseover()
  8. {
  9.    var imgName;
  10.   
  11.    if (event.srcElement.tagName.toLowerCase() == "img")
  12.    {
  13.      imgName = event.srcElement;
  14.    }
  15.    else
  16.     imgName = event.srcElement.all.tags("IMG")[0];
  17.   
  18.    if (imgName.src.toLowerCase().indexOf("minuscold.gif") != -1)
  19.    {
  20.      imgName.src = "minushot.gif";
  21.       
  22.     }
  23.     else
  24.     {
  25.       imgName.src = "plushot.gif";
  26.     }
  27.     event.srcElement.style.color= "blue"; 
  28.     
  29.      
  30.    
  31.    
  32. }
  33.  
  34. function mouseout()
  35. {
  36. var imgName;
  37.  if (event.srcElement.tagName.toLowerCase() == "img")
  38.    {
  39.      imgName = event.srcElement;
  40.    }
  41.    else
  42.     imgName = event.srcElement.all.tags("IMG")[0];
  43.  
  44.    if (imgName.src.toLowerCase().indexOf("minushot.gif") != -1)
  45.    {
  46.      imgName.src = "minuscold.gif";
  47.       
  48.     }
  49.     else
  50.     {
  51.       imgName.src = "pluscold.gif";
  52.     }
  53.     event.srcElement.style.color= ""; 
  54.     
  55.      
  56.    
  57.  
  58. }
  59. function click()
  60. {
  61.   var currHeading = event.srcElement;
  62.   var imgname;
  63.   var divNode;
  64.   
  65.   if (event.srcElement.tagName.toLowerCase() == "img")
  66.     {
  67.       imgname = event.srcElement;
  68.       divNode = event.srcElement.parentNode.nextSibling;
  69.     }
  70.     else
  71.     {
  72.       imgname = currHeading.all.tags("IMG")[0];
  73.       divNode = currHeading.nextSibling;
  74.     }
  75.    
  76.   if (divNode.style.display.toLowerCase().indexOf("none") != -1)
  77.   {
  78.     //alert (imgname.src);
  79.     divNode.style.display = "block";
  80.     imgname.src = "minushot.gif";
  81.   }
  82.   else
  83.   {
  84.     //alert ("else");
  85.     divNode.style.display = "none";
  86.     imgname.src = "plushot.gif";
  87.   }  
  88.   
  89.   
  90. }
  91.  
  92.  
  93. function initExpandos()
  94. {
  95. /*
  96. <H6 style="cursor:hand" onmouseover="mouseover()" onmouseout="mouseout()"><img src="pluscold.gif"/> Writing 
  97.  
  98. or drawing in a card</H6>
  99. */
  100.  
  101. var pTags = document.all.tags("P");
  102. for (j = 0; j < pTags.length; j++)
  103. {
  104.   if (pTags[j].className.toLowerCase() == "label")
  105.   {
  106.     var bText = pTags[j].all.tags("B")[0].innerText;
  107.     pTags[j].removeChild(pTags[j].all.tags("B")[0]);
  108.     pTags[j].insertAdjacentText("beforeEnd",bText);
  109.   }
  110. }
  111. var colDivs = document.all.tags("DIV");
  112.  
  113. for (i = 0; i < colDivs.length; i++)
  114. {
  115.   if (colDivs[i].className.toLowerCase() == "expando")
  116.   {
  117.     var tmpDiv = colDivs[i];
  118.    
  119.     //do a check for h6 here
  120.    
  121.      if ((tmpDiv.children[0] == null) || (tmpDiv.children[0].className.toLowerCase() != "label"))
  122.       continue;
  123.       
  124.     var heading = tmpDiv.removeChild(tmpDiv.children[0]);   
  125.     var teststr = heading.innerText;
  126.     heading.innerText = teststr.trim();
  127.  
  128.  
  129.     heading.insertAdjacentHTML("afterBegin","<img src='pluscold.gif'/> ");
  130.     heading.style.cursor = "hand";
  131.     heading.onmouseover=mouseover;
  132.     heading.onmouseout=mouseout;
  133.     heading.onclick=click;
  134.     tmpDiv.insertAdjacentElement("beforeBegin",heading);
  135.     tmpDiv.style.marginLeft= "15px";
  136.     tmpDiv.style.display= "none";
  137.     
  138.      
  139.   } 
  140. }
  141.  
  142.  
  143.  
  144. }