

/**
* This file has all logic of image search results displaying
*/
google.load('search', '1');

    // the se class encapsulates a left and right search control
    // both controls are driven by a shared search form
    function se(query) {
      var sFormDiv = document.getElementById("searchForm");
      var rightScDiv = document.getElementById("rightSearchControl");

      // create a left, right search control
      // create a custom search form
  
      this.rightControl = new google.search.SearchControl();
      this.searchForm = new google.search.SearchForm(false, sFormDiv);

      // bind clear and submit functions
      this.searchForm.setOnSubmitCallback(this, se.prototype.onSubmit);
      

      // set up for large result sets
    
      this.rightControl.setResultSetSize(GSearch.LARGE_RESULTSET);

     
      // configure right control
      // tabbed layout image, web, news, video
      options = new google.search.SearcherOptions();
		options.setExpandMode(google.search.SearchControl.EXPAND_MODE_OPEN);
      
      this.rightControl.addSearcher(new google.search.ImageSearch(),options);
      

      var drawOptions = new google.search.DrawOptions();
      drawOptions.setDrawMode(GSearchControl.DRAW_MODE_LINEAR);
      //drawOptions.setInput(inputElement) TODO
      
   

      this.rightControl.setNoResultsString(google.search.SearchControl.NO_RESULTS_DEFAULT_STRING );
      this.rightControl.draw(rightScDiv, drawOptions);
      
      this.searchForm.execute("Mantorras Benfica");

	 
        

    }

    // when the form fires a submit, grab its
    // value and call the left and right control
    se.prototype.onSubmit = function(form) {
      var q = form.input.value;
      
      
      if (q && q!= "") {
        
        this.rightControl.execute(q);
        //set the last query value
        setLastQuery(form.input.value);
      }
      
      
      
      return false;
    }

    // when the form fires a clear, call the left and right control
    se.prototype.onClear = function(form) {
      this.leftControl.clearAllResults();
      this.rightControl.clearAllResults();
      form.input.value = "";
      return false;
    }
    
    
    
    bodyOnloadEquivalenteFormImagesPage=function()
    {
    	globalSE=new se();
    	var allInputs = $(":text");
    	allInputs[0].focus();
    	/*if($.cookie('lastQuery')){allInputs[0].value=$.cookie('lastQuery');allInputs[1].value=$.cookie('lastQuery');globalSE.searchForm.execute();}*/
    	
    }
    
    
    google.setOnLoadCallback(bodyOnloadEquivalenteFormImagesPage);
    
    


    
  

