 //<![CDATA[
    google.load('search', '1.0');
    function OnLoad() {
      new RawSearchControl();
    }

    /**
     * The RawSearchControl demonstrates how to use Searcher Objects
     * outside of the standard GSearchControl. This includes calling
     * searcher .execute() methods, reacting to search completions,
     * and if you had previously disabled html generation, how to generate
     * an html representation of the result.
     */
    function RawSearchControl() {
      // latch on to key portions of the document
      this.searcherform = document.getElementById("searcher");
      this.results = document.getElementById("results");
      this.cursor = document.getElementById("cursor");
      this.searchform = document.getElementById("searchform");
	  //this.setResultSetSize(google.search.Search.LARGE_RESULTSET)

      // create map of searchers as well as note the active searcher
      this.activeSearcher = "web";
      this.searchers = new Array();

      // create and wire up an instance of GwebSearch and one of
      // GlocalSearch. Note, we disable html generation. We are doing
      // this so that we can demonstrate how to manually create it if
      // needed. Note that we register to handle search completion notifications
      // when searches complete, they are called in the context of this instance
      // of RawSearchControl and they are passed the searcher that just completed

      // wire up a raw GwebSearch searcher
      var searcher = new google.search.WebSearch();
      searcher.setNoHtmlGeneration();
	  searcher.setResultSetSize(GSearch.LARGE_RESULTSET);
	  searcher.setSiteRestriction("003230347564231714641:mrdyqv8za-k");
      searcher.setSearchCompleteCallback(this,
                                         RawSearchControl.prototype.searchComplete,
                                         [searcher]
                                         );
      this.searchers["web"] = searcher;

      

      // now, create a search form and wire up a submit and clear handler
      this.searchForm = new google.search.SearchForm(true, this.searchform);
      this.searchForm.setOnSubmitCallback(this,
                                          RawSearchControl.prototype.onSubmit);
      this.searchForm.setOnClearCallback(this,
                                          RawSearchControl.prototype.onClear);
    }

    /**
     * figure out which searcher is active by looking at the radio
     * button array
     */
    RawSearchControl.prototype.computeActiveSearcher = function() {
      for (var i=0; i<this.searcherform["searcherType"].length; i++) {
        if (this.searcherform["searcherType"][i].checked) {
          this.activeSearcher = this.searcherform["searcherType"][i].value;
          return;
        }
      }
    }


    /**
     * onSubmit - called when the search form is "submitted" meaning that
     * someone pressed the search button or hit enter. The form is passed
     * as an argument
     */
    RawSearchControl.prototype.onSubmit = function(form) {
      this.computeActiveSearcher();
      if (form.input.value) {
        // if there is an expression in the form, call the active searcher's
        // .execute method
        this.searchers[this.activeSearcher].execute(form.input.value);
      }

      // always indicate that we handled the submit event
      return false;
    }

    /**
     * onClear - called when someone clicks on the clear button (the little x)
     */
    RawSearchControl.prototype.onClear = function(form) {
      this.clearResults();
    }

    /**
     * searchComplete - called when a search completed. Note the searcher
     * that is completing is passes as an arg because thats what we arranged
     * when we called setSearchCompleteCallback
     */
    RawSearchControl.prototype.searchComplete = function(searcher) {
 
      // always clear old from the page
      this.clearResults();

		 if (searcher.cursor == undefined) {
            document.getElementById("resultcount").innerHTML = 0;
        } else {
            document.getElementById("resultcount").innerHTML = "Results "+"<b>"+((searcher.cursor.currentPageIndex*8)+1)+"</b>"+" - "+"<b>"+((searcher.cursor.currentPageIndex+1)*8)+"</b>"+" of about "+"<b>"+searcher.cursor.estimatedResultCount+"</b>";
        }

      // if the searcher has results then process them
      if (searcher.results && searcher.results.length > 0) {
		
		
        for (var i=0; i<searcher.results.length; i++) {
          var result = searcher.results[i];
		 
          searcher.createResultHtml(result);
          if (result.html) {
			//
			 link=result.unescapedUrl;
			 url=result.titleNoFormatting;
		     content=result.content;
			 title=result.title;
			 //alert(link);
			 node=link.replace("http://smarttech\.com","");
			 //alert(node);
			 var notebookLink2=makeRequest(node,'');
			 //alert(notebookLink2);
			 var titleRegex = new RegExp( "[^/]+\.notebook$", "i" ) ;
			 titleTrunc = notebookLink2.match( titleRegex ) ;
			
			//=================
			var ni = document.getElementById('results');
			var newdiv = document.createElement('div');
			var divIdName = 'my'+i+'Div';
			newdiv.setAttribute('id',divIdName);
			newdiv.innerHTML = '<a href=\''+notebookLink2+'\'>'+titleTrunc+'</a>'+'<br/>'+content+'<br/>'+'<cite>'+notebookLink2+'</cite><br/><br/>';
		    ni.appendChild(newdiv);
			//===================

			} 
			else {
            div = createDiv("** failure to create html **");
          }		 
        }

        // now, see if we have a cursor, and if so, create the 
        // cursor control
        if (searcher.cursor) {
          var cursorNode = createDiv(null, "gsc-cursor");
          for (var i=0; i<searcher.cursor.pages.length; i++) {
            var className = "gsc-cursor-page";
            if (i == searcher.cursor.currentPageIndex) {
              className = className + " gsc-cursor-current-page";
            }
            var pageNode = createDiv(searcher.cursor.pages[i].label, className);
			
            pageNode.onclick = methodClosure(this, this.gotoPage, 
                                             [searcher, i]); 
            cursorNode.appendChild(pageNode);
          }
          this.cursor.appendChild(cursorNode);
          var more = createLink(searcher.cursor.moreResultsUrl,
                                GSearch.strings["more-results"] + "&nbsp;&raquo;",
                                GSearch.LINK_TARGET_SELF,
                                "gsc-trailing-more-results");
          this.cursor.appendChild(more);
        }
      }
    }

    RawSearchControl.prototype.gotoPage = function(searcher, page) {
		// Delete all the divs created for the previous page
        for (var number=0; number<8 ; number++ )
        {
			removeElement('my'+number+'Div');
        }
		//
		searcher.gotoPage(page);
    }

    /**
     * clearResults - clear out any old search results
     */
    RawSearchControl.prototype.clearResults = function() {
      removeChildren(this.results);
      removeChildren(this.cursor);
    }

	/**
	* Remove a div in 'result' div by numberID
	*/

	function removeElement(divNum) {
		var d = document.getElementById('results');
		var olddiv = document.getElementById(divNum);
		d.removeChild(olddiv);
	}

    /**
     * Static DOM Helper Functions
     */
    function removeChildren(parent) {
      while (parent.firstChild) {
        parent.removeChild(parent.firstChild);
      }
    }
    function createDiv(opt_text, opt_className) {
      var el = document.createElement("div");
      if (opt_text) {
        el.innerHTML = opt_text;
      }
      if (opt_className) { el.className = opt_className; }
      return el;
    }

    function methodClosure(object, method, opt_argArray) {
      return function() {
        return method.apply(object, opt_argArray);
      }
    }

    function createLink(href, opt_text, opt_target, opt_className, opt_divwrap) {
      var el = document.createElement("a");
      el.href = href;
      if (opt_text) {
        el.innerHTML = opt_text;
      }
      if (opt_className) {
        el.className = opt_className;
      }
      if (opt_target) {
        el.target = opt_target;
      }
      if (opt_divwrap) {
        var div = this.createDiv(null, opt_className);
        div.appendChild(el);
        el = div;
      }
      return el;
    }

	 var http_request = false;

  function makeRequest(url, parameters) {
    var http_request = false;
	var notebookLink=null;

	try {
		http_request = new XMLHttpRequest();
	} 
	catch (trymicrosoft) {
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
			} 
		catch (othermicrosoft) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
				} 
			catch (failed) {
				http_request = false;
			}
		}
	}

	if (!http_request)
		alert("Error initializing XMLHttpRequest!");



