/**
 * A class that handles the search
 *
 * @since Thu Apr 14 2011
 * @author Giso Stallenberg
 **/
var WJSearchfsv = Class.create({
	/**
	 * initialize
	 *
	 * Creates a new WJSearchfsv
	 *
	 * @since Mon Nov 07 2011
	 * @access public
	 * @param integer id
	 * @param Object options
	 * @return WJSearchfsv
	 **/
	initialize: function(options) {
		this.options =  Object.extend({
			
			/**
			* The wrapper div
			*
			* @type HTMLElement
			* @since Mon Nov 07 2011
			**/
			wrapper: $(document.body),
			/**
			* The key for the google Search API
			*
			* @type string
			* @since Mon Nov 07 2011
			**/
			googleApiKey: 'a'
			
		}, arguments[0] || { });
		
		this.initForm();
	},
 
 	/**
	 * initForm
	 *
	 * Registers the form button
	 *
	 * @since Mon Nov 07 2011
	 * @access 
	 * @param 
	 * @return 
	 **/
 	initForm: function() {
		var form = this.options.wrapper.down('form');
		form.observe('submit',
  			function(event) {
				Event.stop(event);
					form.request({
						parameters: {key: this.options.googleApiKey},
	 					onComplete: this.handleResult.bindAsEventListener(this)
					})
				return false;
			}.bind(this)
		);
		
	},
 
	handleResult: function() {
		console.log(arguments);
	}
	
});

