home *** CD-ROM | disk | FTP | other *** search
/ Mundo do CD-ROM 118 / cdrom118.iso / internet / webaroo / WebarooSetup.exe / Webaroo.msi / _DC229DB93036494885118E377367C5E5 < prev    next >
Encoding:
Text File  |  2006-03-23  |  56.1 KB  |  2,029 lines

  1. var cityListXML = new Array();
  2. var TopicBreadCrum = "";
  3. var displayMySitesIfNoPacks = true;
  4.  
  5. var PackSearcherID = "0"; // this means all Web packs except websites
  6. var SiteSearcherID = "-1";
  7. var selectAll = true;
  8.  
  9. var channelNumber = new Array();
  10. var channelDescription = new Array();
  11.  
  12. var channelSubscriptionIDs = new Array();
  13. var channelSubscriptionNames = new Array();
  14.  
  15. /** Our function that initializes when the page
  16.     is finished loading. */
  17. function InitRSH() 
  18. {
  19.     MM_preloadImages('images/webaroo_search_f2.gif','images/webaroo_contents_f2.gif','images/webaroo_prefs_f2.gif','images/webaroo_help_f2.gif');
  20.     // initialize the DHTML History framework
  21.     dhtmlHistory.initialize();
  22.    
  23.     // add ourselves as a DHTML History listener
  24.     dhtmlHistory.addListener(HandleHistoryChange);
  25.     
  26.     if (dhtmlHistory.isFirstLoad())
  27.     {
  28.         historyStorage.put("SearchIndex", 0); // 0 indicates everything
  29.         HandleHistoryChange(window.location.href, "");
  30.     }
  31.     else
  32.     {
  33.         GetStoredInfo();
  34.     }
  35. }
  36.  
  37. function GetStoredInfo()
  38. {
  39.     var searchOptionIndex = historyStorage.get("SearchIndex");
  40.     if (searchOptionIndex != null)
  41.     {
  42.         document.frmSearch.searchOption[searchOptionIndex].checked = true;
  43.     }
  44.     else
  45.     {
  46.         searchOptionIndex = 0;
  47.         SetSearchIndex(searchOptionIndex);
  48.     }
  49.     
  50.     var searchValue = historyStorage.get("SearchValue");
  51.     var searchName = historyStorage.get("SearchName");
  52.     if (searchValue != null)
  53.     {
  54.         SetAllSearchOptions(searchValue, searchName, searchOptionIndex, 0);
  55.     }
  56.     
  57.     channelNumber = historyStorage.get("ChannelNos");
  58.     channelDescription = historyStorage.get("ChannelNames");
  59.     if (channelNumber == null)
  60.     {
  61.         GetChannelList();
  62.     }
  63.     
  64.     channelSubscriptionNames = historyStorage.get("SubscriptionNames");
  65.     channelSubscriptionIDs = historyStorage.get("SubscriptionIds");
  66.     if (channelSubscriptionNames == null)
  67.     {
  68.         GetSubInfo();
  69.     }
  70. }
  71.  
  72. function GetSubInfo()
  73. {
  74.  
  75.     for(var j =0; j<channelNumber.length;j++)
  76.     {
  77.  
  78.         if(channelNumber[j] =='-1') // ignore mysites
  79.             continue;
  80.         // Also get for the other channels, right now its only for channel 1
  81.         var url="/webaroo/e29f1fe6/citylist?channelid=" + channelNumber[j];
  82.         SendSynchornousRequest(url, PopulateSubInfo, j);
  83.  
  84.     }
  85.     
  86.     historyStorage.put("SubscriptionNames", channelSubscriptionNames);
  87.     historyStorage.put("SubscriptionIds", channelSubscriptionIDs);
  88. }
  89.  
  90. function PopulateSubInfo(cityResults, channelIndex)
  91. {
  92.     var subNames = new Array();
  93.     var subIds = new Array();
  94.  
  95.     cityListXML[channelIndex] = cityResults;
  96.     
  97.     if(!cityResults)
  98.         return;
  99.     
  100.     var result = cityResults.getElementsByTagName('subscription');
  101.     if(result.length < 1)
  102.         return;
  103.  
  104.     for (var j=0;j<result.length;j++)
  105.     {
  106.         if (result[j].nodeType != 1) continue;
  107.  
  108.         var subName = result[j].getAttribute("name");
  109.         subNames[j] = subName;
  110.         var subId = result[j].getAttribute("id");
  111.         subIds[j] = doubleUrlEncode(subId);
  112.     }
  113.     if(channelSubscriptionIDs == null) // This code is for refresh on the search browse UI page
  114.     {
  115.         channelSubscriptionIDs = new Array();
  116.         channelSubscriptionNames = new Array();
  117.     }
  118.     channelSubscriptionIDs[channelIndex] = subIds;
  119.     channelSubscriptionNames[channelIndex] = subNames;
  120.  
  121. }
  122.  
  123. function ChangeTabDisplayMode(isShow)
  124. {
  125.     var displayMode;
  126.     
  127.     if (isShow)
  128.     {
  129.         displayMode="block";
  130.     }
  131.     else
  132.     {
  133.         displayMode="none";
  134.     }
  135.  
  136.     document.getElementById('browseTabs').style.display=displayMode;
  137.     document.getElementById('browseTitle').style.display=displayMode;
  138. }
  139.  
  140. function HighlightTab(tabName)
  141. {
  142.     var tabClass = "tab"
  143.     var activeClass = tabClass + " activeTab";
  144.     var packTab = document.getElementById('tabRooPack');
  145.     var siteTab = document.getElementById('tabWebSite');
  146.     
  147.     if (tabName == "pack")
  148.     {
  149.         packTab.className = activeClass;
  150.         siteTab.className = tabClass;
  151.     }
  152.     else
  153.     {
  154.         packTab.className = tabClass;
  155.         siteTab.className = activeClass;
  156.     }
  157. }
  158.  
  159. function StoreSearchOptionIndex()
  160. {
  161.     var searchOptionIndex = document.frmSearch.searchOption[0].checked ? 0 : 1;
  162.     historyStorage.put("SearchIndex", searchOptionIndex);
  163. }
  164.  
  165. function SetSearchIndex(searchIndex)
  166. {
  167.     document.frmSearch.searchOption[searchIndex].checked = true;
  168.     historyStorage.put("SearchIndex", searchIndex);
  169. }
  170.  
  171. function SetSearchOptions(id, displayName, addToHistory)
  172. {
  173.     SetAllSearchOptions(id, displayName, 1, addToHistory);
  174. }
  175.  
  176. function SetAllSearchOptions(id, displayName, index, addToHistory)
  177. {
  178.     document.getElementById('spanOnly').style.display = "inline";
  179.  
  180.     document.frmSearch.searchOption[1].value = id;
  181.     document.frmSearch.searchOption[index].checked = true;
  182.  
  183.     var onlyLabel = document.getElementById('elemOnly');
  184.     onlyLabel.innerHTML = displayName;
  185.     
  186.     if (addToHistory == 1)
  187.     {
  188.         historyStorage.put("SearchName", displayName);
  189.         historyStorage.put("SearchValue", id);
  190.         StoreSearchOptionIndex();
  191.     }
  192. }
  193.  
  194. function GetBrowseMySiteAsynchronously(addToHistory)
  195. {
  196.     displayMySitesIfNoPacks = false;
  197.     // Clear the tables
  198.     ClearAllTables();    
  199.     
  200.     if(selectAll)
  201.     {
  202.         document.frmSearch.searchOption[0].checked = true;
  203.         selectAll = false;
  204.     }
  205.  
  206.     ChangeTabDisplayMode(true);
  207.     HighlightTab("site");
  208.     // Hide the other div block
  209.     ShowDataLoading();
  210.     
  211.     var url="/webaroo/e29f1fe6/browsemysites";
  212.     SendAsynchornousRequest(url, "", mySitesPopulate, "");
  213.  
  214.     if (addToHistory == 1)
  215.     {
  216.         dhtmlHistory.add(url, "");
  217.     }
  218. }
  219.  
  220. function mySitesPopulate(browseMySitesXML, data)
  221. {
  222.     // Clear the tables
  223.     ClearAllTables();    
  224.     
  225.     // Render the mysites in table browsemysitetable
  226.     var tablemysite = document.getElementById('browsemysitetable');
  227.     var htmldata ='';
  228.     
  229.     var listObject = browseMySitesXML.getElementsByTagName('Response');
  230.     var rowkeys = new Array();
  231.     var rowvalues = new Array();
  232.     var keys = new Array();
  233.     var values = new Array();
  234.     var newRow; 
  235.     
  236.     // Add the first Header Row
  237.     keys[0] = "innerHTML";
  238.     keys[1] = "className";
  239.     values[0] = '<b>Web Sites</b>';
  240.     values[1] = "resultBoldTitle";
  241.     newRow = AddRowToTable('browsemysitetable',rowkeys ,rowvalues,keys,values);
  242.  
  243.     if (listObject[0].childNodes.length > 0)
  244.     {
  245.         keys[1] = "align";
  246.         values[0] = 'Site Name';
  247.         values[1] = "left";
  248.         newRow = AddRowToTable('browsemysitetable',rowkeys ,rowvalues,keys,values);
  249.         
  250.         keys[0] = "innerHTML";
  251.         keys[1] = "align";
  252.         values[0] = 'Site URL';
  253.         values[1] = "left";
  254.         AddCellToRow(newRow,keys,values);
  255.             
  256.         keys[0] = "innerHTML";
  257.         keys[1] = "align";
  258.         values[0] = 'Last Updated On';
  259.         values[1] = "left";
  260.         AddCellToRow(newRow,keys,values);
  261.         
  262.         // Add a empty Row
  263.         keys[0] = "innerHTML";
  264.         keys[1] = "align";
  265.         values[0] = " ";
  266.         values[1] = "left";
  267.         AddRowToTable('browsemysitetable',rowkeys ,rowvalues,keys,values);
  268.         AddRowToTable('browsemysitetable',rowkeys ,rowvalues,keys,values);
  269.         
  270.             for (var j=0;j<listObject[0].childNodes.length;j++)
  271.             {
  272.                 if (listObject[0].childNodes[j].nodeType != 1) continue;
  273.                 
  274.                 var siteName = listObject[0].childNodes[j].getElementsByTagName('SiteName');
  275.                 var siteURL = listObject[0].childNodes[j].getElementsByTagName('Url');
  276.                 var siteCachedUrl = listObject[0].childNodes[j].getElementsByTagName('CachedUrl');
  277.                 var siteLastUpdatedOn = listObject[0].childNodes[j].getElementsByTagName('LastUpdated');
  278.                 var siteSubscriptionId = listObject[0].childNodes[j].getElementsByTagName('Id');
  279.                 
  280.                 var siteNameStr = siteName[0].firstChild.nodeValue;
  281.                 var siteURLStr = siteURL[0].firstChild.nodeValue;
  282.                 var siteCachedUrlStr = siteCachedUrl[0].firstChild.nodeValue;
  283.                 var siteLastUpdatedOnStr = siteLastUpdatedOn[0].firstChild.nodeValue;
  284.                 var siteSubscriptionStr = siteSubscriptionId[0].firstChild.nodeValue;;
  285.                 
  286.                 keys[0] = "innerHTML";
  287.                 keys[1] = "align";
  288.                 // Wrap the SiteNameStr if its more than 20 characters
  289.                 if(siteNameStr.length > 20)
  290.                     siteNameStr = TruncateString(siteNameStr,20);
  291.                 values[0] = siteNameStr;
  292.                 values[1] = "left";
  293.                 newRow = AddRowToTable('browsemysitetable',rowkeys ,rowvalues,keys,values);
  294.                 
  295.                 keys[0] = "innerHTML";
  296.                 keys[1] = "class";
  297.                 // Wrap the SiteURLStr if its more than 80 characters
  298.                 if(siteURLStr.length > 70)
  299.                     siteURLStr = WrapString(siteURLStr,70); 
  300.                 values[0] = '<a href="' + siteCachedUrlStr + '">' + siteURLStr+ '</a>';
  301.                 values[1] = "resultLink";
  302.                 AddCellToRow(newRow,keys,values);
  303.                 
  304.                 keys[0] = "innerHTML";
  305.                 keys[1] = "align";
  306.                 values[0] = '<font style="font-size: 10px;">' + siteLastUpdatedOnStr + '</font>';
  307.                 values[1] = "left";
  308.                 AddCellToRow(newRow,keys,values);
  309.             
  310.                 // Add 2 empty Rows
  311.                 keys[0] = "innerHTML";
  312.                 keys[1] = "align";
  313.                 values[0] = " ";
  314.                 values[1] = "left";
  315.                 AddRowToTable('browsemysitetable',rowkeys ,rowvalues,keys,values);
  316.                 AddRowToTable('browsemysitetable',rowkeys ,rowvalues,keys,values);
  317.             }        
  318.         // Hide message below search box
  319.         document.getElementById('NoContentMessage').style.display = "none";
  320.     }
  321.     else
  322.     {
  323.         var rowkeys = new Array();
  324.         var rowvalues =new Array();
  325.         keys[0] = "innerHTML";
  326.         keys[1] = "align";
  327.         var url = "/webaroo/e29f1fe6/content";
  328.         values[0] = 'No Web Sites available in your library. Go to the <a href="' + url + '">Content</a> page to add a Web Site. If you have already added a Web Site, please wait for the updates to complete.';
  329.         values[1] = "left";
  330.         AddRowToTable('browsemysitetable',rowkeys ,rowvalues,keys,values);
  331.         document.frmSearch.searchOption[0].checked = true;
  332.  
  333.         // Also show the message below search box
  334.         document.getElementById('NoContentMessage').style.display = "inline";
  335.     }
  336.     // Show the radio button irrespective of content status
  337.     SetSearchOptions(SiteSearcherID, "Only Web Sites", 1);
  338.     // Hide the other div block
  339.     ShowMySite();
  340. }
  341.  
  342. function GetChannelList()
  343. {
  344.     // URL is /getChannelList
  345.     // XML Format
  346.     // <Channel>
  347.     //    <number></number>
  348.     //    <Description></Description>
  349.     // </Channel>
  350.     var url="/webaroo/e29f1fe6/channellist";
  351.     processXMLData(url);
  352.     var channelList = xmlContent;
  353.     
  354.     channelNumber = new Array();
  355.     channelDescription = new Array();
  356.     var Channel = channelList.getElementsByTagName('subscription');
  357.     if(Channel.length >0)
  358.     {
  359.         for (var j=0;j<Channel.length;j++)
  360.         {
  361.             channelNumber[j] = Channel[j].getAttribute('id');
  362.             channelDescription[j] = Channel[j].getAttribute('name');
  363.         }    
  364.     } 
  365.     // Sort the channels in numerically increasing order
  366.     var tempchannelNumber = new Array();
  367.     var tempchannelDescription = new Array();
  368.     var AddedMySiteChannelFlag = false;
  369.  
  370.     tempchannelNumber[0] = "-1";
  371.     tempchannelDescription[0]="MySites";
  372.  
  373.     for (var j=0;j<Channel.length;j++)
  374.     {
  375.         if(channelNumber[j]==-1)
  376.         {
  377.             AddedMySiteChannelFlag = true;
  378.             continue;    
  379.         }    
  380.         var k = tempchannelNumber.length - 1;
  381.  
  382.         for(;((k >= 0) && (tempchannelNumber[k] > channelNumber[j])); k--)
  383.         {
  384.             tempchannelNumber[k+1] = tempchannelNumber[k];
  385.             tempchannelDescription[k+1] = tempchannelDescription[k];
  386.         }
  387.         tempchannelNumber[k+1] = channelNumber[j];
  388.         tempchannelDescription[k+1] = channelDescription[j];
  389.  
  390.     }
  391.  
  392.     // copy back to original
  393.     channelNumber = tempchannelNumber;
  394.     channelDescription = tempchannelDescription;
  395.  
  396.     historyStorage.put("ChannelNos", channelNumber);
  397.     historyStorage.put("ChannelNames", channelDescription);
  398. }
  399.  
  400. function GetTopicsAsynchronously(addToHistory)
  401. {
  402.     // Clear tables
  403.     ClearAllTables();
  404.  
  405.     if(selectAll)
  406.     {
  407.         document.frmSearch.searchOption[0].checked = true;
  408.         selectAll = false;
  409.     }
  410.  
  411.     ChangeTabDisplayMode(true);
  412.     HighlightTab("pack");
  413.     ShowDataLoading();
  414.     
  415.     // First find out how many channels, user is subscribed to
  416.     GetChannelList();
  417.     
  418.     // Show the Web Pack title
  419.     var keys = new Array();
  420.     var values = new Array();
  421.     
  422.     var innertext = '<b>Web Packs</b>';
  423.     keys[0]='innerHTML';
  424.     keys[1]='className';
  425.     values[0]= innertext;
  426.     values[1]='resultBoldTitle';
  427.     var rootitleelem = document.getElementById('browsetitletable');
  428.     var curRow=rootitleelem.insertRow(-1);
  429.     AddCellToRow(curRow,keys,values);
  430.     // put empty row
  431.     values[0]= ' ';
  432.     curRow=rootitleelem.insertRow(-1);
  433.     AddCellToRow(curRow,keys,values);
  434.     
  435.     var url ="";
  436.     for(var j =0; j<channelNumber.length;j++)
  437.     {
  438.         if(channelNumber.length ==1)
  439.         {
  440.             // Just make a dummy call for channel 1
  441.             url="/webaroo/e29f1fe6/citylist?channelid=1";
  442.             SendSynchornousRequest(url, topicPopulate, j);
  443.         }
  444.         else
  445.         {
  446.             if(channelNumber[j] =='-1') // ignore mysites
  447.                 continue;
  448.             // Also get for the other channels, right now its only for channel 1
  449.             url="/webaroo/e29f1fe6/citylist?channelid=" + channelNumber[j];
  450.             SendSynchornousRequest(url, topicPopulate, j);
  451.         }
  452.     }
  453.     if (addToHistory == 1)
  454.     {
  455.         dhtmlHistory.add(url, "");
  456.     }
  457. }
  458.  
  459. function HandleHistoryChange(newUrl, historyData) 
  460. {
  461.     var currentLocation = window.location.href.split("#");
  462.     
  463.     if (currentLocation[0].indexOf("/webaroo/e29f1fe6/search") == -1)
  464.     {
  465.         return;
  466.     }
  467.     
  468.     var newUrlParts = newUrl.split("#");
  469.     var newLocation = (newUrlParts.length > 1) ? newUrlParts[1] : newUrlParts[0];
  470.     
  471.     document.title = 'Webaroo Search';
  472.     document.frmSearch.txtSearch.value = "";
  473.  
  474.     if (currentLocation.length > 1)
  475.     {
  476.         if (currentLocation[1] == "")
  477.         {
  478.             GetTopicsAsynchronously(0);
  479.         }
  480.         else if (currentLocation[1].indexOf("/webaroo/e29f1fe6/searchresult") != -1)
  481.         {
  482.             if ((historyData != null) && (historyData != ""))
  483.             {
  484.                 goToNext(newLocation, 0);
  485.             }
  486.             else
  487.             {
  488.                 GetTopicsAsynchronously(0);
  489.             }
  490.         }
  491.         else if (currentLocation[1].indexOf("/webaroo/e29f1fe6/topicresult") != -1)
  492.         {
  493.             if ((historyData != null) && (historyData != ""))
  494.             {
  495.                 TopicBreadCrum = historyData;
  496.                 topicNext(newLocation, 0);
  497.             }
  498.             else
  499.             {
  500.                 GetTopicsAsynchronously(0);
  501.             }
  502.         }
  503.         else if (currentLocation[1].indexOf("/toptopics") != -1)
  504.         {
  505.             // Splitting "/toptopics?flt=FLT&slt=SLT&level=LEVEL&topic=TOPIC[&subtopic=SUBTOPIC]&searcherid=SEARCHID"
  506.             var currentUrl = newLocation.split("&");
  507.             var index = 4;
  508.             var currentSubTopic = "";
  509.             
  510.             var urlPart = currentUrl[0].split("=");
  511.             var currentFlt = urlPart[1];
  512.             
  513.             urlPart = currentUrl[1].split("=");
  514.             var currentSlt = urlPart[1];
  515.             
  516.             urlPart = currentUrl[2].split("=");
  517.             var currentLevel = parseInt(urlPart[1]);
  518.             
  519.             urlPart = currentUrl[3].split("=");
  520.             var currentTopic = doubleUrlDecode(urlPart[1]);
  521.             
  522.             if (currentLevel == 2)
  523.             {
  524.                 urlPart = currentUrl[index].split("=");
  525.                 currentSubTopic = doubleUrlDecode(urlPart[1]);
  526.                 ++index;
  527.             }
  528.             
  529.             urlPart = currentUrl[index].split("=");
  530.             var currentSearchId = urlPart[1];
  531.         
  532.             urlPart = currentUrl[index +1].split("=");
  533.             var channelIndex = urlPart[1];    
  534.                 
  535.             var subIndex = GetSubIndex(currentSearchId,channelIndex);
  536.             if (subIndex == -1)
  537.             {
  538.                 GetStoredInfo();
  539.                 subIndex = GetSubIndex(currentSearchId,channelIndex);
  540.                 if (subIndex == -1)
  541.                 {
  542.                     return;
  543.                 }
  544.             }
  545.         
  546.             ShowTopTopics(0, currentFlt, currentSlt, currentLevel, currentTopic, currentSubTopic, 0, subIndex,channelIndex)
  547.         }
  548.         else if (currentLocation[1].indexOf("/webaroo/e29f1fe6/browsemysites") != -1)
  549.         {
  550.             GetBrowseMySiteAsynchronously(0);
  551.         }
  552.         else if (currentLocation[1].indexOf("/webaroo/e29f1fe6/citylist") != -1)
  553.         {
  554.             GetTopicsAsynchronously(0);
  555.         }
  556.         else if (currentLocation[1].indexOf("/webaroo/e29f1fe6/topics") != -1)
  557.         {
  558.             // Splitting "/webaroo/e29f1fe6/topics?searcherid=SEARCHID to get search id
  559.             var currentUrl = newLocation.split("&");
  560.             
  561.             var urlPart = currentUrl[0].split("=");
  562.             var currentSearchId = urlPart[1];
  563.  
  564.             urlPart = currentUrl[1].split("=");
  565.             var channelIndex = -1;
  566.             if (urlPart[0].toLowerCase() == "channelindex")
  567.             {
  568.                 channelIndex = urlPart[1];
  569.             }
  570.             else // Channel id
  571.             {
  572.                 var channelId = urlPart[1];
  573.                 channelIndex = GetChannelIndex(channelId);
  574.                 if (channelIndex == -1)
  575.                 {
  576.                     GetStoredInfo();
  577.                     channelIndex = GetChannelIndex(channelId);
  578.                     if (channelIndex == -1)
  579.                     {
  580.                         return;
  581.                     }
  582.                 }
  583.             }
  584.     
  585.             var subIndex = GetSubIndex(currentSearchId,channelIndex);
  586.             if (subIndex == -1)
  587.             {
  588.                 GetStoredInfo();
  589.                 subIndex = GetSubIndex(currentSearchId,channelIndex);
  590.                 if (subIndex == -1)
  591.                 {
  592.                     return;
  593.                 }
  594.             }
  595.  
  596.             refreshBUI(0, subIndex,channelIndex);
  597.         }
  598.         else if(currentLocation[1].indexOf("/renderCityListWithClearTable") != -1)
  599.         {
  600.             // Splittinh "/showplaces?channelIndex=CHANNELINDEX to get channelIndex
  601.             var currentUrl = newLocation.split("=");
  602.             var channelIndex = currentUrl[1];
  603.             renderCityListWithClearTable(channelIndex);
  604.         }
  605.     }
  606.     else
  607.     {
  608.         GetTopicsAsynchronously(0);
  609.     }
  610. }
  611.  
  612. function GetSubIndex(subId,channelIndex)
  613. {
  614.     var subIds = channelSubscriptionIDs[channelIndex];
  615.  
  616.     if(subIds == null)
  617.         return -1;
  618.  
  619.     var subIndex = -1;
  620.     
  621.     for (var i=0; i < subIds.length; ++i)
  622.     {
  623.         if (subIds[i] == subId)
  624.         {
  625.             subIndex = i;
  626.             break;
  627.         }
  628.     }
  629.     
  630.     return subIndex;
  631. }
  632.  
  633. function ClearAllTables()
  634. {
  635.     ClearBrowseTables();
  636.     ClearSearchTables();
  637. }
  638.  
  639. function ClearEditorPickTable()
  640. {
  641.     ClearTable('EditorPicks');
  642. }
  643.  
  644. function ClearSearchTables()
  645. {
  646.     ClearTable('topTitle');
  647.     ClearTable('searchResult');
  648.     ClearTable('nextpage');
  649.     ClearTable('bottomTitle');
  650. }
  651.  
  652. function ClearBrowseTables()
  653. {
  654.     ClearTable('browsetitletable');
  655.     ClearTable('BrowsePacksEntry');
  656.     ClearTable('topicList');
  657.     ClearTable('EditorPicks');
  658.     ClearTable('browsemysitetable');
  659. }
  660.  
  661. function search()
  662. {
  663.     var varSearchValue = trim(document.frmSearch.txtSearch.value);
  664.     if(IsStartKeyword(varSearchValue))
  665.     {
  666.         alert("Please enter a valid search term."); 
  667.         document.frmSearch.txtSearch.focus();        
  668.         return false;
  669.     }
  670.     else
  671.     {
  672.         if(varSearchValue.length==0)
  673.         {
  674.             alert("Please enter a valid search term");
  675.             document.frmSearch.txtSearch.focus();
  676.             return false;
  677.         }
  678.         else
  679.         {
  680.             var searchUrl = (document.frmSearch.searchOption[1].checked) ? "&searcherid=" + document.frmSearch.searchOption[1].value : "";
  681.             var url = "/webaroo/e29f1fe6/searchresult?main=1&txtSearch="+doubleUrlEncode(document.frmSearch.txtSearch.value) + searchUrl;
  682.             goToNext(url, 1);
  683.  
  684.             return true;
  685.         }
  686.     }
  687. }
  688.  
  689. function goToNext(urlStr, addToHistory)
  690. {
  691.     var currentUrl = urlStr.split("&searcherid=");
  692.     var searchOptionIndex = (currentUrl.length > 1) ? 1 : 0;
  693.     SetSearchIndex(searchOptionIndex);
  694.             
  695.     // Show the data loading message here ...
  696.     ShowDataLoading();
  697.     if (addToHistory == 1)
  698.     {
  699.         dhtmlHistory.add(urlStr, "From_goToNext");
  700.         window.scrollTo(0,0);
  701.     }
  702.     SendAsynchornousRequest(urlStr,"",renderSearchResults,addToHistory);
  703. }
  704.  
  705. //Construct the specific list of Choices for the Browser
  706. function renderSearchResults(searchResults,addToHistory)
  707. {
  708.     var message = searchResults.getElementsByTagName('message');
  709.     var searchresult = searchResults.getElementsByTagName('searchresult');
  710.     var result = searchResults.getElementsByTagName('result');
  711.     
  712.     var searchResultTable = document.getElementById('searchResult');
  713.  
  714.     var keys = new Array();
  715.     var values = new Array();
  716.     
  717.     var messageText = message[0].firstChild.nodeValue;
  718.     
  719.     ClearAllTables();
  720.  
  721.     var totalHits = searchresult[0].getAttribute('totalhits');
  722.     var nextoffset = searchresult[0].getAttribute('nextoffset');
  723.     var prevoffset = searchresult[0].getAttribute('prevoffset');
  724.     var sessionid = searchresult[0].getAttribute('sessionid');
  725.     var query = searchresult[0].getAttribute('query');
  726.     var searchId = searchresult[0].getAttribute('searcherid');
  727.     //escape is used because, accented charaters are getting distorted in the search result in the subsequent pages
  728.     var searchUrlPart = "&txtSearch=" + escape(doubleUrlEncode(query)) + ((searchId != "") ? "&searcherid=" + doubleUrlEncode(searchId) : "");
  729.     // Extra escape is not needed for hyper links. It is needed if resulting url is used as parameter to JS function e.g. searchUrlPart
  730.     var searchUrlForPage = "&txtSearch=" + doubleUrlEncode(query) + ((searchId != "") ? "&searcherid=" + doubleUrlEncode(searchId) : "");
  731.     
  732.     
  733.     var prevLink = "";
  734.     var nextLink = "";
  735.     var firstLink = "";
  736.     var secondLink = "";
  737.     var thirdLink = "";
  738.     var fourthLink = "";
  739.     var fifthLink = "";
  740.     
  741.     var countOfSearchPages = 0;
  742.     var nextPage = document.getElementById('nextpage');
  743.     
  744.     document.title = 'Webaroo Search - ' + query;
  745.     document.frmSearch.txtSearch.value = query;
  746.     
  747.     var next = 0;
  748.     if((parseInt(nextoffset)-1)%10 == 0)
  749.     {
  750.         //a page with no less than 10 results
  751.         next = parseInt(nextoffset);
  752.     }
  753.     else if ((parseInt(nextoffset))%10 == 0)
  754.     {
  755.         next =  parseInt(nextoffset)+1;
  756.     }
  757.     else
  758.     {
  759.         //when results are less than 10; the last page;  
  760.         //doing this just to keep nextoffset 10*n+1; else it'll be a problem
  761.         next = parseInt(nextoffset) + 11 -(parseInt(nextoffset)%10);
  762.     }
  763.     
  764.     var totalResults = parseInt(totalHits);
  765.     var k=-4;
  766.     var count = 0;
  767.     var current = next-10;
  768.     values[0]="";
  769.     
  770.     if(parseInt(prevoffset) != 0) 
  771.     { 
  772.         var linkToPrePage = "/webaroo/e29f1fe6/searchresult?sid="+sessionid+"&offset="+ parseInt(prevoffset) + searchUrlPart;
  773.         values[0] += "<a href=\"javascript:goToNext('"+linkToPrePage+"', 1)\">«</a>  ";
  774.         values[0] += " ";
  775.     }
  776.  
  777.     var pageIds = GetPageNumbers(parseInt(nextoffset),parseInt(totalHits));
  778.     for(var i=0;i<5;i++) 
  779.     {
  780.         var pageIdoffset = (pageIds[i]-1)*10 +1;
  781.         // rendering of all except last page
  782.         if( ((nextoffset%10)==1)&& (pageIdoffset <= parseInt(totalHits))) 
  783.         {
  784.             if(    (pageIdoffset != parseInt(nextoffset)-10) )
  785.             {
  786.                 var linkToPages = "/webaroo/e29f1fe6/searchresult?sid="+sessionid+"&offset="+ pageIdoffset + searchUrlPart;
  787.                 values[0] += "<a href=\"javascript:goToNext('"+linkToPages+"', 1)\">"+  pageIds[i] +"</a>";
  788.                 values[0] += "  ";
  789.             }
  790.             else 
  791.             {
  792.                 //current page. Hence no link (href)
  793.                 values[0] += ""+pageIds[i];
  794.                 values[0] += "  ";
  795.             }
  796.         }
  797.         else if(pageIdoffset <= parseInt(totalHits)) // last page rendering
  798.         {
  799.             if((pageIdoffset >= parseInt(nextoffset)-10)&&(pageIdoffset <= parseInt(totalHits)))
  800.             {
  801.                 //current page. Hence no link (href)
  802.                 values[0] += ""+pageIds[i];
  803.                 values[0] += " ";
  804.             }
  805.             else 
  806.             {
  807.                 var linkToPages = "/webaroo/e29f1fe6/searchresult?sid="+sessionid+"&offset="+ pageIdoffset + searchUrlPart;
  808.                 values[0] += "<a href=\"javascript:goToNext('"+linkToPages+"', 1)\">"+  pageIds[i] +"</a>";
  809.                 values[0] += " ";
  810.             }
  811.         } 
  812.     }
  813.     
  814.     if(next < parseInt(totalHits))
  815.     {
  816.         var linkToNextPage = "/webaroo/e29f1fe6/searchresult?sid="+sessionid+"&offset="+ next + searchUrlPart;
  817.         values[0] += " <a href=\"javascript:goToNext('"+linkToNextPage+"', 1)\">»</a>";
  818.     }
  819.             
  820.     var nextPageLinkText = values[0];
  821.     
  822.     var topTitleTable = document.getElementById('topTitle');
  823.     keys[0] = "innerHTML";
  824.     keys[1] = "width";
  825.     keys[2] = "align";
  826.     keys[3] = "bgcolor";
  827.     keys[4] = "bordertopbottom";
  828.     
  829.     messageText = RenderSpecialHTMLCharacterCode(messageText);
  830.     values[0] = "<font style=\"font:bold 10px verdana,arial,sans-serif;\">" + messageText+"</font>";
  831.     values[1] = "600";
  832.     values[2] = "left";
  833.     values[3] = "#ffcc88";
  834.     values[4] = "";
  835.     var rowTitle = topTitleTable.insertRow(-1);
  836.     AddCellToRow(rowTitle, keys, values);
  837.     if(nextPageLinkText !="")
  838.         values[0]=nextPageLinkText;
  839.     else
  840.         values[0]=" ";
  841.     values[1] = "200";
  842.     values[2] = "right";
  843.     AddCellToRow(rowTitle, keys, values);
  844.  
  845.     keys[3] = "";
  846.     keys[4] = "";
  847.     
  848.     values[0] = "<br>";
  849.     AddCellToRow(topTitleTable.insertRow(-1), keys, values);
  850.  
  851.     for (var j=0;j<result.length;j++)
  852.     {
  853.         if (result[j].nodeType != 1) continue;
  854.  
  855.         var currentNodeObject=result[j];
  856.         var excerpt;
  857.         var title;
  858.         var url;
  859.         var originalUrl;
  860.         var packagename;
  861.         
  862.         for (var k=0;k<currentNodeObject.childNodes.length;k++)
  863.         {
  864.             if (currentNodeObject.childNodes[k].nodeType != 1) continue;
  865.             switch(currentNodeObject.childNodes[k].nodeName)
  866.             {
  867.                 case 'excerpt':
  868.                     if(currentNodeObject.childNodes[k].firstChild)
  869.                         excerpt=currentNodeObject.childNodes[k].firstChild.nodeValue;
  870.                     else
  871.                         excerpt=" ";
  872.                     break;
  873.                 case 'title':
  874.                     title=currentNodeObject.childNodes[k].firstChild.nodeValue;
  875.                     break;
  876.                 case 'url':
  877.                     url=currentNodeObject.childNodes[k].firstChild.nodeValue;
  878.                     break;
  879.                 case 'originalurl':
  880.                     originalurl=currentNodeObject.childNodes[k].firstChild.nodeValue;
  881.                     break;
  882.                 case 'packagename':
  883.                     packagename=currentNodeObject.childNodes[k].firstChild.nodeValue;
  884.                     break;
  885.             }
  886.         }
  887.         
  888.         keys[0] = "innerHTML";
  889.         keys[1] = "width";
  890.         keys[2] = "align";
  891.         
  892.         values[0] = "<a class=\"resultLink\" href=\"/webaroo/e29f1fe6/page?name="+packagename+"&chunkid="+url + searchUrlForPage +"&url="+doubleUrlEncode(originalurl) +"\">"+title+"</a>    [<a target=\"_blank\" href=\"" + originalurl + "\">Online Link</a>]";
  893.         values[1] = "100";
  894.         values[2] = "left";
  895.         AddCellToRow(searchResultTable.insertRow(-1), keys, values);
  896.         
  897.         values[0] = "<font class=\"resultParagraph\">" + WrapIfOneWord(excerpt,80) + "</font>";
  898.         values[1] = "100";
  899.         values[2] = "left";
  900.         AddCellToRow(searchResultTable.insertRow(-1), keys, values);
  901.                     
  902.         values[0] = "<font class=\"resultSite\" size=\"1px\">"+TruncateString(originalurl,90)+"</font>";
  903.         values[1] = "50";
  904.         values[2] = "left";
  905.         AddCellToRow(searchResultTable.insertRow(-1), keys, values);        
  906.  
  907.         keys[0] = "innerHTML";
  908.         keys[1] = "width";
  909.         keys[2] = "align";
  910.  
  911.         values[0] = "<br>";
  912.         values[1] = "100";
  913.         values[2] = "left";
  914.         AddCellToRow(searchResultTable.insertRow(-1), keys, values);
  915.     }
  916.     
  917.     if(nextPageLinkText !="")
  918.     {
  919.         var bottomTitleTable = document.getElementById('bottomTitle');
  920.         keys[0] = "innerHTML";
  921.         keys[1] = "width";
  922.         keys[2] = "align";
  923.         keys[3] = "bgcolor";
  924.         keys[4] = "bordertopbottom";
  925.         
  926.         values[0] = " ";
  927.         values[1] = "600";
  928.         values[2] = "left";
  929.         values[3] = "#ffcc88";
  930.         values[4] = "";
  931.         var rowTitle = bottomTitleTable.insertRow(-1);
  932.         AddCellToRow(rowTitle, keys, values);
  933.         
  934.         values[0]=nextPageLinkText;
  935.         values[1] = "200";
  936.         values[2] = "right";
  937.         AddCellToRow(rowTitle, keys, values);
  938.     }
  939.  
  940.     ChangeTabDisplayMode(false);
  941.     ShowRooPack();
  942.     ShowSearchResults();
  943. }
  944.  
  945. function syncXml(url)
  946. {
  947.     var tempDoc;
  948.     if (window.XMLHttpRequest)
  949.     {
  950.         tempDoc=new XMLHttpRequest();
  951.         //Need this if this is to be done asynchronously
  952.         tempDoc.open("POST",url,false);
  953.         tempDoc.send("dummy");
  954.     }
  955.     // code for IE
  956.     else if (window.ActiveXObject)
  957.     {
  958.         tempDoc=new ActiveXObject("Microsoft.XMLHTTP");
  959.         if(tempDoc)
  960.         {
  961.             //Need this if this is to be done asynchronously
  962.             tempDoc.open("POST",url,false);
  963.             tempDoc.send("dummy");
  964.          }
  965.     }
  966.     checkXml(tempDoc); 
  967.     return tempDoc.responseXML;
  968. }
  969.  
  970. function checkXml(oneXml)
  971. {
  972.     // Once Data is Downloaded...
  973.     if (oneXml.readyState==4)
  974.     {
  975.     // if "OK"
  976.         if (oneXml.status==200)
  977.         {
  978.             return true;
  979.         }
  980.         else
  981.         {
  982.             alert(xml_get_problem);
  983.             return false;
  984.         }
  985.     }
  986. }
  987.  
  988. function ShowRooPack()
  989. {
  990.     document.getElementById('loading').style.display="none";
  991.     document.getElementById('browseUIContentPack').style.display="block";
  992.     document.getElementById('browseMySite').style.display="none";
  993. }
  994.  
  995. function ShowDataLoading()
  996. {
  997.     document.getElementById('loading').style.display="block";
  998.     document.getElementById('browseUIContentPack').style.display="none";
  999.     document.getElementById('browseMySite').style.display="none";
  1000.     document.getElementById('SearchResultDiv').style.display="none";
  1001.     document.getElementById('bottomTitleDiv').style.display="none";
  1002. }
  1003.  
  1004. function ShowSearchResults()
  1005. {
  1006.     document.getElementById('loading').style.display="none";
  1007.     document.getElementById('SearchResultDiv').style.display="block";
  1008.     document.getElementById('bottomTitleDiv').style.display="block";
  1009. }
  1010.  
  1011. function ShowMySite()
  1012. {
  1013.     document.getElementById('loading').style.display="none";
  1014.     document.getElementById('browseUIContentPack').style.display="none";
  1015.     document.getElementById('browseMySite').style.display="block";
  1016. }
  1017.  
  1018.  
  1019. function topicPopulate(cityList, channelIndex)
  1020. {
  1021.     cityListXML[channelIndex] = cityList;
  1022.     renderCityList(cityListXML[channelIndex],channelIndex);
  1023. }
  1024.  
  1025. function refreshBUI(addToHistory, subIndex,channelIndex)
  1026. {
  1027.     var subId = channelSubscriptionIDs[channelIndex][subIndex];
  1028.     var subName = channelSubscriptionNames[channelIndex][subIndex];
  1029.     // Clear tables
  1030.     ClearAllTables();
  1031.     SetSearchOptions(subId, "Only " + subName, 1);
  1032.     // Show the Data Loading form and hide others
  1033.     ShowDataLoading();
  1034.     
  1035.     var url="/webaroo/e29f1fe6/topics?searcherid=" + subId;
  1036.     var tpXml=syncXml(url);
  1037.                      
  1038.     var epurl="/webaroo/e29f1fe6/editorpick?searcherid=" + subId;
  1039.     var epXml=syncXml(epurl);
  1040.     
  1041.     renderTopics(tpXml, subIndex,channelIndex);
  1042.     renderEP(epXml);
  1043.  
  1044.     ConstructBreadCrum("", "", 0, "", "", subIndex,channelIndex);  // no flt/slt, level 0, no topic/subtopic, subscription
  1045.     
  1046.     ChangeTabDisplayMode(true);
  1047.     ShowRooPack();
  1048.     
  1049.     if (addToHistory == 1)
  1050.     {
  1051.         url = url + "&channelIndex=" + channelIndex;
  1052.         dhtmlHistory.add(url, "");
  1053.         window.scrollTo(0,0);
  1054.     }
  1055. }
  1056.  
  1057. function ConstructBreadCrum(flt, slt, level, topic, subTopic, subIndex,channelIndex)
  1058. {
  1059.     var keys = new Array();
  1060.     var values = new Array();
  1061.  
  1062.     ClearTable('browsetitletable');
  1063.     var rootitleelem = document.getElementById('browsetitletable');
  1064.     
  1065.     var breadCrums = new Array();
  1066.     breadCrums[0] = "Web Packs";
  1067.     // This should be dynamic depending on channel
  1068.     //Channel 0 is "Places", 1 is Music etc..
  1069.     breadCrums[1] = channelDescription[channelIndex];
  1070.     
  1071.     breadCrums[2] = channelSubscriptionNames[channelIndex][subIndex];
  1072.     breadCrums[3] = ModifyValue(topic, false);
  1073.     breadCrums[4] = ModifyValue(subTopic, false);
  1074.     
  1075.     var innertext = '<a href="javascript:GetTopicsAsynchronously(1)">' + breadCrums[0] + '</a> > ';
  1076.     innertext += '<a href="javascript:GetTopicsAsynchronously(1)">' + breadCrums[1] + '</a> > ';
  1077.     
  1078.     if (level > 0)
  1079.     {
  1080.         innertext += '<a href="javascript:refreshBUI(1, ' + subIndex + ','+channelIndex+')">' + breadCrums[2] + '</a> > ';
  1081.         TopicBreadCrum = innertext;
  1082.         
  1083.         if (level > 1)
  1084.         {
  1085.             innertext += "<a href=\"javascript:ShowTopTopics(0, '" + flt + "','" + flt + "', 1, '" + topic + "', '', 1, " + subIndex + ","+channelIndex+")\">" +  breadCrums[3] + "</a> > ";
  1086.             TopicBreadCrum = innertext;
  1087.             
  1088.             innertext += '<b>' + breadCrums[4] + '</b> ';
  1089.             TopicBreadCrum += "<a href=\"javascript:ShowTopTopics(0, '" + flt + "','" + slt + "', 2, '" + topic + "', '" + subTopic + "', 1, " + subIndex + ","+channelIndex+")\">" +  breadCrums[4] + "</a> ";
  1090.         }
  1091.         else
  1092.         {
  1093.             innertext += '<b>' + breadCrums[3] + '</b> ';
  1094.             TopicBreadCrum += "<a href=\"javascript:ShowTopTopics(0, '" + flt + "','" + flt + "', 1, '" + topic + "', '', 1, " + subIndex + ","+channelIndex+")\">" +  breadCrums[3] + "</a> ";
  1095.         }
  1096.     }
  1097.     else
  1098.     {
  1099.         innertext += '<b>' + breadCrums[2] + '</b> ';
  1100.     }
  1101.  
  1102.     innertext += '<br/>';
  1103.     
  1104.     keys[0] = "innerHTML";
  1105.     keys[1] = 'className';
  1106.     values[0] = innertext;
  1107.     values[1]="breadCrumTitle";
  1108.     
  1109.     var curRow=rootitleelem.insertRow(-1);
  1110.     AddCellToRow(curRow, keys, values);
  1111. }
  1112.  
  1113. function renderTopics(topicXml, subIndex,channelIndex)
  1114. {
  1115.     var keys = new Array();
  1116.     var values = new Array();
  1117.     
  1118.     ClearTable('topicList');
  1119.     // Hide the text below search box for no content message
  1120.     // Not needed here as would be taken care in upper parent function
  1121.     //check and remove
  1122.     //document.getElementById('NoContentMessage').style.display = "none";            
  1123.     
  1124.     var placetitleelem = document.getElementById('browsetitletable');
  1125.     var innertext = '';
  1126.     keys[0] = "innerHTML";
  1127.     keys[1] = 'className';
  1128.     values[0] = innertext;
  1129.     values[1]="resultLink";
  1130.     var curRow=placetitleelem.insertRow(-1);
  1131.     AddCellToRow(curRow, keys, values);
  1132.     
  1133.     var message = topicXml.getElementsByTagName('message');
  1134.     var result = topicXml.getElementsByTagName('topic');
  1135.     var levelNode=topicXml.getElementsByTagName('level');
  1136.     
  1137.     var level=levelNode[0].firstChild.nodeValue;
  1138.     var messageText = message[0].firstChild.nodeValue;
  1139.     
  1140.     var topicTab=document.getElementById('topicList');
  1141.         
  1142.     
  1143.     if(result.length < 1)
  1144.        return false;
  1145.     
  1146.     var parentTopic = "";
  1147.     if(level == 'two')
  1148.     {
  1149.         var parentNode=topicXml.getElementsByTagName('parent');
  1150.         parentTopic=parentNode[0].firstChild.nodeValue;
  1151.     }
  1152.        
  1153.     // insert few empty rows in Topic table
  1154.     keys[0]="innerHTML";
  1155.     keys[1] ='nowrap';
  1156.     keys[2] ='align';
  1157.     values[0]= "<br/>";
  1158.     values[1] = false;
  1159.     values[2] = "left";
  1160.     AddCellToRow(topicTab.insertRow(-1),keys,values);
  1161.     
  1162.     // Add a Cell
  1163.     keys[0]="innerHTML";
  1164.     values[0]= "<br/>";
  1165.     var curcell =    AddCellToRow(topicTab.insertRow(-1),keys,values);
  1166.     var topiclinetext ="";
  1167.     for (var j=0;j<result.length;j++)
  1168.     {
  1169.         if (result[j].nodeType != 1) continue;
  1170.  
  1171.         var currentNodeObject=result[j];
  1172.         var display="";
  1173.         var subTopiCount="";
  1174.         var fltCode="";
  1175.         var sltCode="";
  1176.  
  1177.         for (var k=0;k<currentNodeObject.childNodes.length;k++)
  1178.         {
  1179.             if (currentNodeObject.childNodes[k].nodeType != 1) continue;
  1180.             switch(currentNodeObject.childNodes[k].nodeName)
  1181.             {
  1182.                 case 'display':
  1183.                     display=currentNodeObject.childNodes[k].firstChild.nodeValue;
  1184.                     break;
  1185.                 case 'subtopiccount':
  1186.                     subTopicCount=currentNodeObject.childNodes[k].firstChild.nodeValue;
  1187.                     break;
  1188.                 case 'flt':
  1189.                     fltCode=currentNodeObject.childNodes[k].firstChild.nodeValue;
  1190.                     break;
  1191.                 case 'slt':
  1192.                     sltCode=currentNodeObject.childNodes[k].firstChild.nodeValue;
  1193.                     break;
  1194.             }
  1195.         }
  1196.         
  1197.         // Show the Topic List in the Row now
  1198.         var cellHtml="";
  1199.         if(level == 'two')
  1200.         {
  1201.             if(j+1 != result.length)
  1202.                 cellHtml="<a href=\"javascript:ShowTopTopics(1, '"+fltCode+"','"+sltCode+"', 2, '" + ModifyValue(parentTopic, true) + "', '" + ModifyValue(display, true) + "', 1, " + subIndex + "," + channelIndex + ")\">"+display+"</a>  | ";
  1203.             else
  1204.                 cellHtml="<a href=\"javascript:ShowTopTopics(1, '"+fltCode+"','"+sltCode+"', 2, '" + ModifyValue(parentTopic, true) + "', '" + ModifyValue(display, true) + "', 1, " + subIndex + "," +channelIndex +")\">"+display+"</a>   ";
  1205.         }
  1206.         else
  1207.         {
  1208.             var topicsAlreadyPresent = (subTopicCount > 0) ? 0 : 1;
  1209.             if(j+1 != result.length)
  1210.                 cellHtml="<a class=\"resultLink2\" href=\"javascript:ShowTopTopics(" + topicsAlreadyPresent + ", '"+fltCode+"','"+fltCode+"', 1, '" + ModifyValue(display, true) + "', '', 1, " + subIndex + ","+channelIndex+")\">"+display+"</a>  |  ";
  1211.             else
  1212.                 cellHtml="<a class=\"resultLink2\" href=\"javascript:ShowTopTopics(" + topicsAlreadyPresent + ", '"+fltCode+"','"+fltCode+"', 1, '" + ModifyValue(display, true) + "', '', 1, " + subIndex + ","+channelIndex+")\">"+display+"</a>    ";
  1213.             
  1214.         }
  1215.         topiclinetext += cellHtml;
  1216.     }
  1217.     keys[0] ='innerHTML';
  1218.     keys[1] ='nowrap';
  1219.     keys[2] ='align';
  1220.     keys[3] ='className';
  1221.     values[0] = topiclinetext;
  1222.     values[1] = false;
  1223.     values[2] = "left";
  1224.     values[3]='resultLink';
  1225.     AssignValueToKey(curcell, keys, values);
  1226.     
  1227.     // Add a empty row now
  1228.     values[0] = "<br>";
  1229.     values[1] = "100";
  1230.     values[2] = "left";
  1231.     AddCellToRow(topicTab.insertRow(-1), keys, values);
  1232.     
  1233.     return true;       
  1234. }
  1235.  
  1236. // TODO: Hack. Don't use this function. Find an alternative.
  1237. // To replace "'" in string to "%" and vice versa.
  1238. function ModifyValue(value, change)
  1239. {
  1240.     var re = change ? /'/g : /%/g;
  1241.     var str = change ? "%" : "'";
  1242.     return value.replace(re, str);
  1243. }
  1244.  
  1245. function renderCityListWithClearTable(channelIndex,addToHistory)
  1246. {
  1247.     ClearAllTables();
  1248.     if(addToHistory ==1)
  1249.     {
  1250.         var hurl = "/renderCityListWithClearTable?channelIndex=" + channelIndex;
  1251.         dhtmlHistory.add(hurl, "");
  1252.     }
  1253.     renderCityList(cityListXML[channelIndex],channelIndex);
  1254. }
  1255.  
  1256. function renderCityList(cityResults,channelIndex)
  1257. {
  1258.        var select= new Array();
  1259.     var cName = new Array();
  1260.     var keys = new Array();
  1261.     var values = new Array();
  1262.     var curRow;
  1263.     var index = 0;
  1264.  
  1265.     var webPackSearcherId = '0';
  1266.  
  1267.  
  1268.     var subNames = new Array();
  1269.     var subIds = new Array();
  1270.  
  1271.     
  1272.     if(!cityResults)
  1273.         return;
  1274.         
  1275.     ShowDataLoading();
  1276.     
  1277.     // Set the text "Web Packs"
  1278.     var rootitleelem = document.getElementById('browsetitletable');
  1279.         
  1280.     var message = cityResults.getElementsByTagName('message');
  1281.     var result = cityResults.getElementsByTagName('subscription');
  1282.     // Get the table element
  1283.     var cityTab=document.getElementById('BrowsePacksEntry');
  1284.     
  1285.     if(result.length < 1)
  1286.     {
  1287.         if((displayMySitesIfNoPacks)&& CheckIfSiteExists())
  1288.         {
  1289.             displayMySitesIfNoPacks = false;
  1290.             selectAll = true;
  1291.             GetBrowseMySiteAsynchronously(0);
  1292.         }
  1293.         else
  1294.         {
  1295.             var rowkeys = new Array();
  1296.             var rowvalues =new Array();
  1297.             keys[0] = "innerHTML";
  1298.             keys[1] = "align";
  1299.             var url = "/webaroo/e29f1fe6/content";
  1300.             values[0] = 'No Web Packs available in your library. Go to the <a href="' + url +'">Content</a> page to add a Web Pack. If you have already added a Web Pack, please wait for the updates to complete.'; // i18N issue
  1301.             values[1] = 'left';
  1302.             curRow=rootitleelem.insertRow(-1);
  1303.             AddCellToRow(curRow, keys, values);
  1304.  
  1305.             document.frmSearch.searchOption[0].checked = true;
  1306.             
  1307.             // Also show the message below search box
  1308.             document.getElementById('NoContentMessage').style.display = "inline";            
  1309.  
  1310.             // No results
  1311.             // Show the rooPack back    
  1312.             ShowRooPack();
  1313.         }
  1314.         // Show the radio button irrespective of the content status
  1315.         SetSearchOptions(webPackSearcherId, "Only Web Packs", 1);
  1316.     
  1317.         return;
  1318.        }
  1319.     // Show the radio button irrespective of the content status
  1320.     SetSearchOptions(webPackSearcherId, "Only Web Packs", 1);
  1321.     
  1322.     displayMySitesIfNoPacks = false;
  1323.     // Also hide the text below search box
  1324.     document.getElementById('NoContentMessage').style.display = "none";            
  1325.     // Also set the text "Places"
  1326.     keys[0] = "innerHTML";
  1327.     keys[1] = "className";
  1328.     // Get this text from channel Name
  1329.     var channelText = channelDescription[channelIndex];
  1330.     
  1331.     innertext = "<span class=\"channel_name\">" + channelText + "</span>";
  1332.     values[0] = innertext;
  1333.     values[1]='resultLink';
  1334.     curRow=cityTab.insertRow(-1);
  1335.     AddCellToRow(curRow, keys, values);
  1336.     // Put a dummy Row
  1337.     curRow=cityTab.insertRow(-1);
  1338.     var htmlcode ="   ";
  1339.     
  1340.     for (var j=0;j<result.length;j++)
  1341.     {
  1342.         if (result[j].nodeType != 1) continue;
  1343.  
  1344.         var subName = result[j].getAttribute("name");
  1345.         subNames[j] = subName;
  1346.         var subId = result[j].getAttribute("id");
  1347.         subIds[j] = doubleUrlEncode(subId);
  1348.         index = j;
  1349.         
  1350.         if(j+1 != result.length)    
  1351.             htmlcode += '<a class="results" href="javascript:refreshBUI(1, ' + index + ','+channelIndex+')" >'+subName+'</a> | ';
  1352.         else
  1353.             htmlcode += '<a class="results" href="javascript:refreshBUI(1, ' + index + ','+channelIndex+')" >'+subName+'</a>  ';
  1354.         index++;
  1355.     }
  1356.  
  1357.     channelSubscriptionIDs[channelIndex] = subIds;    
  1358.     channelSubscriptionNames[channelIndex] = subNames;
  1359.  
  1360.     historyStorage.put("SubscriptionNames", channelSubscriptionNames);
  1361.     historyStorage.put("SubscriptionIds", channelSubscriptionIDs);
  1362.  
  1363.     // Also put it on the page
  1364.     keys[0] = "innerHTML";
  1365.     keys[1] = "width";
  1366.     keys[2] = "align";
  1367.     keys[3] = "className";
  1368.     keys[4] = "nowrap";
  1369.     values[0] = htmlcode;
  1370.     values[1] = "100";
  1371.     values[2] = "left";
  1372.     values[3] = "resultLink3";
  1373.     values[4] = false;
  1374.     AddCellToRow(curRow, keys, values);
  1375.     // put empty row
  1376.     values[0] = ' ';
  1377.     curRow=cityTab.insertRow(-1);
  1378.     AddCellToRow(curRow, keys, values);
  1379.     
  1380.     ShowRooPack();
  1381. }
  1382.  
  1383. function CheckIfSiteExists()
  1384. {
  1385.     var url="/webaroo/e29f1fe6/browsemysites";
  1386.     processXMLData(url);
  1387.     var browseMySitesXML = xmlContent;
  1388.     var listObject = browseMySitesXML.getElementsByTagName('Response');
  1389.     if (listObject[0].childNodes.length > 0)
  1390.         return true;
  1391.     else
  1392.         return false;
  1393. }
  1394.  
  1395. function ShowTopTopics(topicsAlreadyPresent, flt, slt, level, topic, subTopic, addToHistory, subIndex,channelIndex)
  1396. {
  1397.  
  1398.     var subId = channelSubscriptionIDs[channelIndex][subIndex];
  1399.     var subName = channelSubscriptionNames[channelIndex][subIndex];
  1400.  
  1401.     SetSearchOptions(subId, "Only " + subName, 1);
  1402.  
  1403.     if (topicsAlreadyPresent == 0)
  1404.     {
  1405.         ClearEditorPickTable();
  1406.         // Also Clear the search Result
  1407.         ClearSearchTables();
  1408.         ClearTable('browsetitletable');
  1409.         ClearTable('BrowsePacksEntry');
  1410.         var url = "/webaroo/e29f1fe6/topics?flt=" + flt + "&searcherid=" + subId;
  1411.         sendXMLData(url, "");
  1412.         renderTopics(xmlContent, subIndex,channelIndex);
  1413.     }
  1414.     
  1415.     ConstructBreadCrum(flt, slt, level, topic, subTopic, subIndex,channelIndex);
  1416.     
  1417.     var urlRes = "/webaroo/e29f1fe6/topicresult?flt=" + flt + "&slt=" + slt + "&top=" + "5" + "&searcherid=" + subId;
  1418.     sendXMLData(urlRes, "");
  1419.     renderTopicResults(xmlContent, true);
  1420.  
  1421.     if (addToHistory == 1)
  1422.     {
  1423.         var hurl = "/toptopics?flt=" + flt + "&slt=" + slt + "&level=" + level + "&topic=" + doubleUrlEncode(topic) + ((level == 2) ? ("&subtopic=" + doubleUrlEncode(subTopic)) : "") + "&searcherid=" + subId+ "&channelIndex=" + channelIndex;
  1424.         dhtmlHistory.add(hurl, "");
  1425.     }
  1426.  
  1427.     ChangeTabDisplayMode(true);
  1428.     ShowRooPack();
  1429. }
  1430.  
  1431. function topicNext(url, addToHistory)
  1432. {
  1433.     SetSearchIndex(1);
  1434.     // Show data loading
  1435.     ShowDataLoading();
  1436.     sendXMLData(url, "");
  1437.     ClearBrowseTables();
  1438.     renderTopicResults(xmlContent, false);
  1439.     ChangeTabDisplayMode(false);
  1440.     ShowRooPack();
  1441.     ShowSearchResults();
  1442.  
  1443.     if (addToHistory == 1)
  1444.     {
  1445.         dhtmlHistory.add(url, TopicBreadCrum);
  1446.         window.scrollTo(0,0);
  1447.     }
  1448. }
  1449.  
  1450. function renderTopicResults(topicResults, isTopTopics)
  1451. {
  1452.     var message = topicResults.getElementsByTagName('message');
  1453.     var searchresult = topicResults.getElementsByTagName('searchresult');
  1454.     var result = topicResults.getElementsByTagName('result');
  1455.     
  1456.     var searchResultTable = (isTopTopics) ? document.getElementById('EditorPicks') : document.getElementById('searchResult');
  1457.  
  1458.     var keys = new Array();
  1459.     var values = new Array();
  1460.     
  1461.     var messageText = message[0].firstChild.nodeValue;
  1462.     
  1463.     if (isTopTopics)
  1464.     {
  1465.         ClearEditorPickTable();
  1466.     }
  1467.     
  1468.     ClearSearchTables();
  1469.  
  1470.     var totalHits = searchresult[0].getAttribute('totalhits');
  1471.     var nextoffset = searchresult[0].getAttribute('nextoffset');
  1472.     var prevoffset = searchresult[0].getAttribute('prevoffset');
  1473.     var sessionid = searchresult[0].getAttribute('sessionid');
  1474.     var searchId = searchresult[0].getAttribute('searcherid');
  1475.     var flt = searchresult[0].getAttribute('flt');
  1476.     var slt = searchresult[0].getAttribute('slt');
  1477.     var topicInfoUrlPart = "&flt=" + flt + "&slt=" + slt + "&searcherid=" + doubleUrlEncode(searchId);
  1478.     
  1479.     var nextPage = document.getElementById('nextpage');
  1480.     var nextPageLinkText ;
  1481.     if (!isTopTopics)
  1482.     {
  1483.         var topTitleTable = document.getElementById('topTitle');
  1484.         keys[0] = "innerHTML";
  1485.         keys[1] = "width";
  1486.         keys[2] = "align";
  1487.         keys[3] = "bordertopbottom";
  1488.         keys[4] = "bgcolor";
  1489.         
  1490.         values[0] = "<font style=\"font:bold 10px verdana,arial,sans-serif;\">" +    messageText + "<br />" + TopicBreadCrum +"</font>";
  1491.         values[1] = "600";
  1492.         values[2] = "left";
  1493.         values[3] = "";
  1494.         values[4] = "#ffcc88";
  1495.         var rowTitle = topTitleTable.insertRow(-1);
  1496.         AddCellToRow(rowTitle, keys, values);
  1497.         
  1498.         var prevLink = "";
  1499.         var nextLink = "";
  1500.         var firstLink = "";
  1501.         var secondLink = "";
  1502.         var thirdLink = "";
  1503.         var fourthLink = "";
  1504.         var fifthLink = "";
  1505.         
  1506.         var countOfSearchPages = 0;
  1507.         var next = 0;
  1508.         
  1509.         if((parseInt(nextoffset)-1)%10 == 0)
  1510.         {
  1511.             //a page with no less than 10 results
  1512.             next = parseInt(nextoffset);
  1513.         }
  1514.         else if ((parseInt(nextoffset))%10 == 0)
  1515.         {
  1516.             next =  parseInt(nextoffset)+1;
  1517.         }
  1518.         else
  1519.         {
  1520.             //when results are less than 10; the last page;  
  1521.             //doing this just to keep nextoffset 10*n+1; else it'll be a problem
  1522.             next = parseInt(nextoffset) + 11 -(parseInt(nextoffset)%10);
  1523.         }
  1524.         
  1525.         var totalResults = parseInt(totalHits);
  1526.         var k=-4;
  1527.         var count = 0;
  1528.         var current = next-10;
  1529.         values[0]="";
  1530.         
  1531.         if(parseInt(prevoffset) != 0) 
  1532.         { 
  1533.             var linkToPrePage = "/webaroo/e29f1fe6/topicresult?sid=" + sessionid + "&offset=" + prevoffset + topicInfoUrlPart;
  1534.             values[0] += "<a href=\"javascript:topicNext('"+linkToPrePage+"', 1)\">«</a>  ";
  1535.             values[0] += " ";
  1536.         }
  1537.  
  1538.         var pageIds = GetPageNumbers(parseInt(nextoffset),parseInt(totalHits));
  1539.         for(var i=0;i<5;i++) 
  1540.         {
  1541.             var pageIdoffset = (pageIds[i]-1)*10 +1;
  1542.             
  1543.             if( ((nextoffset%10)==1)&& (pageIdoffset <= parseInt(totalHits))) 
  1544.             {
  1545.                 if(pageIdoffset == parseInt(nextoffset)-10)
  1546.                 {
  1547.                     //current page. Hence no link (href)
  1548.                     values[0] += ""+pageIds[i];
  1549.                     values[0] += " ";
  1550.                 }
  1551.                 else if(pageIdoffset <= parseInt(totalHits))
  1552.                 {
  1553.                     var linkToPages = "/webaroo/e29f1fe6/topicresult?sid=" + sessionid + "&offset=" + pageIdoffset + topicInfoUrlPart;
  1554.                     values[0] += "<a href=\"javascript:topicNext('"+linkToPages+"', 1)\">"+  pageIds[i] +"</a>";
  1555.                     values[0] += " ";
  1556.                 }
  1557.             }
  1558.             else if(pageIdoffset <= parseInt(totalHits)) // last page rendering
  1559.             {
  1560.                 if((pageIdoffset >= parseInt(nextoffset)-10)&&(pageIdoffset <= parseInt(totalHits)))
  1561.                 {
  1562.                     //current page. Hence no link (href)
  1563.                     values[0] += ""+pageIds[i];
  1564.                     values[0] += " ";
  1565.                 }
  1566.                 else 
  1567.                 {
  1568.                     var linkToPages = "/webaroo/e29f1fe6/topicresult?sid=" + sessionid + "&offset=" + pageIdoffset + topicInfoUrlPart;
  1569.                     values[0] += "<a href=\"javascript:topicNext('"+linkToPages+"', 1)\">"+  pageIds[i] +"</a>";
  1570.                     values[0] += " ";
  1571.                 }
  1572.             }  
  1573.         }
  1574.         
  1575.         if(next < parseInt(totalHits))
  1576.         {
  1577.             var linkToNextPage = "/webaroo/e29f1fe6/topicresult?sid=" + sessionid+ "&offset=" + next + topicInfoUrlPart;
  1578.             values[0] += " <a href=\"javascript:topicNext('"+linkToNextPage+"', 1)\">»</a>";
  1579.         }
  1580.     
  1581.         nextPageLinkText = values[0];
  1582.         values[1] = "200";
  1583.         values[2] = "right";
  1584.         values[3] = "";
  1585.         values[4] = "#ffcc88";
  1586.         AddCellToRow(rowTitle, keys, values);
  1587.  
  1588.         keys[0] = "innerHTML";
  1589.         keys[1] = "width";
  1590.         keys[2] = "align";
  1591.         keys[3] = "";
  1592.         keys[4] = "";
  1593.         values[0] = "<br>";
  1594.         AddCellToRow(topTitleTable.insertRow(-1), keys, values);
  1595.         
  1596.         var bottomTitleTable = document.getElementById('bottomTitle');
  1597.         keys[0] = "innerHTML";
  1598.         keys[1] = "width";
  1599.         keys[2] = "align";
  1600.         keys[3] = "bordertopbottom";
  1601.         keys[4] = "bgcolor";
  1602.         
  1603.         values[0] = " ";
  1604.         values[1] = "600";
  1605.         values[2] = "left";
  1606.         values[3] = "";
  1607.         values[4] = "#ffcc88";
  1608.         rowTitle = bottomTitleTable.insertRow(-1);
  1609.         AddCellToRow(rowTitle, keys, values);
  1610.         
  1611.         if(nextPageLinkText!="")
  1612.             values[0] = nextPageLinkText;
  1613.         else
  1614.             values[0] = " ";
  1615.         values[1] = "200";
  1616.         values[2] = "right";
  1617.         AddCellToRow(rowTitle, keys, values);
  1618.         
  1619.         keys[2] = "";
  1620.         keys[3] = "";
  1621.         keys[4] = "";
  1622.     }
  1623.     else
  1624.     {
  1625.         // Change background color of next link table
  1626.         keys[0] = "innerHTML";
  1627.         keys[1] = "width";
  1628.         keys[2] = "align";
  1629.         keys[3] = "nowrap";
  1630.  
  1631.         values[0] = "<b>"+messageText+"</b>";
  1632.         values[1] = "100";
  1633.         values[2] = "left";
  1634.         values[3] = false;
  1635.         var rowTitle = searchResultTable.insertRow(-1);
  1636.         AddCellToRow(rowTitle, keys, values);
  1637.  
  1638.         keys[0] = "innerHTML";
  1639.         keys[1] = "width";
  1640.         keys[2] = "align";
  1641.  
  1642.         values[0] = "<br/>";
  1643.         values[1] = "100";
  1644.         values[2] = "center";
  1645.         AddCellToRow(searchResultTable.insertRow(-1), keys, values);
  1646.         
  1647.         if( parseInt(totalHits) > 5)
  1648.         {
  1649.             ClearTable('nextpage');
  1650.         
  1651.             var nextPageTable = document.getElementById('nextpage');
  1652.  
  1653.             var href = "/webaroo/e29f1fe6/topicresult?flt=" + flt + "&slt=" + slt + "&searcherid=" + searchId;
  1654.             var nxtMsg= "<a href=\"javascript:topicNext('"+href+"', 1)\" > More »</a>";
  1655.  
  1656.             keys[0] = "innerHTML";
  1657.             keys[1] = "width";
  1658.             keys[2] = "align";
  1659.  
  1660.             values[0] = nxtMsg;
  1661.             values[1] = "100";
  1662.             values[2] = "right";
  1663.             AddCellToRow(nextPageTable.insertRow(-1), keys, values);
  1664.         }
  1665.  
  1666.     }
  1667.  
  1668.     for (var j=0;j<result.length;j++)
  1669.     {
  1670.         if (result[j].nodeType != 1) continue;
  1671.  
  1672.         var currentNodeObject=result[j];
  1673.         var excerpt;
  1674.         var title;
  1675.         var url;
  1676.         var originalUrl;
  1677.         var packagename;
  1678.         
  1679.         for (var k=0;k<currentNodeObject.childNodes.length;k++)
  1680.         {
  1681.             if (currentNodeObject.childNodes[k].nodeType != 1) continue;
  1682.             switch(currentNodeObject.childNodes[k].nodeName)
  1683.             {
  1684.                 case 'excerpt':
  1685.                     if(currentNodeObject.childNodes[k].firstChild != null)
  1686.                         excerpt=currentNodeObject.childNodes[k].firstChild.nodeValue;
  1687.                     else
  1688.                         excerpt=" ";
  1689.                     break;
  1690.                 case 'title':
  1691.                     title=currentNodeObject.childNodes[k].firstChild.nodeValue;
  1692.                     break;
  1693.                 case 'url':
  1694.                     url=currentNodeObject.childNodes[k].firstChild.nodeValue;
  1695.                     break;
  1696.                 case 'originalurl':
  1697.                     originalurl=currentNodeObject.childNodes[k].firstChild.nodeValue;
  1698.                     break;
  1699.                 case 'packagename':
  1700.                         packagename=currentNodeObject.childNodes[k].firstChild.nodeValue;
  1701.             }
  1702.         }
  1703.         
  1704.         keys[0] = "innerHTML";
  1705.         keys[1] = "width";
  1706.         keys[2] = "align";
  1707.         
  1708.         values[0] = "<a class=\"resultLink\" href=\"/webaroo/e29f1fe6/page?name="+packagename+"&chunkid="+url + topicInfoUrlPart + "&url="+doubleUrlEncode(originalurl) + "\">"+title+"</a>    [<a target=\"_blank\" href=\"" + originalurl + "\">Online Link</a>]";
  1709.         values[1] = "100";
  1710.         values[2] = "left";
  1711.         AddCellToRow(searchResultTable.insertRow(-1), keys, values);
  1712.         
  1713.         values[0] = "<font class=\"resultParagraph\" >" + WrapIfOneWord(excerpt,80) + "</font>";
  1714.         values[1] = "100";
  1715.         values[2] = "left";
  1716.         AddCellToRow(searchResultTable.insertRow(-1), keys, values);
  1717.                             
  1718.         values[0] = "<font class=\"resultSite\" size=\"1px\">"+TruncateString(originalurl,90)+"</font>";
  1719.         values[1] = "50";
  1720.         values[2] = "left";
  1721.         AddCellToRow(searchResultTable.insertRow(-1), keys, values);
  1722.  
  1723.         values[0] = "<br>";
  1724.         values[1] = "100";
  1725.         values[2] = "left";
  1726.         AddCellToRow(searchResultTable.insertRow(-1), keys, values);
  1727.     }        
  1728.     keys[0] = "innerHTML";
  1729.     keys[1] = "width";
  1730.     keys[2] = "align";
  1731.  
  1732.     values[0] = "<br>";
  1733.     values[1] = "100";
  1734.     values[2] = "left";
  1735.     AddCellToRow(searchResultTable.insertRow(-1), keys, values);
  1736. }
  1737.  
  1738. function renderEP(epResults)
  1739. {
  1740.     var message = epResults.getElementsByTagName('message');
  1741.     var searchresult = epResults.getElementsByTagName('editorpics');
  1742.     var result = epResults.getElementsByTagName('result');
  1743.     if(result.length <= 0)
  1744.         return false;
  1745.     
  1746.     var searchResultTable = document.getElementById('EditorPicks');
  1747.  
  1748.     var keys = new Array();
  1749.     var values = new Array();
  1750.     
  1751.     var messageText = message[0].firstChild.nodeValue;
  1752.     
  1753.     ClearEditorPickTable();
  1754.     ClearSearchTables();
  1755.  
  1756.     keys[0] = "innerHTML";
  1757.     keys[1] = "width";
  1758.     keys[2] = "align";
  1759.  
  1760.     values[0] = "<b>"+messageText+"</b>";
  1761.     values[1] = "100";
  1762.     values[2] = "left";
  1763.     AddCellToRow(searchResultTable.insertRow(-1), keys, values);
  1764.     
  1765.     keys[0] = "innerHTML";
  1766.     keys[1] = "width";
  1767.     keys[2] = "align";
  1768.  
  1769.     values[0] = "<br/>";
  1770.     values[1] = "100";
  1771.     values[2] = "center";
  1772.     AddCellToRow(searchResultTable.insertRow(-1), keys, values);
  1773.  
  1774.  
  1775.     for (var j=0;j<result.length;j++)
  1776.     {
  1777.         if (result[j].nodeType != 1) continue;
  1778.  
  1779.         var currentNodeObject=result[j];
  1780.         var excerpt="";
  1781.         var title;
  1782.         var url;
  1783.         var originalUrl;
  1784.         var packagename;
  1785.         
  1786.         for (var k=0;k<currentNodeObject.childNodes.length;k++)
  1787.         {
  1788.             if (currentNodeObject.childNodes[k].nodeType != 1) continue;
  1789.             switch(currentNodeObject.childNodes[k].nodeName)
  1790.             {
  1791.                 case 'excerpt':
  1792.                     if(currentNodeObject.childNodes[k].firstChild)
  1793.                         excerpt=currentNodeObject.childNodes[k].firstChild.nodeValue;
  1794.                     else
  1795.                         excerpt = " ";
  1796.                     break;
  1797.                 case 'title':
  1798.                     title=currentNodeObject.childNodes[k].firstChild.nodeValue;
  1799.                     break;
  1800.                 case 'url':
  1801.                     url=currentNodeObject.childNodes[k].firstChild.nodeValue;
  1802.                     break;
  1803.                 case 'originalurl':
  1804.                     originalurl=currentNodeObject.childNodes[k].firstChild.nodeValue;
  1805.                     break;
  1806.                 case 'packagename':
  1807.                     packagename=currentNodeObject.childNodes[k].firstChild.nodeValue;
  1808.             }
  1809.         }
  1810.         
  1811.         keys[0] = "innerHTML";
  1812.         keys[1] = "width";
  1813.         keys[2] = "align";
  1814.         
  1815.         values[0] = "<a class=\"resultLink\" href=\"/webaroo/e29f1fe6/page?name="+packagename+"&chunkid="+url+"&url="+doubleUrlEncode(originalurl)+" \">"+title+"</a>    [<a target=\"_blank\" href=\"" + originalurl + "\">Online Link</a>]";
  1816.         values[1] = "100";
  1817.         values[2] = "left";
  1818.         AddCellToRow(searchResultTable.insertRow(-1), keys, values);
  1819.         
  1820.         values[0] = "<font class=\"resultParagraph\" >" + WrapIfOneWord(excerpt,80) +"</font>";
  1821.         values[1] = "50";
  1822.         values[2] = "left";
  1823.         AddCellToRow(searchResultTable.insertRow(-1), keys, values);
  1824.         
  1825.         keys[0] = "innerHTML";
  1826.         keys[1] = "width";
  1827.         keys[2] = "align";
  1828.  
  1829.         values[0] = "<font class=\"resultSite\" size=\"1px\">"+TruncateString(originalurl,90)+"</font>";
  1830.         values[1] = "100";
  1831.         values[2] = "left";
  1832.         AddCellToRow(searchResultTable.insertRow(-1), keys, values);
  1833.         
  1834.         // insert a blank row
  1835.         values[0] = " ";
  1836.         values[1] = "100";
  1837.         values[2] = "center";
  1838.         AddCellToRow(searchResultTable.insertRow(-1), keys, values);
  1839.     }
  1840.     
  1841.     values[0] = " ";
  1842.     values[1] = "100";
  1843.     values[2] = "center";
  1844.     AddCellToRow(searchResultTable.insertRow(-1), keys, values);
  1845. }
  1846.  
  1847. function searchTopic(topic)
  1848. {
  1849.     if(document.frmEP.txtEditorPick.value == "")
  1850.     {
  1851.         document.location.href = "/webaroo/e29f1fe6/browseui?main=1&txtBrowseui="+document.frmEP.city_select_form_list.options[document.frmEP.city_select_form_list_box.selectedIndex].value+" " + topic;
  1852.     }
  1853.     else
  1854.     {
  1855.         document.location.href = "/webaroo/e29f1fe6/browseui?main=1&txtBrowseui="+document.frmEP.txtEditorPick.value+" "+ topic;
  1856.     }
  1857. }
  1858.  
  1859. function searchEditorPick()
  1860. {
  1861.         document.frmEP.action="/webaroo/e29f1fe6/search";
  1862.         var ind=document.frmEP.city_select_form_list.options[document.frmEP.city_select_form_list.selectedIndex].value;
  1863.         document.frmEP.txtEditorPick.value=ind;
  1864.         document.frmEP.submit();
  1865. }
  1866.  
  1867. function IsStartKeyword(strText)
  1868. {
  1869.     arrKeyword = new Array('*','~','AND','OR')
  1870.     for (intLoop = 0;intLoop < arrKeyword.length;intLoop++)
  1871.     {
  1872.         if((strText.indexOf(arrKeyword[intLoop])==0) && (strText.length==arrKeyword[intLoop].length))
  1873.         {
  1874.             return true;
  1875.             break;
  1876.         }
  1877.     }
  1878.     return false;
  1879. }
  1880.  
  1881. function trim(str)
  1882.     return((""+str).replace(/^\s*([\s\S]*\S+)\s*$|^\s*$/,'$1') ); 
  1883. }
  1884.  
  1885. function SetEmptyText()
  1886. {
  1887.     var arrQueryString = (location.search).split('&');
  1888.     for(i = 0; i<arrQueryString.length; i++)
  1889.     {
  1890.         if(arrQueryString[i].indexOf("txtBrowseui=") < 0)
  1891.         {
  1892.             continue;
  1893.         }
  1894.         document.frmSearch.txtSearch.value = " ";
  1895.         break;
  1896.     }
  1897. }
  1898.  
  1899. function SetSearchText()
  1900. {
  1901.     var done=0;
  1902.     var arrQueryString = (location.search).split('&');
  1903.     for(i = 0; i<arrQueryString.length; i++)
  1904.     {
  1905.         if(arrQueryString[i].indexOf("txtSearch=") < 0)
  1906.         {
  1907.             continue;
  1908.         }
  1909.         document.frmSearch.txtSearch.value = unescape((arrQueryString[i].split('='))[1]).replace(/\+/g, " ");
  1910.         done=1;
  1911.         break;
  1912.     }
  1913.     if(done==0)
  1914.     {
  1915.             for(i = 0; i<arrQueryString.length; i++)
  1916.             {
  1917.                 if(arrQueryString[i].indexOf("txtBrowseui=") < 0)
  1918.                 {
  1919.                     continue;
  1920.                 }
  1921.                 document.frmSearch.txtSearch.value = unescape((arrQueryString[i].split('='))[1]).replace(/\+/g, " ");
  1922.                 done=1;
  1923.                 break;
  1924.             }
  1925.     }
  1926. }
  1927.  
  1928. function changepage(page)
  1929. {
  1930.     parent.document.location.href=page;
  1931. }
  1932.  
  1933.  
  1934.  
  1935. function GetPageNumbers(nextoffset, totalResults)
  1936. {
  1937.     var numarray = new Array(5);
  1938.     var currentPageID = parseInt(nextoffset/10);
  1939.     var lastPageID = parseInt((totalResults+9)/10);
  1940.     
  1941.     if(nextoffset <= 40) 
  1942.     {
  1943.         //case for first three pages
  1944.         numarray[0] =1;
  1945.         numarray[1] =2;
  1946.         numarray[2] =3;
  1947.         numarray[3] =4;
  1948.         numarray[4] =5;
  1949.     }
  1950.     else if ((totalResults - nextoffset) < 20)
  1951.     {
  1952.         
  1953.         //case for last three pages
  1954.     
  1955.         numarray[0] =lastPageID -4;
  1956.         numarray[1] =lastPageID -3;
  1957.         numarray[2] =lastPageID -2;
  1958.         numarray[3] =lastPageID -1;
  1959.         numarray[4] =lastPageID;
  1960.     }
  1961.     else 
  1962.     {
  1963.         numarray[0] =currentPageID -2;
  1964.         numarray[1] =currentPageID -1;
  1965.         numarray[2] =currentPageID;
  1966.         numarray[3] =currentPageID +1;
  1967.         numarray[4] =currentPageID +2;
  1968.     }
  1969.     return numarray;
  1970. }
  1971.  
  1972.  
  1973. function WrapIfOneWord (message , characterlimit)
  1974. {
  1975.     var wordText;
  1976.     var remainingmessage = message;
  1977.     var newMessage ="";
  1978.     var startIndex,endIndex;
  1979.     
  1980.     if(message.length > characterlimit)
  1981.     {
  1982.         startIndex = 0;
  1983.         do
  1984.         {
  1985.             endIndex = remainingmessage.indexOf(" ");
  1986.             if(endIndex==-1) 
  1987.             {
  1988.                 wordText = remainingmessage;    
  1989.             }    
  1990.             else
  1991.             {
  1992.                 wordText = remainingmessage.substring(startIndex,endIndex);
  1993.                 remainingmessage = remainingmessage.substring(endIndex +1);
  1994.             }
  1995.             if(wordText.length > characterlimit)
  1996.             {
  1997.                 var newWord ="";
  1998.                 var tempWord =""; 
  1999.                 for(var i=0;i<wordText.length;i=i+characterlimit)
  2000.                 {
  2001.                     tempWord = wordText.substring(i,i+characterlimit) + " <br>";
  2002.                     newWord = newWord + tempWord;
  2003.                 }
  2004.                 wordText = newWord;
  2005.             }
  2006.             newMessage = newMessage + " " + wordText;
  2007.         }while(endIndex!=-1)
  2008.             
  2009.         return newMessage;
  2010.     }
  2011.     else
  2012.         return message;
  2013. }
  2014.  
  2015. function GetChannelIndex(channelID)
  2016. {
  2017.     if (channelNumber != null)
  2018.     {
  2019.         for(var i=0;i<channelNumber.length;i++)
  2020.         {
  2021.             if(channelID == channelNumber[i])
  2022.                 return i;
  2023.         }
  2024.     }
  2025.  
  2026.     return -1;
  2027. }
  2028.