/*----------------------------------------------------------------------------
 * JavaScript for webhelp search
 *----------------------------------------------------------------------------
 This file is part of the webhelpsearch plugin for DocBook WebHelp
 Copyright (c) 2007-2008 NexWave Solutions All Rights Reserved.
 www.nexwave.biz Nadege Quaine
 http://kasunbg.blogspot.com/ Kasun Gajasinghe
 */
//string initialization
var htmlfileList = "htmlFileInfoList.js";
var htmlfileinfoList = "htmlFileInfoList.js";
var useCJKTokenizing = false;
var w = new Object();
var scoring = new Object();
var searchTextField = '';
var no = 0;
var noWords = 0;
var partialSearch = "There is no page containing all the search terms.
Partial results:";
var warningMsg = '
';
warningMsg+='
Please note that due to security settings, Google Chrome does not highlight';
warningMsg+=' the search results in the right frame.';
warningMsg+='This happens only when the WebHelp files are loaded from the local file system.
';
warningMsg+='Workarounds:';
warningMsg+='
';
warningMsg+='- Try using another web browser.';
warningMsg+='
- Deploy the WebHelp files on a web server.';
warningMsg+='
" + txt_results_for + " " + "" + fileAndWordList[i][0].motslisteDisplay + "" + "
");
                linkTab.push("");
                for (t in fileAndWordList[i]) {
                    //linkTab.push("- "+fl[fileAndWordList[i][t].filenb]+"");
				                        
                    var ttInfo = fileAndWordList[i][t].filenb;
                    // Get scoring
                    var ttScore = fileAndWordList[i][t].scoring;
                    var tempInfo = fil[ttInfo];
				    
                    var pos1 = tempInfo.indexOf("@@@");
                    var pos2 = tempInfo.lastIndexOf("@@@");
                    var tempPath = tempInfo.substring(0, pos1);
                    var tempTitle = tempInfo.substring(pos1 + 3, pos2);
                    var tempShortdesc = tempInfo.substring(pos2 + 3, tempInfo.length);
                    
                    // toc.html will not be displayed on search result
                    if (tempPath == 'toc.html'){
                        continue;
                    }
                    /*
                    //file:///home/kasun/docbook/WEBHELP/webhelp-draft-output-format-idea/src/main/resources/web/webhelp/installation.html
                    var linkString = "
- " + tempTitle + "";
                    // var linkString = "
- " + tempTitle + "";
                    */
                    var split = fileAndWordList[i][t].motsliste.split(",");
                    // var splitedValues = expressionInput.split(" ");
					// var finalArray = split.concat(splitedValues);					
					
                    arrayString = 'Array(';
                    for(var x in finalArray){
                      if (finalArray[x].length > 2 || useCJKTokenizing){
                    		arrayString+= "'" + finalArray[x] + "',";
                    	} 
                    }
                    arrayString = arrayString.substring(0,arrayString.length - 1) + ")";
                    var idLink = 'foundLink' + no;
                    var linkString = '
- ' + tempTitle + '';
                    var starWidth = (ttScore * 100/ hundredProcent)/(ttScore_first/hundredProcent) * (numberOfWords/maxNumberOfWords);
                    starWidth = starWidth < 10 ? (starWidth + 5) : starWidth;
                    // Keep the 5 stars format
                    if (starWidth > 85){
						starWidth = 85;
					}
					/*
					var noFullStars = Math.ceil(starWidth/17);
					var fullStar  = "curr";
					var emptyStar = "";
					if (starWidth % 17 == 0){
						// am stea plina
						
					} else {
						
					}
					console.info(noFullStars);
					*/
                    // Also check if we have a valid description
                    if ((tempShortdesc != "null" && tempShortdesc != '...')) {
                    
                        linkString += "\n" + tempShortdesc + " ";
                    }
                    linkString += "
";
                    
                    // Add rating values for scoring at the list of matches	
					linkString += "";
					linkString += "
";
					//linkString += "
" 
					//				+ ((ttScore * 100/ hundredProcent)/(ttScore_first/hundredProcent)) * 1 + "
";
	                linkString += "
";
					linkString += "";
	                linkString += "
";
	                
	                linkString += "
";
	                linkString += "
";
					linkString += "
");
            }
        }
    }
    var results = "";
    if (linkTab.length > 0) { 
        /*writeln ("" + txt_results_for + " " + ""  + cleanwordsList + "" + "
"+"
");*/
        results = "";
        //write("