home *** CD-ROM | disk | FTP | other *** search
/ NCSLI Conference Promo 2006 / NCSL06.ISO / pc / NCSL06 / searchFunctions.js < prev    next >
Encoding:
JavaScript  |  2006-06-22  |  18.6 KB  |  547 lines

  1. //******************************************
  2. // This is a special european version of searchFunctions.js
  3. // that converts european search term characters to ISO-8859-1
  4. //******************************************
  5.  
  6. //This generic function will return the value of a QueryString
  7. function getQueryString(Val) {
  8.     thisURLparamStr = document.location.search;
  9.     //chop "?" off thisURLparamStr
  10.     if (thisURLparamStr.charAt(0) == "?") thisURLparamStr = thisURLparamStr.substring(1, thisURLparamStr.length);
  11.     returnStr = "";
  12.     if (thisURLparamStr != "") {
  13.         //Build array out of thisURLparamStr using "&" as delimiter
  14.         divide1=(thisURLparamStr.split("&"))
  15.         for (i=0; i < divide1.length; i++) {
  16.             divide2 = divide1[i].split("=")
  17.             if (unescape(divide2[0]) == Val) {
  18.                 if (returnStr == "") {
  19.                     returnStr = unescape(divide2[1]);
  20.                 } else {
  21.                     returnStr += "|" + unescape(divide2[1])
  22.                 }
  23.             }
  24.         }
  25.     }
  26.     
  27.     var myRegExp = new RegExp();
  28.     myREgExp = /\+/g;
  29.     returnStr = returnStr.replace(myREgExp, " ");    
  30.     return returnStr;
  31. }
  32.  
  33.  
  34. // This function merges title, brief description, page content, keywords 
  35. function mergeStrings(str1, str2, str3) {
  36.  
  37.     var mergeStr = "";
  38.     var mergeString = "";
  39.     // join str2 (brief description) and str3 (rest of page text)
  40.     // if page content is longer than brief description length,
  41.     // then str2 ends "..."
  42.     // if str2 ends "..." remove dots
  43.     if ((str2.length > 0) && (str2.charAt(0) != " ")) str2 = " " + str2;
  44.     if (str2.substring(str2.length - 3, str2.length) == "...") {
  45.             mergeString = str2.substring(0, str2.length - 3).concat(str3);
  46.     } else {
  47.             mergeString = str2.concat(str3);
  48.     }
  49.     mergeString = str1 + mergeString
  50.     return mergeString
  51.  
  52. }
  53.  
  54.  
  55. //this function builds brief description object
  56. function briefDescrip(posStart, posEnd, posTerm, termTxt, isBegin, isEnd) {
  57.  
  58.  
  59.     //get workable substring from termTxt characters
  60.     var subStrStart = (isBegin)? 0:termTxt.indexOf(" ");
  61.     var subStrEnd = (isEnd)? termTxt.length:termTxt.lastIndexOf(" ");
  62.     termTxt = termTxt.substring(subStrStart, subStrEnd);
  63.     //adjust position properties to new termTxt substring
  64.     var termStrStart = posStart + subStrStart;
  65.     var termStrEnd = termStrStart + termTxt.length;
  66.     var posTerm = posTerm - subStrStart;
  67.     
  68.     //alert(termTxt + ", " + termStrStart + ", " + termStrEnd + ", " + posTerm)
  69.  
  70.     this.posStart = termStrStart;
  71.     this.posEnd = termStrEnd;
  72.     this.posTerm = posTerm;
  73.     this.termTxt= termTxt;
  74. }
  75.  
  76.  
  77. //This function ensures that the brief description string does not contain repeats
  78. function noPreviousOccur(thisArray, thisIndex) {
  79.     returnStr = true;
  80.  
  81.     if (thisIndex > refineAllString.length) {
  82.         returnStr = false;
  83.     } else {
  84.         //if thisIndex is contained in an existing substring return false
  85.         for (x=0; x < thisArray.length; x++) {
  86.             if ((thisIndex > thisArray[x].posStart) && (thisIndex < thisArray[x].posEnd)) {
  87.                 returnStr = false;
  88.                 break;
  89.             }
  90.         }
  91.     }
  92.     return returnStr;
  93. }
  94.  
  95.  
  96. // This function will parse the URL search string and change a name/value pair
  97. function changeParam(whichParam, newVal) {
  98.     newParamStr = "";
  99.     thisURLstr = document.location.href.substring(0, document.location.href.indexOf("?"));
  100.     thisURLparamStr = document.location.href.substring(document.location.href.indexOf("?") + 1, document.location.href.length);
  101.     //Build array out of thisURLparamStr using "&" as delimiter
  102.     divide1=(thisURLparamStr.split("&"))
  103.     for (cnt=0; cnt < divide1.length; cnt++) {
  104.         divide2 = divide1[cnt].split("=")
  105.         if (divide2[0] == whichParam) {
  106.             // if we find whichParam in thisURLparamStr replace whichParam's value with newVal
  107.             newParamStr = newParamStr + divide2[0] + "=" + escape(newVal) + "&";
  108.         } else {
  109.             //leave other parameters intact
  110.             newParamStr = newParamStr + divide2[0] + "=" + divide2[1] + "&";
  111.         }
  112.     }
  113.     //strip off trailing ampersand
  114.     if (newParamStr.charAt(newParamStr.length - 1) == "&") newParamStr = newParamStr.substring(0, newParamStr.length - 1);
  115.     //return new URL
  116.      return(thisURLstr + "?" + newParamStr);
  117. }
  118.  
  119.  
  120. // Sorts search results based on 1.Number of hits 2.alphabetically
  121. function compare(a, b) {
  122.     if (parseInt(a) - parseInt(b) != 0) {
  123.         return parseInt(a) - parseInt(b)
  124.     }else {
  125.         var aComp = a.substring(a.indexOf("|") + 1, a.length).toLowerCase();
  126.         var bComp = b.substring(b.indexOf("|") + 1, b.length).toLowerCase();
  127.         if (aComp < bComp) {return -1}
  128.         if (aComp > bComp) {return 1}
  129.         return 0
  130.     }
  131. }
  132.  
  133.  
  134. function cleanUp(inputStr) {
  135.     var returnStr = "";
  136.     //myRE = new RegExp(/(\*|\/|\?|\[|\])/g)
  137.     var myRegExp = new RegExp();
  138.     myREgExp = /\+/g;
  139.     returnStr = inputStr.replace(myREgExp, " ");
  140.     //clean up spaces at beginning of string
  141.     while (returnStr.charAt(0) == ' ') {                    
  142.         returnStr = returnStr.substring(1,returnStr.length);
  143.     }
  144.     //clean up spaces at end of string
  145.     while (returnStr.charAt(returnStr.length - 1) == ' ') {
  146.         returnStr = returnStr.substring(0,returnStr.length - 1);
  147.     }
  148.  
  149.     //change ASCII euro to ISO-8859-1
  150.     returnStr = convertSGML(returnStr);
  151.     return returnStr;
  152. }
  153.  
  154. //convert ASCII euro characters to ISO-8859-1
  155. function convertSGML(entry) {
  156.  
  157.     var SGMLlist = new Array("└|À", "α|à", "┴|Á", "ß|á", "┬|Â", "Γ|â", "├|Ã", "π|ã", "─|Ä", "Σ|ä", "┼|Å", "σ|å", "╞|Æ", "µ|æ", "╟|Ç", "τ|ç", "╚|È", "Φ|è", "╔|É", "Θ|é", "╩|Ê", "Ω|ê", "╦|Ë", "δ|ë", "╠|Ì", "∞|ì", "═|Í", "φ|í", "╬|Î", "ε|î", "╧|Ï", "∩|ï", "╨|Ð", "≡|ð", "╤|Ñ", "±|ñ", "╥|Ò", "≥|ò", "╙|Ó", "≤|ó", "╘|Ô", "⌠|ô", "╒|Õ", "⌡|õ", "╓|Ö", "÷|ö", "╪|Ø", "°|ø", "┘|Ù", "∙|ù", "┌|Ú", "·|ú", "█|Û", "√|û", "▄|Ü", "▄|Ü", "ⁿ|ü", "▌|Ý", "²|ý");
  158.  
  159.     for (i=0; i<SGMLlist.length; i++) {
  160.         divide = SGMLlist[i].split("|");
  161.         eval("myRE = /"+divide[0]+"/g");
  162.         entry = entry.replace(myRE, divide[1]);
  163.     }
  164.  
  165.     return entry;
  166. }
  167.  
  168. function checkMetaData() {
  169.     thisMeta = 3;
  170.     isMatch = true;
  171.     meta_loop:
  172.     for (i=0; i<metaArray.length; i++) {
  173.         //alert("meta" + parseInt(i+1) + ": " + metaArray[i])
  174.         if (metaArray[i] != "") {
  175.             metaSplit = metaArray[i].split("|");
  176.             for (j=0; j<metaSplit.length; j++) {
  177.                 isMatch = false;
  178.                 //alert((splitline[thisMeta].toUpperCase()) + ": " + (metaSplit[j].toUpperCase()))
  179.                 //if (splitline[thisMeta].toUpperCase() == metaSplit[j].toUpperCase()) {
  180.                 if (splitline[thisMeta].toUpperCase().indexOf(metaSplit[j].toUpperCase()) > -1) {
  181.                     isMatch = true;
  182.                     break;
  183.                 }
  184.             }
  185.             if (isMatch == false) break meta_loop;
  186.         }
  187.         thisMeta++;
  188.         
  189.     }
  190.     //alert(isMatch)
  191.     return isMatch;
  192. }
  193.  
  194. //retrieve form submission, declare globals
  195. var searchTerm = cleanUp(getQueryString("searchField"));
  196. var srcCrit = getQueryString("srcriteria");
  197. var meta1 = getQueryString("meta1");
  198. var meta2 = getQueryString("meta2");
  199. var meta3 = getQueryString("meta3");
  200. var meta4 = getQueryString("meta4");
  201. var meta5 = getQueryString("meta5");
  202. var meta6 = getQueryString("meta6");
  203. var meta7 = getQueryString("meta7");
  204. var meta8 = getQueryString("meta8");
  205. var meta9 = getQueryString("meta9");
  206. var meta10 = getQueryString("meta10");
  207. var metaArray = new Array(meta1, meta2, meta3, meta4, meta5, meta6, meta7, meta8, meta9, meta10);
  208. var srcRange = (getQueryString("range") != "")? parseInt(getQueryString("range")):1;
  209. var maxPages = 10;
  210. var OccurNum = 0;
  211. var beginPhrase = 0;
  212. var splitline = new Array();
  213. var searchArray = new Array();
  214. var matchArray = new Array();
  215. var descripStrArray = new Array();
  216. var DescripStr = "";
  217. var allConfirmation = true;
  218. var atBegin = false;
  219. var atEnd = false;
  220. var isMatchPage = false;
  221. var REsearchTerm = searchTerm;
  222. var myRegExp = new RegExp();
  223. var specialChars = new Array("*", "/", "?", "[", "]")
  224. for (i=0; i<specialChars.length; i++) {
  225.     eval("myREgExp = /\\" + specialChars[i] + "/g");
  226.     REsearchTerm = REsearchTerm.replace(myREgExp, "\\" + specialChars[i]);
  227. }
  228.  
  229.  
  230.  
  231. function doSearch() {
  232.     for (cnt1=0; cnt1<profiles.length; cnt1++) {
  233.     
  234.         OccurNum = 0;
  235.         MatchesPerTerm = 0;
  236.         isMatchPage = false;
  237.         splitline = profiles[cnt1].split("|");
  238.         //refineAllString = mergeStrings(splitline[0], splitline[1], splitline[2])
  239.         refineAllString = mergeStrings(splitline[0], splitline[1], "")
  240.         pgKeyWds = splitline[3];
  241.         descripStrArray = new Array();
  242.         DescripStr = "";
  243.  
  244.         if (checkMetaData()) {   //does meta tag info match?
  245.         
  246.             isMatchPage = (REsearchTerm == "")? true:false;
  247.             switch (srcCrit) {
  248.  
  249.                 case "all":    //user requests ALL WORDS
  250.                 allConfirmation = true;
  251.                 if (REsearchTerm!= "") searchArray = REsearchTerm.split(" ");
  252.                 //determine how many terms get a phrase in the description
  253.                 MatchesPerTerm = (parseInt(4/searchArray.length) > 0)? parseInt(4/searchArray.length):1;
  254.                 // loop through all search terms
  255.                 for (cnt2 = 0; cnt2 < searchArray.length; cnt2++) {
  256.                     TotalMatches = 0;    //reset to zero for every new word
  257.                     eval("myRE = /" + searchArray[cnt2] + "/gi");
  258.                     OccurTest = myRE.test(refineAllString + pgKeyWds);
  259.  
  260.                     if (OccurTest) {    // matches are found
  261.                         OccurArray = myRE.exec(refineAllString + pgKeyWds);
  262.                         myRE.firstIndex = 0;
  263.                         myRE.lastIndex = 0;
  264.                         beginPhrase = 0;
  265.                         while (OccurArray = myRE.exec(refineAllString + pgKeyWds)) {
  266.                         //while (refineAllString.match(myRE)) {
  267.                             OccurNum++;
  268.  
  269.                             if ((TotalMatches < MatchesPerTerm) && (descripStrArray.length < 4)) {
  270.                                 // if index for this term is not already contained in descripStrArray items then
  271.                                 // build description object with four properties:
  272.                                 // start index, end index, term position index, matching substring.
  273.                                 beginPhrase = myRE.lastIndex - myRE.source.length;
  274.                                 if (noPreviousOccur(descripStrArray, beginPhrase)) {
  275.  
  276.                                     //is substring beginning of refineAllString?
  277.                                     if (beginPhrase - 35 > 0) {
  278.                                         startPos = beginPhrase - 35;
  279.                                         atBegin = false;
  280.  
  281.                                     } else {
  282.                                         startPos = 0;
  283.                                         atBegin = true;
  284.                                     }
  285.                                     //is substring end of refineAllString?
  286.                                     if (myRE.lastIndex + 35 < refineAllString.length) {
  287.                                         endPos =  myRE.lastIndex + 35;
  288.                                         atEnd = false;
  289.  
  290.                                     } else {
  291.                                         endPos = refineAllString.length;
  292.                                         atEnd = true;
  293.                                     }
  294.                                     descripStrArray[descripStrArray.length] = new briefDescrip(startPos, endPos, beginPhrase, refineAllString.substring(startPos, endPos), atBegin, atEnd)
  295.                                     TotalMatches++;
  296.                                 }
  297.  
  298.                             } else {
  299.                                 break;
  300.                             }
  301.  
  302.                         }    //end while
  303.  
  304.  
  305.                     } else {    //no match on this term
  306.                         allConfirmation = false;
  307.                         break;
  308.                     }
  309.  
  310.  
  311.                 } // end cnt2 loop
  312.  
  313.                 if (allConfirmation) {
  314.  
  315.                     //build brief description
  316.                     DescripStr = "";
  317.                     for (cnt2 = 0; cnt2 < descripStrArray.length; cnt2++) {
  318.                         DescripStr += descripStrArray[cnt2].termTxt + "…";
  319.                     }
  320.                     //matchArray[matchArray.length] = (0 - OccurNum) + "|" + splitline[0] + "|" + DescripStr + "|" + splitline[13]
  321.                     isMatchPage = true;
  322.                 }
  323.                 break;
  324.  
  325.  
  326.                 case "phrase":    //user requests EXACT PHRASE
  327.                 TotalMatches = 0;
  328.                 MatchesPerTerm = 4;
  329.                 if (REsearchTerm != "") {
  330.                     eval("myRE = /" + REsearchTerm + "/gi");
  331.                     OccurTest = myRE.test(refineAllString + pgKeyWds);
  332.                 } else {
  333.                     OccurTest = false;
  334.                 }
  335.                 if (OccurTest) {
  336.                     OccurArray = myRE.exec(refineAllString + pgKeyWds);
  337.                     myRE.firstIndex = 0;
  338.                     myRE.lastIndex = 0;
  339.                     beginPhrase = 0;
  340.                     while (OccurArray = myRE.exec(refineAllString + pgKeyWds)) {
  341.                         OccurNum++;
  342.                         if ((TotalMatches < MatchesPerTerm) && (descripStrArray.length < 4)) {
  343.  
  344.                             beginPhrase = myRE.lastIndex - myRE.source.length;
  345.                             if (noPreviousOccur(descripStrArray, beginPhrase)) {
  346.  
  347.                                 //is substring beginning of refineAllString?
  348.                                 if (beginPhrase - 35 > 0) {
  349.                                     startPos = beginPhrase - 35;
  350.                                     atBegin = false;
  351.  
  352.                                 } else {
  353.                                     startPos = 0;
  354.                                     atBegin = true;
  355.                                 }
  356.                                 //is substring end of refineAllString?
  357.                                 if (myRE.lastIndex + 35 < refineAllString.length) {
  358.                                     endPos =  myRE.lastIndex + 35;
  359.                                     atEnd = false;
  360.  
  361.                                 } else {
  362.                                     endPos = refineAllString.length;
  363.                                     atEnd = true;
  364.                                 }
  365.                                 descripStrArray[descripStrArray.length] = new briefDescrip(startPos, endPos, beginPhrase, refineAllString.substring(startPos, endPos), atBegin, atEnd)
  366.                                 TotalMatches++;
  367.                             }
  368.                         }
  369.                     }
  370.                     DescripStr = "";
  371.                     for (cnt2 = 0; cnt2 < descripStrArray.length; cnt2++) {
  372.                         DescripStr += descripStrArray[cnt2].termTxt + "…";
  373.                     }
  374.  
  375.                     //matchArray[matchArray.length] = (0 - OccurNum) + "|" + splitline[0] + "|" + DescripStr + "|" + splitline[3]
  376.                     isMatchPage = true;
  377.                 }
  378.                 break;
  379.  
  380.  
  381.                 default:        //user requests nothing or ANY WORDS
  382.                 if (REsearchTerm != "") {
  383.                     searchArray = REsearchTerm.split(" ");
  384.                 } else {
  385.                     
  386.                     searchArray = new Array();
  387.                 }
  388.                 MatchesPerTerm = (parseInt(4/searchArray.length) > 0)? parseInt(4/searchArray.length):1;
  389.                 for (cnt2 = 0; cnt2 < searchArray.length; cnt2++) {
  390.  
  391.                     TotalMatches = 0;    //reset to zero for every new word
  392.                     eval("myRE = /" + searchArray[cnt2] + "/gi");
  393.                     OccurTest = myRE.test(refineAllString + pgKeyWds);
  394.  
  395.                     if (OccurTest) {    // matches are found
  396.                         OccurArray = myRE.exec(refineAllString + pgKeyWds);
  397.                         myRE.firstIndex = 0;
  398.                         myRE.lastIndex = 0;
  399.                         beginPhrase = 0;
  400.                         while (OccurArray = myRE.exec(refineAllString + pgKeyWds)) {
  401.                             OccurNum++;
  402.                             if ((TotalMatches < MatchesPerTerm) && (descripStrArray.length < 4)) {
  403.                                 // if index for this term is not already contained in descripStrArray items then
  404.                                 // build description object with four properties:
  405.                                 // start index, end index, term position index, matching substring.
  406.                                 beginPhrase = myRE.lastIndex - myRE.source.length;
  407.                                 if (noPreviousOccur(descripStrArray, beginPhrase)) {
  408.  
  409.                                     //is substring beginning of refineAllString?
  410.                                     if (beginPhrase - 35 > 0) {
  411.                                         startPos = beginPhrase - 35;
  412.                                         atBegin = false;
  413.  
  414.                                     } else {
  415.                                         startPos = 0;
  416.                                         atBegin = true;
  417.                                     }
  418.                                     //is substring end of refineAllString?
  419.                                     if (myRE.lastIndex + 35 < refineAllString.length) {
  420.                                         endPos =  myRE.lastIndex + 35;
  421.                                         atEnd = false;
  422.  
  423.                                     } else {
  424.                                         endPos = refineAllString.length;
  425.                                         atEnd = true;
  426.                                     }
  427.                                     descripStrArray[descripStrArray.length] = new briefDescrip(startPos, endPos, beginPhrase, refineAllString.substring(startPos, endPos), atBegin, atEnd);
  428.                                     TotalMatches++;
  429.                                 }
  430.  
  431.                             } else {
  432.                                 break;
  433.                             }
  434.                         }
  435.                     }
  436.                 }
  437.                 if (OccurNum > 0) {
  438.                     //build brief description
  439.                     DescripStr = "";
  440.                     for (cnt3 = 0; cnt3 < descripStrArray.length; cnt3++) {
  441.                         DescripStr += descripStrArray[cnt3].termTxt + "…";
  442.                     }
  443.                     //matchArray[matchArray.length] = (0 - OccurNum) + "|" + splitline[0] + "|" + DescripStr + "|" + splitline[3]
  444.                     isMatchPage = true;
  445.                 }
  446.                 break;
  447.  
  448.             } //end switch
  449.             
  450.             
  451.         if (isMatchPage) matchArray[matchArray.length] = (0 - OccurNum) + "|" + splitline[0] + "|" + DescripStr + "|" + splitline[13]
  452.  
  453.         } //end if checkMetaData()
  454.  
  455.     } //end cnt1
  456.  
  457.  
  458.  
  459.     //for (i=0; i<matchArray.length; i++) {
  460.     //    divide = matchArray[i].split("|");
  461.     //    document.write("<br>" + "<b>" + divide[1] + "</b> (" + divide[0] + ") " + "<br>" + divide[2] + "<br>")
  462.     //}
  463.  
  464.     //results = passedArray;
  465.     //pgRange = (getQueryString("range") != "")? parseInt(getQueryString("range")):1;
  466.     document.writeln("<a name=\"top_of_page\"></a><h3>Search Results</h3>");
  467.     document.writeln("<h4><hr size=\"1\">Search Query: " + searchTerm + "<br>");
  468.     document.writeln("Search Results: "+ matchArray.length + "");
  469.     document.writeln("<hr size=\"1\"></h4>");
  470.     thisPg = 1;
  471.     endPg = matchArray.length;
  472.     if (matchArray.length > maxPages) {
  473.         thisPg = (maxPages * srcRange) - (maxPages - 1);
  474.         endPg = (parseInt(thisPg + (maxPages - 1)) < matchArray.length)? parseInt(thisPg + (maxPages - 1)):matchArray.length;
  475.         document.writeln(thisPg + " - " + endPg + " of " + matchArray.length);
  476.     }
  477.     document.writeln("<dl>");
  478.     matchArray.sort(compare);
  479.     if (REsearchTerm != "") {
  480.         wrdArray = (srcCrit != "phrase")? REsearchTerm.split(" "):new Array(REsearchTerm);
  481.     } else {
  482.         wrdArray = new Array();
  483.     }
  484.  
  485.     
  486.     for (i = (thisPg - 1); i < endPg; i++) {
  487.         divide = matchArray[i].split("|");             // Print each profile result as a unit of a definition list
  488.         
  489.         // begin hilite terms in red
  490.         for (j=0; j<wrdArray.length; j++) {
  491.             eval("myRE1 = /" + wrdArray[j] + "/gi");
  492.             regArr = null;
  493.             regArr = divide[2].match(myRE1);
  494.             if (regArr != null) {
  495.                 //look for uniqueness in regArr
  496.                 beenThere = new Array();
  497.                 for (k=0; k<regArr.length; k++) {
  498.                     beenhere = 0; 
  499.                     for (l=0; l<beenThere.length; l++) {
  500.                         if (beenThere[l] == regArr[k]) {
  501.                             beenhere = 1;
  502.                             //break;
  503.                         }
  504.                     }
  505.                     if (beenhere == 0) {
  506.                         beenThere[beenThere.length] = regArr[k];
  507.                         //escape RegExp special chars for RegExp
  508.                         var specialChars = new Array("*", "/", "?", "[", "]")
  509.                         tmpRegArr = regArr[k];
  510.                         for (l=0; l<specialChars.length; l++) {
  511.                             eval("myRE1a = /\\" + specialChars[l] + "/g");
  512.                             regArr[k] = regArr[k].replace(myRE1a, "\\" + specialChars[l]);
  513.                         }
  514.                         eval("myRE2 = /"+regArr[k]+"/g");
  515.                         divide[2] = divide[2].replace(myRE2, "<\|>" + tmpRegArr + "<\/\|>");
  516.                     }
  517.                 }
  518.             }
  519.         }
  520.  
  521.         myRE3 = /\<\|\>/g;
  522.         myRE4 = /\<\/\|\>/g;
  523.         divide[2] = divide[2].replace(myRE3, "<font color=red>");
  524.         divide[2] = divide[2].replace(myRE4, "</font>");
  525.         // end hilite terms in red
  526.         document.writeln("<dt><a href=\""+divide[3]+"\" target=\"_self\"><b>" + divide[1] + "</b></a><\dt>");
  527.         document.writeln("<dd>" + divide[2] + "</dd><br><br>");
  528.     }
  529.     
  530.     document.writeln("</dl>");                // Finish the HTML document
  531.  
  532.     //write results page numbers
  533.     if (matchArray.length > maxPages) {
  534.         pgNum = parseInt(matchArray.length/maxPages);
  535.         if (matchArray.length/maxPages > pgNum) pgNum++;
  536.         pgLinks = "go to page: ";
  537.         for (i=0; i < pgNum; i ++) {
  538.             locationStr = (location.href.indexOf("&range=") > -1)? changeParam("range", parseInt(i + 1)):location.href + "&range=" + parseInt(i + 1);
  539.             pgLinks += (parseInt(i + 1) != srcRange)? "<a href=\"" + locationStr + "\">" + (i + 1) + "</a> ":"<b>" + (i + 1) + "</b> ";
  540.         }
  541.         document.writeln(pgLinks + "<hr size=\"1\">");
  542.     } 
  543.  
  544.  
  545. }
  546.  
  547.