home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 June / ChipCD 6.02.iso / software / ccallcenter / acc.exe / %MAINDIR% / acc.chm / shared / shared.js < prev    next >
Encoding:
Text File  |  2002-05-06  |  39.4 KB  |  989 lines

  1. // Filename: shared.js in NTShared.chm
  2. // Version post beta 3 (7)
  3. // version 05.19.99
  4.  
  5. //************************************************ EVENT HANDLING ********************************************
  6. //*******************************************************************************************************************
  7. //  re-directs to the proper event-driven functions.
  8.  
  9. window.onload= loadPage;
  10. document.onclick= onclickTriage;
  11. document.onmouseover= gettingHot;
  12. document.onmouseout= gettingCold;
  13. window.onunload=saveChecklistState;
  14. window.onresize= resizeDiv;
  15.  
  16. window.onbeforeprint= set_to_print;
  17. window.onafterprint= reset_form;
  18. //********************************************  USER-DEFINED GLOBAL VARIABLES  ************************************
  19. //********************************************************************************************************************
  20. //  The images listed below can all be changed by the user.
  21.  
  22. var sPreviousTip= "Previous topic";
  23. var sNextTip= "Next topic";
  24. var sExpandTip= "Expand/collapse";
  25. var sPopupTip= "View definition";
  26. var sShortcutTip= "";
  27.  
  28. var moniker= "";                                         // moniker= ""; for flat files
  29. var sSharedCHM= moniker+"../shared/";
  30.  
  31. var closed = sSharedCHM + "plusCold.gif";                //image used for collapsed item in callExpand()
  32. var closedHot = sSharedCHM + "plusHot.gif";            //hot image used for collapsed item in callExpand()
  33. var expand = sSharedCHM + "minusCold.gif";            //image used for expanded item in callExpand()
  34. var expandHot = sSharedCHM + "minusHot.gif";        //hot image used for expanded item in callExpand()
  35.  
  36. var previousCold= sSharedCHM + "previousCold.gif";
  37. var previousHot= sSharedCHM + "previousHot.gif"; 
  38. var nextCold= sSharedCHM + "nextCold.gif";
  39. var nextHot= sSharedCHM + "nextHot.gif"; 
  40.  
  41. var shortcutCold= sSharedCHM + "shortcutCold.gif";
  42. var shortcutHot= sSharedCHM + "shortcutHot.gif";
  43.  
  44. var popupCold= sSharedCHM + "popupCold.gif";
  45. var popupHot= sSharedCHM + "popupHot.gif";
  46.  
  47. var emptyImg= sSharedCHM + "empty.gif";        //image used for empty expand
  48. var noteImg= sSharedCHM + "note.gif";            //image used for notes
  49. var tipImg= sSharedCHM + "tip.gif";            //image used for tips
  50. var warningImg= sSharedCHM + "warning.gif";        //image used for warnings
  51. var cautionImg= sSharedCHM + "caution.gif";        //image used for cautions
  52. var importantImg= sSharedCHM + "important.gif";        //image used for important notice
  53. var relTopicsImg= sSharedCHM + "rel_top.gif";        //image used for important notice
  54.  
  55. var branchImg= sSharedCHM + "elle.gif";
  56. var branchImg_RTL= sSharedCHM + "elle_rtl.gif";
  57.  
  58.  
  59. //********************************************  GLOBAL VARIABLES  ******************************************
  60. //********************************************************************************************************
  61.  
  62. var printing = "FALSE";
  63. var single = "FALSE";
  64. var isRTL= (document.dir=="rtl");
  65. var imgStyleRTL= ""; 
  66.       if (isRTL) imgStyleRTL=" style='filter:flipH' ";
  67.  
  68. var sActX_TDC= "CLASSID='CLSID:333C7BC4-460F-11D0-BC04-0080C7055A83'";        //Tabular Data Control  for  reusable text data
  69. var sSharedReusableTextFile= sSharedCHM + "shared.txt";                                        // common reusable text file
  70. var sSharedReusableTextFileRecord= "para";                                                        //reusable text record
  71.  
  72. var numbers= /\d/g;                //javascript regular expression
  73. var spaces= /\s/g;                //javascript regular expression
  74. var semicolon= /;/g;            //javascript regular expression
  75.  
  76. var isIE5= (navigator.appVersion.indexOf("MSIE 5")>0) || (navigator.appVersion.indexOf("MSIE")>0 && parseInt(navigator.appVersion)> 4);
  77. var isPersistent= false;
  78.  
  79.  
  80. //********************************************  INITIALIZATION  *************************************************
  81. //******************************************************************************************************************
  82.  
  83. //*** loadPage **********************************************************************************************
  84. //  Adds the default image tags and re-usable text to the HTML page.
  85.  
  86. function loadPage(){
  87. isPersistent= (document.all.item("checklist")!=null) && (isIE5);
  88.  
  89.   setPreviousNext();
  90.   resizeDiv();
  91.   if (isPersistent) getChecklistState();
  92.   addReusableText();
  93.   insertImages();
  94. }
  95.  
  96. //****** setPreviousNext  ************************************************************************ ********************************************************************************************* 
  97. // insert previous/next navbar
  98. // called by: <div id="nav">@@HTMLsequenceFile.txt or .lst@@</div>
  99.  
  100. function setPreviousNext(){
  101.  
  102.  
  103.   var oNav = document.all.item("nav");
  104.         if (oNav == null ) return;
  105.   
  106.   var sPreviousALT= sPreviousTip;
  107.   var sNextALT= sNextTip;
  108.   var sHTMLfile= oNav.innerHTML;
  109.  
  110.   var imgPrev= "<IMG SRC='"+previousCold+"' BORDER=0 ALT='"+ sPreviousALT +"' ALIGN='top' "+ imgStyleRTL +">";
  111.   var imgNext= "<IMG SRC='"+nextCold+"' BORDER=0 ALT='"+ sNextALT  + "' ALIGN='top' "+ imgStyleRTL +">";
  112.   
  113.   var previousNextObject= "<OBJECT ID='HTMlist' WIDTH=100 HEIGHT=51 " + sActX_TDC +"><param name='DataURL' value='"
  114.         +sHTMLfile +"'><param name='UseHeader' value=True></OBJECT>";
  115.       
  116.         oNav.innerHTML= "<TABLE WIDTH='100%' STYLE='margin-top:0;' cellspacing=0>"
  117.         + "<TR><TD style='text-align=left; background-color:transparent'><A ID='previousLink' HREF='#' REL='previous' CLASS='navbar'>"
  118.         +imgPrev + "</A></TD><TD width='100%' align='center'></td><TD style='text-align=right; background-color:transparent'><A ID='nextLink' HREF='#' REL='next' CLASS='navbar'>"
  119.         +imgNext+ "</A></TD></TR></TABLE>";
  120.                     
  121.       document.body.innerHTML= document.body.innerHTML +  previousNextObject;
  122.       findPageSeq();
  123.       if (printing == "TRUE") return;
  124.       var  thisLoc= document.location.href +"#";
  125.  
  126.       if (previousLink.href== thisLoc) previousLink.style.display="none";
  127.       else  previousLink.style.display="block";
  128.  
  129.       if (nextLink.href== thisLoc) nextLink.style.display="none";
  130.       else  nextLink.style.display="block";
  131.       
  132. }
  133.  
  134. //****** findPageSeq *********************************************************************************************
  135. // finds this page in the "html sequence list" file (filename.lst) and determines the previous & next pages from the list
  136. // the list is created from a tool named "chumper"
  137.  
  138. function findPageSeq() {
  139.  
  140. var rs= HTMlist.recordset;
  141. var thisLoc= document.location.href;
  142. var iLoc= thisLoc.lastIndexOf("/");
  143.  
  144.     if (iLoc > 0) thisLoc= thisLoc.substring(iLoc+1, thisLoc.length);
  145.     
  146.     
  147.     if (nav.style == "[object]") {
  148.                 nav.style.visibility="hidden";
  149.                 printing = "FALSE";
  150.                 }
  151.         else
  152.             {
  153.                 printing = "TRUE";
  154.                 return;
  155.             }
  156.     
  157.        
  158.     rs.moveFirst();
  159.        
  160.     while (!rs.EOF) {
  161.           if (thisLoc == rs.fields("HTMfiles").value){
  162.               nav.style.visibility="visible"; 
  163.                 rs.MoveNext();
  164.               break;
  165.           }
  166.           previousLink.href=rs.fields("HTMfiles").value;      
  167.           rs.moveNext();
  168.      }
  169.                 
  170.       if (!rs.EOF) nextLink.href=rs.fields("HTMfiles").value;
  171. }
  172.  
  173.  
  174. //******Re-usable text ********************************************************************************************* 
  175. // Inserts the Tabular Data Control (TDC) object at the end of the page 
  176. // Inserts "re-usable text" from the txt file at: <span id="@@CHM_name@@@@index#@@" class="reuse"></span>
  177. // e.g.<span id="printing4" class="reuse"></span> for record#4 in the printing.txt in printing.chm.
  178.  
  179. function addReusableText(){
  180.  
  181. var ntsharedAdded= false;                    // make sure the object is only added once
  182. var CHMspecificAdded= false;                // make sure the object is only added once
  183. var coll = document.all.tags("SPAN");
  184. var sIndex,sRecord,sFile,sFileID,dataBindingObject;
  185.  
  186. // TDC object for ntshared.chm
  187. var coreObject= "WIDTH=100 HEIGHT=51 "+sActX_TDC+"><param name='UseHeader' value=True><param name='FieldDelim' value='~'><param name='sort' value='INDEX'>";
  188. var shareTextObject = "<OBJECT ID='NTsharedText' " + coreObject + "<param name='DataURL' value='"+sSharedReusableTextFile+"'></OBJECT>";
  189.  
  190.     for (var i=0; i< coll.length; i++)                                   
  191.          if (coll[i].className.toLowerCase()=="reuse"){
  192.              if (isRTL) coll[i].dir= "rtl";
  193.              
  194.              if (coll[i].id == null) return;
  195.              
  196.                 sFile= coll[i].id.toLowerCase();
  197.              sFile= sFile.replace(spaces,"");
  198.              sFileID= sFile;
  199.              sFile= sFile.replace(numbers,""); 
  200.  
  201.              if (sFile == sSharedReusableTextFileRecord) coll[i].dataSrc= "#NTsharedText";
  202.              else coll[i].dataSrc= "#CHMspecificText";
  203.     
  204.              coll[i].dataField= "INDEX";
  205.       
  206.              if (!ntsharedAdded && sFile==sSharedReusableTextFileRecord){
  207.                  document.body.innerHTML= document.body.innerHTML + shareTextObject;
  208.                  ntsharedAdded= true;
  209.              }
  210.  
  211.              else if (!CHMspecificAdded && sFile !=sSharedReusableTextFileRecord){
  212.                       dataBindingObject= "<OBJECT ID='CHMspecificText'" + coreObject
  213.                       + "<param name='DataURL' value='"+sSharedCHM+sFile+".txt'></OBJECT>";
  214.                       document.body.innerHTML= document.body.innerHTML + dataBindingObject; 
  215.                       CHMspecificAdded= true;
  216.              }
  217.                     
  218.              if (sFile == sSharedReusableTextFileRecord)
  219.                  sRecord= NTsharedText.recordset;
  220.              else sRecord= CHMspecificText.recordset; 
  221.                                                     
  222.              sRecord.moveFirst(); 
  223.     
  224.               do { sIndex= sRecord.fields("INDEX").value;
  225.                      sText= sRecord.fields("TEXT").value;
  226.                      
  227.                      if (sIndex < sFileID) sRecord.moveNext();
  228.                      else break;
  229.               } while (!sRecord.EOF);
  230.                   
  231.                if (sIndex == sFileID) coll[i].innerHTML= sText;
  232.     }           
  233. }
  234.  
  235.  //****** insertImages ********************************************************************************************* 
  236.  //  Inserts shared images in User-Defined Variables section and thumbnails.
  237.  
  238. function insertImages(){
  239.  
  240. // insert alert icons
  241.   var collP = document.all.tags("P");
  242.   for (var i=0; i<collP.length; i++) {
  243.        if (collP[i].className.toLowerCase()=="note")            collP[i].innerHTML ="<img class='alert' src='"+noteImg+"' "+ imgStyleRTL +"> " +     collP[i].innerHTML;
  244.        else if (collP[i].className.toLowerCase()=="warning")    collP[i].innerHTML ="<img class='alert' src='"+warningImg+"'> " +  collP[i].innerHTML;
  245.        else if (collP[i].className.toLowerCase()=="caution")    collP[i].innerHTML ="<img class='alert' src='"+cautionImg+"'> " +  collP[i].innerHTML;
  246.        else if (collP[i].className.toLowerCase()=="tip")        collP[i].innerHTML ="<img class='alert' src='"+tipImg+"'> " +      collP[i].innerHTML;
  247.        else if (collP[i].className.toLowerCase()=="important")  collP[i].innerHTML ="<img class='alert' src='"+importantImg+"'> " + collP[i].innerHTML;
  248.        else if (collP[i].className.toLowerCase()=="empty")      collP[i].innerHTML ="<img class='alert' src='"+emptyImg+"'> " +    collP[i].innerHTML;
  249.        else if (collP[i].className.toLowerCase()=="reltopics")  collP[i].innerHTML ="<img class='alert' src='"+relTopicsImg+"'> " + collP[i].innerHTML;
  250.   }
  251.   
  252. //indents for Navigation Tree 
  253. var collUL = document.all.tags("UL");
  254.  
  255. for (var i=0; i<collUL.length; i++) {
  256.        var indent= 0;
  257.        if (collUL[i].className.toLowerCase()=="navtree"){
  258.            if (isRTL) collUL[i].style.listStyleImage= "url('" + branchImg_RTL + "')";
  259.            else collUL[i].style.listStyleImage= "url('" + branchImg + "')";
  260.              for (var j = 0; j < collUL[i].children.length; j++)
  261.                 if (collUL[i].children[j].className.toLowerCase()=="branch"){
  262.                     if (isRTL) collUL[i].children[j].style.marginRight= (indent +'em');
  263.                     else   collUL[i].children[j].style.marginLeft= (indent +'em');
  264.                     indent= indent + 0.75;
  265.                 }
  266.       }
  267. }
  268.    
  269.   for (var i=0; i < document.anchors.length; i++){
  270.          var imgInsert="";  
  271.          var imgStyle= "";
  272.          var imgSpace= "<span class='space'></span>";      
  273.          var oBefore=document.anchors[i].parentElement.tagName;
  274.          var oAnchor= document.anchors[i].id.toLowerCase();
  275.          
  276. // insert RELTOPICS icons
  277. //       if (oAnchor=="reltopics")          
  278. //            if (document.anchors[i].children.tags("IMG")(0) && document.anchors[i].children.tags("IMG")(0).className.toLowerCase() == "reltopics")
  279. //                    imgInsert= "";    // not to re-insert when persistent
  280. //            else  imgInsert= "<img class='alert' src='"+relTopicsImg+"'>" + imgSpace;
  281.             
  282. // insert SHORTCUT icons
  283.        if (oAnchor=="shortcut") {    
  284.             document.anchors[i].title= sShortcutTip;     
  285.             if (document.anchors[i].children.tags("IMG")(0) && document.anchors[i].children.tags("IMG")(0).className.toLowerCase() == "shortcut")
  286.                     imgInsert= "";    // not to re-insert when persistent
  287.             else  imgInsert= "<img class='shortcut' src='"+shortcutCold+"' "+ imgStyleRTL+ ">" + imgSpace;
  288.         }    
  289.                       
  290. // insert POPUP icons
  291.        else if (oAnchor=="wpopup" || oAnchor=="wpopupweb") document.anchors[i].title= sPopupTip;
  292.        else if (document.anchors[i].className.toLowerCase()=="popupicon")
  293.             if (document.anchors[i].children.tags("IMG")(0) && document.anchors[i].children.tags("IMG")(0).className.toLowerCase() == "popup")
  294.                    imgInsert= "";    // not to re-insert when persistent
  295.             else imgInsert= "<img class='popup' src='"+popupCold+"'>" + imgSpace;
  296.  
  297. // insert EXPAND icons 
  298.        else if (oAnchor=="expand") {
  299.               document.anchors[i].title= sExpandTip;
  300.               if (document.anchors[i].children.tags("IMG")(0) && document.anchors[i].children.tags("IMG")(0).className.toLowerCase() == "expand")
  301.                   imgInsert= "";     // not to re-insert when persistent      
  302.               else{ 
  303.                   if (document.anchors[i].parentElement.offsetLeft == document.anchors[i].offsetLeft) {
  304.                       imgSpace= "<span class='space' style='width:0'></span>";     
  305.                       if (isRTL){ document.anchors[i].parentElement.style.marginRight= "1.5em";  imgStyle=" style=margin-right:'-1.5em'";}
  306.                       else { document.anchors[i].parentElement.style.marginLeft= "1.5em";  imgStyle=" style=margin-left:'-1.5em'";}
  307.                   }      
  308.                   imgInsert= "<img class='expand' src='"+ closed +"' "+imgStyle+">" +imgSpace;
  309.               }
  310.        }
  311.  
  312. // insert thumbnail images       
  313.        else if (oAnchor=="thumbnail"  || oAnchor=="thumbnailweb"){ 
  314.             var sAltText = document.anchors[i].innerHTML; 
  315.             var sThumbnailText = document.anchors[i].title; 
  316.             var oImg = document.anchors[i].href.toLowerCase();
  317.                   if (oAnchor=="thumbnail") 
  318.                          var sThumbnailImg= moniker + getURL(oImg);
  319.                   else var sThumbnailImg = document.anchors[i].href.toLowerCase();
  320.                 document.anchors[i].outerHTML = "<DIV id='thumbDiv' class='thumbnail'>"+document.anchors[i].outerHTML+"</div>";
  321.                 document.anchors[i].innerHTML = "<img class='thumbnail' src='" + sThumbnailImg + "' alt= ' " + sAltText + "'><p>" +sThumbnailText+"</p>";
  322.                 
  323.                   if (isRTL) thumbDiv.style.styleFloat= "right";
  324.        }
  325.             
  326.         document.anchors[i].innerHTML = imgInsert + document.anchors[i].innerHTML;
  327.        if (isRTL) document.anchors[i].dir="rtl";
  328.    }
  329. }
  330.  
  331.  
  332. //***** onclickTriage ****************************************************************************************
  333. // redirects to the appropriate function based on the ID of the clicked <A> tag.
  334.  
  335. function onclickTriage(){
  336. var e= window.event.srcElement;
  337.  
  338. //  if the innerHTML in the <a> tag is encapsulated by a style tag or hightlighted in the word seach,
  339. //  the parentElement is called.
  340.  
  341.     for (var i=0; i < 5; i++)
  342.            if (e.tagName!="A" && e.parentElement!=null) e= e.parentElement;
  343.     eID= e.id.toLowerCase();
  344.                 
  345.     if (popupOpen) closePopup();
  346.     
  347.  // expand image in a new window
  348.     if (eID=="thumbnail" || eID=="pophtm") popNewWindow(e);
  349.     else if (eID=="thumbnailweb") callThumbnailWeb(e);
  350.     else if (eID=="wpopup")    callPopup(e);
  351.     else if (eID=="wpopupweb") callPopupWeb(e);
  352.     else if (eID=="shortcut")  callShortcut(e);
  353.     else if (eID=="reltopics") callRelatedTopics(e);
  354.     else if (eID=="altloc")    callAltLocation(e);
  355.     else if (eID=="expand")    callExpand(e);
  356.     return;
  357. }
  358.  
  359.  
  360. //*** gettingHot ****************************************************************************************
  361. // Makes all the required changes for mouseover.
  362.  
  363. function gettingHot() {
  364. var e = window.event.srcElement;
  365.  
  366.   if (e.id.toLowerCase()=="cold")  e.id ="hot";
  367.   else if (e.src== previousCold)  e.src = previousHot;
  368.   else if (e.className.toLowerCase()=="navbar" && e.children.tags("IMG")(0).src== previousCold)  e.children.tags("IMG")(0).src= previousHot;
  369.   else if (e.src== nextCold)  e.src = nextHot;
  370.   else if (e.className.toLowerCase()=="navbar" && e.children.tags("IMG")(0).src== nextCold)  e.children.tags("IMG")(0).src= nextHot;
  371.   
  372.   else if (e.className.toLowerCase()=="shortcut" && e.tagName=="IMG")  e.src = shortcutHot;            //<img> tags have a class
  373.   else if (e.id.toLowerCase()=="shortcut")  e.children.tags("IMG")(0).src = shortcutHot;            //<a> tags have an ID
  374.   
  375.   else if (e.className.toLowerCase()=="popup" && e.tagName=="IMG")  e.src = popupHot;            //<img> tags have a class
  376.   else if (e.className.toLowerCase()=="popupicon")  e.children.tags("IMG")(0).src = popupHot;            //<a> tags have an ID
  377.   
  378.   else if ((e.className.toLowerCase()=="expand" && e.tagName=="IMG") ||( e.id.toLowerCase()=="expand")) expandGoesHot(e);
  379. }
  380.  
  381. //*** gettingCold **************************************************************************************
  382. // Initial state for mouseout.
  383.  
  384. function gettingCold() {
  385. var e = window.event.srcElement;
  386.  
  387.   if (e.id.toLowerCase()=="hot")  e.id ="cold";
  388.   else if (e.src== previousHot)  e.src = previousCold;
  389.   else if (e.className.toLowerCase()=="navbar" && e.children.tags("IMG")(0).src== previousHot)  e.children.tags("IMG")(0).src= previousCold;
  390.   else if (e.src== nextHot)  e.src = nextCold;
  391.   else if (e.className.toLowerCase()=="navbar" && e.children.tags("IMG")(0).src== nextHot)  e.children.tags("IMG")(0).src= nextCold;
  392.   
  393.   else if (e.className.toLowerCase()=="shortcut" && e.tagName=="IMG")   e.src = shortcutCold;        //<img> tags have a class
  394.   else if (e.id.toLowerCase()=="shortcut")  e.children.tags("IMG")(0).src= shortcutCold;             //<a> tags have an ID
  395.   
  396.   else if (e.className.toLowerCase()=="popup" && e.tagName=="IMG")   e.src = popupCold;        //<img> tags have a class
  397.   else if (e.className.toLowerCase()=="popupicon")  e.children.tags("IMG")(0).src= popupCold;             //<a> tags have an ID
  398.   
  399.   else if ((e.className.toLowerCase()=="expand" && e.tagName=="IMG") ||( e.id.toLowerCase()=="expand")) expandGoesCold(e);
  400. }
  401.  
  402. //****************************************** OBJECT CONSTRUCTION **************************************
  403. //*****************************************************************************************************
  404. //  Uses an A tag to pass parameters between an HTML page and this script.
  405. //  Creates an ActiveX Object from these parameters, appends the Object to the end of the page,
  406. //  and clicks it. These objects relate to HTMLHelp environment and information about them can be found on the http://HTMLHelp site.
  407.  
  408. //  Object construction variables *********************************************************************
  409.  
  410. var sParamCHM,sParamFILE, sParamEXEC, sParamMETA,iEND;
  411. var sActX_HH= " type='application/x-oleobject' classid='clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11' ";
  412.  
  413.  
  414. //*** callPopup ***************************************************************************************
  415. // creates an object from an <A> tag HREF, the object inserts a winhelp popup
  416. // called by: <A ID="wPopup" HREF="HELP=@@file_name.hlp@@ TOPIC=@@topic#@@">@@Popup text@@</A>
  417.  
  418. function callPopup(eventSrc) {
  419. var e= eventSrc;
  420. var eH= unescape(e.href);
  421. var eH_= eH.toLowerCase();
  422.        event.returnValue = false;
  423.                                                                
  424.   var iTOPIC      = eH_.lastIndexOf("topic=");
  425.         if (iTOPIC==-1) return;
  426.         sParamTOPIC = eH.substring((iTOPIC+6),eH.length);          // extracts the topic for item2
  427.         
  428.   var iHELP       = eH_.lastIndexOf("help=");
  429.         if (iHELP==-1) return;
  430.         sParamHELP = eH.substring(iHELP+5,iTOPIC);            // extracts the help file for item1
  431.         
  432.         if (document.hhPopup) document.hhPopup.outerHTML = "";    // if hhPopup object exists, clears it
  433.  
  434.  
  435.  var  h= "<object id='hhPopup'"+ sActX_HH + "STYLE='display:none'><param name='Command' value='WinHelp, Popup'>";
  436.       h= h + "<param name='Item1' value='" + sParamHELP + "'><param name='Item2' value='" + sParamTOPIC + "'></object>";
  437.         
  438.         document.body.insertAdjacentHTML("beforeEnd", h);     
  439.         document.hhPopup.hhclick();
  440. }
  441.  
  442.  
  443. //*** callAltLocation******************************************************************************
  444. // creates an object from an <A> tag HREF, the object will navigate to the alternate location if the first location is not found.
  445. // called from: <A ID="altLoc" HREF="CHM=@@1st_chm_name.chm;Alt_chm_name.chm@@  FILE=@@1st_file_name.htm;Alt_file_name.htm@@">@@Link text here@@</A>
  446.    
  447.  
  448. function callAltLocation(eventSrc) {
  449. var e= eventSrc;
  450. var eH= unescape(e.href);
  451. var eH_= eH.toLowerCase();
  452. var sFILEarray,sCHMarray;
  453.      event.returnValue = false;
  454.      
  455.   var sParamTXT= e.innerHTML;
  456.       sParamTXT= sParamTXT.replace(semicolon,"");
  457.                                        
  458.   var iFILE = eH_.lastIndexOf("file=");
  459.         if (iFILE==-1) return;
  460.         sParamFILE= eH.substring((iFILE+5),eH.length);                  // extracts the 2 HTM files
  461.         sParamFILE= sParamFILE.replace(spaces,"");
  462.         iSPLIT= sParamFILE.match(semicolon);
  463.         if (iSPLIT)
  464.               sFILEarray = sParamFILE.split(";");                                        // separates the 2 HTM files
  465.         else return;
  466.           
  467.   var iCHM  = eH_.lastIndexOf("chm=");
  468.         if(iCHM==-1) return;
  469.         else         sParamCHM = eH.substring(iCHM+4,iFILE);            // extracts the 2 CHM's
  470.         sParamCHM= sParamCHM.replace(spaces,"");
  471.         iSPLIT= sParamCHM.match(semicolon);
  472.         if (iSPLIT)
  473.             sCHMarray= sParamCHM.split(";");                                    // separates the 2 CHM's
  474.         else return;
  475.         
  476.         sParamFILE= moniker + sCHMarray[0]+ "::/" + sFILEarray[0] + ";" + moniker + sCHMarray[1]+ "::/" + sFILEarray[1];
  477.                 
  478.         if (document.hhAlt) document.hhAlt.outerHTML = "";                // if hhAlt object exists, clears it
  479.  
  480.  
  481.   var h= "<object id='hhAlt'"+ sActX_HH + "STYLE='display:none'><PARAM NAME='Command' VALUE='Related Topics'>";
  482.       h= h + "<param name='Item1' value='" + sParamTXT +";" + sParamFILE + "'></object>";
  483.     
  484.         document.body.insertAdjacentHTML("beforeEnd", h); 
  485.         document.hhAlt.hhclick();
  486. }
  487.  
  488.  
  489. //*** callRelatedTopics******************************************************************************
  490. // creates an object from an <A> tag HREF, the object inserts a popup of the related topics to select
  491. // called from: <A ID="relTopics" HREF="CHM=@@chm_name1.chm;chm_name2.chm@@ META=@@a_filename1;a_filename2@@">Related Topics</A>
  492.    
  493.  
  494. function callRelatedTopics(eventSrc) {
  495. var e= eventSrc;
  496. var eH= unescape(e.href);
  497. var eH_= eH.toLowerCase();
  498.      event.returnValue = false;
  499.                                        
  500.   var iMETA = eH_.lastIndexOf("meta=");
  501.         if (iMETA==-1) return;
  502.         sParamMETA = eH.substring((iMETA+5),eH.length);              // extracts the META keywords for item2
  503.         
  504.   var iCHM  = eH_.lastIndexOf("chm=");
  505.         if(iCHM==-1) sParamCHM = "";
  506.         else         sParamCHM = eH.substring(iCHM+4,iMETA);            // extracts the CHM files for item1
  507.     
  508.         if (document.hhRel) document.hhRel.outerHTML = "";            // if hhRel object exists, clears it
  509.  
  510.  
  511.   var h= "<object id='hhRel'"+ sActX_HH + "STYLE='display:none'><param name='Command' value='ALink,MENU'>";
  512.       h= h + "<param name='Item1' value='" + sParamCHM + "'><param name='Item2' value='" + sParamMETA + "'></object>";
  513.     
  514.         document.body.insertAdjacentHTML("beforeEnd", h);     
  515.         document.hhRel.hhclick();
  516. }
  517.  
  518. //*** popNewWindow***************************************************************************************
  519. // creates an object from an <A> tag HREF, the object then opens a new window from the image URL found in the HREF
  520. // called from: <a id="thumbnail" title="Enlarge figure" href="CHM=NTArt.chm FILE=@@image_name.gif@@">@@alt text here@@</A>
  521. // the thumbnail image is loaded by loadPage();
  522.  
  523.  
  524. function popNewWindow(eventSrc) {
  525. var eH= eventSrc.href;
  526.       event.returnValue = false;
  527.        
  528.  // extracts the thumbnail image URL from the <a> tag HREF
  529.     sParamFILE =  getURL(eH);
  530.     if (sParamFILE=="") return;
  531.        
  532.  // if the hhWindow object exists, clears it
  533.     if (document.hhWindow) document.hhWindow.outerHTML = "";        
  534.         
  535. var  h =  "<object id='hhWindow'"+ sActX_HH +" STYLE='display:none'><param name='Command' value='Related Topics'>";
  536.      h = h + "<param name='Window' value='$global_largeart'><param name='Item1' value='$global_largeart;" + moniker + sParamFILE+ "'> </object>";
  537.     
  538.      document.body.insertAdjacentHTML("beforeEnd", h);
  539.      document.hhWindow.hhclick();
  540. }
  541.  
  542. //*** callShortcut ***************************************************************************************
  543. // creates an object from an <A> tag, the object then calls the executable code
  544. // called from: <A ID="shortcut" HREF="EXEC=@@executable_name.exe@@ CHM=ntshared.chm FILE=@@error_file_name.htm@@">@@Shortcut text@@</A>
  545. // the shortcut image is loaded by loadInitialImg();
  546.  
  547. function callShortcut(eventSrc) {
  548. var e= eventSrc;
  549. var eH= unescape(e.href);
  550. var eH_= eH.toLowerCase();
  551.  
  552.  
  553.     event.returnValue = false;
  554.               
  555.  // extracts the error file URL from the <a> tag HREF
  556.     iEND= eH.length;
  557.     sParamFILE =  getURL(eH); 
  558.  
  559. var iEXEC = eH_.lastIndexOf("exec="); 
  560.         if (iEXEC==-1) return;
  561.         else           sParamEXEC = eH.substring(iEXEC+5,iEND);                // extracts the executable for item1
  562.  
  563.         if (document.hhShortcut) document.hhShortcut.outerHTML = "";            // if the hhShortcut object exists, clears it
  564.     
  565. var  h =  "<object id='hhShortcut'"+ sActX_HH +" STYLE='display:none'> <param name='Command' value='ShortCut'>";
  566.      if(sParamFILE != "") h = h + "<param name='Window' value='" + moniker + sParamFILE+ "'>";
  567.      h = h + "<param name='Item1' value='" + sParamEXEC + "'><param name='Item2' value='msg,1,1'></object>";
  568.  
  569.         document.body.insertAdjacentHTML("beforeEnd", h);
  570.         document.hhShortcut.hhclick();
  571. }
  572.  
  573. //****************************************  EXPAND FUNCTIONS *********************************************************
  574. //********************************************************************************************************************
  575.  
  576. //**  callExpand **************************************************************************************************
  577. //  This expands & collapses (based on current state) "expandable" nodes as they are clicked.
  578. //  Called by: <A ID="expand" href="#">@@Hot text@@</A>
  579. //  Followed by:  <div class="expand">
  580.  
  581. function callExpand(eventSrc) {
  582.  
  583. var e= eventSrc;
  584.     event.returnValue = false;                    // prevents navigating for <A> tag
  585.     
  586. var oExpandable = getExpandable(e); 
  587. var oImg = getImage(e);
  588.  
  589.      if (oExpandable.style.display == "block")
  590.           doCollapse(oExpandable, oImg);
  591.      else doExpand(oExpandable, oImg);
  592. }
  593.  
  594. //** expandGoesHot *********************************************************************************************
  595. // Returns expand image to hot. 
  596.  
  597. function expandGoesHot(eventSrc){
  598. var e= eventSrc;
  599.     
  600. var oExpandable = getExpandable(e);  
  601. var oImg = getImage(e);
  602.  
  603.     if (oExpandable.style.display == "block") oImg.src = expandHot;
  604.     else oImg.src = closedHot;
  605. }
  606.  
  607.  
  608. //** expandGoesCold *********************************************************************************************
  609. // Returns expand image to cold.
  610.  
  611. function expandGoesCold(eventSrc){
  612. var e= eventSrc;
  613.  
  614. var oExpandable = getExpandable(e);   
  615. var oImg = getImage(e);
  616.  
  617.     if (oExpandable.style.display == "block") oImg.src = expand;
  618.     else oImg.src = closed;
  619. }
  620.  
  621.  
  622. //** getExpandable *****************************[used by callExpand, expandGoesHot, expandGoesCold]*******
  623. //  Determine if the element is an expandable node or a child of one.  
  624.  
  625. function getExpandable(eventSrc){
  626. var  e = eventSrc;
  627. var iNextTag, oExpandable;
  628.  
  629.        for (var i=1;i<4; i++){
  630.                iNextTag=    e.sourceIndex+e.children.length+i;
  631.               oExpandable= document.all(iNextTag);
  632.               if (oExpandable.className.toLowerCase()=="expand" || iNextTag == document.all.length)
  633.                    break;
  634.        }
  635.        return oExpandable;
  636. }
  637.  
  638. //**  getImage ***********************************[used by callExpand, expandGoesHot, expandGoesCold]*******
  639. //  Find the first image in the children of the current srcElement.   
  640. // (allows the  image to be placed anywhere inside the <A HREF> tag)
  641.  
  642. function getImage(header) {
  643. var oImg = header;
  644.  
  645.        if(oImg.tagName != "IMG") oImg=oImg.children.tags("IMG")(0);
  646.        return oImg;
  647. }
  648.  
  649.  
  650. //****  expandAll *******************************************************************************************************
  651. //  Will expand or collapse all "expandable" nodes when clicked. [calls closeAll()]
  652. //  called by: <A HREF="#" onclick="expandAll();">expand all</A>
  653.  
  654. var stateExpand = false;    //applies to the page 
  655.  
  656. //**** ****************************************************************************************************************
  657.  
  658. function expandAll() {
  659. var oExpandToggle, oImg;
  660. var expandAllMsg = "Expand all";                    //message returned when CloseAll() is invoked
  661. var closeAllMsg = "Collapse all";                        //message returned when ExpandAll() is invoked
  662. var e= window.event.srcElement;
  663.        event.returnValue = false;
  664.  
  665.        for (var i=0; i< document.anchors.length; i++){
  666.                oExpandToggle = document.anchors[i];
  667.          
  668.                 if (oExpandToggle.id.toLowerCase() == "expand"){ 
  669.                      oExpandable = getExpandable(oExpandToggle);  
  670.                      oImg = getImage(oExpandToggle);
  671.              
  672.                      if (stateExpand == true) doCollapse(oExpandable, oImg);
  673.                      else                     doExpand(oExpandable, oImg);
  674.                 }
  675.        }
  676.        if (stateExpand == true) {
  677.             stateExpand = false;
  678.             e.innerText= expandAllMsg;
  679.        }
  680.        else {
  681.             stateExpand = true;
  682.             e.innerText= closeAllMsg;
  683.        }
  684. }
  685.  
  686.  
  687. //****  doExpand *******************************************************************************************************
  688. //  Expands expandable block & changes image
  689.     
  690. var redo = false;    
  691. function doExpand(oToExpand, oToChange) {
  692. var oExpandable= oToExpand;
  693. var oImg= oToChange;
  694.     
  695.     oImg.src = expand;
  696.     oExpandable.style.display = "block";
  697.     
  698.     if (!redo && !isIE5) {
  699.         redo = true;
  700.         focus(oToExpand);
  701.         doExpand(oToExpand, oToChange);
  702.         }
  703.     
  704. }
  705.  
  706.  
  707. //****  doCollapse *****************************************************************************************************
  708. //  Collapses expandable block & changes image
  709.     
  710. function doCollapse(oToCollapse, oToChange) {
  711. if (printing == "TRUE") return;
  712. var oExpandable= oToCollapse;
  713. var oImg= oToChange;
  714.  
  715.     oExpandable.style.display = "none";
  716.     oImg.src = closed;
  717. }
  718.  
  719. //*******************************************************************************************************
  720. //******* WEB  FUNCTIONS **************************************************************************
  721. //*******************************************************************************************************
  722.  
  723. //**** callThumbnailWeb **************************************************************************************
  724.  
  725. function callThumbnailWeb(eventSrc) {
  726. var e= eventSrc;
  727.        event.returnValue = false;
  728.                     
  729. var thumbnailWin= window.open (e.href, "$global_largeart",  "height=450, width=600, left=10, top=10, dependent=yes, resizable=yes, status=no, directories=no, titlebar=no, toolbar=yes, menubar=no, location=no","true");
  730.  
  731. thumbnailWin.document.write ("<html><head><title>Windows 2000</title></head><body><img src='"+e.href+"'></body></html>");
  732.  
  733. return;
  734. }
  735.  
  736. //*********************************************************************************************************
  737. //*********************************************************************************************************
  738.                                 
  739.                                 
  740. var popupOpen= false;                //state of popups
  741. var posX, posY;                        //coordinates of popups
  742. var oPopup;                            //object to be used as popup content
  743.  
  744. //**** callPopupWeb **************************************************************************************
  745. // the web popups have been converted from the object winHelp popup for the web.
  746. // called by: <A ID="wPopupWeb" HREF="#">@@Popup text@@</A>
  747. // followed by: <div class="popup">Popup content</div>
  748.  
  749.  
  750. function callPopupWeb(eventSrc) {
  751. var e= eventSrc;
  752.   
  753.   // find the popup <div> that follows <a id="wPopupWeb"></a>
  754.   findPopup(e);
  755.   positionPopup(e)
  756.  
  757.   oPopup.style.visibility = "visible";
  758.   popupOpen = true;
  759.  
  760.   return;
  761. }
  762.  
  763. //**** findPopup ****************************************************************************************
  764.  
  765. function findPopup(oX){
  766. var e= oX;
  767. var iNextTag;
  768.     
  769.     for (var i=1;i<4; i++){
  770.          iNextTag=    e.sourceIndex + i;
  771.          oPopup= document.all(iNextTag);
  772.          if (oPopup.className.toLowerCase()=="popup" || iNextTag == document.all.length)
  773.              break;
  774.     }
  775.     if (iNextTag != document.all.length) {
  776.         posX = window.event.clientX; 
  777.         posY = window.event.clientY + document.body.scrollTop+10;
  778.     }
  779.     else closePopup();
  780. }
  781.  
  782. //****  positionPopup ************************************************************************************
  783. // Set size and position of popup.
  784. // If it is off the page, move up, but not past the very top of the page.
  785.  
  786. function positionPopup(oX){
  787. var e= oX;    
  788. var popupOffsetWidth = oPopup.offsetWidth;
  789.  
  790. //determine if popup will be offscreen to right
  791. var rightlimit = posX + popupOffsetWidth;
  792.  
  793.   if (rightlimit >= document.body.clientWidth) 
  794.       posX -= (rightlimit - document.body.clientWidth);
  795.   if (posX < 0) posX = 0;
  796.     
  797. //position popup
  798.   oPopup.style.top = posY;
  799.   oPopup.style.left = posX;
  800.  
  801. var pageBottom = document.body.scrollTop + document.body.clientHeight;
  802. var popupHeight = oPopup.offsetHeight;
  803.   
  804.   if (popupHeight + posY >= pageBottom) {
  805.       if (popupHeight <= document.body.clientHeight)
  806.           oPopup.style.top = pageBottom - popupHeight;
  807.       else
  808.            oPopup.style.top = document.body.scrollTop;
  809.   }
  810. }
  811.  
  812. //**** closePopup ****************************************************************************************
  813. // Close Popup
  814. function closePopup() {
  815.  
  816.   oPopup.style.visibility = "hidden";
  817.   popupOpen = false;
  818.   return;
  819. }
  820.  
  821. //*********************************************  GENERAL FUNCTIONS ************************************************
  822. //**************************************************************************************************************************
  823.  
  824. //***ajustImg *************************************************************************************************************
  825. // expands an image to the with of the window or shrinks it to 90px
  826.  
  827. function ajustImg(eventSrc) {
  828. var e= eventSrc;
  829. var fullWidth= document.body.offsetWidth;
  830.  
  831.     fullWidth = fullWidth - 50;
  832.     if (e.style.pixelWidth==90)
  833.          e.style.pixelWidth=fullWidth;
  834.     else e.style.pixelWidth=90;
  835. }
  836.  
  837.  
  838. //**  getURL **************************************[used in callShortcut, popNewWindow& loadPage]********
  839. // extracts the file location (CHM::/HTM) URL 
  840.  
  841. function getURL(sHREF) {
  842. var spaces= /\s/g
  843. var eH = unescape(sHREF);
  844.     eH = eH.replace(spaces,""); 
  845.  
  846. var eH_= eH.toLowerCase();
  847. var sParamFILE= "";
  848. var sParamCHM= "";
  849.  
  850. var iFILE= eH_.lastIndexOf("file=");
  851.     if (iFILE!=-1){
  852.         iEND= iFILE +1;
  853.         sParamFILE = eH.substring(iFILE+5,eH.length);
  854.     }  
  855.  
  856. var iCHM  = eH_.lastIndexOf("chm=");
  857.     if (iCHM!=-1){
  858.         iEND  = iCHM +1;                             // iEND used by callShortcut
  859.  
  860.         sParamCHM = eH.substring(iCHM+4, iFILE);
  861.         sParamFILE= sParamCHM+"::/"+sParamFILE;
  862.     }    
  863.     return sParamFILE;
  864. }
  865.  
  866. //****************************************************************************************************************************
  867. //********************************************  IE5 PERSISTENCE  *************************************************************
  868. //****************************************************************************************************************************
  869.  
  870. var oTD,iTD;         // persistence
  871.  
  872. //****** Persistence for userData ********************************************************************************************* 
  873.  
  874. function getChecklistState(){ 
  875.  
  876.  var pageID= addID();
  877.  
  878.     if (checklist.all== "[object]") {
  879.     oTD=checklist.all.tags("INPUT");
  880.     iTD= oTD.length;
  881.         }
  882.     else
  883.         {
  884.         printing = "TRUE";
  885.         isPersistent = false;
  886.         return;
  887.         }
  888.  
  889.     if (iTD == 0){
  890.         printing = "TRUE";
  891.         isPersistent = false;
  892.         return;
  893.         }
  894.     
  895.     checklist.load("oXMLStore");
  896.     
  897.     if (checklist.getAttribute("sPersist"+pageID+"0"))    
  898.     for (i=0; i<iTD; i++){
  899.  
  900.          if (oTD[i].type =="checkbox" || oTD[i].type =="radio"){
  901.          checkboxValue= checklist.getAttribute("sPersist"+pageID+i);
  902.         
  903.          if (checkboxValue=="yes") oTD[i].checked=true;
  904.          else oTD[i].checked=false;
  905.          }// if
  906.          if (oTD[i].type =="text")              
  907.               oTD[i].value= checklist.getAttribute("sPersist"+pageID+i);
  908.      }// for
  909. } // end persistence
  910.  
  911. //**  saveChecklistState *************************************************************************************************************
  912. function saveChecklistState(){
  913. var pageID= addID(); 
  914.  
  915.         if (!isPersistent) return; 
  916.  
  917.         for (i=0; i<iTD; i++){
  918.  
  919.                 if (oTD[i].type =="checkbox" || oTD[i].type =="radio"){
  920.                  if (oTD[i].checked) checkboxValue="yes";
  921.                  else checkboxValue="no";
  922.                  
  923.                  checklist.setAttribute("sPersist"+pageID+i, checkboxValue);
  924.              }// if
  925.             
  926.               if (oTD[i].type =="text") 
  927.                  checklist.setAttribute("sPersist"+pageID+i, oTD[i].value);
  928.          }    // for    
  929.      checklist.save("oXMLStore");
  930. }//end function
  931.  
  932. //**  resizeDiv *******************************[used with callPopupWeb, setPreviousNext}****************************************************
  933. //  resize the page when the <div class=nav></div> && <div class=text></div> are found
  934. function resizeDiv(){
  935. if (printing == "TRUE") return;
  936. var oNav = document.all.item("nav");
  937. var oText= document.all.item("text");
  938.  
  939.     if (popupOpen) closePopup();
  940.     if (oText == null) return;
  941.     if (oNav != null){
  942.         document.all.nav.style.width= document.body.offsetWidth;
  943.         document.all.text.style.width= document.body.offsetWidth-4;
  944.         document.all.text.style.top= document.all.nav.offsetHeight;
  945.         if (document.body.offsetHeight > document.all.nav.offsetHeight)
  946.             document.all.text.style.height= document.body.offsetHeight - document.all.nav.offsetHeight;
  947.          else document.all.text.style.height=0; 
  948.   }
  949. }
  950.  
  951. //**  addID *************************************************************************************************************
  952. function addID(){
  953.  
  954. var locID = document.location.href; 
  955. var iHTM = locID.lastIndexOf(".htm");
  956. var iName=locID.lastIndexOf("/");
  957.       locID = locID.substring(iName+1,iHTM);
  958.     
  959.     return locID;
  960. }    
  961. //** set_to_print ***************
  962. function set_to_print(){
  963.     var i;
  964.     printing = "TRUE";
  965.         
  966.     for (i=0; i < document.all.length; i++){
  967.         if (document.all[i].id == "expand") {
  968.             callExpand(document.all[i]);
  969.             single = "TRUE";
  970.             }
  971.         if (document.all[i].tagName == "BODY") {
  972.             document.all[i].scroll = "auto";
  973.             }
  974.         }
  975.  
  976. }
  977. //** used to reset a page if needed ********************
  978. function reset_form(){
  979.  
  980.     if (single == "TRUE") document.location.reload();
  981.     
  982. }
  983.     
  984.     
  985. //** on error routine *********************************
  986. function errorHandler() {
  987.   // alert("Error Handled");
  988.   return true;
  989. }