
POP.GoogleCSE = function (options) {
	var self = this;
	this.options = {
		proxyForm:			$('#searchbox'),
		proxyTxtInput:		$('#searchQuery'),
		proxySubmitBtn:		$('#submitSearchQuery'),
		cseForm:			$('#cse_search_box'),
		cseFormTxtInput:	$('#cseQuery')
	};
	if (typeof options === 'object') {
		$.extend(this.options, options);
	}
	this.options.proxyForm.bind('keypress', function (event) {
		if (event.keyCode == 13) {
			event.preventDefault();
			self.postSearchQuery();
        }
	});
	this.options.proxySubmitBtn.bind('click', function (event) {
		event.preventDefault();
		self.postSearchQuery();
	});
};

POP.GoogleCSE.prototype = {
	postSearchQuery: function() {
		var txtInputVal = this.options.proxyTxtInput.val();
		if (txtInputVal != '') {
			this.options.cseFormTxtInput.val(txtInputVal);
			this.options.cseForm.submit();
		}
	}
};

