   function cuInjectionFix(aPath, aResize, aDebug) {
     // Adjusts URL paths when script processing changes the URL location
     // of the document.

     if (aDebug) alert("Debug On!");
     
	 // Capture the URL location of this page.
     var scriptName = document.body.getAttribute("cuhost") + document.body.getAttribute("cupath");
     var scriptName = scriptName + document.body.getAttribute("cuscript");
     if (!scriptName) scriptName = document.location.toString();
     scriptLoc = scriptName.substr(0, scriptName.lastIndexOf("/"));
     var fromParm = aPath.replace(/\/$/,"").replace(/^\//, "");

     var scriptHost = document.body.getAttribute("cuhost");
     if (!scriptHost) scriptHost = document.location.protocol + "//" + document.location.host;
     scriptHost = scriptHost.toLowerCase();

     var tagAttrs = new Array();
     tagAttrs["a"] = "href";
     tagAttrs["img"] = "src";
     tagAttrs["iframe"] = "src";

     var tagLinks = new Array();
     tagLinks["a"] = true;

     if (aDebug) alert("Scanning spans.");
     if (aDebug) alert("Collection: " + document.getElementsByTagName("span"));
     // Propegate "cuInjected" attribute inside spans.
     for (var i=0; i < document.getElementsByTagName("span").length; i++) {
       if (aDebug) alert("Checking span.");
       var spanTag = document.getElementsByTagName("span")[i];
       if (spanTag.getAttribute("cuInjected")) {
         if (aDebug) alert("Propegating attribute for span.");
         for (var tagType in tagAttrs) {
           var allTags = spanTag.getElementsByTagName(tagType);
           // Propegate to inner tags.
           for (var j=0; j < allTags.length; j++) {
             var tagNoFix = allTags[j];
             tagNoFix.setAttribute("cuInjected", true);
           }
         }
       }
     }

     // Find Base Target
     var docBaseTags = document.getElementsByTagName('BASE');
     var docBaseTarget = (docBaseTags && docBaseTags.length) ? docBaseTags[0].target : null;

     for (var tagType in tagAttrs) {
       // Adjust URL locations for all links and images.
       var allTags = document.getElementsByTagName(tagType);
       for (var i=0; i < allTags.length; i++) {
         var tagFix = allTags[i];
         var tagAbsAttr = eval("tagFix." + tagAttrs[tagType]);
         if (tagAbsAttr) {
           var tagSrcAttr = refSrc(tagFix, tagAttrs[tagType]);
           var urlPref = tagAbsAttr.match(/^\w*:[/]{0,2}/);
           if (tagFix.getAttribute("cuInjected")) {
             // Process injected objects
             if (tagLinks[tagType] && !tagFix.getAttribute("target") && docBaseTarget) {
               // Fix Target for injected links
               tagFix.setAttribute("target", "_self");
             }
             // Fix injected links for mhtml files
             if (tagSrcAttr.indexOf(urlPref) != 0 && tagSrcAttr.indexOf("/") != 0) {
               // Change relative child references to absolute references
               tagAbsAttr = scriptLoc + "/" + tagSrcAttr;
               tagFix.setAttribute(tagAttrs[tagType], tagAbsAttr);
             }else if (tagSrcAttr.indexOf(urlPref) != 0) {
               // Redirect absolute on site references
               tagAbsAttr = scriptHost + tagSrcAttr;
               tagFix.setAttribute(tagAttrs[tagType], tagAbsAttr);
             }
           }else if (tagSrcAttr.indexOf(urlPref) == 0 && tagSrcAttr.toLowerCase().indexOf(scriptHost) != 0) {
             // Process original clickable content objects with of site source
             if (tagLinks[tagType] && !linkTarget(tagFix)) {
               // Add Target for off site links
               if (tagFix.getAttribute("cuTarget")) {
                 tagFix.setAttribute("target", tagFix.getAttribute("cuTarget"));
               }else{
                 tagFix.setAttribute("target", "_blank");
               }
             }
           }else if (tagSrcAttr.indexOf(urlPref) != 0 && tagSrcAttr.indexOf("/") != 0) {
             // Process original content objects relative child source
             if (tagLinks[tagType] && tagSrcAttr.indexOf("/") == -1 && !linkTarget(tagFix)) {
               // Refer back to contentUtils script for in folder files
               tagAbsAttr = scriptName + "?from=" + cuUrlEncode(fromParm) + "&topic=" + tagSrcAttr;
             }else{
               // Add Target for out of folder links
               if (tagLinks[tagType] && !linkTarget(tagFix)) {
                 if (tagFix.getAttribute("cuTarget")) {
                   tagFix.setAttribute("target", tagFix.getAttribute("cuTarget"));
                 }else{
                   tagFix.setAttribute("target", "_blank");
                 }
               }
               // Insert "aPath" for out of folder files
               tagAbsAttr = scriptLoc + aPath + tagSrcAttr;
             }
             tagFix.setAttribute(tagAttrs[tagType], tagAbsAttr);
           }
         }
       }
     }

     // Some tags don't inherit CSS classes.  These are them.
     var classTags = new Array();
     classTags["td"] = "cuDynoStyleChild";
     classTags["a"] = "cuDynoStyleChild";

     // Propegate class attribute to tags inside divs with class="cuDynoStyle".
     for (var i=0; i < document.getElementsByTagName("div").length; i++) {
       var divTag = document.getElementsByTagName("div")[i];
       if (divTag.className == "cuDynoStyle") {
         // We found one.  While we're here, make it as tall as its parent container.
         var parentHeight = divTag.offsetParent.clientHeight
         while (aResize && divTag.offsetHeight < parentHeight) {
           divTag.innerHTML += "<br>&nbsp;"
         }
         // Find all the inner tags that have tricky style inheritence.
         for (var tagType in classTags) {
           var childClass = classTags[tagType];
           // Propegate font color from parent class
           fixClass(divTag, tagType, childClass);
           var allTags = divTag.getElementsByTagName(tagType);
           // Propegate class to inner tags.
           for (var j=0; j < allTags.length; j++) {
             var tagStyleFix = allTags[j];
             if (!tagStyleFix.className) {
               tagStyleFix.className = childClass;
             }
           }
         }
       }
     }

     function refSrc(aTag, aAttr) {
       // Extract the original attribute value supplied in the document source.

       var tagSrc = aTag.outerHTML;
       if (tagSrc) {
         // IE code.
         // IE does not return the original source of the attribute using "getAttribute".
         // IE supports "outerHTML" which is a larger piece of original source.
         var attrPos = tagSrc.toUpperCase().indexOf((aAttr + '=').toUpperCase());
         var attrVal = tagSrc.substr(attrPos + aAttr.length + 1).replace(/^\s*/, "");
         attrVal = attrVal.substr(1, attrVal.indexOf(attrVal.substr(0, 1), 1)-1);
         attrVal = attrVal.replace(/&amp;/g,"&");
         return attrVal;
       }else{
         // FireFox code.
         // FireFox returns the original source of the attribute using "getAttribute"
         // FireFox does not support "outerHTML", so using the harder method written 
         //  for IE won't work in FireFox.
         return aTag.getAttribute(aAttr); 
       }
     }
     
     function linkTarget(aTag) {
       // Return the name of the link's target or null when effectively the current window
       var targetWork = aTag.getAttribute("target") ? aTag.getAttribute("target") : docBaseTarget;
       if (targetWork == "_self" || targetWork == window.name || (targetWork == "_top" && window == window.top)) {
         targetWork = null;
       }
       return targetWork;
     }

     function fixClass(aTag, aTagName, aClass) {
       // Identify class of parent element
       var parentClass = aTag.parentNode.className;

       // Make lists of desired rules
       var ruleListChild = new Array();
       var ruleListParent = new Array();

       // Check for base class rule
       var selectorChild = '.' + aClass;
       var selectorParent = '.' + parentClass;
       ruleListChild[ruleListChild.length] = selectorChild;
       ruleListParent[ruleListParent.length] = selectorParent;

       // Check for tag specific class rule (Upper Case for IE)
       selectorChild = aTagName.toUpperCase() + '.' + aClass;
       selectorParent = aTagName.toUpperCase() + '.' + parentClass;
       ruleListChild[ruleListChild.length] = selectorChild;
       ruleListParent[ruleListParent.length] = selectorParent;

       // Check pseudo classes
       if (aTagName.toUpperCase() == 'A') {
         ruleListChild[ruleListChild.length] = selectorChild + ':link';
         ruleListParent[ruleListParent.length] = selectorParent + ':link';
         ruleListChild[ruleListChild.length] = selectorChild + ':visited';
         ruleListParent[ruleListParent.length] = selectorParent + ':visited';
         ruleListChild[ruleListChild.length] = selectorChild + ':active';
         ruleListParent[ruleListParent.length] = selectorParent + ':active';
       }

       // Check for tag specific class rule (Lower Case for Firefox)
       selectorChild = aTagName.toLowerCase() + '.' + aClass;
       selectorParent = aTagName.toLowerCase() + '.' + parentClass;
       ruleListChild[ruleListChild.length] = selectorChild;
       ruleListParent[ruleListParent.length] = selectorParent;

       // Check pseudo classes
       if (aTagName.toLowerCase() == 'a') {
         ruleListChild[ruleListChild.length] = selectorChild + ':link';
         ruleListParent[ruleListParent.length] = selectorParent + ':link';
         ruleListChild[ruleListChild.length] = selectorChild + ':visited';
         ruleListParent[ruleListParent.length] = selectorParent + ':visited';
         ruleListChild[ruleListChild.length] = selectorChild + ':active';
         ruleListParent[ruleListParent.length] = selectorParent + ':active';
       }

       // Make lists of found rules
       var rulesFoundChild = new Array();
       var rulesFoundParent = new Array();

       for (var i=0; i<document.styleSheets.length; i++) {
         // Grab the rules collection appropriate to the browser
         var cssRules = (document.styleSheets[i].rules) ? document.styleSheets[i].rules : document.styleSheets[i].cssRules

         // Save a reference to any rules matching the list of desired rules
         for (var j=0; j<cssRules.length; j++) {
           if (elementIsFound(cssRules[j].selectorText, ruleListChild)) {
             rulesFoundChild[cssRules[j].selectorText] = cssRules[j];
           }
           if (elementIsFound(cssRules[j].selectorText, ruleListParent)) {
             rulesFoundParent[cssRules[j].selectorText] = cssRules[j];
           }
         }
       }

       // Propegate color attribute for all found parent rules.
       var dynoStyles = document.styleSheets[document.styleSheets.length -1];
       for (var i=0; i<ruleListParent.length; i++) {
         if (rulesFoundParent[ruleListParent[i]] && rulesFoundParent[ruleListParent[i]].style.color) {
           if (rulesFoundChild[ruleListChild[i]]) {
             if (!rulesFoundChild[ruleListChild[i]].style.color) {
               // Add color attribute to existing rule
               rulesFoundChild[ruleListChild[i]].style.color = rulesFoundParent[ruleListParent[i]].style.color;
             }
           }else{
             // Create corresponding rule with color attribute.
             if (dynoStyles.addRule) {
               dynoStyles.addRule(ruleListChild[i], "color: " + rulesFoundParent[ruleListParent[i]].style.color);
             }else{
               dynoStyles.insertRule(ruleListChild[i] + "{color: " + rulesFoundParent[ruleListParent[i]].style.color + "}", dynoStyles.length);
             }
           }
         }
       }
     }

     function elementIsFound(aValue, aArray) {
       for (var i=0; i<aArray.length; i++) {
         if (aArray[i] == aValue) {
           return true;
         }
       }
       return false;
     }
   }
   
   function cuImageSize(aImg) {

     if (aImg.getAttribute("cuResized")) {
       if (aImg.getAttribute("cuOrigHeight") && aImg.getAttribute("cuOrigWidth")) {
         // Save resized dimensions
         aImg.setAttribute("cuNewHeight", aImg.height);
         aImg.setAttribute("cuNewWidth", aImg.width);

         // Switch back to original dimensions
         aImg.setAttribute("height", aImg.getAttribute("cuOrigHeight"));
         aImg.setAttribute("width", aImg.getAttribute("cuOrigWidth"));
         aImg.setAttribute("cuResized", null);
         aImg.setAttribute("title", "Click to zoom out");
       }
     }else if (aImg.getAttribute("cuNewHeight") && aImg.getAttribute("cuNewWidth")) {
       // Resize to precalculated dimensions
       aImg.setAttribute("height", aImg.getAttribute("cuNewHeight"));
       aImg.setAttribute("width", aImg.getAttribute("cuNewWidth"));
       aImg.setAttribute("cuResized", true);
       aImg.setAttribute("title", "Click to zoom in");
     }else{
       // Calculate height of page less space above image
       var newHeight = (document.body.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight;
       newHeight -= cuTotalTop(aImg);

       // Take the height of the containing object, if smaller
       var imgHolder = aImg.offsetParent;
       if (imgHolder.clientHeight < newHeight) {
         newHeight = imgHolder.clientHeight;
       }

       // Find the width of containing object
       var newWidth = imgHolder.clientWidth;

       // Resize if height or width of image is greater than available space
       if (newHeight < aImg.height) {
         saveDims(aImg);
         newWidth = aImg.clientWidth * (newHeight / aImg.clientHeight);
         aImg.setAttribute("height", newHeight);
         aImg.setAttribute("width", newWidth);
       }else if (newWidth < aImg.width) {
         saveDims(aImg);
         newHeight = aImg.clientHeight * (newWidth / aImg.clientWidth);
         aImg.setAttribute("height", newHeight);
         aImg.setAttribute("width", newWidth);
       }
     }
     
     function saveDims(aTag) {
       aTag.setAttribute("cuOrigHeight", aTag.height);
       aTag.setAttribute("cuOrigWidth", aTag.width);
       aTag.setAttribute("cuResized", true);
       aTag.setAttribute("title", "Click to zoom in");
     }
   }

   function cuMediaSize(aObject) {
     // Calculate height of page less space above object 
     var newHeight = (document.body.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight;
     newHeight -= cuTotalTop(aObject);

     // Take the height of the containing object, if smaller
     var objHolder = aObject.offsetParent;
     if (objHolder.clientHeight < newHeight) {
       newHeight = objHolder.clientHeight;
     }

     // Find the width of containing object
     var newWidth = objHolder.clientWidth;

     var heightRatio = aObject.clientHeight / newHeight;
     var widthRatio = aObject.clientWidth / newWidth;
     
     // Adjust the lesser dimension to eliminate stretch or skew
     if (heightRatio > widthRatio) {
       newWidth = aObject.clientWidth / heightRatio;
     }else{
       newHeight = aObject.clientHeight / widthRatio;
     }

     // Resize away
     aObject.style.height=newHeight;
     aObject.style.width=newWidth;
   }
   
   function cuTotalTop(aTag) {
     var topWork = aTag.offsetTop;
     var parentWork = aTag.offsetParent;
     while (parentWork.tagName != "BODY") {
       topWork += parentWork.offsetTop;
       parentWork = parentWork.offsetParent;
     }
     return topWork;
   }

   function cuUrlEncode(a_Parm) {
     var encodedParm = escape(a_Parm);
     encodedParm = encodedParm.replace(/\+/g,"%2B");
     encodedParm = encodedParm.replace(/\%20/g,"+");
     return encodedParm;
   }
