// this JS is used for Google_search page
  google.load("search", "1");
   
    // looks for query string passed to the search page
    // pass the paramater to be fetched - if found the value is returned
    // else 0 is returned
    function querySt(ji) {
        hu = window.location.search.substring(1);
        gy = hu.split("&");
        for (i=0;i<gy.length;i++) {
            ft = gy[i].split("=");
            if (ft[0] == ji) {
                return unescape(ft[1]);
            }
        }
       
        return 0;
    }
   
    // set the websearch
    // pass the search label and the site to be restricted
    function setWebSearch(tabbed, searchLabel, searchSite) {
        var siteSearch = new google.search.WebSearch();
        siteSearch.setUserDefinedLabel(searchLabel);
        siteSearch.setUserDefinedClassSuffix("siteSearch");
        siteSearch.setSiteRestriction(searchSite);
        tabbed.addSearcher(siteSearch);
        tabbed.setNoResultsString(google.search.SearchControl.NO_RESULTS_DEFAULT_STRING); // for no results        
        tabbed.setLinkTarget(google.search.Search.LINK_TARGET_SELF); // open result in same window
   
    }

    function OnLoad() {
        // create a tabbed mode search control
        var tabbed = new google.search.SearchControl();
        tabbed.setResultSetSize(google.search.Search.LARGE_RESULTSET);
       
        // create the tabs
        setWebSearch(tabbed, "Livemint", "www.livemint.com");
        setWebSearch(tabbed, "MarketInfo", "marketinfo.livemint.com");
        setWebSearch(tabbed, "Blogs", "blogs.livemint.com");

        // web search
        tabbed.addSearcher(new google.search.WebSearch());
        tabbed.setNoResultsString(google.search.SearchControl.NO_RESULTS_DEFAULT_STRING); // for no results
       
        // draw in tabbed layout mode
        var drawOptions = new google.search.DrawOptions();
        drawOptions.setDrawMode(google.search.SearchControl.DRAW_MODE_TABBED);
        tabbed.draw(document.getElementById("search_control_tabbed"), drawOptions);

        // check if search string has been passed
        // look for qs
        var searchString = querySt("qs");
       
        if (searchString != 0) {
            tabbed.execute(searchString);
        }
    }
    google.setOnLoadCallback(OnLoad, true); 