//	if (window.XMLHttpRequest)     // Object of the current windows
//	{ 
//		alert("IE7 or firefox");
//		var http_request = new XMLHttpRequest();     // Firefox, Safari, ...
//	} 
//	else {
//		alert("IE6");
//		if (window.ActiveXObject)   // ActiveX version
//		{
//			var http_request = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
//		} 
//	}


    //http_request = new XMLHttpRequest();
    if (http_request.overrideMimeType) {
      http_request.overrideMimeType('text/xml');
    }
    if (!http_request) {
      alert('Cannot create XMLHTTP instance');
      return false;
    }
	//alertContents;
	//alert("/"+url + parameters);//http_request.onreadystatechange = contentIsReady;
	
    http_request.open('GET', url + parameters, false); 
	
	http_request.send(null);
	
    var string2 = http_request.responseText;
	var hrefRegex = new RegExp( "href=\"([^\"]+)\"", "i" ) ;
	var resultat = string2.match( hrefRegex ) ;
	notebookLink=resultat[1];
	return notebookLink;	
  }


function retour(url){
	var lien=makeRequest(url,'');
	return lien;
}

function doThis(lien){
	notebookLink=lien;
}
	// register to be called at OnLoad when the page loads
    google.setOnLoadCallback(OnLoad, true);
    //]]>