2329. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 1/2/2018 11:58:08 AM Eastern Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

2329.1 Files compared

# Location File Last Modified
1 Tue Jan 2 16:58:08 2018 UTC
2 HTRE_P2.zip\src.zip\output\IHTA OLH Files.zip\ihta_admin.zip\ihta.zip whfhost.js Fri Mar 24 20:39:28 2017 UTC

2329.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 0 0
Changed 0 0
Inserted 1 3849
Removed 0 0

2329.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

2329.4 Active regular expressions

No regular expressions were active.

2329.5 Comparison detail

        1   //      We bHelp 5.10 .003
        2   var gsNoTo pics="No T opics Foun d.";
        3   var gsLoad XmlFailed= "Error: Fa iled to lo ad xml fil e.";
        4   var gsInit DatabaseFa iled="Erro r: Failed  to initial ize databa se.";
        5   var gsNotA llDatabase Inited="Wa rning: Not  all datab ases have  been loade d. Some to pics will  not be fou nd.";
        6   var gsInva lidExpress ion_1="The  words you  typed is  not a vali d expressi on.";
        7   var gsInva lidExpress ion_2="Cli ck";
        8   var gsInva lidExpress ion_3="Hel p";
        9   var gsInva lidExpress ion_4="to  learn how  to use que ry express ion.(To be  finished) ";
        10   var gsSear ching="Sea rching..." ;
        11   var gsTitl e="Title";
        12   var gsRank ="Rank";
        13   var gsCanc el="Cancel ";
        14   var gsCanc eled="Canc eled";
        15   var gsPage Dir="ltr";
        16  
        17   var gsTota lNumberOfS earchResul ts = "Tota l Number o f Search R esults : % 1";
        18   var gbShow TotalNumbe rOfSearchR esults=1;
        19   var gbEnab leAndSearc h =false;
        20  
        21   var gsSubs trSrch=0;
        22   var gsHide RankColumn =0;
        23  
        24   var g_Rune sVowels="\ u0061\u006 5\u0069\u0 06F\u0075\ u0079";
        25   var g_Rune sWordBreak s="\u0001\ u0002\u000 3\u0004\u0 005\u0006\ u0007\u000 8\u0009\u0 00A\u000B\ u000C\u000 D\u000E\u0 00F\u0010\ u0011\u001 2\u0013\u0 014\u0015\ u0016\u001 7\u0018\u0 019\u001A\ u001B\u001 C\u001D\u0 01E\u001F\ u0022\u005 C\u0020\u0 02E\u002C\ u0021\u004 0\u0023\u0 024\u0025\ u005E\u002 6\u002A\u0 028\u0029\ u007E\u002 7\u0060\u0 03A\u003B\ u003C\u003 E\u003F\u0 02F\u007B\ u007D\u005 B\u005D\u0 07C\u002B\ u002D\u003 D\u0081\u0 082\u0083\ u0084\u008 5\u0086\u0 087\u0088\ u0089\u008 A\u008B\u0 08C\u008D\ u008E\u008 F\u0090\u0 091\u0092\ u0093\u009 4\u0095\u0 096\u0097\ u0098\u009 9\u009A\u0 09B\u009C\ u009D\u009 E\u009F\u0 0A1\u00A9\ u00AB\u00A E\u00B7\u0 0BB\u00BF\ u00A0\u200 0\u2001\u2 002\u2003\ u2004\u200 5\u2006\u2 007\u2008\ u2009\u200 A\u2028\u2 029\u202F\ u205F\u300 0";
        26   var g_Rune sWhiteSpac es="\u0020 \u0009\u00 0D\u000A\u 00A0\u2000 \u2001\u20 02\u2003\u 2004\u2005 \u2006\u20 07\u2008\u 2009\u200A \u2028\u20 29\u202F\u 205F\u3000 ";
        27   var g_Rune sSpecialBr eaks = ",! @#$%^&*()~ '`:;<>?/{} []|+-=" ;
        28   var g_Rune sQuote='\x 22';
        29   var g_Rune sHelSuffix es=new Arr ay("ed,0", "ingly,0", "ings,0"," ing,0","ly ,1","s,1", "e,1");
        30  
        31   var gbHigh Light=true ;
        32   var gsHLCo lorFront=" #000000";
        33   var gsHLCo lorBackgro und="#b2b4 bf";
        34   var gsAsce ndFlag = " &#9651;";
        35   var gsDesc endFlag =  "&#9661;";
        36  
        37   var gAIRSe archObject ;
        38   var gsResu ltDivID="R esultDiv";
        39   var gbRead y=false;
        40   var gbXML= false;
        41   var gsBgCo lor="#ffff ff";
        42   var gsBgIm age="";
        43   var gsMarg in="0pt";
        44   var gsInde nt="0pt";
        45   var goFont =null;
        46   var goErrF ont=null;
        47   var goHove rFont=null ;
        48   var gsABgC olor="#ccc ccc";
        49   var gbWhFH ost=false;
        50   var gbAIRS earchResul tDisplayDo neFn=dummy SearchResu ltFn;
        51   var gbAIRS earchResul tDoneSteps =0;
        52   var gbAIRS earchResul tDone=fals e;
        53  
        54   var g_nSor tType = 0;
        55   var g_nX0  = 0;
        56   var g_nIni tWidth = 0 ;
        57   var g_bDra ging = fal se;
        58   var g_nRan kWidthMin  = 20;
        59  
        60   var ECS_NO NE                      = 0;
        61   var ECS_FT SREADY                  = 1;
        62   var ECS_SE ARCHING                 = 2;
        63   var ECS_FA TALERROR                = 3;
        64   var ECS_CA NCELED                  = 4;
        65   var ECS_SE ARCHFAILED     = 5;
        66   var ECS_FO UND                     = 6;
        67  
        68   var g_CurS tate = nul l;
        69   var g_CurP age = 1;
        70   var g_nMax Pages = 3  ;
        71   var g_sQue stion='';
        72   var g_bSer verResult= false;
        73   gbSearchPa ge=true;
        74   var gbAIRS ynonymStri ng='';
        75   var gbAIRS earchStrin g='';
        76   var g_nMax Result = 0 ;
        77   var gsSear chQuery =  '';
        78   var gbExtr aInfoInSea rchQuery =  '';
        79   var gChang edQuery='  ';
        80  
        81   function s etBackgrou nd(sBgImag e)
        82   {
        83           gs BgImage=sB gImage;
        84   }
        85  
        86   function s etBackgrou ndcolor(sB gColor)
        87   {
        88           gs BgColor=sB gColor;
        89   }
        90  
        91   function s etFont(sTy pe,sFontNa me,sFontSi ze,sFontCo lor,sFontS tyle,sFont Weight,sFo ntDecorati on)
        92   {
        93           va r vFont=ne w whFont(s FontName,s FontSize,s FontColor, sFontStyle ,sFontWeig ht,sFontDe coration);
        94           if (sType=="N ormal")
        95                    goFo nt=vFont;
        96           el se if(sTyp e=="Error" )
        97                    goEr rFont=vFon t;
        98           el se if(sTyp e=="Hover" )
        99                    goHo verFont=vF ont;
        100   }
        101  
        102   function s etActiveBg Color(sBgC olor)
        103   {
        104           gs ABgColor=s BgColor;
        105   }
        106  
        107   function s etMargin(s Margin)
        108   {
        109           gs Margin=sMa rgin;
        110   }
        111  
        112   function s etIndent(s Indent)
        113   {
        114           gs Indent=sIn dent;
        115   }
        116  
        117   function w indow_OnLo ad()
        118   {
        119           if (gsBgImage &&gsBgImag e.length>0 )
        120           {
        121                    docu ment.body. background =gsBgImage ;
        122           }
        123           if (gsBgColor &&gsBgColo r.length>0 )
        124           {
        125                    docu ment.body. bgColor=gs BgColor;
        126           }
        127           wr iteResultD iv();
        128           if (gbAIR)
        129                    retu rn;
        130           if (gbAIRSSL)
        131           {
        132                    var  strProject Dir=_getPa th(documen t.location .href);
        133                    SeeF orSearch(s trProjectD ir);
        134                    retu rn;
        135           }
        136                    
        137           lo adFts();
        138   }
        139  
        140   function S earchPendi ngRequest( )
        141   {
        142       var oM sg=new whM essage(WH_ MSG_SHOWFT S,null,nul l);
        143           no tify(oMsg) ;
        144           oM sg = new w hMessage(W H_MSG_GETS EARCHSTR,  null, null );
        145           re quest(oMsg , onGetSea rchStr);
        146   }
        147  
        148   function o nGetSearch Str(oMsg)
        149   {
        150       var st rTerms = " ";
        151       strTer ms = oMsg. oParam;              
        152           if  (strTerms  != " " )
        153           {
        154                    oMsg  = new whM essage(WH_ MSG_SEARCH THIS, strT erms, null );                 
        155                    noti fy(oMsg);
        156           }        
        157   }
        158  
        159   function w riteResult Div()
        160   {
        161           va r sHTML= " <div id='"  + gsResul tDivID+ "'  style='po sition:abs olute; wid th:100%'>< /div>";
        162           if (gbAIRSSL)
        163                    docu ment.body. innerHTML  = sHTML;
        164           el se    docu ment.body. insertAdja centHTML(" beforeEnd" ,sHTML);
        165   }
        166  
        167   function r egistListe ner( a_Con text, a_th is )
        168   {
        169           if (!gbAIRSSL )
        170                    regi sterListen er2(WH_MSG _SEARCHFTS KEY );
        171   }
        172  
        173   function F tsWriteCla ssStyle()
        174   {
        175           va r marginHo riZontal =  (gsPageDi r == "rtl" )?"margin- right":"ma rgin-left" ;
        176           va r floatDir  = (gsPage Dir == "rt l")?"right ":"left";
        177           va r borderSt yleright =  (gsPageDi r == "rtl" )?"none":" solid";
        178           va r borderSt yleleft =  (gsPageDir  == "rtl") ?"solid":" none";
        179           va r directio nHoriZonta l = (gsPag eDir == "r tl")?"righ t":"left";
        180           
        181           va r sStyle=" <STYLE TYP E='text/cs s'>\n";
        182           if  (gsBgImag e)
        183                    sSty le+="body  {border-to p:"+gsBgCo lor+" 1px  solid;}\n" ;
        184           el se if(gbAI R)
        185                    sSty le+="body  {border-to p:white 1p x solid;}\ n";
        186           el se 
        187                sStyle+= "body {bor der-top:bl ack 1px so lid;}\n";
        188           sS tyle+="P.m sg {"+getF ontStyle(g oErrFont)+  marginHor iZontal +  ":"+gsInde nt+";margi n-top:"+gs Margin+";} \n";
        189           sS tyle+="dl  {"+getFont Style(goFo nt)+ margi nHoriZonta l + ":"+gs Indent+";m argin-top: "+gsMargin +";}\n";
        190           sS tyle+="A.f r_tc:link  {"+getFont Style(goFo nt)+"font- weight:bol d;}\n";
        191           sS tyle+="A.f r_tc:visit ed {"+getF ontStyle(g oFont)+"fo nt-weight: bold;}\n";
        192           sS tyle+="A.f r_tc:hover  {"+getFon tStyle(goH overFont)+ "font-weig ht:bold;}\ n";
        193           sS tyle+="A.f r_act {bac kground-co lor:"+gsAB gColor+";} \n";
        194           sS tyle+="A.f r_act:link  {"+getFon tStyle(goF ont)+"}\n" ;
        195           sS tyle+="A.f r_act:visi ted {"+get FontStyle( goFont)+"} \n";
        196           sS tyle+="A.f r_act:hove r {"+getFo ntStyle(go HoverFont) +"}\n";
        197           sS tyle+="LI. sl_page{di splay:bloc k;display: inline-blo ck;float:"  + floatDi r +";curso r:pointer; text-decor ation:none ;border:1p x solid #c cc;padding :.3em .7em ;margin:0  .38em 0 0; text-align :center}\n ";
        198           sS tyle+="LI. sl_pageC{b ackground: #f0f7e8;bo rder:1px s olid #83bc 46;display :block;dis play:inlin e-block;fl oat:" + fl oatDir +"; cursor:poi nter;text- decoration :none;padd ing:.3em . 7em;margin :0 .38em 0  0;text-al ign:center }\n";
        199           sS tyle+="LI. sl_pageN{c ursor:poin ter;paddin g:.2em .5e m;margin:0  .38em 0 0 ;border:no ne;text-de coration:u nderline}\ n";
        200           sS tyle+="TD. fr_tt, TD. fr_tc, TD. fr_ts {"+g etFontStyl e(goFont)+ "height:au to;}\n";
        201           if (gbAIRSSL)
        202                sStyle+= "TD.fr_ts  {padding:0 .2em 0em;b order-styl e:solid "  + borderSt yleright +  " solid "  + borderS tyleleft +  ";border- color:"+gs ABgColor+" ;border-wi dth:1px;}\ n";
        203           el se
        204                sStyle+= "TD.fr_ts  {padding:0 .2em 0em;b order-styl e:none " +  borderSty leright +  " solid "  + borderSt yleleft +  ";border-c olor:"+gsA BgColor+"; border-wid th:1px;}\n ";
        205           if (gbAIRSSL)
        206                sStyle+= "TD.fr_tt  {padding:0 .2em 0.5em ;border-st yle:solid  none solid  none;bord er-color:" +gsABgColo r+";border -width:1px ;}\n";
        207           el se
        208                sStyle+= "TD.fr_tt  {padding:0 .2em 0.5em ;border-st yle:none n one solid  none;borde r-color:"+ gsABgColor +";border- width:1px; }\n";
        209           sS tyle+="TD. fr_tc {pad ding:0.2em  0.5em;}\n ";
        210           sS tyle+="P.p b_tt {"+ge tFontStyle (goErrFont )+"padding :0;margin: 3px;}\n";
        211           sS tyle+="P.p b_in {"+ge tFontStyle (goErrFont )+"positio n:relative ;padding:0 ;margin:0; " + direct ionHoriZon tal + ":0% ;top:0%;he ight:10px; border-sty le:none;ba ckground-c olor:blue; }\n";
        212           sS tyle+="DIV .pb_out {w idth:100%; border-sty le:solid;b order-widt h:1px;padd ing:0;marg in:0;backg round-colo r:"+gsABgC olor+";}\n ";
        213           sS tyle+="P.p b_cancel { "+getFontS tyle(goHov erFont)+"c ursor:poin ter;paddin g:0;margin :3px}\n";
        214           sS tyle+="</S TYLE>";
        215           do cument.wri te(sStyle) ;
        216   }
        217  
        218   function w indow_Unlo ad()
        219   {
        220           if (!gbAIRSSL )
        221           {
        222                    unre gisterList ener2(WH_M SG_PROJECT READY);
        223                    unre gisterList ener2(WH_M SG_SEARCHF TSKEY);
        224                    unre gisterList ener2(WH_M SG_SETMAXR SLT);
        225           }
        226   }
        227  
        228   function m rFindFTSKe y()
        229   {
        230           if ( goOdinHu nter.aProj Pathes.len gth<=0 )
        231                    retu rn;
        232  
        233           //  request t he server
        234           va r sUrl=goO dinHunter. aProjPathe s[0].strOd bPath+'&qu estion='+e scape(g_sQ uestion)+' &log=1';
        235  
        236           g_ bServerRes ult=true;
        237           lo adDataXML( sUrl,false );
        238   };
        239  
        240   function o nReceiveNo tification (oMsg)
        241   {
        242       if(gbA IRSSL)
        243                    retu rn true;
        244           if (oMsg.msgI d == WH_MS G_SEARCHFT SKEY )
        245           {
        246                    if ( oMsg.iPara m)
        247                    {
        248                         // redirec t to roboe ngine sear ch if gbEn gine==true
        249                             if( mr IsOnEngine ()==true )
        250                             {
        251                                      // this  is server  side fts
        252                                      g_sQuest ion=oMsg.i Param;
        253                                      mrFindFT SKey();
        254                             }else
        255                             {
        256                                      // this  is client  side fts
        257                                      goOdinHu nter.strQu ery = oMsg .iParam.st rQuery;
        258                    gbEx traInfoInS earchQuery  = oMsg.iP aram.Extra Info;
        259                                      setTimeo ut( "Query ()", 1 );
        260                             };
        261                    } 
        262           }
        263           el se if ( oM sg.msgId = = WH_MSG_P ROJECTREAD Y )
        264       {
        265                loadFts( );
        266       }
        267       else i f(oMsg.msg Id == WH_M SG_SETMAXR SLT)
        268       {
        269           if (oMsg.iPar am)
        270           {
        271                g_nMaxRe sult = oMs g.iParam;
        272           }    
        273       }
        274       return  true;
        275   }
        276  
        277   ////////// //// ODIN  FULL-TEXT  SEARCH---- ---------- ---------- ---------- ----
        278  
        279   // Odin gl obal varia bles------ ---------- --------
        280  
        281   var contex t = new Hu ginContext ();
        282   var goOdin Hunter = n ull;
        283  
        284   // XmlUtil ity.js---- ---------- ---------- --------
        285  
        286   var theXml Reader = n ew XmlRead er();
        287  
        288   function X mlNode()
        289   {
        290           th is.strTagN ame = null ;
        291           th is.aAttrs  = new Arra y();
        292   }
        293  
        294   function X mlData()
        295   {
        296           th is.strFile Path = nul l;
        297           th is.strRoot  = null;
        298           th is.aNodes  = new Arra y();
        299   }
        300  
        301   function X mlReader()
        302   {
        303           th is.strFile Path = nul l;                          //in
        304           th is.funcCal lback = nu ll;                         //in
        305  
        306           th is.bSuccee d = false;                             //ou t
        307  
        308           th is.xmlDoc  = null;
        309           th is.aCache  = new Arra y();
        310           th is.bCache  = false;
        311           th is.curData  = null;     
        312  
        313           th is.loadFro mCache = f unction()
        314           {
        315                    for  ( var i =  0; i < thi s.aCache.l ength; i++  )
        316                    {
        317                             if ( t his.aCache [i].strFil ePath == t his.strFil ePath )
        318                             {
        319                                      this.cur Data = thi s.aCache[i ];
        320                                      return t rue;
        321                             }
        322                    }
        323                    retu rn false;
        324           }
        325  
        326           th is.loadFro mFile = fu nction(a_C ontext, a_ funcCallba ck, a_bCac he )
        327           {
        328                    this .bSucc = f alse;
        329                    this .funcCallb ack = a_fu ncCallback ;
        330                    this .bCache =  ( a_bCache  == true )  ? true :  false;
        331                    if (  this.load FromCache( ) )
        332                    {
        333                             this.f uncCallbac k();
        334                             return ;
        335                    }
        336                    //lo adDataXML(  this.strF ilePath,fa lse );
        337  
        338                    var  sCurrentDo cPath = _g etPath(doc ument.loca tion.href) ;
        339                    var  sdocPath =  _getFullP ath(sCurre ntDocPath,  this.strF ilePath);
        340                    var  fileName =  _getRelat iveFileNam e(sCurrent DocPath, s docPath);
        341                    
        342                    a_Co ntext.paus e();
        343                    xmlJ sReader.lo adFile(fil eName, fun ction(a_xm lDoc, args ){
        344                    if(a _xmlDoc !=  null)
        345                                      putDataX ML(a_xmlDo c, sdocPat h);
        346                    else  {
        347                         onLoadXMLE rror();
        348                    }
        349                                 if (gbAIRSSL)
        350                                      setTimeo ut( functi on() { con text.resum e();}, 1);
        351                                 el se
        352                                 se tTimeout(" context.re sume()", 1 );
        353                         });
        354           }
        355  
        356           th is.receive Dom = func tion( a_Xm lDoc )
        357           {
        358                    this .curData =  null;
        359                    if (  a_XmlDoc. documentEl ement == n ull )
        360                             return ;
        361  
        362                    this .curData =  new XmlDa ta();
        363                    this .curData.s trFilePath  = this.st rFilePath;
        364                    with ( a_XmlDoc .documentE lement )
        365                    {
        366                             this.c urData.str Root = tag Name;
        367                             for (  var i = 0;  i < child Nodes.leng th; i++ )
        368                             {
        369                                      with( a_ XmlDoc.doc umentEleme nt.childNo des.item(  i ) )
        370                                      {
        371                                               if( nodeTy pe == 3 )
        372                                                       co ntinue;
        373                                               var nLen =  this.curD ata.aNodes .length;
        374                                               this.curDa ta.aNodes[ nLen] = ne w XmlNode( );
        375                                               this.curDa ta.aNodes[ nLen].strT agName = t agName;
        376                                               for ( var  j = 0; j <  attribute s.length;  j++ )
        377                                               {
        378                                                       th is.curData .aNodes[nL en].aAttrs [attribute s.item( j  ).name] =  attributes .item( j ) .value;
        379                                               }
        380                                      }
        381                             }
        382                    }
        383                    if (  this.bCac he )
        384                    {
        385                             this.a Cache[this .aCache.le ngth] = th is.curData ;
        386                    }
        387           }
        388           
        389           th is.getNumO fNodes = f unction()
        390           {
        391                return t his.curDat a.aNodes.l ength ;
        392           }
        393           
        394           th is.getNumO fTopics =  function(i )
        395           {
        396                with( th is.curData  )
        397                    {
        398                             if( i  < aNodes.l ength)
        399                             {
        400                                      var num  ;
        401                                      try
        402                                      {
        403                                               num = pars eInt(aNode s[i].aAttr s["num"]);
        404                                      }
        405                                      catch(e)
        406                                      {
        407                                          retu rn 0 ;
        408                                      }
        409                                      return n um ;
        410                             }
        411                             else
        412                                      return 0  ;
        413                    }
        414                    
        415           }
        416           
        417           th is.checkRo ot = funct ion( a_str RootName )
        418           {
        419                    retu rn this.cu rData.strR oot == a_s trRootName ;
        420           }
        421           
        422           th is.getSyno nyms = fun ction ( a_ strQuery )
        423           {
        424                    if ( gsSubstrSr ch)
        425                    {
        426                             var sy nonyms = " " ;
        427                             with(  this.curDa ta )
        428                             {
        429                                      for ( va r i = 0; i  < aNodes. length; i+ + )
        430                                      {
        431                                               if (aNodes [i].aAttrs ["nm"].ind exOf(a_str Query) !=  -1)
        432                                                       sy nonyms +=  "," + aNod es[i].aAtt rs["sy"];
        433                                      }
        434                             }
        435                             return  synonyms  ;
        436                    }
        437                    else
        438                    {
        439                             return  this.getA ttr( "wd",  "nm", a_s trQuery, " sy" ) ;
        440                    }
        441           }
        442  
        443           th is.getWord Rec = func tion ( a_s trQuery ,  bPhraseSea rch)
        444           {
        445                    var  begin = 0 
        446                    var  end = this .curData.a Nodes.leng th ; 
        447                    var  mid = Math .floor((en d -begin )  / 2) ;
        448                    whil e (mid > 0  )
        449                    {
        450                             mid =  mid + begi n ;                       
        451                             var te rm = this. curData.aN odes[mid]. aAttrs["nm "] ;
        452                             if (a_ strQuery <  term) 
        453                                      end = mi d ;
        454                             else i f (a_strQu ery > term )
        455                                      begin =  mid ;
        456                             else
        457                                      break ;
        458                             mid =  Math.floor ((end -beg in ) / 2)  ;
        459                    }
        460                    if ( ((end-begi n) == 1)&& (!this.mat chPrefix(a _strQuery, this.curDa ta.aNodes[ mid].aAttr s["nm"])))
        461                    {
        462                             mid =  end ;                       
        463                    }
        464                    if ( mid < this .curData.a Nodes.leng th)
        465                    {
        466                             if (!b PhraseSear ch && gsSu bstrSrch)
        467                             {
        468                                      //get al l the reco rds with m atching pr efix
        469                                      var arrT opicRecs =  new Array ();
        470                                      while( m id<this.cu rData.aNod es.length)
        471                                      {
        472                                               if (this.c urData.aNo des[mid].a Attrs["sp" ])
        473                                               {
        474                                                       mi d++ ;
        475                                                       co ntinue ;
        476                                               }
        477                                               else if (t his.matchP refix(a_st rQuery,thi s.curData. aNodes[mid ].aAttrs[" nm"]))
        478                                               {
        479                                                       ar rTopicRecs [arrTopicR ecs.length ] = this.c urData.aNo des[mid].a Attrs["rd" ] ;
        480                                                       mi d++ ;
        481                                               }
        482                                               else
        483                                                       br eak ;
        484                                      }
        485                                      if (arrT opicRecs.l ength == 0  )
        486                                               return ""  ;
        487                                      var merg edRec = ar rTopicRecs [0] ;
        488                                      for (var  i = 1 ; i  < arrTopi cRecs.leng th ; i++)
        489                                      {
        490                                               mergedRec  = mergeTop icRec(merg edRec , ar rTopicRecs [i]);
        491                                      }
        492                                      return m ergedRec ;                                                                             
        493                             }
        494                             else
        495                             {
        496                                      //get th e one with  exact mat ch
        497                                      if ((thi s.curData. aNodes[mid ].aAttrs[" nm"])==a_s trQuery) 
        498                                      {
        499                                               if (bPhras eSearch ||  gsSubstrS rch)
        500                                                       re turn this. curData.aN odes[mid]. aAttrs["rd "] ;
        501                                               else
        502                                               {
        503                                                       // do not ret urn stop w ords
        504                                                       if  (this.cur Data.aNode s[mid].aAt trs["sp"])
        505                                                                retu rn "" ;
        506                                                       el se
        507                                                                retu rn this.cu rData.aNod es[mid].aA ttrs["rd"]  ;
        508                                               }                
        509                                      }
        510                                      else
        511                                               return ""  ;
        512                             }
        513                    }                         
        514           }
        515           
        516           th is.getTopi cRec = fun ction ( a_ nTopicId)
        517           {
        518                    if ( (a_nTopicI d >= 0)&&( a_nTopicId  < this.cu rData.aNod es.length  ))
        519                    {
        520                             var ob jResult =  new Object () ;
        521                             objRes ult.rd = t his.curDat a.aNodes[a _nTopicId] .aAttrs["r d"];
        522                             objRes ult.ct = t his.curDat a.aNodes[a _nTopicId] .aAttrs["c t"];
        523                             return  objResult  ;
        524                    }
        525                    else
        526                             return  null ;   
        527           }
        528           
        529           th is.getPack ageIndex =  function  (a_strQuer y)
        530           {
        531                    var  begin = 0 
        532                    var  end = this .curData.a Nodes.leng th - 1 ; 
        533                    var  mid;
        534                    whil e (begin < = end)
        535                    {
        536                             mid =  Math.floor ((begin+en d)/2);
        537                             var st artWord =  this.curDa ta.aNodes[ mid].aAttr s["fm"] ;
        538                             var en dWord = th is.curData .aNodes[mi d].aAttrs[ "to"] ;
        539                             if (en d == begin )
        540                             {
        541                                      if ((a_s trQuery >=  startWord  )&&(a_str Query <= e ndWord))
        542                                               return mid  ;
        543                                      else 
        544                                               return -1  ;
        545                             }
        546                             if (a_ strQuery <  startWord  )
        547                                      end = mi d - 1 ;
        548                             else i f (a_strQu ery > endW ord )
        549                                      begin =  mid + 1;
        550                             else
        551                                      return m id ;             
        552                    }                 
        553                    retu rn -1 ;
        554           }
        555           
        556           th is.matchPr efix = fun ction (a_s trQuery ,  a_strTerm  )
        557           {
        558                    if ( a_strQuery .length >  a_strTerm. length )
        559                             return  false ;
        560                    var  bPrefix =  true ;
        561                    var  i ; 
        562                    for  (i=0; i< a _strQuery. length;i++ )
        563                    {
        564                             if (a_ strQuery.c harAt(i) ! = a_strTer m.charAt(i ))
        565                             {
        566                                      bPrefix  = false ;
        567                                      break ;
        568                             }
        569                    }
        570                    retu rn bPrefix  ;
        571           }
        572  
        573           th is.getAttr  = functio n( a_strTa gName )
        574           {
        575                    var  nArgsNum =  this.getA ttr.argume nts.length ;
        576                    if (  nArgsNum  < 2 || nAr gsNum % 2  != 0 )
        577                             return  "";
        578                             
        579                    with ( this.cur Data )
        580                    {
        581                             for (  var i = 0;  i < aNode s.length;  i++ )
        582                             {
        583                                      if ( utf 8Compare(a Nodes[i].s trTagName, a_strTagNa me) != 0 )
        584                                               continue;
        585                                      for ( va r j = 1; j  + 1 < nAr gsNum - 1;  j += 2 )
        586                                      {
        587                                               if ( utf8C ompare(aNo des[i].aAt trs[this.g etAttr.arg uments[j]] , this.get Attr.argum ents[j + 1 ]) != 0 )
        588                                                       br eak;
        589                                      }
        590                                      if ( j +  1 < nArgs Num - 1 )
        591                                               continue;
        592                                      if ( aNo des[i].aAt trs[this.g etAttr.arg uments[j]]  )
        593                                               return aNo des[i].aAt trs[this.g etAttr.arg uments[j]] ;
        594                                      else
        595                                               continue;
        596                             }
        597                             return  "";
        598                    }
        599           }
        600           
        601           th is.checkAt tr = funct ion( a_str TagName )
        602           {
        603                    var  nArgsNum =  this.chec kAttr.argu ments.leng th;
        604                    if (  nArgsNum  < 1 || nAr gsNum % 2  == 0 )
        605                             return  false;
        606                             
        607                    with ( this.cur Data )
        608                    {
        609                             for (  var i = 0;  i < aNode s.length;  i++ )
        610                             {
        611                                      if ( utf 8Compare(a Nodes[i].s trTagName,  a_strTagN ame) != 0  )
        612                                               continue;
        613                                      for ( va r j = 1; j  < nArgsNu m - 1; j + = 2 )
        614                                      {
        615                                               if ( utf8C ompare(aNo des[i].aAt trs[this.c heckAttr.a rguments[j ]], this.c heckAttr.a rguments[j  + 1]) !=  0 )
        616                                                       br eak;
        617                                      }
        618                                      if ( j <  nArgsNum  - 1 )
        619                                               continue;
        620                                      return t rue;
        621                             }
        622                             return  false;
        623                    }
        624           }
        625   }
        626  
        627   function p utDataXML(  xmlDoc, s docPath )
        628   {
        629           if (g_bServer Result==tr ue)
        630           {
        631                    g_bS erverResul t=false;
        632  
        633                    // r eceived th e search r esult
        634                    var  cRoot=xmlD oc.lastChi ld;
        635                    var  cResult=ne w HuginQue ryResult() ;
        636                    var  nIndex=1;
        637                    if(c Root)
        638                    {
        639                             var cN ode=cRoot. firstChild ;
        640                             while( cNode)
        641                             {
        642                                      if(cNode .nodeName= ="topic")
        643                                      {
        644                                               var cTopic =new Objec t();
        645                                               cTopic.nIn dex=nIndex ;
        646                                               cTopic.str Title=cNod e.getAttri bute("name ");
        647                                               cTopic.str Url=cNode. getAttribu te("url");
        648                                               cTopic.str Summary=cN ode.getAtt ribute("su mmary");
        649                                               cTopic.nRa nk=cNode.g etAttribut e("rank");
        650  
        651                                               cResult.aT opics[cRes ult.aTopic s.length]= cTopic;
        652                                      };
        653                                      cNode=cN ode.nextSi bling;
        654                                      nIndex=n Index+1;
        655                             };
        656                    };
        657  
        658                    disp layTopics( cResult)
        659           }e lse
        660           {
        661                    theX mlReader.r eceiveDom(  xmlDoc );
        662                    theX mlReader.b Succ = tru e;
        663                    //th eXmlReader .funcCallb ack();
        664           };
        665   }
        666  
        667   function m ergeTopicR ec(a_strPa rentRec ,  a_strNewRe c)
        668   {
        669           va r arrOldRe cords = a_ strParentR ec.split(" |");  
        670           va r arrNewRe cords = a_ strNewRec. split("|") ;     
        671                    
        672           va r mergedRe c = "" ;
        673           va r i = 0 ;
        674           va r j = 0 ;      
        675           va r arrFinal Rec = new  Array();
        676           wh ile ( i< a rrOldRecor ds.length  && j < arr NewRecords .length)
        677           {                 
        678                    var  oldTopicRe cord = get TopicDetai ls(arrOldR ecords[i]) ;
        679                    if ( oldTopicRe cord == nu ll)
        680                    {
        681                             i++;
        682                             contin ue ;
        683                    }
        684                    var  newTopicRe cord = get TopicDetai ls(arrNewR ecords[j]) ;
        685                    if ( newTopicRe cord == nu ll)
        686                    {
        687                             j++;
        688                             contin ue ;
        689                    }
        690                    if ( oldTopicRe cord.nTopi cId < newT opicRecord .nTopicId)
        691                    {
        692                             arrFin alRec[arrF inalRec.le ngth] = ar rOldRecord s[i] ;
        693                             i++ ;
        694                    }
        695                    else  if (oldTo picRecord. nTopicId >  newTopicR ecord.nTop icId)
        696                    {
        697                             arrFin alRec[arrF inalRec.le ngth] = ar rNewRecord s[j] ;
        698                             j++ ;
        699                    }
        700                    else
        701                    {
        702                             var te mp = arrOl dRecords[i ].split(": ");
        703                             var uE mphasis =   (oldTopic Record.uEm phasis > n ewTopicRec ord.uEmpha sis)?oldTo picRecord. uEmphasis: newTopicRe cord.uEmph asis;
        704                             var st rRec = old TopicRecor d.nTopicId  + "," + u Emphasis +  ":" + tem p [1] ; // since this  will not  be called  in case of  phrase se arch, we c an ignore  positions  of other r ec
        705                             arrFin alRec[arrF inalRec.le ngth] = st rRec ;
        706                             j++ ;
        707                             i++ ;
        708                    }
        709           }
        710           wh ile (i< ar rOldRecord s.length)
        711           {
        712                    arrF inalRec[ar rFinalRec. length] =  arrOldReco rds[i] ;
        713                    i++  ;
        714           }
        715           wh ile (j < a rrNewRecor ds.length)
        716           {
        717                    arrF inalRec[ar rFinalRec. length] =  arrNewReco rds[j] ;
        718                    j++  ;
        719           }
        720  
        721           if  (arrFinal Rec.length  == 0)
        722                    retu rn a_strPa rentRec ; 
        723           me rgedRec =  arrFinalRe c[0];
        724           fo r ( i = 1  ; i < arrF inalRec.le ngth ; i++ )
        725                    merg edRec += " |" + arrFi nalRec[i]  ;
        726           re turn merge dRec ;       
        727   }
        728  
        729   function g etTopicDet ails( a_st rRecord )
        730   {
        731           va r index =  a_strRecor d.indexOf( ",");
        732           if  (index ==  -1)
        733                    retu rn null ;
        734           va r nTopicId  = a_strRe cord.subst ring(0 , i ndex);
        735           va r strTopic Details =  a_strRecor d.substrin g(index+1, a_strRecor d.length);         
        736           va r aShapes  = strTopic Details.sp lit( ":" ) ;
        737           if  ( aShapes .length ==  0 )
        738                    retu rn null;
        739  
        740           va r record =  new Objec t();
        741           re cord.nTopi cId = nTop icId ;
        742           re cord.uEmph asis = par seInt( aSh apes[0] );
        743           re turn recor d ;
        744   }
        745  
        746   function o nLoadXMLEr ror()
        747   {
        748           // For Debug  & Test---- --
        749           if  ( window. gbTesting  )
        750                    retu rn;
        751           // ---------- ---------- --
        752  
        753           th eXmlReader .bSucc = f alse;
        754           // theXmlRead er.funcCal lback();
        755   }
        756  
        757   ////////// ////////// ////////// //
        758  
        759   function s plitPathNa me( a_strP ath )      //this uti lity funct ion only f it this pr oject.
        760   {
        761           va r rslt = n ew Object( );
        762           rs lt.strDir  = "";
        763           rs lt.strFile  = "";
        764           rs lt.strExt  = "";
        765  
        766           va r rg1 = /^ (.*[\\\/]) ?([^\\\/]+ )(\.[^\\\/ \.]*)$/;
        767           va r rg2 = /^ (.*[\\\/]) ?([^\\\/.] +)$/;
        768           
        769           va r v = a_st rPath.matc h( rg1 );
        770           if  ( v != nu ll )
        771           {
        772                    rslt .strDir =  v[1];
        773                    rslt .strFile =  v[2];
        774                    rslt .strExt =  v[3];
        775           }
        776           el se
        777           {
        778                    v =  a_strPath. match( rg2  );
        779                    rslt .strDir =  v[1];
        780                    rslt .strFile =  v[2];
        781                    rslt .strExt =  "";
        782           }
        783           re turn rslt;
        784   }
        785  
        786   function g etAbsPath(  a_strBase Path, a_st rRelPath )
        787   {
        788           va r sf = spl itPathName ( a_strBas ePath );
        789           re turn sf.st rDir + a_s trRelPath;
        790   }
        791  
        792   // HuginCo ntext.js-- ---------- ---------- --------
        793  
        794   function H uginContex t()
        795   {
        796           th is.aTasks  = new Arra y();
        797  
        798           th is.bExecut ing = fals e;
        799           th is.bCallBa ck = false ;
        800           th is.bCallBa ckReady =  false;
        801  
        802           th is.nLastTi me = 0;
        803  
        804           th is.bError  = false;
        805           th is.bCancel  = false;
        806           th is.strMsg  = null;
        807           th is.bPause  = false;
        808  
        809           th is.reset =  function( )
        810           {
        811                    this .aTasks.le ngth = 0;
        812  
        813                    this .bExecutin g = false;
        814                    this .bCallBack  = false;
        815                    this .bCallBack Ready = fa lse;
        816  
        817                    this .nLastTime  = 0;
        818  
        819                    this .bError =  false;
        820                    this .bCancel =  false;
        821                    this .strMsg =  null;
        822                    this .bPause =  false;
        823           }
        824  
        825           th is.push =  function()
        826           {
        827                    var  i = 0;
        828                    var  ttasks = n ew Array() ;
        829                    whil e( i < con text.push. arguments. length )
        830                    {
        831                             var nL en = ttask s.length;
        832                             ttasks [nLen] = n ew Object( );
        833                             ttasks [nLen].fun c = contex t.push.arg uments[i];
        834                             ttasks [nLen].own er = conte xt.push.ar guments[i  + 1];
        835                             i += 2 ;
        836                             var bS uspend = f alse;
        837                             if ( i  < context .push.argu ments.leng th &&
        838                                       context .push.argu ments[i].c onstructor .toString( ).search(  /^\nfuncti on Boolean / ) == 0 )
        839                             {
        840                                      var bSus pend = con text.push. arguments[ i];
        841                                      ++i;
        842                             }
        843                             ttasks [nLen].bSu spend = bS uspend;
        844                    }
        845                    for  ( i = ttas ks.length  - 1; i >=  0; --i )
        846                             contex t.aTasks[c ontext.aTa sks.length ] = ttasks [i];
        847           }
        848  
        849           th is.pop = f unction()
        850           {
        851                    if (  context.a Tasks.leng th == 0 )
        852                             return  null;
        853                    
        854                    var  task = con text.aTask s[context. aTasks.len gth - 1];
        855                    cont ext.aTasks .length--;         
        856                    retu rn task;
        857           }
        858  
        859           th is.initTim e = functi on()
        860           {
        861                    cont ext.nLastT ime = ( ne w Date() ) .getTime() ;
        862           }
        863           
        864           th is.needBre athe = fun ction()
        865           {
        866                    var  nCurTime =  ( new Dat e() ).getT ime();
        867                    retu rn nCurTim e - contex t.nLastTim e >= 100;
        868           }
        869  
        870           th is.resume  = function ()
        871           {
        872                    if (  context.b Executing  )
        873                    {
        874                             if ( c ontext.bCa llBack )
        875                                      context. bCallBackR eady = tru e;
        876                             return ;
        877                    }
        878           
        879                    cont ext.bExecu ting = tru e;
        880                    cont ext.bPause  = false;
        881                    cont ext.initTi me();
        882                    whil e ( true )
        883                    {
        884                             if ( c ontext.bCa ncel )
        885                             {
        886                                      context. bExecuting  = false;
        887                                      g_CurSta te = ECS_C ANCELED;
        888                                      updateRe sultView() ;
        889                                      return t rue;
        890                             }
        891                             
        892                             var ta sk = conte xt.pop();
        893                             if ( t ask == nul l )
        894                             {        //All ta sks were f inished.
        895                                      context. bExecuting  = false;
        896                                      return t rue;
        897                             }
        898  
        899                             contex t.bCallBac k = task.b Suspend;
        900                             task.f unc( conte xt, task.o wner, cont ext.resume  );        //If it is  not a sus pend task,  the 3rd a rgument wi ll be igno red.
        901                             if ( c ontext.bEr ror )
        902                             {        //Failed . Stop exe cuting.
        903                                      context. bExecuting  = false;
        904                                      g_CurSta te = ECS_F ATALERROR;
        905                                      updateRe sultView() ;
        906                                      return;
        907                             }
        908  
        909                             if ( c ontext.bCa llBack &&  !context.b CallBackRe ady )
        910                             {        //Callba ck functio n not fini shed. Give  the resum e right to  it.
        911                                      context. bExecuting  = false;
        912                                      return;
        913                             }
        914                             contex t.bCallBac k = false;
        915                             contex t.bCallBac kReady = f alse;
        916  
        917                             if( co ntext.bPau se )
        918                             {
        919                                      context. bExecuting  = false;
        920                                      updateRe sultView() ;
        921                                      return;
        922                             }
        923  
        924                             if ( c ontext.nee dBreathe()  )
        925                             {        //Give G UI a chanc e to proce ss message s.
        926                                      context. bExecuting  = false;
        927                                      updateRe sultView() ;
        928                                      if(gbAIR )
        929                                               context.re sume();
        930                                      else set Timeout( " context.re sume();",  1 );
        931                                      return;
        932                             }
        933                    }
        934           }
        935           
        936           th is.pause =  function( )
        937           {
        938                    cont ext.bPause  = true;
        939           }
        940           
        941           th is.stop =  function()
        942           {
        943                    cont ext.bCance l = true;
        944           }
        945   }
        946  
        947   // Base64. js-------- ---------- ---------- --------
        948  
        949   var XX = 1 27;            //mark  for not u sed
        950  
        951   var s_strB ase64 = "A BCDEFGHIJK LMNOPQRSTU VWXYZabcde fghijklmno pqrstuvwxy z012345678 9+/";
        952   var s_aAsc iiToBase64  = new Arr ay
        953   (
        954           XX ,     XX,      XX,      XX,      XX,     XX ,     XX,      XX,      XX,      XX,     XX ,     XX,      XX,      XX,      XX,     XX ,              //  00 ~0F
        955           XX ,     XX,      XX,      XX,      XX,     XX ,     XX,      XX,      XX,      XX,     XX ,     XX,      XX,      XX,      XX,     XX ,              //  10 ~1F
        956           XX ,     XX,      XX,      XX,      XX,     XX ,     XX,      XX,      XX,      XX,     XX ,     62,      XX,      XX,      XX,     63 ,              //  20 ~2F        '+'=62, '/ '=63
        957           52 ,     53,      54,      55,      56,     57 ,     58,      59,      60,      61,     XX ,     XX,      XX,      XX,      XX,     XX ,              //  30 ~3F        '0'=52 to  '9'=61
        958           XX ,     0,       1,       2,       3,      4,       5,       6,       7,       8,      9,       10,      11,      12,      13,     14 ,              //  40 ~4F        'A'=0 to ' O'=14
        959           15 ,     16,      17,      18,      19,     20 ,     21,      22,      23,      24,     25 ,     XX,      XX,      XX,      XX,     XX ,              //  50 ~5F        'P'=15 to  'Z'=25
        960           XX ,     26,      27,      28,      29,     30 ,     31,      32,      33,      34,     35 ,     36,      37,      38,      39,     40 ,              //  60 ~6F        'a'=26 to  'o'=40
        961           41 ,     42,      43,      44,      45,     46 ,     47,      48,      49,      50,     51 ,     XX,      XX,      XX,      XX,     XX                //  70 ~7F        'p'=41 to  'z'=51
        962   );
        963   var s_aOdi nToAscii =  new Array
        964   (       //  the first  the char  is '\0', s o that s_a OdinToAsci i[0] means  end of st ring
        965           '\ 0', '0', ' 1', '2', ' 3', '4', ' 5', '6',
        966           '7 ', '8', '9 ', '|', ': ', ',', '\ 0', '\0'
        967   );
        968  
        969   var s_aBas e64DecodeM ap = new A rray();
        970  
        971   function _ decordBase 64ToStr( a _nA, a_nB  )
        972   {
        973           va r uBuf = (  s_aAsciiT oBase64[a_ nA] << 6 )  + s_aAsci iToBase64[ a_nB];
        974           va r strRslt  = "";
        975           va r uCur = 0 ;
        976           fo r ( var i  = 0; i <=  8; i += 4  )
        977           {        
        978                    uCur  = uBuf >>  ( 8 - i )  & 0x000F;
        979                    if (  uCur == 0  )
        980                             return  strRslt;
        981                    strR slt += s_a OdinToAsci i[uCur];
        982           }
        983           re turn strRs lt;
        984   }
        985  
        986   // Decode  a base64 f ormatted s tring into  an odin f ormatted o ne (only c ontains ch aractors o ccur in s_ strBase64
        987   // [in]a_s trBase64:      Base64  formatted  string;
        988   // RESULT:                         Odin for matted str ing;
        989   function d ecodeBase6 4ToOdin( a _strBase64  )
        990   {
        991           va r nLen = a _strBase64 .length;
        992           va r strRslt  = "";
        993           va r str = 0;
        994           fo r ( var i  = 0; i + 1  < nLen; i  += 2 )
        995           {
        996                    str  = s_aBase6 4DecodeMap [( a_strBa se64.charC odeAt( i )  << 8 ) +  a_strBase6 4.charCode At( i + 1  )]
        997                    if (  !str )               return str Rslt;
        998                    strR slt += str ;
        999           }
        1000           if  ( i < nLe n )
        1001           {
        1002                    str  = s_aBase6 4DecodeMap [( a_strBa se64.charC odeAt( i )  << 8 ) +  s_strBase6 4.charCode At( 0 )]
        1003                    if (  !str )               return str Rslt;
        1004                    strR slt += str ;
        1005           }
        1006           re turn strRs lt;
        1007   }
        1008  
        1009   function i nitBase64D ecodeMap()
        1010   {
        1011           va r i, j;
        1012           fo r ( i = 0;  i < 64; i ++ )
        1013                    for  ( j = 0; j  < 64; j++  )
        1014                             s_aBas e64DecodeM ap[( s_str Base64.cha rCodeAt( i  ) << 8 )  + s_strBas e64.charCo deAt( j )]  = _decord Base64ToSt r( s_strBa se64.charC odeAt( i ) , s_strBas e64.charCo deAt( j )  );
        1015           fo r ( i = 0;  i < 64; i ++ )
        1016                    s_aB ase64Decod eMap[s_str Base64.cha rCodeAt( i  ) << 8] =  _decordBa se64ToStr(  s_strBase 64.charCod eAt( i ),  s_strBase6 4.charCode At( 0 ) );
        1017   }
        1018  
        1019   initBase64 DecodeMap( );
        1020  
        1021   // HuginPa ckageReade r.js------ ---------- --------
        1022  
        1023   function H uginStemRe cordTopicS hape()
        1024   {
        1025           th is.aPositi ons = null ;
        1026   }
        1027  
        1028   function H uginStemRe cordTopic( )
        1029   {
        1030           th is.uEmphas is = null;
        1031           th is.aShapes  = null;
        1032   }
        1033  
        1034   function H uginStemRe cord()
        1035   {
        1036           th is.aTopics  = null;
        1037   }
        1038  
        1039   function H uginPackag eReaderRes ult()
        1040   {
        1041           th is.strNefS tem = null ;
        1042           th is.strReco rd = null;
        1043           th is.bStopWo rd = null  ;
        1044   }
        1045  
        1046   function H uginPackag eReader()
        1047   {
        1048           th is.strPack agePath =  null;                       //in
        1049           th is.strSyno nymPath =  null ;             // in
        1050           th is.recordR esult = nu ll;                         //ou t
        1051           th is.strQuer yWord = nu ll;            //in
        1052           th is.bPhrase Search = f alse ;
        1053           th is.bSucc =  true;
        1054  
        1055           th is.prepare Query = fu nction()
        1056           {
        1057                    this .recordRes ult = null ;                         //out
        1058                    this .bSucc = t rue;
        1059                    this .strQueryW ord = null ;
        1060                    this .bPhraseSe arch = fal se ;
        1061           }
        1062  
        1063           th is.loadFro mFile = fu nction( a_ Context, a _this, a_f uncCallbac k )
        1064           {
        1065                    theX mlReader.l oadFromFil e(a_Contex t, a_funcC allback, f alse );
        1066           }
        1067  
        1068           th is.pickSyn onyms = fu nction( a_ strStem )
        1069           {
        1070                    retu rn theXmlR eader.getS ynonyms(a_ strStem).s plit( ","  );
        1071           }
        1072           
        1073           th is.setSyno nymForHigh lighting =  function(  a_Context , a_this )
        1074           {
        1075                    if (  !theXmlRe ader.bSucc  )
        1076                    {
        1077                             return ;
        1078                    }
        1079                    var  strSyn = " ";
        1080                    var  arySynonym s = a_this .pickSynon yms( a_thi s.strQuery Word );
        1081                    for  ( var i =  0; i < ary Synonyms.l ength; ++i  )
        1082                    {
        1083                             strSyn  += " " +  arySynonym s[i];                   
        1084                    }
        1085                    if ( (strSyn ==  "")||(str Syn == " " ))
        1086                             return  ;
        1087                    if(! gbAIRSSL)
        1088                    {
        1089                             var oR esMsg = ne w whMessag e( WH_MSG_ SETSYNSTR,  strSyn, n ull );
        1090                             notify ( oResMsg  );
        1091                    }
        1092                    else
        1093                    {
        1094                         gbAIRSynon ymString =  strSyn;
        1095                    }        
        1096           }
        1097  
        1098  
        1099           th is.doQuery WordRecord  = functio n( a_Conte xt, a_this  )
        1100           {
        1101                    if (  !theXmlRe ader.bSucc  )
        1102                    {
        1103                             a_Cont ext.strMsg  = gsLoadX mlFailed;
        1104                             a_Cont ext.bError  = true;
        1105                             return ;
        1106                    }
        1107  
        1108                    if (  !a_this.b Succ )
        1109                             return ;
        1110                             
        1111                    //       By Lei n 4:59 PM  7/15/2004
        1112                    a_th is.recordR esult = ne w HuginPac kageReader Result();
        1113                    var  strRecord  = theXmlRe ader.getWo rdRec(a_th is.strQuer yWord,a_th is.bPhrase Search);
        1114                    if (  strRecord  == null )
        1115                             return ;
        1116                    a_th is.recordR esult.bSto pWord = fa lse;
        1117                    a_th is.recordR esult.strN efStem = a _this.strQ ueryWord;
        1118                    a_th is.recordR esult.strR ecord = st rRecord;
        1119                    if ( strRecord  == "" )
        1120                    {
        1121                             a_this .bSucc = f alse;
        1122                             return ;
        1123                    }
        1124                    a_th is.bSucc =  true;
        1125                    theX mlReader.s trFilePath  = a_this. strSynonym Path;
        1126                    a_Co ntext.push ( a_this.l oadFromFil e, a_this,
        1127                                                       a_ this.setSy nonymForHi ghlighting , a_this ) ;              
        1128           }
        1129  
        1130           th is.query =  function(  a_Context , a_this )
        1131           {
        1132                    a_th is.bSucc =  true;
        1133                    theX mlReader.s trFilePath  = a_this. strPackage Path;
        1134                    a_Co ntext.push ( a_this.l oadFromFil e, a_this,
        1135                                                       a_ this.doQue ryWordReco rd, a_this  );
        1136           }
        1137   }
        1138  
        1139   function H uginPackag eIndexRead er()
        1140   {
        1141           th is.queryWo rd = null;                             //in
        1142           th is.strPack ageIndexPa th = null;         // in
        1143           th is.package Info = nul l;                          //ou t
        1144           th is.bSucc =  true;
        1145           th is.strCurQ uery = nul l;
        1146           th is.strPack ageInfo =  null;
        1147  
        1148           th is.prepare Query = fu nction()
        1149           {
        1150                    this .packageIn fo = null;                           //out
        1151                    this .bSucc = t rue;
        1152                    this .strCurQue ry = null;
        1153                    this .strPackag eInfo = nu ll;
        1154           }
        1155  
        1156           th is.getPack agePath =  function(  a_strSuffi x )
        1157           {
        1158                    var  sf = split PathName(  this.strPa ckageIndex Path );
        1159                    retu rn sf.strD ir + "pack age_" + a_ strSuffix  + sf.strEx t;
        1160           }
        1161           
        1162           th is.getTopi cTablePath  = functio n( a_strSu ffix )
        1163           {
        1164                    var  sf = split PathName(  this.strPa ckageIndex Path );
        1165                    retu rn sf.strD ir + "topi ctable_" +  a_strSuff ix + sf.st rExt;
        1166           }
        1167  
        1168           th is.parsePa ckageInfo  = function ( a_Contex t, a_this  )
        1169           {
        1170                    if (  !theXmlRe ader.bSucc  ||
        1171                              !theX mlReader.c heckRoot(  "cki" ) )
        1172                    {
        1173                             a_this .bSucc = f alse;                     
        1174                             return ;
        1175                    }
        1176                    var  nPackageIn dex = theX mlReader.g etPackageI ndex(a_thi s.strCurQu ery);
        1177                    if (  nPackageI ndex == nu ll || nPac kageIndex  < 0 )
        1178                    {
        1179                             a_this .packageIn fo = null;
        1180                             a_this .bSucc = f alse;                     
        1181                             return ;
        1182                    }
        1183  
        1184                    a_th is.package Info = a_t his.getPac kagePath(  nPackageIn dex );
        1185                    this .bSucc = t rue;
        1186                    retu rn ;
        1187           }
        1188           
        1189           th is.parseTo picInfo =  function(  a_Context,  a_this )
        1190           {
        1191                    if (  !theXmlRe ader.bSucc  ||
        1192                              !theX mlReader.c heckRoot(  "cki" ) )
        1193                    {
        1194                             a_this .bSucc = f alse;                     
        1195                             return ;
        1196                    }
        1197                    var  nPackageIn dex = theX mlReader.g etPackageI ndex(a_thi s.strCurQu ery);
        1198                    if (  nPackageI ndex == nu ll || nPac kageIndex  < 0 )
        1199                    {
        1200                             a_this .packageIn fo = null;
        1201                             a_this .bSucc = f alse;                     
        1202                             return ;
        1203                    }
        1204  
        1205                    a_th is.package Info = a_t his.getTop icTablePat h( nPackag eIndex );
        1206                    this .bSucc = t rue;
        1207                    retu rn ;
        1208           }
        1209           
        1210           th is.loadFro mFile = fu nction( a_ Context, a _this, a_f uncCallbac k )
        1211           {
        1212                    theX mlReader.l oadFromFil e(a_Contex t, a_funcC allback ,  false);
        1213           }
        1214  
        1215           th is.queryPa ckageInfo  = function ( a_Contex t, a_this  )
        1216           {
        1217                    a_th is.bSucc =  true;
        1218                    theX mlReader.s trFilePath  = a_this. strPackage IndexPath;
        1219                    a_Co ntext.push ( a_this.l oadFromFil e, a_this,
        1220                                                       a_ this.parse PackageInf o, a_this  );
        1221           }
        1222           
        1223           th is.queryTo picInfo =  function(  a_Context,  a_this )
        1224           {
        1225                    a_th is.bSucc =  true;
        1226                    theX mlReader.s trFilePath  = a_this. strPackage IndexPath;
        1227                    a_Co ntext.push ( a_this.l oadFromFil e, a_this,
        1228                                                       a_ this.parse TopicInfo,  a_this );
        1229           }
        1230   }
        1231  
        1232   function H uginTopicT ableReader ()
        1233   {
        1234           th is.nQueryI d = null;                              //in
        1235           th is.strTopi cTablePath  = null;           // in
        1236           th is.lastInd ex = -1;
        1237           th is.topicIn fo = null;                             //ou t
        1238           th is.bSucc =  true;
        1239           th is.strTopi cInfo = nu ll;
        1240           th is.strTopi cContext =  null;
        1241           th is.topicMa p = null ;
        1242           th is.curTopi cIndex = n ull ;
        1243           
        1244           th is.prepare Query = fu nction()
        1245           {
        1246                    this .bSucc = t rue;
        1247                    this .strTopicI nfo = null ;                
        1248           }
        1249           
        1250           th is.loadFro mFile = fu nction( a_ Context, a _this, a_f uncCallbac k )
        1251           {
        1252                    theX mlReader.l oadFromFil e(a_Contex t, a_funcC allback );
        1253           }
        1254  
        1255           th is.process ReaderResu lt = funct ion( a_Con text, a_th is )
        1256           {
        1257                    if (  !theXmlRe ader.bSucc  ||
        1258                              !theX mlReader.c heckRoot(  "ck" ) )
        1259                    {
        1260                             a_this .bSucc = f alse;
        1261                             a_this .bInited =  false;
        1262                             return ;
        1263                    }
        1264                    var  queryId =  a_this.nQu eryId ;
        1265                    if ( a_this.cur TopicIndex  > 0 )
        1266                         queryId =  queryId -  a_this.top icMap[a_th is.curTopi cIndex -1  ] ;
        1267                    var  topicInfo  = theXmlRe ader.getTo picRec(que ryId);
        1268                    a_th is.strTopi cInfo = to picInfo.rd ;
        1269                    a_th is.strTopi cContext =  topicInfo .ct;
        1270           }
        1271  
        1272           th is.parseTo picInfo =  function(  a_Context,  a_this )
        1273           {
        1274                    if (  !a_this.b Succ )
        1275                             return ;
        1276  
        1277                    a_th is.topicIn fo = new O bject();
        1278                    var  v = a_this .strTopicI nfo.split(  "|" );
        1279                    if (  v.length  < 2 || v[0 ] == "" ||  v[1] == " " )
        1280                    {
        1281                             a_this .bSucc ==  false;
        1282                             return ;
        1283                    }
        1284                    a_th is.topicIn fo.strUrl  = v[0];
        1285                    a_th is.topicIn fo.strTitl e = v[1];
        1286           }
        1287  
        1288           th is.queryTo picInfo =  function(  a_Context,  a_this )
        1289           {
        1290                    for  (var i = 0  ; i < a_t his.topicM ap.length  ; i++)
        1291                    {
        1292                             if (a_ this.nQuer yId < a_th is.topicMa p[i] )
        1293                                      break ;                   
        1294                    }
        1295                    if ( i >= a_thi s.topicMap .length)
        1296                    {
        1297                             a_this .bSucc ==  false;
        1298                             return ;
        1299                    }
        1300                    a_th is.curTopi cIndex = i  ;
        1301                    var  topictable filename =  "topictab le_" + i +  ".xml" ;
        1302           if (i != a_th is.lastInd ex)
        1303                    {
        1304                             a_this .lastIndex  = i;
        1305                             theXml Reader.str FilePath =  getAbsPat h( a_this. strTopicTa blePath, t opictablef ilename );
        1306                             a_Cont ext.push(  a_this.loa dFromFile,  a_this,
        1307                                                       a_ this.proce ssReaderRe sult, a_th is,
        1308                                                       a_ this.parse TopicInfo,  a_this );
        1309                    }
        1310                    else
        1311                    {
        1312                             a_Cont ext.push(  a_this.pro cessReader Result, a_ this,
        1313                                                       a_ this.parse TopicInfo,  a_this );
        1314                    }
        1315           }
        1316           
        1317           th is.makeInd exMap = fu nction( a_ Context, a _this )
        1318           {
        1319                    a_th is.topicMa p = new Ar ray() ;
        1320                    var  prev = 0 ;
        1321                    for  (var i = 0 ; i < theX mlReader.g etNumOfNod es() ; i++ )
        1322                    {
        1323                             a_this .topicMap[ i] = theXm lReader.ge tNumOfTopi cs(i) + pr ev;
        1324                             prev =  a_this.to picMap[i]  ;
        1325                    }                 
        1326           }
        1327           
        1328           th is.prepare Map  = fun ction( a_C ontext, a_ this )
        1329           {
        1330                    a_th is.bSucc =  true;
        1331                    theX mlReader.s trFilePath  =  a_this .strTopicT ablePath;
        1332                    a_Co ntext.push ( a_this.l oadFromFil e, a_this,
        1333                                                       a_ this.makeI ndexMap, a _this);
        1334           }
        1335   }
        1336  
        1337   // HuginDa tabase.js- ---------- ---------- --------
        1338  
        1339   function H uginDataba se()
        1340   {
        1341           th is.strOdbP ath = "";                     // in
        1342  
        1343           th is.queryWo rd = null;                    // in
        1344           th is.bNeedSt opWord = f alse;              // in
        1345           th is.recordR esult = nu ll;                // out
        1346           th is.eType =  null ;               //in
        1347           th is.aQueryT opics = nu ll;                // in out
        1348  
        1349           th is.bSucc =  false;
        1350           th is.bInited  = false;
        1351           
        1352           th is.strTopi cTablePath  = null;
        1353           th is.strPack ageIndexPa th = null;
        1354           th is.strSyno nymPath =  null ;
        1355           th is.package Info = nul l;
        1356           
        1357           th is.iCurTop ic = null;
        1358  
        1359           th is.package IndexReade r = new Hu ginPackage IndexReade r();
        1360           th is.package Reader = n ew HuginPa ckageReade r();
        1361           th is.topicRe ader = new  HuginTopi cTableRead er();
        1362  
        1363           th is.prepare Query = fu nction()
        1364           {
        1365                    this .recordRes ult = null ;
        1366                    this .bSucc = t rue;
        1367                    
        1368                    this .packageIn fo = null;
        1369                    
        1370                    this .iCurTopic  = 0;
        1371  
        1372                    this .packageIn dexReader. prepareQue ry();
        1373                    this .packageRe ader.prepa reQuery();
        1374                    this .topicRead er.prepare Query();
        1375                    this .eType = E SNT_DEFAUL T ;
        1376           }
        1377  
        1378           th is.getInde xUrl = fun ction( a_s trIndexTyp e )
        1379           {
        1380                    var  strRelPath  = theXmlR eader.getA ttr( "inde x", "type" , a_strInd exType, "u rl" );
        1381                    if (  strRelPat h == "" )
        1382                             return  "";
        1383  
        1384                    retu rn getAbsP ath( this. strOdbPath , strRelPa th );
        1385           }
        1386  
        1387           th is.readOdb Info = fun ction( a_C ontext, a_ this )
        1388           {
        1389                    if (  !theXmlRe ader.bSucc  ||
        1390                              !theX mlReader.c heckRoot(  "odb" ) )
        1391                    {
        1392                             a_this .bSucc = f alse;
        1393                             a_this .bInited =  false;
        1394                             return ;
        1395                    }
        1396                                              
        1397                    a_th is.strTopi cTablePath  = a_this. getIndexUr l( "TopicI ndex" );
        1398                    a_th is.strPack ageIndexPa th = a_thi s.getIndex Url( "Pack ageIndex"  );
        1399                    a_th is.strSyno nymPath =  a_this.get IndexUrl(  "Synonym"  );
        1400  
        1401                    if (  a_this.st rTopicTabl ePath == " " || a_thi s.strPacka geIndexPat h == ""  | | a_this.s trSynonymP ath == "")
        1402                    {
        1403                             a_this .bSucc = f alse;
        1404                             a_this .bInited =  false;
        1405                             return ;
        1406                    }
        1407                    else
        1408                    {
        1409                             a_this .bSucc = t rue;
        1410                             a_this .bInited =  true;
        1411                    }
        1412           }
        1413  
        1414           th is.loadFro mFile = fu nction( a_ Context, a _this, a_f uncCallbac k )
        1415           {
        1416                    theX mlReader.l oadFromFil e(a_Contex t, a_funcC allback );
        1417           }
        1418  
        1419           th is.queryRe cordInPack age = func tion( a_Co ntext, a_t his )
        1420           {
        1421                    if (  !a_this.p ackageInde xReader.bS ucc )
        1422                             return ;
        1423  
        1424                    a_th is.package Info = a_t his.packag eIndexRead er.package Info;
        1425                    a_th is.package Reader.str PackagePat h = a_this .packageIn fo;
        1426                    a_th is.package Reader.str SynonymPat h = a_this .strSynony mPath ;
        1427                    a_th is.package Reader.bPh raseSearch  = (a_this .eType ==  ESNT_PHRAS E);
        1428                    if ( gsSubstrSr ch)
        1429                             a_this .packageRe ader.strQu eryWord =  a_this.que ryWord.str Normalized Org;
        1430                    else
        1431                             a_this .packageRe ader.strQu eryWord =  a_this.que ryWord.str HelStem;                  //use  stem in ca se substri ng search  is off
        1432                    a_Co ntext.push ( a_this.p ackageRead er.query,  a_this.pac kageReader  );
        1433           }
        1434           
        1435           th is.makeRes ult = func tion( a_Co ntext, a_t his )
        1436           {
        1437                    if (  !a_this.p ackageInde xReader.bS ucc ||
        1438                              !a_th is.package Reader.bSu cc )
        1439                    {
        1440                             a_this .bSucc = f alse;
        1441                    }
        1442                    a_th is.recordR esult = a_ this.packa geReader.r ecordResul t;
        1443                    if ( a_this.eTy pe == ESNT _NOT)
        1444                    {
        1445                if ((typ eof(a_this .recordRes ult)=='und efined')|| (a_this.re cordResult ==null))
        1446                {
        1447                    a_th is.bSucc =  true ;
        1448                    a_th is.recordR esult = a_ this.makeD ummyResult Rec(a_this .queryWord .strNormal izedOrg,a_ this.query Word.strHe lStem) ;
        1449                }
        1450                theXmlRe ader.strFi lePath = a _this.strT opicTableP ath;
        1451                a_Contex t.push( a_ this.loadF romFile, a _this,
        1452                                                       a_ this.makeN otResult,  a_this );              
        1453                    }     
        1454           }
        1455           
        1456           th is.makeDum myResultRe c = functi on(strOrg,  strStem)
        1457           {
        1458                var reco rdResult =  new Objec t();
        1459                recordRe sult.strRe cord = ""  ;
        1460                recordRe sult.strNe fStem = st rStem ;
        1461                recordRe sult.bStop Word = fal se ;
        1462                return r ecordResul t ;
        1463           }
        1464           
        1465           th is.makeNot Result = f unction( a _Context,  a_this )
        1466           {
        1467                var topi cRecs = a_ this.recor dResult.st rRecord.sp lit( "|" ) ;
        1468                var bInc ludeAll =  (a_this.re cordResult .strRecord  == "" );
        1469           va r arrTopic Ids = new  Array();
        1470           va r j ;             
        1471           fo r(j=0;j<to picRecs.le ngth;j++)
        1472           {
        1473                var pos  = topicRec s[j].index Of(",");
        1474                if(pos ! = -1)
        1475                    arrT opicIds[ar rTopicIds. length] =  topicRecs[ j].substri ng(0,pos);
        1476           }    
        1477           va r bCheck =  false ;
        1478           if (arrTopicI ds.length  > 0)
        1479                bCheck =  true ;
        1480           va r curIndex  = 0 ;          
        1481           va r sDummyTo picRec = " ,192:0,0,1 0" ;             
        1482           va r i = 0;
        1483           va r numTopic s = 0 ;
        1484                    for  (var k =0  ; k < theX mlReader.g etNumOfNod es() ; k++ )
        1485                    {
        1486                             numTop ics += the XmlReader. getNumOfTo pics(k);
        1487                    }
        1488           a_ this.recor dResult.st rRecord =  '' ;
        1489           wh ile(i < nu mTopics)
        1490           {
        1491                var bInc ludeTopic  = true ;
        1492                if (bChe ck && (cur Index < ar rTopicIds. length)&&( arrTopicId s[curIndex ]==i) && ( !bIncludeA ll))
        1493                {
        1494                    curI ndex++ ;
        1495                    bInc ludeTopic  = false ;
        1496                }
        1497                if(bIncl udeTopic)
        1498                {
        1499                    a_th is.bSucc =  true ;
        1500                    var  topicRec =  i + sDumm yTopicRec  ;
        1501                    if ( a_this.rec ordResult. strRecord  == '')
        1502                         a_this.rec ordResult. strRecord  = topicRec  ;
        1503                    else
        1504                         a_this.rec ordResult. strRecord  += "|" + t opicRec ;
        1505                }
        1506                i++ ;
        1507           }              
        1508           }
        1509           
        1510           th is.init =  function(  a_Context,  a_this )
        1511           {
        1512                    theX mlReader.s trFilePath  = a_this. strOdbPath ;
        1513                    a_Co ntext.push ( a_this.l oadFromFil e, a_this,
        1514                                                       a_ this.readO dbInfo, a_ this );
        1515           }
        1516  
        1517           th is.queryRe cord = fun ction( a_C ontext, a_ this )
        1518           {
        1519                    if (  !a_this.b Inited )
        1520                    {
        1521                             a_this .bSucc = f alse;
        1522                             return ;
        1523                    }
        1524                    a_th is.bSucc =  true;
        1525  
        1526                    a_th is.package IndexReade r.strPacka geIndexPat h = a_this .strPackag eIndexPath ;
        1527                    if ( gsSubstrSr ch)
        1528                             a_this .packageIn dexReader. strCurQuer y = a_this .queryWord .strNormal izedOrg;
        1529                    else
        1530                             a_this .packageIn dexReader. strCurQuer y = a_this .queryWord .strHelSte m;    //us e stem in  case subst ring searc h is off
        1531                    a_Co ntext.push ( a_this.p ackageInde xReader.qu eryPackage Info, a_th is.package IndexReade r,
        1532                                                       a_ this.query RecordInPa ckage, a_t his,
        1533                                                       a_ this.makeR esult, a_t his )
        1534           }
        1535           
        1536           th is.process TopicInfo  = function ( a_Contex t, a_this  )
        1537           {
        1538                    if (  !a_this.t opicReader .bSucc )
        1539                    {
        1540                             a_this .bSucc = f alse;
        1541                             return ;
        1542                    }
        1543                    a_th is.aQueryT opics[a_th is.iCurTop ic].strUrl  = a_this. topicReade r.topicInf o.strUrl;
        1544                    a_th is.aQueryT opics[a_th is.iCurTop ic].strTit le = a_thi s.topicRea der.topicI nfo.strTit le;
        1545                    a_th is.aQueryT opics[a_th is.iCurTop ic].strSum mary = a_t his.topicR eader.strT opicContex t;
        1546           }
        1547           
        1548           th is.incCurT opic = fun ction( a_C ontext, a_ this )
        1549           {
        1550                    a_th is.iCurTop ic++;
        1551           }
        1552  
        1553           th is.queryTo picInfo =  function(  a_Context,  a_this )
        1554           {
        1555                    if (  a_this.iC urTopic >=  a_this.aQ ueryTopics .length )
        1556                             return ;
        1557  
        1558                    a_th is.topicRe ader.nQuer yId = a_th is.aQueryT opics[a_th is.iCurTop ic].nTopic Id;
        1559                    a_Co ntext.push ( a_this.t opicReader .queryTopi cInfo, a_t his.topicR eader,
        1560                                                       a_ this.proce ssTopicInf o, a_this,
        1561                                                       a_ this.incCu rTopic, a_ this,
        1562                                                       a_ this.query TopicInfo,  a_this );
        1563           }
        1564  
        1565           th is.queryTo picInfos =  function(  a_Context , a_this )
        1566           {
        1567                    if (  !a_this.b Inited )
        1568                    {
        1569                             a_this .bSucc = f alse;
        1570                             return ;
        1571                    }
        1572                    a_th is.bSucc =  true;
        1573  
        1574                    a_th is.topicRe ader.strTo picTablePa th = a_thi s.strTopic TablePath;
        1575                    a_th is.iCurTop ic = 0;                                                //this is  an iterato r of a "fo r" loop
        1576                    a_th is.topicRe ader.lastI ndex = -1;
        1577                    a_Co ntext.push ( a_this.t opicReader .prepareMa p , a_this .topicRead er,
        1578                                                       a_ this.query TopicInfo,  a_this );
        1579           }
        1580   }
        1581  
        1582   // Languag eService.j s--------- ---------- --------
        1583  
        1584   function L anguageSer vice()
        1585   {
        1586           th is.getNorm alizedOrg  = function ( a_strOrg , a_Result  )
        1587           {
        1588                    var  strUpper =  a_strOrg. toUpperCas e();
        1589                    var  strLower =  a_strOrg. toLowerCas e();
        1590  
        1591                    if (  utf8Compa re(strUppe r, strLowe r) == 0 ||  utf8Compa re(strUppe r, a_strOr g) != 0 )
        1592                    {
        1593                             a_Resu lt.strNorm alizedOrg  = strLower ;
        1594                             a_Resu lt.bUpperC ase = fals e;
        1595                    }
        1596                    else
        1597                    {
        1598                             a_Resu lt.strNorm alizedOrg  = strUpper ;
        1599                             a_Resu lt.bUpperC ase = true ;
        1600                    }
        1601           }
        1602           th is.stemWit h = functi on( a_strW ord, a_str Suffix )
        1603           {
        1604                    var  s = a_strS uffix.spli t( "," );
        1605                    var  strSuffix  = s[0];
        1606                    var  bRemoveOnl y = ( s[1]  == '1' );
        1607                    
        1608                    var  ss = a_str Word.match ( "^..+" +  strSuffix  + "$" );
        1609                    if (  ss == nul l )
        1610                             return  null;
        1611  
        1612                    var  nLenRest =  a_strWord .length -  strSuffix. length;
        1613                    var  bAddE = fa lse;
        1614                    if (  !bRemoveO nly )
        1615                    {
        1616                             if ( ! this.isVow el( a_strW ord.charAt ( nLenRest  - 1 ) ) )
        1617                             {
        1618                                      if ( a_s trWord.cha rAt( nLenR est - 1 )  == a_strWo rd.charAt(  nLenRest  - 2 ) )
        1619                                               nLenRest-- ;
        1620                                      else
        1621                                               bAddE = tr ue;
        1622                             }
        1623                    }
        1624                    
        1625                    var  strStem =  a_strWord. substr( 0,  nLenRest  );
        1626                    
        1627                    if (  strStem.l ength < 2  || (( strS tem.length  == 2) &&  !bAddE ) )
        1628                             return  null;
        1629  
        1630                    //if  ( strStem .length <=  2 )
        1631                             //retu rn null;
        1632                             
        1633                    retu rn strStem ;
        1634           }
        1635           th is.helStem  = functio n( a_Resul t )
        1636           {
        1637                    var  strWord =  a_Result.s trNormaliz edOrg.toLo werCase();
        1638  
        1639                    var  nSuffixNum  = g_Runes HelSuffixe s.length;
        1640                    var  nStemFound  = 0;
        1641                    var  strStem =  null;
        1642                    for  ( var i =  0; i < nSu ffixNum; i ++ )
        1643                    {
        1644                             strSte m = this.s temWith( s trWord, g_ RunesHelSu ffixes[i]  );
        1645                             if ( s trStem !=  null )
        1646                             {
        1647                                      nStemFou nd = i + 1 ;
        1648                                      break;
        1649                             }
        1650                    }
        1651                    if (  strStem = = null )
        1652                             strSte m = strWor d;
        1653  
        1654                    a_Re sult.strHe lStem = st rStem;
        1655                    a_Re sult.nHelW ordShape =  a_Result. bUpperCase  ? nStemFo und * 2 +  1 : nStemF ound * 2;
        1656           }
        1657           th is.isVowel  = functio n( a_ch )
        1658           {
        1659                    retu rn g_Runes Vowels.ind exOf( a_ch  ) >= 0;
        1660           }
        1661           th is.isWordB reak = fun ction( a_c h )
        1662           {
        1663                    retu rn ( !this .isQuote(  a_ch ) &&  g_RunesWor dBreaks.in dexOf( a_c h ) >= 0 ) ;
        1664           }
        1665           th is.isWhite Space = fu nction( a_ ch )
        1666           {
        1667                    retu rn ( g_Run esWhiteSpa ces.indexO f( a_ch )  >= 0 );
        1668           }
        1669           th is.isSpeci alBreak =  function(  a_ch )
        1670           {
        1671                    retu rn ( g_Run esSpecialB reaks.inde xOf( a_ch  ) >= 0 );
        1672           }        
        1673           th is.isCJKCo dePoint =  function(  a_ch )
        1674           {
        1675                    //fr om http:// en.wikiped ia.org/wik i/Plane_%2 8Unicode%2 9
        1676                    if (  (typeof(a _ch) == "u ndefined"  ) || (a_ch  == "" ) )
        1677                             return  false ;
        1678                    var  val = a_ch .charCodeA t(0)    ;
        1679                                      
        1680                    retu rn (  ((0x 2E80 <= va l) &&  ( v al <= 0x9F FF)) //Eas t Asian sc ripts and  symbols
        1681                                       || ((0x F900 <= va l) &&  ( v al <= 0xFA FF))  //CJ K Compatib ility Ideo graphs
        1682                                       || ((0x FE30 <= va l) &&  ( v al <= 0xFE 4F))        //CJK Com patibility  Forms 
        1683                                       || ((0x FF00 <= va l) &&  ( v al <= 0xFF EF)) ); // Halfwidth  and Fullwi dth Forms  (FF00–FF EF)
        1684           }
        1685           th is.isQuote  = functio n( a_ch )
        1686           {
        1687                    retu rn ( a_ch  == g_Runes Quote );
        1688           }
        1689           th is.isAND =  function(  a_strOp )
        1690           {        retu rn ( a_str Op == "and " );    }
        1691           th is.isOR =  function(  a_strOp )
        1692           {        retu rn ( a_str Op == "or"  );              }
        1693           th is.isNOT =  function(  a_strOp )
        1694           {        retu rn ( a_str Op == "not " );    }
        1695           th is.isOpera tor = func tion( strO p )
        1696           {        if (  strOp ==  "and" ||
        1697                              strOp  == "or" | |
        1698                              strOp  == "not"  )
        1699                             return  true;
        1700           }
        1701   }
        1702  
        1703   // Runes.j s--------- ---------- ---------- -----
        1704  
        1705   var     ES NT_AND                  = 1;
        1706   var     ES NT_OR                   = 2;
        1707   var     ES NT_NOT                  = 3;
        1708   var     ES NT_DEFAULT     = 4;
        1709   var     ES NT_PHRASE               = 5;
        1710  
        1711   function R unesContex t( a_strSr c )
        1712   {
        1713           th is.strSrc  = a_strSrc ;
        1714           th is.nCur =  0;
        1715           th is.bFailed  = false;
        1716           th is.bNot =  false;
        1717           th is.nWordIn dex = 0;
        1718           
        1719           th is.getCurC har = func tion()
        1720           {
        1721                    retu rn this.st rSrc.charA t( this.nC ur );
        1722           }
        1723           th is.getChar  = functio n( i )
        1724           {
        1725                    retu rn this.st rSrc.charA t( i );
        1726           }
        1727           th is.reachEn d = functi on()
        1728           {
        1729                    retu rn this.nC ur >= this .strSrc.le ngth;
        1730           }
        1731   }
        1732  
        1733   function D olWord( a_ strWord, a _nPosition  )
        1734   {
        1735           th is.strWord              = a_strW ord;
        1736           th is.nPositi on           = a_nPos ition;
        1737   }
        1738  
        1739   function S olNode(){}
        1740  
        1741   function R unesServic e()
        1742   {
        1743           th is.langSev  = new Lan guageServi ce();
        1744           
        1745           th is.isOpera tor = func tion( a_st r, a_nFrom  )
        1746           {
        1747                    var  strOp = th is.getWord ( a_str, a _nFrom ).t oLowerCase ();
        1748  
        1749                    if (  this.lang Sev.isOper ator( strO p ) )
        1750                             return  true;
        1751  
        1752                    retu rn false;
        1753           }
        1754           
        1755           th is.getLeng thOfWordBr eak = func tion( a_st r, a_nFrom  )
        1756           {
        1757                    var  i = a_nFro m, nLen =  a_str.leng th;
        1758                    whil e ( i < nL en && this .langSev.i sWordBreak ( a_str.ch arAt( i )  ) )
        1759                             i++;
        1760                    retu rn i - a_n From;
        1761           }
        1762           
        1763           th is.getLeng thOfCJKWor dBreak = f unction( a _str, a_nF rom )
        1764           {
        1765                    var  i = a_nFro m, nLen =  a_str.leng th;
        1766                    whil e ( i < nL en && (thi s.langSev. isWordBrea k( a_str.c harAt( i )  ) || this .langSev.i sCJKCodePo int( a_str .charAt( i  ) )))
        1767                             i++;
        1768                    retu rn i - a_n From;
        1769           }
        1770  
        1771           th is.getLeng thOfWord =  function(  a_str, a_ nFrom )
        1772           {
        1773                    var  i = a_nFro m, nLen =  a_str.leng th;
        1774                    whil e ( i < nL en &&
        1775                                      !this.la ngSev.isWo rdBreak( a _str.charA t( i ) ) & &
        1776                                      !this.la ngSev.isQu ote( a_str .charAt( i  ) ) )
        1777                             ++i;
        1778                    retu rn i - a_n From;
        1779           }
        1780           
        1781           th is.getNonC JKWord = f unction( a _str, a_nF rom )
        1782           {
        1783                    var  i = a_nFro m, nLen =  a_str.leng th;
        1784                    whil e ( i < nL en &&
        1785                                      !this.la ngSev.isWo rdBreak( a _str.charA t( i ) ) & &
        1786                                      !this.la ngSev.isCJ KCodePoint ( a_str.ch arAt( i )  ) &&
        1787                                      !this.la ngSev.isQu ote( a_str .charAt( i  ) ) )
        1788                             ++i;
        1789                    var  nLen =  i  - a_nFrom;
        1790                    retu rn a_str.s ubstr( a_n From, nLen  );
        1791           }
        1792  
        1793           th is.getWord  = functio n( a_str,  a_nFrom )
        1794           {
        1795                    var  nLen = thi s.getLengt hOfWord( a _str, a_nF rom );
        1796                    retu rn a_str.s ubstr( a_n From, nLen  );
        1797           }
        1798           
        1799           th is.getTerm  = functio n( a_Conte xt, a_Rslt  )
        1800           {
        1801                    if (  this.lang Sev.isQuot e( a_Conte xt.getCurC har() ) )
        1802                    {
        1803                             a_Cont ext.nCur++ ;
        1804  
        1805                             var nL en = this. getLengthO fPhrase( a _Context.s trSrc, a_C ontext.nCu r );
        1806                             if ( n Len <= 0 )
        1807                                      return f alse;
        1808  
        1809                             if(gbE nableAndSe arch && gC hangedQuer y.length >  0 )
        1810                             {
        1811                                      a_Contex t.strSrc =  gChangedQ uery;
        1812                             }
        1813  
        1814                             a_Rslt .eType = E SNT_PHRASE ;
        1815                             a_Rslt .strTerm =  a_Context .strSrc.su bstr( a_Co ntext.nCur , nLen );
        1816                             a_Cont ext.nCur + = nLen + 1 ;
        1817                    }
        1818                    else
        1819                    {
        1820                             var nL en = this. getLengthO fDefault(  a_Context. strSrc, a_ Context.nC ur );
        1821                             if ( n Len <= 0 )
        1822                                      return f alse;
        1823  
        1824                             if(gbE nableAndSe arch && gC hangedQuer y.length >  0 )
        1825                             {
        1826                                      a_Contex t.strSrc =  gChangedQ uery;
        1827                             }
        1828  
        1829                             a_Rslt .eType = E SNT_DEFAUL T;
        1830                             a_Rslt .strTerm =  a_Context .strSrc.su bstr( a_Co ntext.nCur , nLen );
        1831                             a_Cont ext.nCur + = nLen;
        1832                    }
        1833  
        1834                    retu rn true;
        1835           }
        1836  
        1837           th is.getOper ator = fun ction( a_C ontext, a_ Rslt )
        1838           {
        1839                    if (  a_Context .reachEnd( ) )
        1840                             return  false;
        1841  
        1842                    var  strOp = th is.getWord ( a_Contex t.strSrc,  a_Context. nCur ).toL owerCase() ;
        1843  
        1844                    if (  this.lang Sev.isAND(  strOp ) )
        1845                    {
        1846                             a_Rslt .eType = E SNT_AND;
        1847                             a_Cont ext.nCur + = strOp.le ngth;
        1848                    }
        1849                    else  if ( this .langSev.i sOR( strOp  ) )
        1850                    {
        1851                             a_Rslt .eType = E SNT_OR;
        1852                             a_Cont ext.nCur + = strOp.le ngth;
        1853                    }
        1854                    else  if ( this .langSev.i sNOT( strO p ) )
        1855                    {
        1856                             a_Rslt .eType = E SNT_NOT;
        1857                             a_Cont ext.nCur + = strOp.le ngth;
        1858                    }
        1859                    else
        1860                    {
        1861                             a_Rslt .eType = E SNT_OR;
        1862                    }
        1863                    
        1864                    retu rn true;
        1865           }
        1866  
        1867           th is.getLeng thOfPhrase  = functio n( a_str,  a_nFrom )
        1868           {
        1869                    var  i = a_nFro m, nLen =  a_str.leng th;
        1870                    whil e ( i < nL en )
        1871                    {
        1872                             if ( t his.langSe v.isQuote(  a_str.cha rAt( i ) )  )
        1873                             {
        1874                                      if(gbEna bleAndSear ch)
        1875                                      {
        1876                                               var nWordB reakLen =  0;
        1877                                               nWordBreak Len = this .getLength OfWordBrea k( a_str,  i+1 );
        1878                                              
        1879                                               var str =  a_str.subs tring(i+nW ordBreakLe n, nLen);
        1880                                      
        1881                                               str = trim (str);
        1882  
        1883                                               if(str !=  "\"" && st r.length > 0)
        1884                                                       gC hangedQuer y = a_str. substring( 0, i+1) +  " AND " +  str;
        1885  
        1886                                      }
        1887                             
        1888                                      return i  - a_nFrom ;
        1889                             }
        1890                             
        1891                             ++i;
        1892                    }
        1893                    retu rn -1;
        1894           }
        1895  
        1896           th is.getLeng thOfDefaul t = functi on( a_str,  a_nFrom )
        1897           {
        1898                    var  i = a_nFro m, nLen =  a_str.leng th;
        1899                    whil e ( i < nL en &&
        1900                                      !this.is Operator(  a_str, i )  &&
        1901                                      !this.la ngSev.isQu ote( a_str .charAt( i  ) ) )
        1902                    {
        1903                             i += t his.getLen gthOfWord(  a_str, i  );
        1904                             
        1905                             if(gbE nableAndSe arch)
        1906                             {
        1907                                      var nWor dBreakLen  = 0;
        1908                                      nWordBre akLen = th is.getLeng thOfWordBr eak( a_str , i );
        1909                                      
        1910                                      var str  = a_str.su bstring(i+ nWordBreak Len, nLen) ;
        1911                                      
        1912                                      str = tr im(str);
        1913                                      
        1914                                      if(str.l ength>0)                                   
        1915                                               gChangedQu ery = a_st r.substrin g(0, i) +  " AND " +  str;
        1916                                      
        1917                                      i+=1;
        1918                                      break;
        1919                             }
        1920                             else
        1921                                      i += thi s.getLengt hOfWordBre ak( a_str,  i );
        1922                                      
        1923                                      
        1924                    }
        1925                    retu rn i - a_n From;
        1926           }
        1927  
        1928           th is.parseOp erator = f unction( a _Context,  a_Result,  a_bNotAllo wed )
        1929           {
        1930                    a_Co ntext.nCur  += this.g etLengthOf WordBreak(  a_Context .strSrc, a _Context.n Cur );
        1931  
        1932                    var  rslt = new  Object;
        1933                    if (  !this.get Operator(  a_Context,  rslt ) )
        1934                             return  false;
        1935  
        1936                    if (  rslt.eTyp e == ESNT_ NOT )
        1937                    {
        1938                             if (a_ bNotAllowe d)
        1939                             {
        1940                                 if  ( a_Conte xt.bNOT )
        1941                                 {
        1942                                          rslt .eType = E SNT_OR;
        1943                                 }
        1944                                 el se
        1945                                 {
        1946                                          a_Co ntext.bNOT  = true;
        1947                                 }
        1948                             }
        1949                             else
        1950                             {
        1951                                 a_ Context.bF ailed = tr ue;
        1952                                 re turn false  ;                        
        1953                             }
        1954                    }
        1955                    a_Re sult.eType  = rslt.eT ype;
        1956                    a_Re sult.right  = new Sol Node();
        1957                    if (  !this.par seTerm( a_ Context, a _Result.ri ght ) )
        1958                             return  false;
        1959  
        1960                    retu rn true;
        1961           }
        1962  
        1963           /* *
        1964           St art parsin g the sear ch query f rom a_Cont ext.nCur a nd check f or presenc e of a phr ase or nor mal term
        1965           Or  a term pr efixed wit h NOT oper ator. In c ase a phra se or norm al term is  encounter ed, check  for operat ors
        1966           in  the rest  of the exp ression.  
        1967           A  term can c ontain man y words fo r e.g. 
        1968           Se arch query : hello wo rld AND fi rst topic
        1969           Th is consist  of two se arch terms
        1970           1)  hello wor ld
        1971           2)  first top ic
        1972           An d each of  these term s have two  words eac h.
        1973           ** /
        1974           th is.parseTe rm = funct ion( a_Con text, a_Re sult )
        1975           {
        1976                    a_Co ntext.nCur  += this.g etLengthOf WordBreak(  a_Context .strSrc, a _Context.n Cur );
        1977  
        1978                    var  rslt = new  Object;
        1979                    if (  !this.get Term( a_Co ntext, rsl t ) )
        1980                    {
        1981                             if ((  this.parse Operator(  a_Context,  rslt, tru e ) )&&(rs lt.eType = = ESNT_NOT ))
        1982                         {
        1983                             a_Resu lt.eType =  rslt.eTyp e;
        1984                             if (rs lt.right.e Type == ES NT_DEFAULT )
        1985                             {
        1986                                      a_Result .strTerm =  rslt.righ t.strTerm;   
        1987                                      return t rue ;                
        1988                                 }
        1989                                 el se
        1990                                 {
        1991                                      a_Contex t.bFailed  = true;
        1992                                      return f alse;
        1993                                 }
        1994                         }
        1995                         else
        1996                         {
        1997                             a_Cont ext.bFaile d = true;
        1998                                 re turn false ;
        1999                         }                    
        2000                    }
        2001  
        2002                    if (  this.pars eOperator(  a_Context , a_Result , false )  )
        2003                    {
        2004                             a_Resu lt.left =  new SolNod e();
        2005                             a_Resu lt.left.eT ype = rslt .eType;
        2006                             a_Resu lt.left.st rTerm = rs lt.strTerm ;
        2007                    }
        2008                    else
        2009                    {
        2010                             a_Resu lt.eType =  rslt.eTyp e;
        2011                             a_Resu lt.strTerm  = rslt.st rTerm;
        2012                    }
        2013                    
        2014                    retu rn true;
        2015           }
        2016  
        2017           th is.extract Term = fun ction( a_C ontext, a_ Term )
        2018           {
        2019                    a_Te rm.aWords  = new Arra y();
        2020                    var  termType =  a_Term.eT ype ;
        2021                    
        2022                    this .dolSegmen t( a_Term  );
        2023                    if ( (termType  == ESNT_NO T ) && ( a _Term.eTyp e == ESNT_ PHRASE))
        2024                             return  false ; / /change in  term type  to pharse  means CJK  search; n ot allowed  for not o perator
        2025  
        2026                    if (  a_Term.aW ords.lengt h == 0 )
        2027                             return  false;
        2028  
        2029                    if(a _Term.eTyp e != ESNT_ PHRASE)
        2030                    {
        2031                             //if s earch type  is not ph rase searc h, remove  special br eak charac ters
        2032                             var j  =0;
        2033                             for (  var i = 0;  i < a_Ter m.aWords.l ength; i++  )
        2034                             {
        2035                                      if(!this .langSev.i sSpecialBr eak( a_Ter m.aWords[i ].strWord. charAt( 0  ) ))
        2036                                      {
        2037                                               a_Term.aWo rds[j] = a _Term.aWor ds[i];
        2038                                               j++;
        2039                                      }
        2040                             }
        2041                             a_Term .aWords.le ngth = j;
        2042                    }
        2043                    
        2044  
        2045                    for  ( var i =  0; i < a_T erm.aWords .length; i ++ )
        2046                    {
        2047                             a_Term .aWords[i] .nWordId =  a_Term.aW ords[i].nP osition +  a_Context. nWordIndex ;
        2048                    }
        2049                    a_Co ntext.nWor dIndex = a _Term.aWor ds[a_Term. aWords.len gth - 1].n WordId + 1 ;
        2050                    retu rn true;
        2051           }
        2052  
        2053           /* *
        2054           Ch eck each t erm in the  query and  break up  each term  in individ ual words.
        2055           ** /
        2056           th is.parsePh raseAndDef ault = fun ction( a_C ontext, a_ Node )
        2057           {
        2058                    if (  a_Node.eT ype == ESN T_PHRASE | | a_Node.e Type == ES NT_DEFAULT  || a_Node .eType ==  ESNT_NOT)
        2059                    {
        2060                             if ( ! this.extra ctTerm( a_ Context, a _Node ) &&
        2061                                       a_Node. eType == E SNT_PHRASE  )
        2062                                      a_Contex t.bFailed  = true;
        2063                    }
        2064                    else
        2065                    {
        2066                             this.p arsePhrase AndDefault ( a_Contex t, a_Node. left );
        2067                             this.p arsePhrase AndDefault ( a_Contex t, a_Node. right );
        2068                    }
        2069           }
        2070  
        2071           th is.helStem  = functio n( a_strOr g, a_Resul t )
        2072           {
        2073                    this .langSev.g etNormaliz edOrg( a_s trOrg, a_R esult );
        2074                    this .langSev.h elStem( a_ Result );
        2075           }
        2076           
        2077           /* *
        2078            *  Check pre sence of a ny break c haracters  in given t erm, start ing from " cur" posit ion.
        2079            *  If the br eak charac ters prese nt are spe cial break /CJK, incl ude them i n a_Result .
        2080            *  Update po sition of  next word  and also c haracter p osition of  next non  breaking
        2081            *  character  in the te rm. 
        2082            *  Change th e term typ e to phras e, if a CJ K break is  encounter ed.
        2083            * /
        2084           th is.parseBr eakCharact ers  = fun ction( a_T erm , a_po sitions)
        2085           {
        2086                    var  a_strSrc =  a_Term.st rTerm;
        2087                    var  a_Result =  a_Term.aW ords ;  
        2088                    var  nLen = a_s trSrc.leng th;
        2089                    var  nCur = a_p ositions[" cur"];
        2090                    var  nPosition  = a_positi ons["pos"]  ;
        2091                    var  bCJKTerm =  false ;
        2092                    var  bCJKBreak  = false ;
        2093                    whil e ( nCur <  nLen && ( this.langS ev.isWordB reak( a_st rSrc.charA t( nCur ))  || this.l angSev.isC JKCodePoin t( a_strSr c.charAt(  nCur ))) )
        2094                    {
        2095                             
        2096                             if ( t his.langSe v.isSpecia lBreak( a_ strSrc.cha rAt( nCur  ) ) || (bC JKBreak =  this.langS ev.isCJKCo dePoint( a _strSrc.ch arAt( nCur  ))) )
        2097                             {
        2098                                      //it's a  special w ord/CJK br eak, inclu de it in s earch
        2099                                      a_Result [a_Result. length] =  new DolWor d( a_strSr c.charAt(  nCur ), nP osition );
        2100                                      nPositio n++;
        2101                                      
        2102                                      if (!bCJ KTerm && b CJKBreak)  //set the  term as CJ K term
        2103                                               bCJKTerm   = true ;
        2104                             }
        2105                             nCur++ ;
        2106                    }
        2107                    a_po sitions["c ur"] = nCu r ;
        2108                    a_po sitions["p os"] = nPo sition ;                  
        2109                    
        2110                    if ( bCJKTerm)
        2111                             a_Term .eType = E SNT_PHRASE  ;
        2112           }
        2113           
        2114           /* *
        2115           Br eak the cu rrent term  in words.
        2116           If  the term  contains C JK charact ers, treat  each one  of them
        2117           as  a seperat e word.
        2118           If  any of th e words is  a CJK cha racter, tr eat this t erm as a p hrase term .
        2119           ** /
        2120           th is.dolSegm ent = func tion( a_Te rm )
        2121           {
        2122                    var  a_strSrc =  a_Term.st rTerm;
        2123                    var  a_Result =  a_Term.aW ords ;           
        2124                    var  nLen = a_s trSrc.leng th;
        2125                    var  strWord =  "";                
        2126                    var  positions  = new Arra y();
        2127                    posi tions["cur "] = 0 ;
        2128                    posi tions["pos "] = 1 ;
        2129  
        2130                    this .parseBrea kCharacter s( a_Term,  positions  );
        2131                    
        2132                    whil e ( positi ons["cur"]  < nLen )
        2133                    {
        2134                             strWor d = this.g etNonCJKWo rd( a_strS rc, positi ons["cur"]  );
        2135                             a_Resu lt[a_Resul t.length]  = new DolW ord( strWo rd, positi ons["pos"]  );
        2136                             
        2137                             positi ons["cur"]  += strWor d.length;
        2138                             positi ons["pos"] ++ ;
        2139                             
        2140                             //chec k if we ca n find som e special  break/CJK  characters  in betwee n this and  next word           
        2141                             this.p arseBreakC haracters(  a_Term, p ositions   );
        2142                    }
        2143           }
        2144           
        2145           th is.solPars e = functi on( a_strS rc, a_Resu lt )
        2146           {
        2147                    var  context =  new RunesC ontext( a_ strSrc );
        2148                    this .parseTerm ( context,  a_Result  );
        2149  
        2150                    if (  context.b Failed )
        2151                             return  false;
        2152                             
        2153                    this .parsePhra seAndDefau lt( contex t, a_Resul t );
        2154                    if (  context.b Failed )
        2155                             return  false;
        2156  
        2157                    retu rn true;
        2158           }
        2159   }
        2160  
        2161   // HuginIn put.js---- ---------- ---------- --------
        2162  
        2163   function _ helStemNod e( a_Runes , a_Node )
        2164   {
        2165           wi th ( a_Nod e )
        2166           {
        2167                    if (  eType ==  ESNT_PHRAS E || eType  == ESNT_D EFAULT ||  eType == E SNT_NOT)
        2168                    {
        2169                             for (  var i = 0;  i < aWord s.length;  i++ )
        2170                             {
        2171                                      a_Runes. helStem( a Words[i].s trWord, aW ords[i] )
        2172                             }
        2173                    }
        2174                    else
        2175                    {
        2176                             _helSt emNode( a_ Runes, lef t );
        2177                             _helSt emNode( a_ Runes, rig ht );
        2178                    }
        2179           }
        2180   }
        2181  
        2182   function p arseQueryE xpression(  a_strQuer y )
        2183   {
        2184           va r runes =  new RunesS ervice();
        2185           va r expressi on = new S olNode();
        2186           if  ( !runes. solParse(  a_strQuery , expressi on ) )
        2187                    retu rn null;
        2188                    
        2189           _h elStemNode ( runes, e xpression  )
        2190           
        2191           re turn expre ssion;
        2192   }
        2193  
        2194  
        2195   // Ranking Calculator .js------- ---------- --------
        2196  
        2197   var     EW MT_NotMatc h                     = 0;
        2198   var     EW MT_Synonym Match                 = 1;
        2199   var     EW MT_WordMat ch                    = 2;
        2200   var     EW MT_ShapeMa tch                   = 3;
        2201  
        2202   var WEIGHT _OF_SHAPE_ MATCH                         =  0.5;
        2203   var WEIGHT _OF_SINGLE _WORD_SCOR E          = 0.5;
        2204   var HUGIN_ KEYWORD_FL AG                            =  0x0040;
        2205   var HUGIN_ TITLE_FLAG                               =  0x0080;
        2206   var WORDSH APE_SYNONY M                             =  -2;
        2207  
        2208   function _ rank_ULaw(  a_fX )
        2209   {
        2210           if  ( a_fX <  0.0 )
        2211                    retu rn 0.0;
        2212  
        2213           re turn 1.0 -  1.0 / ( a _fX + 1.0  );
        2214   }
        2215  
        2216   function _ rank_Weake n( a_fWeig ht, a_fPer cent )
        2217   {
        2218           va r fPercent  = ( a_fPe rcent < 0. 0 ) ? 0.0 
        2219                                         ( a_f Percent >  1.0 ) ? 1. 0 : a_fPer cent;
        2220  
        2221           re turn 1 - f Percent +  a_fWeight  * fPercent ;
        2222   }
        2223  
        2224   function _ isKeyWord(  a_uEmphas is )
        2225   {
        2226           re turn ( a_u Emphasis &  HUGIN_KEY WORD_FLAG  ) != 0;
        2227   }
        2228  
        2229   function _ isTitle( a _uEmphasis  )
        2230   {
        2231           re turn ( a_u Emphasis &  HUGIN_TIT LE_FLAG )  != 0;
        2232   }
        2233  
        2234   function _ isUpperCas eShape( a_ nWordShape  )
        2235   {
        2236           re turn a_nWo rdShape %  2 != 0;
        2237   }
        2238  
        2239   function _ emphasisTo Score( a_u Emphasis )
        2240   {
        2241           va r nScore =  0;
        2242  
        2243           // H1 = 64, H 2 = 32, H3  = 16, H4  = 8, H5 =  4, H6 = 2
        2244           fo r ( var i  = 5, nInc  = 2; i >=  0; i--, nI nc *= 2 )
        2245                    nSco re += nInc  * ( ( a_u Emphasis > > i ) & 1  );
        2246  
        2247           re turn nScor e;
        2248   }
        2249  
        2250   function _ getWordMat chType( a_ Word, a_Ti le, a_nPos ition, a_n Offset )
        2251   {
        2252           va r eRslt =  EWMT_NotMa tch;
        2253  
        2254           //  The term  must be co nsecutive.
        2255           if  ( a_nPosi tion - a_n Offset !=  a_Word.nWo rdId )
        2256                    retu rn eRslt;
        2257  
        2258           fo r ( var i  = 0; i < a _Tile.aWor ds.length;  i++ )
        2259           {
        2260                    var  eCur = EWM T_NotMatch ;
        2261                    if (  a_Tile.aW ords[i].nW ordId == a _Word.nWor dId )
        2262                    {
        2263                             if ( a _Tile.aWor ds[i].nWor dForm == W ORDSHAPE_S YNONYM )
        2264                                      eCur = E WMT_Synony mMatch;
        2265                             else
        2266                             {
        2267                                      if ( _is UpperCaseS hape( a_Wo rd.nWordSh ape ) )
        2268                                      {
        2269                                               if ( a_Wor d.nWordSha pe == a_Ti le.aWords[ i].nWordFo rm )
        2270                                                       eC ur = EWMT_ ShapeMatch ;
        2271                                               else
        2272                                                       eC ur = EWMT_ NotMatch;
        2273                                      }
        2274                                      else
        2275                                      {
        2276                                               if ( a_Wor d.nWordSha pe == a_Ti le.aWords[ i].nWordFo rm ||
        2277                                                        a _Word.nWor dShape ==  a_Tile.aWo rds[i].nWo rdForm - 1  )
        2278                                                       eC ur = EWMT_ ShapeMatch ;
        2279                                               else
        2280                                                       eC ur = EWMT_ WordMatch;
        2281                                      }
        2282                             }
        2283                    }
        2284                    if (  eRslt < e Cur )
        2285                             eRslt  = eCur;
        2286           }
        2287           re turn eRslt ;
        2288   }
        2289  
        2290   function _ getTermMat chType( a_ aTiles, a_ nTileFrom,  a_aWords,  a_nFrom,  a_nLen )
        2291   {
        2292           va r eRslt =  EWMT_Shape Match;
        2293  
        2294           if  ( a_nFrom  < 0 || a_ nLen <= 0  || a_aWord s.length <  a_nFrom +  a_nLen )
        2295                    retu rn EWMT_No tMatch;
        2296  
        2297           va r nOffset  = a_nTileF rom ;
        2298  
        2299           va r j = a_nT ileFrom;
        2300           fo r ( var i  = a_nFrom;  i < a_nFr om + a_nLe n; i++  )
        2301           {                 
        2302                    nOff set = nOff set - a_aW ords[i].nW ordId
        2303                    j =  nOffset +  a_aWords[i ].nWordId;       //se ek j to th e tile tha t should b e matched
        2304                    
        2305                    if (  !a_aTiles [j] )
        2306                             return  EWMT_NotM atch;
        2307           
        2308                    var  eCur = _ge tWordMatch Type( a_aW ords[i], a _aTiles[j] , j, nOffs et );
        2309                    if (  eCur < eR slt )
        2310                             eRslt  = eCur;
        2311                    if (  eRslt ==  EWMT_NotMa tch )
        2312                             return  eRslt;
        2313                nOffset  = nOffset  + a_aWords [i].strWor d.length +  a_aWords[ i].nWordId  ;
        2314           }
        2315           re turn eRslt ;
        2316   }
        2317  
        2318   function _ matchTypeT oScore( a_ eMatchType  )
        2319   {
        2320           sw itch( a_eM atchType )
        2321           {
        2322           ca se EWMT_No tMatch:                       re turn 0;
        2323           ca se EWMT_Sy nonymMatch :          return 1;
        2324           ca se EWMT_Wo rdMatch:              return 2;
        2325           ca se EWMT_Sh apeMatch:             return 4;
        2326           de fault:                                            retu rn 0;
        2327           }
        2328   }
        2329  
        2330   function _ computeSin gleWordSco re( a_Topi cImage, a_ nWordId )
        2331   {
        2332           if  ( !a_Topi cImage.aWo rds[a_nWor dId] )
        2333                    retu rn 0.0;
        2334  
        2335           va r emphasis  = a_Topic Image.aWor ds[a_nWord Id].uEmpha sis ;
        2336           if  (emphasis  != 0 )
        2337                emphasis  = _emphas isToScore( emphasis )  ;
        2338                    
        2339           em phasis +=  a_TopicIma ge.aWords[ a_nWordId] .uFreq;        
        2340                
        2341           va r fWeightS core = _ra nk_Weaken(  _rank_ULa w( emphasi s ), WEIGH T_OF_SINGL E_WORD_SCO RE );
        2342  
        2343           if  ( _isTitl e( a_Topic Image.aWor ds[a_nWord Id].uEmpha sis ) )               // Words i n title ar e importan t than key  words and  the rest.
        2344           {
        2345                    retu rn fWeight Score / 3. 0 + 2.0 /  3.0;
        2346           }
        2347           if  ( _isKeyW ord( a_Top icImage.aW ords[a_nWo rdId].uEmp hasis ) )    // Key w ords are a lways more  important  than non- keywords.
        2348           {
        2349                    retu rn fWeight Score / 3. 0 + 1.0 /  3.0;
        2350           }        
        2351           el se
        2352           {
        2353                    retu rn fWeight Score / 3. 0;
        2354           }
        2355   }
        2356  
        2357   function _ computeTer mWeight( a _TopicImag e, a_Term  )
        2358   {
        2359           va r nTermLen  = a_Term. aWords.len gth;             // e mpty term  means igno red or all  stop word s
        2360           if  ( nTermLe n == 0 )
        2361                    retu rn -1.0;
        2362  
        2363           va r fTermSco re = 0.0;                                                // posit ion indepe ndent scor e
        2364           fo r ( i = 0;  i < nTerm Len; i++ )
        2365                    fTer mScore +=  _computeSi ngleWordSc ore( a_Top icImage, a _Term.aWor ds[i].nWor dId );
        2366           if  ( a_Term. eType == E SNT_PHRASE  )
        2367           {
        2368                    //ch eck if its  a phrase
        2369                    var  bPhrase =  false ;
        2370                    var  iPosition  = 0;                        
        2371                    for  ( var strP osition in  a_TopicIm age.aTiles  )
        2372                    {
        2373                             iPosit ion = pars eInt( strP osition );
        2374                             bPhras e = _getPh raseMatch(  a_TopicIm age.aTiles , iPositio n, a_Term. aWords, 0  );
        2375                             if ( b Phrase )
        2376                                      break ;
        2377                    }
        2378                    
        2379                    if ( bPhrase)
        2380                             return  fTermScor e;
        2381                    else
        2382                             return  0.0 ;
        2383           }
        2384           el se
        2385           {                 
        2386                    retu rn fTermSc ore;
        2387           }
        2388   }
        2389  
        2390   function _ getPhraseM atch(a_aTi les, iPosi tion, a_aW ords, a_nC urIdx )
        2391   {
        2392           va r nOffset  = iPositio n ;
        2393           if  (a_nCurId x >= a_aWo rds.length )
        2394                    retu rn false ;
        2395           if  (iPositio n >= a_aTi les.length )
        2396                    retu rn false ;
        2397           va r nCurWord Id = a_aWo rds[a_nCur Idx].nWord Id ;
        2398           if (!a_aTiles [iPosition ])
        2399                    retu rn false ;
        2400                    
        2401           va r i  ;
        2402           fo r ( i = 0  ; i < a_aT iles[iPosi tion].aWor ds.length  ; i++)
        2403           {
        2404                    var  wordAtPos  = a_aTiles [iPosition ].aWords[i ].nWordId    ;
        2405           if  (wordAtPo s == nCurW ordId)
        2406           {
        2407                    if ( a_nCurIdx  == (a_aWor ds.length  -1 ))
        2408                    {
        2409                             //last  word matc hes, then  return tru e
        2410                             return  true ;
        2411                    }
        2412                    else
        2413                    {
        2414                             var wo rdLen = a_ aWords[a_n CurIdx].st rWord.leng th ;
        2415                             return  _getPhras eMatch(a_a Tiles , iP osition +  wordLen ,  a_aWords ,  a_nCurIdx +1);
        2416                    }
        2417           }
        2418           }
        2419                    retu rn false ;
        2420   }
        2421  
        2422   function _ removeNega tiveWeight ( a_fWeigh t, a_eOpTy pe )
        2423   {
        2424           if  ( a_fWeig ht >= 0.0  )
        2425                    retu rn a_fWeig ht;
        2426  
        2427           sw itch ( a_e OpType )
        2428           {
        2429           ca se ESNT_OR :   return  0.0;
        2430           ca se ESNT_AN D:  return  1.0;
        2431           ca se ESNT_NO T:  return  0.0;
        2432           }
        2433           re turn 0.0;
        2434   }
        2435  
        2436   function _ getWeightO fNode( a_T opicImage,  a_Node )
        2437   {
        2438           if  ( a_Node  == null )
        2439                    retu rn 0.0;
        2440  
        2441           if  ( a_Node. eType == E SNT_DEFAUL T || a_Nod e.eType ==  ESNT_PHRA SE || a_No de.eType = = ESNT_NOT )
        2442           {
        2443                    retu rn _comput eTermWeigh t( a_Topic Image, a_N ode );
        2444           }
        2445           el se
        2446           {
        2447                    // R ight has o nly 1/2 we ight of le ft
        2448                    var  fWeightRig ht = _getW eightOfNod e( a_Topic Image, a_N ode.right  ) / 2.0;
        2449                    var  fWeightLef t = _getWe ightOfNode ( a_TopicI mage, a_No de.left );
        2450                    
        2451                    // T o both neg ativeWeigh t return n egative
        2452                    if (  fWeightRi ght < 0.0  && fWeight Left < 0.0  )
        2453                             return  -1.0;
        2454  
        2455                    // C onvert Neg ativeWeigh t to 1.0 o r 0.0 acco rding to o perator ty pe
        2456                    fWei ghtRight =  _removeNe gativeWeig ht( fWeigh tRight, a_ Node.eType  );
        2457                    fWei ghtLeft =  _removeNeg ativeWeigh t( fWeight Left, a_No de.eType ) ;
        2458  
        2459                    // B oolean ope ration
        2460                    swit ch ( a_Nod e.eType )
        2461                    {
        2462                    case  ESNT_OR:
        2463                             return  ( fWeight Left + fWe ightRight  ) / 2.0;
        2464                    case  ESNT_AND:
        2465                             return  ( fWeight Left * fWe ightRight  );
        2466                    case  ESNT_NOT:
        2467                             fWeigh tRight = (  fWeightRi ght == 0.0  ) ? 1.0 :  0.0;
        2468                             return  fWeightLe ft * fWeig htRight;
        2469                    }
        2470                    
        2471                    // U ncoverd ca ses (inexi stent).
        2472                    retu rn 0.0;
        2473           }
        2474   }
        2475  
        2476   function c alculateRa nking( a_T opicImage,  a_Express ion )
        2477   {
        2478           re turn _getW eightOfNod e( a_Topic Image, a_E xpression  );
        2479   }
        2480  
        2481   // HuginHu nter.js--- ---------- ---------- --------
        2482  
        2483   function a rrayRemove At( a_ary,  a_nIndex  )
        2484   {
        2485           va r nLen = a _ary.lengt h;
        2486           fo r ( var i  = a_nIndex ; i < nLen  - 1; i++  )
        2487                    a_ar y[i] = a_a ry[i + 1];
        2488           a_ ary.length --;
        2489   }
        2490  
        2491   function H uginQueryR esult()
        2492   {
        2493           th is.aTopics  = new Arr ay();     
        2494   }
        2495  
        2496   function H uginImageW ord()
        2497   {
        2498           th is.uEmphas is = 0;      
        2499           th is.uFreq      = 0;
        2500           
        2501   };
        2502  
        2503   function H uginImageT ileWord( a _nWordId,  a_nWordFor m )
        2504   {
        2505           th is.nWordId  = a_nWord Id;
        2506           th is.nWordFo rm = a_nWo rdForm;
        2507   }
        2508  
        2509   function H uginImageT ile()
        2510   {
        2511           th is.aWords  = new Arra y();
        2512   }
        2513  
        2514   function H uginTopicI mage( a_nT opicId )
        2515   {
        2516           th is.aWords  = new Arra y();
        2517           th is.aTiles  = new Arra y();;
        2518   }
        2519  
        2520   function H uginHunter ()
        2521   {
        2522           th is.aOdbPat hes = null ;                           //in
        2523           th is.strOdbP ath = null ;                           //in
        2524           
        2525           th is.strQuer y = null;                              //in
        2526           th is.queryRe sult = nul l;                          //ou t
        2527           
        2528           th is.bInited  = false;
        2529           th is.bSucc =  true;
        2530           
        2531           th is.aDataba ses = null ;
        2532  
        2533           th is.iCurPro j = null;
        2534           
        2535           th is.queryEx pression =  null;
        2536           th is.queryWo rd = null;
        2537           th is.curTerm Node = nul l;
        2538  
        2539           th is.aRecord Table = nu ll;       
        2540           th is.aSuspen dTopics =  null;
        2541           th is.aTopics  = null;
        2542           th is.iCurTop ic = null;
        2543           
        2544           th is.aTopicI mages = nu ll;
        2545           th is.aNodeSt ack = null ;
        2546           th is.iCurTer mNodeWord  = null;
        2547  
        2548           th is.aPossib leOrgs = n ull;
        2549           th is.aRanked Topics = n ull;
        2550           
        2551           th is.nWordLo aded = 0;
        2552           th is.nWordNu m = 0;
        2553           th is.nState  = 0;
        2554           th is.nProgre ss = 0;
        2555  
        2556           th is.prepare Query = fu nction()
        2557           {
        2558                    this .queryResu lt = null;
        2559                    this .bSucc = t rue;
        2560                    
        2561                    this .iCurProj  = 0;
        2562                    this .queryExpr ession = n ull;
        2563                    this .queryWord  = null;
        2564                    this .curTermNo de = null;
        2565  
        2566                    this .aRecordTa ble = null ;       
        2567                    this .aSuspendT opics = nu ll;
        2568                    this .aTopics =  null;
        2569                    this .iCurTopic  = 0;
        2570  
        2571                    this .aTopicIma ges = null ;
        2572                    this .aNodeStac k = null;
        2573                    this .iCurTermN odeWord =  0;
        2574  
        2575                    this .aPossible Orgs = nul l;
        2576                    this .aRankedTo pics = nul l;
        2577  
        2578                    this .nWordLoad ed = 0;
        2579                    this .nWordNum  = 0;
        2580                    this .nState =  0;
        2581                    this .nProgress  = 0;
        2582  
        2583                    for  ( var i in  this.aDat abases )
        2584                             this.a Databases[ i].prepare Query();
        2585           }
        2586           
        2587           th is.updateP rogress =  function()
        2588           {
        2589                    var  fProgress  = 100 * th is.iCurPro j / this.a Databases. length;
        2590                    var  fBase = 10 0 / this.a Databases. length;
        2591  
        2592                    if (  this.nSta te == 1 )
        2593                             this.n Progress =  Math.roun d( fProgre ss + ( thi s.nWordLoa ded / this .nWordNum  ) * ( fBas e / 3 ) );
        2594                    else  if ( this .nState ==  2 )
        2595                             this.n Progress =  Math.roun d( fProgre ss + fBase  / 3 +
        2596                                                                                            ( this.iC urTopic /  this.aTopi cs.length  ) * ( fBas e * 2 / 3  ) );
        2597           }
        2598  
        2599           th is.incCurP rojForInit  = functio n( a_Conte xt, a_this  )
        2600           {
        2601                    a_th is.iCurPro j++;
        2602                    if (  a_this.iC urProj < a _this.aDat abases.len gth )
        2603                    {
        2604                             a_Cont ext.push(  a_this.aDa tabases[a_ this.iCurP roj].init,  a_this.aD atabases[a _this.iCur Proj],
        2605                                                                a_th is.incCurP rojForInit , a_this ) ;
        2606                    }
        2607           }
        2608           
        2609           th is.incCurP rojForEval uate = fun ction( a_C ontext, a_ this )
        2610           {
        2611                    a_th is.iCurPro j++;
        2612                    if (  a_this.iC urProj < a _this.aDat abases.len gth )
        2613                    {
        2614                             a_this .aRankedTo pics[a_thi s.iCurProj ] = new Ar ray();
        2615                             a_Cont ext.push(  a_this.get Records, a _this,
        2616                                                                a_th is.evaluat eTopics, a _this,
        2617                                                                a_th is.getTopi cInfo, a_t his,
        2618                                                                a_th is.incCurP rojForEval uate, a_th is );
        2619                    }
        2620           }
        2621           
        2622           th is.incCurT ermNodeWor d = functi on( a_Cont ext, a_thi s )
        2623           {
        2624                    a_th is.nState  = 1;
        2625  
        2626                    a_th is.iCurTer mNodeWord+ +;
        2627                    a_th is.nWordLo aded++;
        2628                    a_th is.updateP rogress();
        2629           }
        2630  
        2631           th is.incCurT opic = fun ction( a_C ontext, a_ this )
        2632           {
        2633                    a_th is.nState  = 2;
        2634  
        2635                    a_th is.iCurTop ic++;
        2636                    a_th is.updateP rogress();
        2637           }
        2638           
        2639           th is.checkIn itSucc = f unction( a _Context,  a_this )
        2640           {
        2641                    var  bAllFailed  = true;
        2642                    var  bNotAllDat abaseInite d = false;
        2643                    a_th is.bInited  = false;
        2644                    for  ( var i =  0; i < a_t his.aDatab ases.lengt h; i++ )
        2645                    {
        2646                             if ( ! a_this.aDa tabases[i] .bSucc ||  !a_this.aD atabases[i ].bInited  )
        2647                                      bNotAllD atabaseIni ted = true ;
        2648                             else
        2649                                      bAllFail ed = false ;
        2650                    }
        2651                    if (  bAllFaile d )
        2652                    {
        2653                             a_Cont ext.strMsg  = gsInitD atabaseFai led;
        2654                             g_CurS tate = ECS _FATALERRO R;
        2655                             update ResultView ();
        2656                             return ;
        2657                    }
        2658                    if (  bNotAllDa tabaseInit ed )
        2659                    {
        2660                             a_Cont ext.strMsg  = gsInitD atabaseFai led;
        2661                    }
        2662                    a_Co ntext.strM sg = "";
        2663                    g_Cu rState = E CS_FTSREAD Y;
        2664                    a_th is.bInited  = true;
        2665           }
        2666  
        2667           th is.getWord ImageToAdd  = functio n( a_nWord Id, a_aWor ds )
        2668           {
        2669                    retu rn a_aWord s[a_nWordI d] ? a_aWo rds[a_nWor dId] : ( a _aWords[a_ nWordId] =  new Hugin ImageWord( ) );
        2670           }
        2671           
        2672           th is.getTile ImageToAdd  = functio n( a_nPosi tion, a_aT iles )
        2673           {
        2674                    retu rn a_aTile s[a_nPosit ion] ? a_a Tiles[a_nP osition] :  ( a_aTile s[a_nPosit ion] = new  HuginImag eTile() );
        2675           }
        2676  
        2677           th is.addReco rdToRecord Table = fu nction( a_ nWordId, a _strRecord  )
        2678           {
        2679                    if (  a_strReco rd == "" )
        2680                             return ;
        2681  
        2682                    if(t ypeof(this .aRecordTa ble[a_nWor dId]) == " undefined" )
        2683                             this.a RecordTabl e[a_nWordI d] = new A rray();
        2684                    
        2685                    var  aTopics =  a_strRecor d.split( " |" );
        2686                    for  ( var iTop ic = 0; iT opic < aTo pics.lengt h; iTopic+ + )
        2687                    {
        2688                             var to picHead =  aTopics[iT opic].matc h( "^(\\d+ ),(.*)$" ) ;
        2689                             if ( t opicHead = = null )
        2690                                      continue ;
        2691                             this.a RecordTabl e[a_nWordI d][topicHe ad[1]] = t opicHead[2 ];
        2692                             this.a SuspendTop ics[topicH ead[1]] =  true;
        2693                    }
        2694           }
        2695           
        2696           th is.process RecordResu lt = funct ion( a_Con text, a_th is )
        2697           {
        2698                    if (  !a_this.a Databases[ a_this.iCu rProj].bSu cc )                          //  Go on sea rching for  other wor ds while o ne not fou nd
        2699                             return ;
        2700  
        2701                    a_th is.wordRec ord = a_th is.aDataba ses[a_this .iCurProj] .recordRes ult;
        2702                    a_th is.addReco rdToRecord Table( a_t his.queryW ord.nWordI d, a_this. wordRecord .strRecord  );          
        2703           }
        2704           
        2705           th is.getReco rdOfTermWo rd = funct ion( a_Con text, a_th is )
        2706           {
        2707                    if (  a_this.iC urTermNode Word >= a_ this.curTe rmNode.aWo rds.length  )
        2708                             return ;
        2709  
        2710                    a_th is.queryWo rd = a_thi s.curTermN ode.aWords [a_this.iC urTermNode Word];
        2711                    a_th is.aDataba ses[a_this .iCurProj] .queryWord  = a_this. queryWord;
        2712                    a_th is.aDataba ses[a_this .iCurProj] .eType = a _this.curT ermNode.eT ype ;
        2713                    a_th is.aDataba ses[a_this .iCurProj] .bNeedStop Word = a_t his.bNeedS topWord;
        2714                    a_Co ntext.push ( a_this.a Databases[ a_this.iCu rProj].que ryRecord,  a_this.aDa tabases[a_ this.iCurP roj],
        2715                                                       a_ this.proce ssRecordRe sult, a_th is,
        2716                                                       a_ this.incCu rTermNodeW ord, a_thi s,
        2717                                                       a_ this.getRe cordOfTerm Word, a_th is );
        2718           }
        2719           
        2720           th is.getReco rdOfTermNo de = funct ion( a_Con text, a_th is )
        2721           {
        2722                    a_th is.aPossib leOrgs = n ew Array() ;
        2723                    a_th is.bNeedSt opWord = (  a_this.cu rTermNode. eType == E SNT_PHRASE  );
        2724                    a_th is.iCurTer mNodeWord  = 0;                                        //Init the  iterator  of a "for  loop"
        2725                    a_Co ntext.push ( a_this.g etRecordOf TermWord,  a_this);
        2726           }
        2727           
        2728           th is.getReco rdOfNode =  function(  a_Context , a_this )
        2729           {
        2730                    if (  a_this.aN odeStack.l ength == 0  )
        2731                             return ;
        2732                             
        2733                    var  curNode =  a_this.aNo deStack[a_ this.aNode Stack.leng th - 1];
        2734                    a_th is.aNodeSt ack.length --;
        2735  
        2736                    if (  curNode ! = null )
        2737                    {
        2738                             if ( c urNode.eTy pe == ESNT _PHRASE ||  curNode.e Type == ES NT_DEFAULT  || curNod e.eType ==  ESNT_NOT)
        2739                             {
        2740                                      a_this.c urTermNode  = curNode ;
        2741                                      a_Contex t.push( a_ this.getRe cordOfTerm Node, a_th is );
        2742                             }
        2743                             else
        2744                             {
        2745                                      a_this.a NodeStack[ a_this.aNo deStack.le ngth] = cu rNode.righ t;
        2746                                      a_this.a NodeStack[ a_this.aNo deStack.le ngth] = cu rNode.left ;
        2747  
        2748                                      a_Contex t.push( a_ this.getRe cordOfNode , a_this,
        2749                                                                         a_this .getRecord OfNode, a_ this );
        2750                             }
        2751                    }
        2752           }
        2753           
        2754           th is.addToTo picImage =  function(  a_Image,  a_nWordId,  a_Record  )
        2755           {
        2756                    var  wordImage  = this.get WordImageT oAdd( a_nW ordId, a_I mage.aWord s );
        2757  
        2758                    word Image.uEmp hasis |= a _Record.uE mphasis;
        2759                    word Image.uFre q = a_Reco rd.aPositi ons.length  ;
        2760                    for  ( var strP osition in  a_Record. aPositions  )
        2761                    {
        2762                             var ti leImage =  this.getTi leImageToA dd( a_Reco rd.aPositi ons[strPos ition],
        2763                                                                                                                              a_Image. aTiles );
        2764                             tileIm age.aWords [tileImage .aWords.le ngth] = ne w HuginIma geTileWord ( a_nWordI d, 0 /*nWo rdShape*/  );                        
        2765                    }
        2766           }
        2767           
        2768           th is.unpackT opicRecord  = functio n( a_strRe cord )
        2769           {
        2770                    var  aShapes =  a_strRecor d.split( " :" );
        2771                    if (  aShapes.l ength == 0  )
        2772                             return  null;
        2773  
        2774                    var  record = n ew Object( );
        2775                    reco rd.uEmphas is = parse Int( aShap es[0] );
        2776                    reco rd.aPositi ons = aSha pes[1].spl it( "," );
        2777                    if (  record.aP ositions.l ength < 1  )
        2778                             return  null;             
        2779                    retu rn record;
        2780           }
        2781           
        2782           th is.makeTop icImage =  function(  a_nTopicId  )
        2783           {
        2784                    var  topicImage  = new Hug inTopicIma ge();
        2785                    for  ( var strW ordId in t his.aRecor dTable )
        2786                    {
        2787                             if ( ! this.aReco rdTable[st rWordId][a _nTopicId]  )
        2788                                      continue ;
        2789  
        2790                             var re cord = thi s.unpackTo picRecord(  this.aRec ordTable[s trWordId][ a_nTopicId ] )
        2791                             this.a ddToTopicI mage( topi cImage, pa rseInt( st rWordId ),  record );
        2792                    }
        2793                    retu rn topicIm age;
        2794           }
        2795           
        2796           th is.calcula teRanking  = function ( a_TopicI mage )
        2797           {
        2798                    retu rn calcula teRanking(  a_TopicIm age, this. queryExpre ssion );
        2799           }
        2800           
        2801           th is.calcula teWordNum  = function ( a_Node )
        2802           {
        2803                    if (  a_Node.eT ype == ESN T_PHRASE | | a_Node.e Type == ES NT_DEFAULT  || a_Node .eType ==  ESNT_NOT)
        2804                    {
        2805                             this.n WordNum +=  a_Node.aW ords.lengt h;
        2806                    }
        2807                    else
        2808                    {
        2809                             this.c alculateWo rdNum( a_N ode.right  );
        2810                             this.c alculateWo rdNum( a_N ode.left ) ;
        2811                    }
        2812           }
        2813           
        2814           th is.getReco rds = func tion( a_Co ntext, a_t his )
        2815           {
        2816                    a_th is.aNodeSt ack = new  Array();
        2817                    a_th is.aNodeSt ack[a_this .aNodeStac k.length]  = a_this.q ueryExpres sion;
        2818                    a_th is.aRecord Table = ne w Array();
        2819                    a_th is.aSuspen dTopics =  new Array( );
        2820                    
        2821                    a_th is.nWordLo aded = 0;
        2822                    a_th is.calcula teWordNum(  a_this.qu eryExpress ion );
        2823                    
        2824                    a_Co ntext.push ( a_this.g etRecordOf Node, a_th is );
        2825           }
        2826           
        2827           th is.evaluat eTopic = f unction( a _Context,  a_this )
        2828           {
        2829                    if (  a_this.iC urTopic >=  a_this.aT opics.leng th )
        2830                             return ;
        2831                    
        2832                    var  rankedTopi c = new Ob ject();
        2833                    rank edTopic.fR anking = a _this.calc ulateRanki ng( a_this .makeTopic Image( a_t his.aTopic s[a_this.i CurTopic]  ) );
        2834                    if (  rankedTop ic.fRankin g > 0 )
        2835                    {
        2836                             ranked Topic.nTop icId = par seInt( a_t his.aTopic s[a_this.i CurTopic]  );
        2837                             a_this .aRankedTo pics[a_thi s.iCurProj ][a_this.a RankedTopi cs[a_this. iCurProj]. length] =  rankedTopi c;
        2838                    }
        2839                    a_Co ntext.push ( a_this.i ncCurTopic , a_this,
        2840                                                       a_ this.evalu ateTopic,  a_this );
        2841           }
        2842  
        2843           th is.evaluat eTopics =  function(  a_Context,  a_this )
        2844           {
        2845                    a_th is.aTopics  = new Arr ay();
        2846                    for  ( var iTop ic in a_th is.aSuspen dTopics )
        2847                             a_this .aTopics[a _this.aTop ics.length ] = iTopic ;
        2848                    
        2849                    a_th is.iCurTop ic = 0;
        2850                    a_Co ntext.push ( a_this.e valuateTop ic, a_this  );
        2851           }
        2852  
        2853           th is.createT opicImages  = functio n( a_Conte xt, a_this  )
        2854           {
        2855                    a_th is.aTopicI mages = ne w Array();
        2856                    a_th is.aPossib leOrgs = n ew Array() ;
        2857  
        2858                    a_th is.aNodeSt ack = new  Array();
        2859                    a_th is.aNodeSt ack[a_this .aNodeStac k.length]  = a_this.q ueryExpres sion;
        2860  
        2861                    a_Co ntext.push ( a_this.a ddNodeToTo picImages,  a_this );
        2862           }
        2863  
        2864           th is.calcula teRankings  = functio n( a_Conte xt, a_this  )
        2865           {
        2866                    a_th is.aRanked Topics = n ew Array() ;
        2867                    for  ( var strT opicId in  a_this.aTo picImages  )
        2868                    {
        2869                             var ra nkedTopic  = new Obje ct();
        2870                             ranked Topic.fRan king = cal culateRank ing( a_thi s.aTopicIm ages[strTo picId], a_ this.query Expression  );
        2871                             if ( r ankedTopic .fRanking  <= 0 )
        2872                                      continue ;
        2873                             ranked Topic.nTop icId = par seInt( str TopicId );
        2874                             docume nt.writeln ( "<br>" +  rankedTop ic.nTopicI d + "<br>"  );
        2875                             a_this .aRankedTo pics[a_thi s.aRankedT opics.leng th] = rank edTopic;
        2876                    }
        2877           }
        2878           
        2879           th is.compRan kedTopics  = function ( a_itemA,  a_itemB )
        2880           {
        2881                    if (  a_itemA.f Ranking >  a_itemB.fR anking )
        2882                             return  true;
        2883                    else  if ( a_it emA.fRanki ng == a_it emB.fRanki ng )
        2884                    {
        2885                             var k  = compare(  a_itemA.s trTitle, a _itemB.str Title );
        2886                             if ( k  < 0 )
        2887                                      return t rue;
        2888                    }
        2889                    retu rn false;
        2890           }
        2891           
        2892           th is.swapRan kedTopics  = function ( a_aTopic s, a_nIdx,  a_itemNew  )
        2893           {
        2894                    a_aT opics[a_nI dx] = a_it emNew;
        2895           }
        2896           
        2897           th is.quickSo rtRankedTo pics = fun ction( a_n Low, a_nHi gh )
        2898           {
        2899                    quic kSort( thi s.queryRes ult.aTopic s,
        2900                                         0, th is.queryRe sult.aTopi cs.length  - 1,
        2901                                         this. compRanked Topics,
        2902                                         this. swapRanked Topics );
        2903           }
        2904           
        2905           th is.compPos sibleOrgs  = function ( a_itemA,  a_itemB )
        2906           {
        2907                    if (  utf8Compa re(a_itemA , a_itemB)  <= 0 )
        2908                             return  true;
        2909                    retu rn false;
        2910           }
        2911           
        2912           th is.swapPos sibleOrgs  = function ( a_aOrgs,  a_nIdx, a _itemNew )
        2913           {
        2914                    a_aO rgs[a_nIdx ] = a_item New;
        2915           }
        2916  
        2917           th is.getTopi cInfo = fu nction( a_ Context, a _this )
        2918           {        // t he databas e will fil l the quer y result i n the same  mapRanked Topics
        2919                    a_th is.aDataba ses[a_this .iCurProj] .aQueryTop ics = a_th is.aRanked Topics[a_t his.iCurPr oj];
        2920                    a_Co ntext.push ( a_this.a Databases[ a_this.iCu rProj].que ryTopicInf os, a_this .aDatabase s[a_this.i CurProj] ) ;
        2921           }
        2922  
        2923           th is.evaluat eExpressio n = functi on( a_Cont ext, a_thi s )
        2924           {
        2925           // In case of  AIR, the  AND search  variable  is set thr ough other  route
        2926           if (!gbAIRSSL )
        2927           {
        2928                //To set  the gbEna bleAndSear ch variabl e which en ables the  AND search
        2929                SetVaria blesFromNa meValuePai rString(gb ExtraInfoI nSearchQue ry,false);
        2930           }
        2931  
        2932           gC hangedQuer y='';
        2933                    a_th is.queryEx pression =  parseQuer yExpressio n( a_this. strQuery ) ;
        2934                    if (  a_this.qu eryExpress ion == nul l )
        2935                    {
        2936                             a_Cont ext.strMsg  = gsInval idExpressi on_1 ;
        2937                             a_this .bSucc = f alse;
        2938                             return ;
        2939                    }
        2940  
        2941                    a_th is.aRanked Topics = n ew Array() ;
        2942                    a_th is.iCurPro j = -1;
        2943                    a_Co ntext.push ( a_this.i ncCurProjF orEvaluate , a_this ) ;
        2944           }
        2945  
        2946           th is.makeRes ult = func tion( a_Co ntext, a_t his )
        2947           {
        2948                    a_th is.queryRe sult.aTopi cs = new A rray();
        2949                    if (  !a_this.b Succ )
        2950                             return ;
        2951                    var  nLen = 0;
        2952                    for  ( var i =  0; i < a_t his.aRanke dTopics.le ngth; i++  )
        2953                    {
        2954                             for (  var j = 0;  j < a_thi s.aRankedT opics[i].l ength; j++  )
        2955                             {
        2956                                      nLen = a _this.quer yResult.aT opics.leng th;
        2957                                      a_this.q ueryResult .aTopics[n Len] = a_t his.aRanke dTopics[i] [j];
        2958                                      strTopic Url = a_th is.queryRe sult.aTopi cs[nLen].s trUrl;
        2959                                      if(!(_is AbsPath(st rTopicUrl)  || _isRem oteUrl(str TopicUrl)) )
        2960                                      {
        2961                                               if(gbAIRSS L)
        2962                                               {
        2963                                                       a_ this.query Result.aTo pics[nLen] .strProjDi r = a_this .aProjPath es[i].strP rojDir;
        2964                                               }
        2965                                          a_th is.queryRe sult.aTopi cs[nLen].s trUrl = a_ this.aProj Pathes[i]. strProjDir
        2966                                                                                                                                + a_th is.queryRe sult.aTopi cs[nLen].s trUrl;
        2967                                      }
        2968                                      a_this.q ueryResult .aTopics[n Len].fRank ing = a_th is.aRanked Topics[i][ j].fRankin g;
        2969                             }
        2970                    }
        2971                    a_th is.quickSo rtRankedTo pics( 0, a _this.quer yResult.aT opics.leng th - 1 );
        2972                    for  ( var i =  0; i < a_t his.queryR esult.aTop ics.length ; i++ )
        2973                    {
        2974                             a_this .queryResu lt.aTopics [i].nIndex  = i + 1;
        2975                    }                 
        2976           }
        2977  
        2978           // interface
        2979           th is.init =  function(  a_Context,  a_this )
        2980           {
        2981                    a_th is.bInited  = false;
        2982                    
        2983                    a_th is.aDataba ses = new  Array();
        2984                    for  ( var i in  a_this.aP rojPathes  )
        2985                    {
        2986                             var nL en = a_thi s.aDatabas es.length;
        2987                             a_this .aDatabase s[nLen] =  new HuginD atabase();
        2988                             a_this .aDatabase s[nLen].st rOdbPath =  a_this.aP rojPathes[ i].strOdbP ath;
        2989                    }
        2990                    if (  a_this.aD atabases.l ength == 0  )
        2991                             return ;
        2992  
        2993                    // f or the rob oengine se rver we do n't need d atabase in its
        2994                    if(  gbAIRSSL | | mrIsOnEn gine()==fa lse )
        2995                    {
        2996                             a_this .iCurProj  = 0;
        2997                             a_Cont ext.push(  a_this.aDa tabases[a_ this.iCurP roj].init,  a_this.aD atabases[a _this.iCur Proj],
        2998                                                       a_ this.incCu rProjForIn it, a_this ,
        2999                                                       a_ this.check InitSucc,  a_this );
        3000                    };
        3001           }
        3002  
        3003           th is.query =  function(  a_Context , a_this )
        3004           {
        3005                    if (  !a_this.b Inited )
        3006                    {
        3007                             a_this .bSucc = f alse;
        3008                             return ;
        3009                    }
        3010  
        3011                    a_th is.prepare Query();
        3012                    g_Cu rState = E CS_SEARCHI NG;
        3013                    upda teResultVi ew();
        3014                    
        3015                    a_th is.queryRe sult = new  HuginQuer yResult();
        3016                    a_Co ntext.push ( a_this.e valuateExp ression, a _this,
        3017                                                       a_ this.makeR esult, a_t his );
        3018           }
        3019   }
        3020  
        3021   //Display/ ////////// ////////// ////////// ////////// ////////// ////////// ////////
        3022  
        3023   function g etEventX(  e )
        3024   {
        3025           if  ( gbIE5 )
        3026                    retu rn event.x ;
        3027           if  ( gbNav7  ||gbAIR)
        3028                    retu rn e.pageX ;
        3029           re turn 0;
        3030   }
        3031  
        3032   function g etEventY(  e )
        3033   {
        3034           if  ( gbIE5 )
        3035                    retu rn event.y ;
        3036           if  ( gbNav7  ||gbAIR)
        3037                    retu rn e.pageY ;
        3038           re turn 0;
        3039   }
        3040  
        3041   function s etInnerHTM L( a_Node,  a_strText  )
        3042   {
        3043           a_ Node.inner HTML = a_s trText;
        3044   }
        3045  
        3046   function c ompByTitle Descend( a _itemA, a_ itemB )
        3047   {
        3048           va r k = comp are( getIn nerText( a _itemA.cel ls[0] ), g etInnerTex t( a_itemB .cells[0]  ) );
        3049           if  ( k > 0 )
        3050                    retu rn true;
        3051           el se if ( k  == 0 )
        3052                    retu rn compByR ank( a_ite mA, a_item B );
        3053           el se
        3054                    retu rn false;
        3055   }
        3056  
        3057   function c ompByTitle Ascend( a_ itemA, a_i temB )
        3058   {
        3059           va r k = comp are( getIn nerText( a _itemA.cel ls[0] ), g etInnerTex t( a_itemB .cells[0]  ) );
        3060           if  ( k < 0 )
        3061                    retu rn true;
        3062           el se if ( k  == 0 )
        3063                    retu rn compByR ank( a_ite mA, a_item B );
        3064           el se
        3065                    retu rn false;
        3066  
        3067           re turn getIn nerText( a _itemA.cel ls[0] ) <=  getInnerT ext( a_ite mB.cells[0 ] );
        3068   }
        3069  
        3070   function c ompByRank(  a_itemA,  a_itemB )
        3071   {
        3072           re turn parse Int( getIn nerText( a _itemA.cel ls[2] ) )  <= parseIn t( getInne rText( a_i temB.cells [2] ) );
        3073   }
        3074  
        3075   function s wapTableNo de( a_aIte ms, a_nIdx , a_itemB  )
        3076   {
        3077           a_ aItems[a_n Idx].swapN ode( a_ite mB );
        3078   }
        3079  
        3080   function g etPartitio n( a_aRows , i, j, a_ funcComp,  a_funcSwap  )
        3081   {
        3082           va r pivot =  a_aRows[i] ;
        3083           wh ile( i < j  )
        3084           {
        3085                    whil e( i < j & & a_funcCo mp( pivot,  a_aRows[j ] ) )
        3086                             j--;
        3087                    if(  i < j )
        3088                             a_func Swap( a_aR ows, i++,  a_aRows[j]  );
        3089                    whil e( i < j & & a_funcCo mp( a_aRow s[i], pivo t ) )
        3090                             i++;
        3091                    if(  i < j )
        3092                             a_func Swap( a_aR ows, j--,  a_aRows[i]  );
        3093           }
        3094           a_ funcSwap(  a_aRows, i , pivot );
        3095           re turn i;
        3096   }
        3097  
        3098   function q uickSort(  a_aRows, a _nLow, a_n High, a_fu ncComp, a_ funcSwap )
        3099   {
        3100           if  ( a_nLow  < a_nHigh  )
        3101           {
        3102                    var  nPivotpos  = getParti tion( a_aR ows, a_nLo w, a_nHigh , a_funcCo mp, a_func Swap );
        3103                    quic kSort( a_a Rows, a_nL ow, nPivot pos - 1, a _funcComp,  a_funcSwa p );
        3104                    quic kSort( a_a Rows, nPiv otpos + 1,  a_nHigh,  a_funcComp , a_funcSw ap );
        3105           }
        3106   }
        3107  
        3108   function u pdateHeade r()
        3109   {
        3110           va r tdTitle  = getEleme nt( "OdinF tsTitle" ) ;
        3111           va r tdRank =  getElemen t( "OdinFt sRank" );
        3112           if  ( tdTitle  == null | | tdRank = = null )
        3113                    retu rn;
        3114           sw itch( g_nS ortType )
        3115           {
        3116                    case  0: setInn erHTML( td Title, gsT itle );
        3117                                      setInner HTML( tdRa nk, gsRank  + ' ' + g sAscendFla g );
        3118                                      break;
        3119                    case  1: setInn erHTML( td Title, gsT itle + ' '  + gsAscen dFlag );
        3120                                      setInner HTML( tdRa nk, gsRank  );
        3121                                      break;
        3122                    case  2: setInn erHTML( td Title, gsT itle + ' '  + gsDesce ndFlag );
        3123                                      setInner HTML( tdRa nk, gsRank  );
        3124                                      break;
        3125           }
        3126   }
        3127  
        3128   function q uickSortRe sult()
        3129   {
        3130           va r tbl = ge tElement(  "OdinFtsRs lt" );
        3131           if  ( tbl ==  null )
        3132                    retu rn;
        3133           
        3134           va r tdRank =  getElemen t( "OdinFt sRank" );
        3135                    if (  tdRank ==  null )
        3136                             return ;
        3137  
        3138           va r comp = g _nSortType  == 0 ? co mpByRank
        3139                                                                         : g_nS ortType ==  1 ? compB yTitleAsce nd
        3140                                                                                                                     : comp ByTitleDes cend;
        3141           qu ickSort( t bl.rows, 0 , tbl.rows .length -  1, comp, s wapTableNo de );
        3142           up dateHeader ();
        3143   }
        3144  
        3145   function g etStylePro pertyValue (elementTa g,stylePro p)
        3146   {
        3147       var y= null;
        3148           if  (elementT ag.current Style)
        3149                    y =  elementTag .currentSt yle[styleP rop];
        3150           el se if (win dow.getCom putedStyle )
        3151                    y =  document.d efaultView .getComput edStyle(el ementTag,n ull).getPr opertyValu e(stylePro p);
        3152           re turn y;
        3153   }
        3154  
        3155   function u iMouseDown ( e )
        3156   {
        3157           va r myEvent  = gbNav7 | | gbAIR ?  e : event;
        3158           va r clickedE lement = g bNav7 || g bAIR ? myE vent.targe t : myEven t.srcEleme nt;
        3159           if  ( clicked Element.id  == 'DragS ep' )
        3160           {
        3161                    var  tdRank = g etElement(  "OdinFtsR ank" );
        3162                    if (  tdRank ==  null )
        3163                             return ;
        3164                             
        3165                    var  elementWid th = tdRan k.style.wi dth;
        3166                    if(e lementWidt h==null ||  elementWi dth.length ==0)
        3167                    {
        3168                    elem entWidth =  getStyleP ropertyVal ue(tdRank, "width");
        3169                    }
        3170                    if(e lementWidt h != null  && element Width.leng th>0)
        3171                    {
        3172                         //in case  of every t hing fail  try the of fsetwidth  as well
        3173                         if(tdRank. offsetWidt h)
        3174                             elemen tWidth = ' ' +tdRank. offsetWidt h+'px';
        3175                    }
        3176                    
        3177                    if(e lementWidt h != null  && element Width.leng th>0)
        3178                    {
        3179                         var matchR esult = el ementWidth .match( "^ (.+)px$" ) ;
        3180                         if(matchRe sult!=null )
        3181                         {
        3182                             g_nIni tWidth = p arseInt( e lementWidt h.match( " ^(.+)px$"  )[1] );
        3183                             if ( g _nInitWidt h.toString () != "NaN " )
        3184                                 {
        3185                                 g_ nX0 = getE ventX( e ) ;
        3186                                 g_ bDraging =  true;
        3187                             }
        3188                         }
        3189                    }
        3190           }
        3191           el se if ( cl ickedEleme nt.id == ' OdinFtsTit le' )
        3192           {
        3193                    g_nS ortType =  g_nSortTyp e != 1 ? 1  : 2;
        3194                    quic kSortResul t();      
        3195           }
        3196           el se if ( cl ickedEleme nt.id == ' OdinFtsRan k' )
        3197           {
        3198                    g_nS ortType =  0;
        3199                    quic kSortResul t();      
        3200           }
        3201   }
        3202  
        3203   function u iMouseMove ( e )
        3204   {
        3205           va r tdRank =  getElemen t( "OdinFt sRank" );
        3206           if  ( tdRank  == null )
        3207                    retu rn;
        3208           if  ( g_bDrag ing == tru e )
        3209           {
        3210                    var  d = getEve ntX( e ) -  g_nX0;
        3211                    if (  g_nInitWi dth - d >  g_nRankWid thMin )
        3212                             tdRank .style.wid th = g_nIn itWidth -  d;
        3213           }
        3214   }
        3215  
        3216   function u iMouseUp(  e )
        3217   {
        3218           g_ bDraging =  false;
        3219   }
        3220  
        3221   function u iClick( e  )
        3222   {
        3223           va r myEvent  = gbNav7 ?  e : event ;
        3224           va r clickedE lement = g bNav7 ? my Event.targ et : myEve nt.srcElem ent;
        3225           if  ( clicked Element.cl assName ==  "fr_tc" & & clickedE lement.tag Name == "A " )
        3226           {
        3227                    var  lnkAct = g etElement(  "ActiveLi nk" );
        3228                    if (  lnkAct !=  null )
        3229                    {
        3230                             lnkAct .id = "";
        3231                             lnkAct .className  = "fr_tc" ;
        3232                    }
        3233  
        3234                    clic kedElement .id = "Act iveLink";
        3235                    clic kedElement .className  = "fr_act ";
        3236           }
        3237           el se if (gbA IR && clic kedElement .className  == "sl_pa ge" && cli ckedElemen t.tagName  == "LI" )
        3238           {
        3239                var id =  clickedEl ement.id;
        3240                if(id!=n ull && id. length>0)
        3241                {
        3242                         var pageNu m =parseIn t(clickedE lement.id) ;
        3243                         onClickPag e(pageNum) ;
        3244                    }
        3245           }        
        3246   }
        3247  
        3248   if ( gbNav 7 || gbAIR  ||gbSafar i)
        3249   {
        3250           No de.prototy pe.swapNod e = functi on( a_Node  )
        3251           {
        3252                    var  nextSiblin g = this.n extSibling ;
        3253                    var  parentNode  = this.pa rentNode;
        3254                    a_No de.parentN ode.insert Before( th is, a_Node  );
        3255                    pare ntNode.ins ertBefore(  a_Node, n extSibling  );  
        3256           }
        3257  
        3258           do cument.cap tureEvents ( Event.MO USEMOVE |  Event.MOUS EDOWN | Ev ent.MOUSEU P | Event. CLICK );
        3259   }
        3260  
        3261   ////////// ////////// ////////// ////////// ////////// ////////// ////////// /////
        3262   function o nGetProjIn fo(oMsg)
        3263   {
        3264       if(oMs g && oMsg. oParam)
        3265       {
        3266           gb Ready = tr ue;
        3267                    var  oProj = oM sg.oParam;
        3268                    var  aProj = oP roj.aProj;
        3269                    gbXM L = oProj. bXML;
        3270                    if(  aProj && a Proj.lengt h > 0 )
        3271                    {
        3272                             contex t = new Hu ginContext ();
        3273                             goOdin Hunter = n ew HuginHu nter();
        3274                             goOdin Hunter.aPr ojPathes =  new Array ();
        3275                var proj Indx = 0;
        3276                             for (v ar i=0; i< aProj.leng th; i++ )
        3277                             {
        3278                    if(t ypeof(aPro j[i].sFts)  != 'undef ined' && a Proj[i].sF ts != null ){
        3279                                          goOd inHunter.a ProjPathes [projIndx]  = new Obj ect();
        3280                                          goOd inHunter.a ProjPathes [projIndx] .strProjDi r = aProj[ i].sPPath;
        3281                                          goOd inHunter.a ProjPathes [projIndx] .strOdbPat h = aProj[ i].sPPath  + aProj[i] .sDPath +  aProj[i].s Fts;
        3282                         projIndx++ ;
        3283                    }
        3284                             }
        3285                             
        3286                             contex t.reset();
        3287                             contex t.push( go OdinHunter .init, goO dinHunter,
        3288                             regist Listener,  this,
        3289                             Search PendingReq uest, this );
        3290                             contex t.resume() ;
        3291                    }
        3292       }
        3293   }
        3294  
        3295   function l oadFts()
        3296   {
        3297           if ( !gbReady  )
        3298           {
        3299                    var  oResMsg =  new whMess age( WH_MS G_GETPROJI NFO, null,  null );
        3300                    requ est(oResMs g, onGetPr ojInfo);
        3301           }
        3302   }
        3303  
        3304   var gbAIRM ergeArray;
        3305   function o nGetMergeP rojInfo(me rgeProjInf o, strProj Dir)
        3306   {
        3307       goOdin Hunter = n ew HuginHu nter();
        3308           go OdinHunter .aProjPath es = new A rray();
        3309           go OdinHunter .aProjPath es[0] = ne w Object() ;
        3310           go OdinHunter .aProjPath es[0].strP rojDir = s trProjDir 
        3311           go OdinHunter .aProjPath es[0].strO dbPath = g oOdinHunte r.aProjPat hes[0].str ProjDir +  "whxdata/w hfts.xml";
        3312           
        3313           if (mergeProj Info!=null )
        3314           {
        3315                    var  index=0;
        3316                    whil e(index<me rgeProjInf o.length)
        3317                    {
        3318                             goOdin Hunter.aPr ojPathes[i ndex+1] =  new Object ();
        3319                             goOdin Hunter.aPr ojPathes[i ndex+1].st rProjDir =  mergeProj Info[index ];
        3320                             goOdin Hunter.aPr ojPathes[i ndex+1].st rOdbPath =  mergeProj Info[index ] + "whxda ta/whfts.x ml";
        3321                             index+ +;
        3322                    }
        3323                             
        3324           }
        3325  
        3326           co ntext = ne w HuginCon text();
        3327           co ntext.rese t();
        3328           
        3329           go OdinHunter .strQuery  = GetSearc hTextFromU RL();
        3330           co ntext.push ( goOdinHu nter.init,  goOdinHun ter,
        3331                                        Query,  this );
        3332                                        
        3333           co ntext.resu me();
        3334   }
        3335  
        3336   function l oadFts_con text(strPr ojDir , st rFtsFile)
        3337   {
        3338           tr y
        3339           {
        3340                    if(g bAIR)
        3341                             onGetM ergeProjIn fo(gbAIRMe rgeArray,  strProjDir );
        3342                    else  if(gbAIRS SL)
        3343                    {
        3344                         if(isChrom eLocal()){
        3345                             this.p arent.post Message("g etMergePro jInfo" + g MsgSeparat or + " ",  "*");
        3346                         }
        3347                         else{
        3348                                 if (this.pare nt.gbAIRme rgeProject Array != n ull)
        3349                                          onGe tMergeProj Info(this. parent.gbA IRmergePro jectArray,  strProjDi r);
        3350                         }
        3351                    }
        3352           }c atch(e){}
        3353   }
        3354  
        3355   function i sValidType (obj)
        3356   {
        3357           re turn ( (ty peof(obj)! ='undefine d')&&(obj! =null) );
        3358   }
        3359  
        3360   function Q uery()
        3361   {
        3362       if(gbA IRSSL)
        3363       {
        3364           if (goOdinHun ter.bInite d == false )
        3365           {
        3366                setTimeo ut(functio n() { Quer y(); }, 10 );
        3367                return;
        3368           }
        3369       }
        3370           gb AIRSearchS tring  = g oOdinHunte r.strQuery ;
        3371           g_ CurPage =  1;
        3372           if  (isValidT ype(contex t) && isVa lidType(co ntext.aTas ks))
        3373           {
        3374                    whil e(context. aTasks.len gth>0)
        3375                    {
        3376                             contex t.resume() ;
        3377                    }
        3378           }
        3379           co ntext = ne w HuginCon text();
        3380           co ntext.rese t();
        3381           co ntext.push ( goOdinHu nter.query , goOdinHu nter,
        3382                                        proces sHunterRes ult, null  );
        3383           co ntext.resu me();
        3384   }
        3385  
        3386   function c hangeResul tView( a_s trHTML )
        3387   {
        3388           va r resultDi v = getEle ment( gsRe sultDivID  );
        3389           if (resultDiv  )
        3390           {
        3391                    var   resultDiv Parent = g etParentNo de( result Div );
        3392                    if ( !resultDiv Parent )
        3393                             return ;
        3394                    resu ltDiv.inne rHTML = a_ strHTML;
        3395           }
        3396           el se documen t.body.inn erHTML = a _strHTML;
        3397   }
        3398  
        3399   function d isplayMsg(  a_strMsg  )
        3400   {
        3401           if (!gbAIRSSL )
        3402           {
        3403                    //se t num of r esults
        3404                    var  oMsg = new  whMessage (WH_MSG_SE TNUMRSLT,  0, null);
        3405                    noti fy(oMsg);
        3406           }
        3407           ch angeResult View( "<P  CLASS='msg '>" + a_st rMsg + "</ P>" );
        3408   }
        3409  
        3410   function w riteTableH ead()
        3411   {
        3412           if (!gsHideRa nkColumn)
        3413           {
        3414                    if(g bAIRSSL)
        3415                    {
        3416                                      return   "<TABLE CE LLSPACING= 0 CEllPADD ING=0 STYL E='table-l ayout:fixe d; width:1 00%'>" +
        3417                                                       "< THEAD>" + 
        3418                                                                "<TR  STYLE='fo nt-weight: bold'>" +
        3419                                                                         "<TD I D='OdinFts Title'  CL ASS='fr_tt ' STYLE='c ursor:poin ter'>"+gsT itle+"</TD >" +
        3420                                                                         "<TD I D='DragSep '                CLAS S='fr_ts'  STYLE='cur sor:w-resi ze; width: 4px'>&nbsp ;</TD>" +
        3421                                                                         "<TD I D='OdinFts Rank'   CL ASS='fr_tt ' STYLE='c ursor:poin ter; width :60px'>"+g sRank+"^</ TD>" +
        3422                                                                "</T R>" +
        3423                                                       "< /THEAD>" +
        3424                                                       "< TBODY ID=' OdinFtsRsl t'>";
        3425                    }
        3426                    else
        3427                    {
        3428                                      return   "<TABLE CE LLSPACING= 0 CEllPADD ING=0 STYL E='table-l ayout:fixe d; width:1 10%'>" +
        3429                                                       "< THEAD>" + 
        3430                                                                "<TR  STYLE='fo nt-weight: bold'>" +
        3431                                                                         "<TD I D='OdinFts Title'  CL ASS='fr_tt ' STYLE='c ursor:poin ter'>"+gsT itle+"</TD >" +
        3432                                                                         "<TD I D='DragSep '                CLAS S='fr_ts'  STYLE='cur sor:w-resi ze; width: 4px'>&nbsp ;</TD>" +
        3433                                                                         "<TD I D='OdinFts Rank'   CL ASS='fr_tt ' STYLE='c ursor:poin ter'>"+gsR ank+"^</TD >" +
        3434                                                                "</T R>" +
        3435                                                       "< /THEAD>" +
        3436                                                       "< TBODY ID=' OdinFtsRsl t'>";
        3437                    }
        3438           }
        3439           el se
        3440                    retu rn "<TABLE  CELLSPACI NG=0 CEllP ADDING=0 S TYLE='tabl e-layout:f ixed; widt h:110%'>"  +
        3441                                      "<TBODY  ID='OdinFt sRslt'>";
        3442   }
        3443  
        3444   function w riteResult ( a_strUrl , a_strHig hlight, a_ strTitle,  a_strFont,  a_nIndex,  a_sSummar y )
        3445   {
        3446           va r strOutpu t = "";
        3447           if (a_sSummar y.length >  0)
        3448           {
        3449                    strO utput = "< TR>" +
        3450                                      "<TD CLA SS='fr_tc' ><A CLASS= 'fr_tc'" +
        3451                                      " HREF=' " + a_strU rl + "'" +  ">" + _te xtToHtml_n onbsp(a_st rTitle) +  "</A><div> " + _textT oHtml_nonb sp(a_sSumm ary) + "</ div><br></ TD>";
        3452                    if(! gsHideRank Column)
        3453                    {
        3454                                      strOutpu t += "<TD  CLASS='fr_ tc'>&nbsp; </TD>" +
        3455                                      "<TD CLA SS='fr_tc'  STYLE='te xt-align:c enter'>" +  a_nIndex  + "</TD>";
        3456                    }
        3457                    strO utput += " </TR>";
        3458           }
        3459           el se
        3460           {
        3461                    strO utput = "< TR>" +
        3462                                      "<TD CLA SS='fr_tc' ><A CLASS= 'fr_tc' ST YLE='font- weight:nor mal;'" +
        3463                                      " HREF=' " + a_strU rl + "'" +  ">" + _te xtToHtml_n onbsp(a_st rTitle) +  "</A></TD> ";
        3464                    if(! gsHideRank Column)
        3465                    {
        3466                                      strOutpu t += "<TD  CLASS='fr_ tc'>&nbsp; </TD>" +
        3467                                      "<TD CLA SS='fr_tc'  STYLE='te xt-align:c enter'>" +  a_nIndex  + "</TD>";
        3468                    }
        3469                    strO utput += " </TR>";
        3470           }
        3471  
        3472           re turn strOu tput;
        3473   }
        3474  
        3475   function w riteTableT ail()
        3476   {
        3477           re turn  "</T BODY>" +
        3478                             "</TAB LE>";
        3479   }
        3480  
        3481   function H andleAIRSe archFuncti on()
        3482   {
        3483           if (gAIRSearc hObject !=  undefined  && gAIRSe archObject .displayFu nction !=  undefined)
        3484           {
        3485                    gAIR SearchObje ct.display Function() ;
        3486                    retu rn;
        3487           }
        3488   }
        3489  
        3490   function d isplayTopi cs( a_Quer yResult)
        3491   {
        3492           Ha ndleAIRSea rchFunctio n();
        3493           va r sHTML =  "";
        3494           va r sLine =  "";
        3495           va r szSearch Strings= g bAIRSearch String;
        3496           va r sHighlig ht = "CLRF =" + gsHLC olorFront  +
        3497                                                ",CLRB="  + gsHLColo rBackgroun d + ",HL=" ;
        3498           
        3499           va r nMaxResu lt = 10 ;
        3500           if (g_nMaxRes ult > 0)
        3501                nMaxResu lt = g_nMa xResult;
        3502           if (gbAIRSSL)
        3503                    nMax Result = 2 5;
        3504           
        3505           va r i = 0;
        3506           if  (g_CurPag e < 1)
        3507                g_CurPag e = 1 ;
        3508           
        3509           if  ( a_Query Result !=  null )
        3510           {
        3511                    if(! gbAIRSSL)
        3512                    {
        3513                             //set  num of res ults
        3514                             var oM sg = new w hMessage(W H_MSG_SETN UMRSLT, a_ QueryResul t.aTopics. length, nu ll);
        3515                             notify (oMsg);
        3516                    }
        3517                    
        3518           if  (gbShowTo talNumberO fSearchRes ults && a_ QueryResul t.aTopics. length > 0 )
        3519           {
        3520                var strT emp = gsTo talNumberO fSearchRes ults.repla ce(/%1/i,  a_QueryRes ult.aTopic s.length);
        3521                sHTML =  "<p class= 'msg'>" +  strTemp +  "</p>";
        3522                sHTML += "<hr width =150% />";
        3523           }
        3524  
        3525  
        3526                    sHTM L += write TableHead( );
        3527                    if (  gbHighLig ht )
        3528                    {
        3529                             var st rAddForHig hlight;
        3530                             strAdd ForHighlig ht = "?" ;
        3531                             if(gbA IRSSL)
        3532                             {
        3533                                      strAddFo rHighlight  += "searc hhighlight TextString RoboHelp=\ "";   
        3534                                      //in cas e of AIR,  we need to  add synon yms as wel l
        3535                                      if(gbAIR SynonymStr ing!=null  && gbAIRSy nonymStrin g.length>0 )
        3536                                          szSe archString s+= gbAIRS ynonymStri ng;
        3537                             }
        3538                             sHighl ight = str AddForHigh light + es cape( szSe archString s ) + "\"" ;
        3539                    }
        3540                    else
        3541                             sHighl ight = "";
        3542                    
        3543                    for(  i = (g_Cu rPage-1)*n MaxResult;  (i < a_Qu eryResult. aTopics.le ngth)&&(i< (g_CurPage *nMaxResul t)); i++ )
        3544                    {
        3545                             var sz TopicURL =  a_QueryRe sult.aTopi cs[i].strU rl;
        3546                             var bA ddHighLigh t=false;
        3547                             if(gbA IRSSL) 
        3548                             {
        3549                                      if(!_isR emoteUrl(s zTopicURL)  )
        3550                                      {
        3551                                               bAddHighLi ght = true ;
        3552                                      }
        3553                                      else if( isValidTyp e(a_QueryR esult.aTop ics[i].str ProjDir))
        3554                                      {
        3555                                               //check if  the lengt h is great er than
        3556                                               if(a_Query Result.aTo pics[i].st rProjDir.l ength>0)
        3557                                               {
        3558                                                       bA ddHighLigh t = true;
        3559                                               }
        3560                                      }
        3561                             }
        3562                             
        3563                             if(bAd dHighLight )
        3564                             {
        3565                                      //if it  is AIR, we  need to a dd the hig hlight opt ion now
        3566                                      szTopicU RL += sHig hlight;
        3567                             }
        3568                             sLine  += writeRe sult( szTo picURL,
        3569                                                                           sHig hlight,
        3570                                                                           a_Qu eryResult. aTopics[i] .strTitle,
        3571                                                                           getF ontStyle(g oFont),
        3572                                                                           a_Qu eryResult. aTopics[i] .nIndex,
        3573                                                                           a_Qu eryResult. aTopics[i] .strSummar y );
        3574                             if( i  & 0xF == 0  )
        3575                             {
        3576                                      sHTML +=  sLine;
        3577                                      sLine =  "";
        3578                             }
        3579                    }
        3580                    if(  sLine.leng th > 0 )
        3581                             sHTML  += sLine;
        3582                                              
        3583                    sHTM L += write TableTail( );
        3584                    
        3585                    var  nNumPages  = Math.cei l(a_QueryR esult.aTop ics.length  / nMaxRes ult );
        3586                    var  sPageHTML  = "" ;
        3587                    var  j ;
        3588                    if ( nNumPages  > 1)
        3589                    {
        3590                             sHTML  += "<div>< ul style=\ "list-styl e:none; ma rgin:0; pa dding:0\"  >" ;
        3591                             if (g_ CurPage >  1)
        3592                                      sPageHTM L += "<li  class='sl_ page' id=' "+(g_CurPa ge-1).toSt ring()+"'  onMouseOve r=\"this.c lassName=' sl_pageC'\ " onMouseO ut=\"this. className= 'sl_page'\ " onclick= \"onClickP age(" + (g _CurPage-1 ).toString () + ")\"> &lt;&lt;</ li>" ;         
        3593                             var sC lass = "sl _page" ;
        3594                             for (j =g_CurPage ;j<=nNumPa ges && j<= (g_CurPage +g_nMaxPag es) ;j++)
        3595                             {
        3596                                      if (j ==  g_CurPage  )
        3597                                               sClass = " sl_pageC"  ;
        3598                                      else
        3599                                               sClass = " sl_page" ;
        3600                                      sPageHTM L += "<li  class='" + sClass + " ' id='"+j. toString() +"' onMous eOver=\"th is.classNa me='sl_pag eC'\" onMo useOut=\"t his.classN ame='" + s Class + "' \" onclick =\"onClick Page(" + j  + ")\">"  + j.toStri ng() + "</ li>" ;
        3601                             }
        3602                             
        3603                             if(g_C urPage !=  nNumPages)
        3604                                      sPageHTM L += "<li  class='sl_ page' id=' "+(g_CurPa ge+1).toSt ring()+"'  onMouseOve r=\"this.c lassName=' sl_pageC'\ " onMouseO ut=\"this. className= 'sl_page'\ " onclick= \"onClickP age(" + (g _CurPage+1 ).toString () + ")\"> &gt;&gt;</ li>" ;                          
        3605                             sHTML  += sPageHT ML ;
        3606                             sHTML  += "</ul>< /div>" ;
        3607                    }                 
        3608           }
        3609           
        3610           if ( a_QueryR esult.aTop ics.length  == 0 )
        3611                    sHTM L = "<P CL ASS='msg'> " + gsNoTo pics + "</ P>"
        3612           el se
        3613                    sHTM L= "<dl>"  + sHTML +  "</dl>";
        3614  
        3615           ch angeResult View( sHTM L );
        3616           if (gbAIR)
        3617           {
        3618                    quic kSortResul t();
        3619                    if(g bAIRSearch ResultDisp layDoneFn! =null)
        3620                    {
        3621                             gbAIRS earchResul tDoneSteps ++;
        3622                             if(gbA IRSearchRe sultDoneSt eps>0)
        3623                             {
        3624                                      gbAIRSea rchResultD one = true ;
        3625                                      gbAIRSea rchResultD oneSteps =  0;
        3626                                      gbAIRSea rchResultD isplayDone Fn();
        3627                             }
        3628                    }
        3629           }        
        3630           el se    setT imeout( "q uickSortRe sult();",  1 );
        3631   }
        3632  
        3633   function d ummySearch ResultFn()
        3634   {
        3635           // don no
        3636   }
        3637  
        3638   function o nClickPage ( a_nPageN umber )
        3639   {
        3640       g_CurP age = a_nP ageNumber  ;
        3641       g_CurS tate = ECS _FOUND ;
        3642       update ResultView ();
        3643   }
        3644  
        3645   function d isplaySear chProgress Bar( a_nPr ogress )
        3646   {
        3647           va r pb = get Element( ' SearchProg ressBar' ) ;
        3648           va r pt = get Element( ' SearchProg ress' );
        3649           if ( !pb || ! pt )
        3650           {
        3651                    var  sHTML = "< P ID='Sear chProgress ' CLASS='p b_tt'>" +  gsSearchin g + " " +  a_nProgres s + "%</P> \n" +
        3652                                               "<DIV CLAS S='pb_out' >\n" +
        3653                                               "<P ID='Se archProgre ssBar' CLA SS='pb_in'  STYLE='wi dth:" + a_ nProgress  + "%'></P> \n" +
        3654                                               "</DIV>\n"  +
        3655                                               "<CENTER>< P CLASS='p b_cancel'  ONMOUSEDOW N='context .stop()'>" +gsCancel+ "</P></CEN TER>\n";
        3656                    chan geResultVi ew( sHTML  );
        3657           }
        3658           el se
        3659           {
        3660                    setI nnerHTML(  pt, gsSear ching + "  " + a_nPro gress + "% " );
        3661                    pb.s tyle.width  = a_nProg ress + "%" ;
        3662           }
        3663   }
        3664  
        3665   function u pdateResul tView()
        3666   {
        3667           if  ( g_CurSt ate == ECS _SEARCHING  )
        3668                    disp laySearchP rogressBar ( goOdinHu nter.nProg ress );
        3669                    
        3670           el se if ( g_ CurState = = ECS_FOUN D )
        3671                    disp layTopics(  goOdinHun ter.queryR esult );
        3672                    
        3673           el se if ( g_ CurState = = ECS_SEAR CHFAILED )
        3674                    disp layMsg( co ntext.strM sg );
        3675                    
        3676           el se if ( g_ CurState = = ECS_FATA LERROR )
        3677                    disp layMsg( co ntext.strM sg );
        3678                    
        3679           el se if ( g_ CurState = = ECS_CANC ELED )
        3680                    disp layMsg( gs Canceled ) ;
        3681                    
        3682           if (g_CurStat e == ECS_S EARCHFAILE D ||
        3683                g_CurSta te == ECS_ FATALERROR  ||
        3684                g_CurSta te == ECS_ CANCELED 
        3685              )
        3686           {
        3687                HandleAI RSearchFun ction();
        3688           }
        3689   }
        3690  
        3691   function p rocessHunt erResult(  a_Context  )
        3692   {
        3693           if  ( a_Conte xt )
        3694           {
        3695                    upda teResultVi ew();
        3696                    if(g bAIR)
        3697                             proces sHunterRes ult();
        3698                    else  setTimeou t( "proces sHunterRes ult();", 1  );
        3699                    retu rn;
        3700           }
        3701           
        3702           if  ( goOdinH unter == n ull )
        3703                    retu rn;
        3704  
        3705           if  ( !goOdin Hunter.bSu cc )
        3706           {
        3707                    g_Cu rState = E CS_SEARCHF AILED;
        3708                    upda teResultVi ew();
        3709                    retu rn;
        3710           }
        3711  
        3712           g_ CurState =  ECS_FOUND ;
        3713           up dateResult View();
        3714   }
        3715  
        3716   function s tringToBoo lean(strin g){
        3717           sw itch(strin g.toLowerC ase()){
        3718                    case  "true": c ase "yes":  case "1":  return tr ue;
        3719                    case  "false":  case "no":  case "0":  case null : return f alse;
        3720                    defa ult: retur n Boolean( string);
        3721           }
        3722   }
        3723  
        3724   function S etVariable sFromNameV aluePairSt ring(strNa meValuePai r,bDecodeV alue)      //we need  to decode  in case of  BB URL pa rameters 
        3725   {
        3726       var nv Pairs = st rNameValue Pair.split ('&');
        3727  
        3728       for (i  = 0; i <  nvPairs.le ngth; i++)  {
        3729           va r nvPair =  nvPairs[i ].split("= ");
        3730           va r name = n vPair[0];
        3731           va r value =  nvPair[1];
        3732                    
        3733                    if(b DecodeValu e)
        3734                    {
        3735                             value  = decodeUR IComponent (value);
        3736                    }
        3737                    
        3738                    
        3739                    if ( window[nam e] != unde fined) 
        3740                    {
        3741                             if( ty peof windo w[name] ==  'number')
        3742                             {        
        3743                                      window[n ame] = str ingToBoole an(value);
        3744                             }
        3745                if( type of window[ name] == ' boolean')
        3746                             {        
        3747                                      window[n ame] = str ingToBoole an(value);
        3748                             }
        3749                             else
        3750                                      window[n ame] = val ue;   
        3751                    }
        3752       }
        3753   }
        3754  
        3755   function G etSearchTe xtFromURL( )
        3756   {
        3757       var st rLocation  = document .location. href;
        3758           
        3759           st rLocation  = decodeUR I(strLocat ion);
        3760  
        3761           va r searchSt ring = str Location.s ubstring(s trLocation .indexOf(' ?') + 1 );
        3762           
        3763       SetVar iablesFrom NameValueP airString( searchStri ng,true);
        3764  
        3765       return  gsSearchQ uery;
        3766           
        3767   }
        3768  
        3769   function s etSearchDi splayFunct ion(funcNa me)
        3770   {
        3771           gA IRSearchOb ject = new  Object();
        3772           gA IRSearchOb ject.displ ayFunction  = funcNam e;
        3773   }
        3774  
        3775   if ( gbAIR SSL || !wi ndow.gbTes ting )
        3776   {
        3777           if  ( window. gbWhUtil & & window.g bWhLang &&  window.gb WhVer &&
        3778                     (wi ndow.gbAIR SSL || 
        3779                             (
        3780                                       window. gbWhProxy  &&
        3781                                       window. gbWhMsg 
        3782                             )
        3783                    )
        3784           )
        3785           {
        3786                    goFo nt=new whF ont("Verda na","8pt", "#000000", "normal"," normal","n one");
        3787                    goEr rFont=new  whFont("Ve rdana","8p t","#00000 0","normal ","bold"," none");
        3788                    goHo verFont=ne w whFont(" Verdana"," 8pt","#007 f00","norm al","norma l","underl ine");
        3789                    if(! gbAIR)
        3790                             window .onload=wi ndow_OnLoa d;
        3791                    wind ow.onbefor eunload=wi ndow_BUnlo ad;
        3792                    wind ow.onunloa d=window_U nload;
        3793                    if(! gbAIRSSL)
        3794                    {
        3795                             regist erListener 2(WH_MSG_P ROJECTREAD Y);
        3796                             regist erListener 2(WH_MSG_S ETMAXRSLT) ;
        3797                    }
        3798                    gbWh FHost=true ;
        3799           }
        3800           el se
        3801           {
        3802                    docu ment.locat ion.reload ();
        3803           }
        3804   }
        3805  
        3806   function u tf8Compare (strText1, strText2)
        3807   {
        3808           va r strt1=st rText1;
        3809           va r strt2=st rText2;
        3810  
        3811           tr y {
        3812                    strt 1=strText1 .toLowerCa se();
        3813           }
        3814           ca tch(er) {
        3815           }
        3816  
        3817           tr y {
        3818                    strt 2=strText2 .toLowerCa se();
        3819           }
        3820           ca tch(er) {
        3821           }
        3822  
        3823           if (strt1<str t2) return  -1;
        3824           if (strt1>str t2) return  1;
        3825           re turn 0;
        3826   }
        3827  
        3828  
        3829   function l trim(str) 
        3830           fo r(var k =  0; k < str .length &&  isWhitesp ace(str.ch arAt(k));  k++);
        3831           re turn str.s ubstring(k , str.leng th);
        3832   }
        3833   function r trim(str)  {
        3834           fo r(var j=st r.length-1 ; j>=0 &&  isWhitespa ce(str.cha rAt(j)) ;  j--) ;
        3835           re turn str.s ubstring(0 ,j+1);
        3836   }
        3837   function t rim(str) {
        3838           re turn ltrim (rtrim(str ));
        3839   }
        3840   function i sWhitespac e(charToCh eck) {
        3841           va r whitespa ceChars =  " \t\n\r\f ";
        3842           re turn (whit espaceChar s.indexOf( charToChec k) != -1);
        3843   }
        3844  
        3845  
        3846   document.o nmousedown  = uiMouse Down;
        3847   document.o nmousemove  = uiMouse Move;
        3848   document.o nmouseup =  uiMouseUp ;
        3849   document.o nclick = u iClick;