///THE PRIMARY COPY OF THIS SCRIPT LIBRARY RESIDES IN THE CTAS.NSF DBfunction replaceSubstring(inputString, fromString, toString) {   // Goes through the inputString and replaces every occurrence of fromString with toString   var temp = inputString;   if (fromString == "") {      return inputString;   }   if (toString.indexOf(fromString) == -1) { // If the string being replaced is not a part of the replacement string (normal situation)      while (temp.indexOf(fromString) != -1) {         var toTheLeft = temp.substring(0, temp.indexOf(fromString));         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);         temp = toTheLeft + toString + toTheRight;      }   } else { // String being replaced is part of replacement string (like "+" being replaced with "++") - prevent an infinite loop      var midStrings = new Array("~", "`", "_", "^", "#");      var midStringLen = 1;      var midString = "";      // Find a string that doesn't exist in the inputString to be used      // as an "inbetween" string      while (midString == "") {         for (var i=0; i < midStrings.length; i++) {            var tempMidString = "";            for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }            if (fromString.indexOf(tempMidString) == -1) {               midString = tempMidString;               i = midStrings.length + 1;            }         }      } // Keep on going until we build an "inbetween" string that doesn't exist      // Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string      while (temp.indexOf(fromString) != -1) {         var toTheLeft = temp.substring(0, temp.indexOf(fromString));         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);         temp = toTheLeft + midString + toTheRight;      }      // Next, replace the "inbetween" string with the "toString"      while (temp.indexOf(midString) != -1) {         var toTheLeft = temp.substring(0, temp.indexOf(midString));         var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);         temp = toTheLeft + toString + toTheRight;      }   } // Ends the check to see if the string being replaced is part of the replacement string or not   return temp; // Send the updated string back to the user} // Ends the "replaceSubstring" functionfunction rightBack (strSource, strSearch) {sourceStringBack = "";searchStringBack = "";result = "";turn = "";pos = -1;for (i = strSource.length; i>-1; i--) {sourceStringBack=sourceStringBack + strSource.charAt(i)} //end forfor (i = strSearch.length; i>-1; i--) {searchStringBack=searchStringBack + strSearch.charAt(i)} //end forpos = sourceStringBack.indexOf(searchStringBack);result = sourceStringBack.substring(0,pos)for (i = result.length; i>-1; i--) {turn=turn + result.charAt(i)}return turn}function strLeft(sourceStr, keyStr){return (sourceStr.indexOf(keyStr) == -1 | keyStr=='') ? '' : sourceStr.split(keyStr)[0];}function GAtrack (str) {//this function just tracks main page opens in the ctas.nsf db// take part of the url out so that it just shows the page name in GAstr=str.toUpperCase();str=replaceSubstring(str, "HTTP://WWW.CTAS.TENNESSEE.EDU/PUBLIC/WEB/CTAS.NSF/", "");str=replaceSubstring(str, "HTTP://WWW.CTAS.TENNESSEE.EDU./PUBLIC/WEB/CTAS.NSF/", "");str=replaceSubstring(str, "HTTP://WWW.CTAS.UTK.EDU/PUBLIC/WEB/CTAS.NSF/", "");str=replaceSubstring(str, "HTTP://WWW.CTAS.UTK.EDU//PUBLIC/WEB/CTAS.NSF/", "");str=replaceSubstring(str, "HTTP://CTAS-NOTES.IPS.UTK.EDU/PUBLIC/WEB/CTAS.NSF/", "");str=replaceSubstring(str, "HTTP://WWW.CTAS.UTK.EDU./PUBLIC/WEB/CTAS.NSF/", "");str=replaceSubstring(str, "SEARCH/", "");pageTracker._trackEvent("WEBSITE",str);//alert("WEBSITE" + "/" + str);}function GAtrack2 (str2ndCategory, str2ndCategoryURL, strLabel, strAction) {//change everything to capsstr2ndCategory=str2ndCategory.toUpperCase();str2ndCategoryURL=str2ndCategoryURL.toUpperCase();strAction=strAction.toUpperCase();strLabel=strLabel.toUpperCase();// track page open WebSite/Category/Title or WebSite/strAction/strLabelpageTracker._trackEvent("WEBSITE",strAction, strLabel);//alert("WEBSITE" + "/" + strAction + "/" + strLabel);if (str2ndCategory=="DOWNLOADS") {	var strFileName=rightBack (str2ndCategoryURL.toUpperCase(), "$FILE/");	// tracks downloads -  Downloads/Category/Title or  str2ndCategory/strAction/strLabel     if (strFileName=="") {	  pageTracker._trackEvent(str2ndCategory,strAction + "-" + strLabel);       //alert(str2ndCategory + "/" + strAction + "-" + strLabel);}	else {	       pageTracker._trackEvent(str2ndCategory,strFileName, strAction + "-" + strLabel);       //alert(str2ndCategory + "/" + strFileName + "/" + strAction + "-" + strLabel);}}else if (str2ndCategory=="EXTERNAL LINK") {	//tracks external links - External Link/Category/URL or  str2ndCategory/strAction/str2ndCategoryURL    pageTracker._trackEvent(str2ndCategory,str2ndCategoryURL,strAction + "-" + strLabel);    //alert(str2ndCategory + "/" + str2ndCategoryURL + "/" + strAction + "-" + strLabel);}else if (str2ndCategory=="EMAIL") {	//tracks external links - External Link/Category/URL or  str2ndCategory/strAction/str2ndCategoryURL    pageTracker._trackEvent(str2ndCategory,str2ndCategoryURL, strAction + "-" + strLabel);    //alert(str2ndCategory + "/" + str2ndCategoryURL + "/" + strAction + "-" + strLabel);}}function GAtrackNotesDb (strNotesDb, strLabel, strAction) {//this function just tracks document opens//change everything to capsstrNotesDb=strNotesDb.toUpperCase();strAction=strAction.toUpperCase();strLabel=strLabel.toUpperCase();pageTracker._trackEvent(strNotesDb,strAction,strLabel);//alert(strNotesDb + "/" + strAction + "/" + strLabel);}function GAtrackNotesDb2 (strNotesDb, str2ndCategory, str2ndCategoryURL, strLabel, strAction) {//change everything to capsstr2ndCategory=str2ndCategory.toUpperCase();str2ndCategoryURL=str2ndCategoryURL.toUpperCase();strAction=strAction.toUpperCase();strLabel=strLabel.toUpperCase();strNotesDb=strNotesDb.toUpperCase();// track page open WebSite/Category/Title or WebSite/strAction/strLabelpageTracker._trackEvent(strNotesDb,strAction, strLabel);//alert(strNotesDb + "/" + strAction + "/" + strLabel);if (str2ndCategory=="DOWNLOADS") {	var strFileName=rightBack (str2ndCategoryURL.toUpperCase(), "$FILE/");	// tracks downloads -  Downloads/Category/Title or  str2ndCategory/strAction/strLabel	if (strFileName=="") {	  pageTracker._trackEvent(str2ndCategory,strAction + "-" + strLabel);       //alert(str2ndCategory + "/" + strAction + "-" + strLabel);}	else {	       pageTracker._trackEvent(str2ndCategory,strFileName, strAction + "-" + strLabel);       //alert(str2ndCategory + "/" + strFileName + "/" + strAction + "-" + strLabel);}}else if (str2ndCategory=="EXTERNAL LINK") {	//tracks external links - External Link/Category/URL or  str2ndCategory/strAction/str2ndCategoryURL    pageTracker._trackEvent(str2ndCategory,str2ndCategoryURL,strAction + "-" + strLabel);    //alert(str2ndCategory + "/" + str2ndCategoryURL + "/" + strAction + "-" + strLabel);}else if (str2ndCategory=="EMAIL") {	//tracks external links - External Link/Category/URL or  str2ndCategory/strAction/str2ndCategoryURL    pageTracker._trackEvent(str2ndCategory,str2ndCategoryURL, strAction + "-" + strLabel);    //alert(str2ndCategory + "/" + str2ndCategoryURL + "/" + strAction + "-" + strLabel);}}function GAtrackExternalLink (extlink) {var extlink2=extlink.toUpperCase();pageTracker._trackEvent("EXTERNAL LINK",extlink2);//alert("EXTERNAL LINK" + "/" + extlink2);window.open(extlink);}