    google.load('search', '1');
	var siteSearch;
	var searchControl;
    function loadgsearch(searchtxt) {
      // create a search control
	  	 var container=document.getElementById("mas_container");
    	 searchControl = new google.search.SearchControl();
		 siteSearch = new google.search.WebSearch();
    	 siteSearch.setUserDefinedLabel("No results");
         siteSearch.setUserDefinedClassSuffix("siteSearch");
         siteSearch.setSiteRestriction("dir.bg");
         searchControl.setResultSetSize(google.search.Search.LARGE_RESULTSET);
         var options = new google.search.DrawOptions();
         options.setSearchFormRoot(document.getElementById("search"));
         options.setDrawMode(google.search.SearchControl.DRAW_MODE_TABBED);
		 var searchoptions = new google.search.SearcherOptions();
		 searchoptions.setExpandMode(google.search.SearchControl.EXPAND_MODE_OPEN);
         searchControl.addSearcher(siteSearch,searchoptions);
  	     siteSearch.setSearchCompleteCallback(this, searchComplete, [siteSearch]);
         searchControl.draw(container,options);
		 searchControl.execute(searchtxt);
    }	
	
	function searchComplete(searcher) {
  // Check that we got results
  if (searcher.results && searcher.results.length > 0) {
    // Grab our content div, clear it.
    var containtDiv=document.getElementById("mas_container");
    containtDiv.innerHTML = '';

    // Loop through our results, printing them to the page.
    var results = searcher.results;
    for (var i = 0; i < results.length; i++) {
      // For each result write it's title and image to the screen
      var result = results[i];
      var container = document.createElement('div');
	  
      var searchtxt = document.createElement('div');

      var title = document.createElement('a');
      // We use titleNoFormatting so that no HTML tags are left in the title
      title.innerHTML = result.titleNoFormatting;
           // There is also a result.url property which has the escaped version
      title.href = result.unescapedUrl;
	  title.target="_top";
	  searchtxt.innerHTML=result.content;
	  container.appendChild(document.createElement('br'));
      container.appendChild(title);
  	  container.appendChild(document.createElement('br'));
      container.appendChild(searchtxt);
  	  container.appendChild(document.createElement('br'));
      // Put our title + image in the content
      containtDiv.appendChild(container);
   	  }
	   var cursor = siteSearch.cursor;
  		var curPage = cursor.currentPageIndex; // check what page the app is on
 		 var pagesDiv = document.createElement('div');
  	for (var i = 0; i < cursor.pages.length; i++) {
   	 var page = cursor.pages[i];
    	if (curPage == i) { // if we are on the curPage, then don't make a link
     	 var label = document.createTextNode(' [' + page.label + '] ');
        // label.style.margin = '10px 10px';
     	 pagesDiv.appendChild(label);
   	 } else {
      // If we aren't on the current page, then we want a link to this page.
      // So we create a link that calls the gotoPage() method on the searcher.
      var link = document.createElement('a');
      link.href = 'javascript:siteSearch.gotoPage('+i+');';
      link.innerHTML = page.label;
      link.style.margin = '10px 10px';
      pagesDiv.appendChild(link);
    }
	containtDiv.appendChild(pagesDiv);
  }

  	 }
	}