/**
 * @author Matthew Foster
 * @date   August 3rd 2007
 * @purpose A class that manages the requests and callbacks of a Gwebsearch instance.  It extends from the Ajax.Service.History class to allow back/forward capabilities
 */
var GWebSearchHistoryService = Class.create();

Object.extend(Object.extend(GWebSearchHistoryService.prototype, Ajax.Service.History.prototype),
				{
					initialize : function(ele, restriction){
						
						this.buildInterface(ele);
						this.createEngine(restriction);
						this.createListener();
						this.attachListener();
						
					},
					createEngine : function(restriction){
						
						this.engine = new GwebSearch();
						this.engine.setSiteRestriction(restriction);
						this.engine.setResultSetSize(GSearch.LARGE_RESULTSET);
					
					},
					attachListener : function(){
						
						Ajax.Service.History.prototype.attachListener.apply(this, arguments);
						this.engine.setSearchCompleteCallback(this, this.handleSearch);
					
					
					},
					search : function(query){
						this.lastQuery = query;
						this.engine.execute(query);
					
					},
					handleSearch : function(results){
						
						this.registerRequest("searchComplete", { query : this.lastQuery, results : this.engine.results});
					
					}
					
					
				
				}
			);