function Search(suggestSearchURL, form, errorContainer, queryInput, instanceName, submitButton) {
	
	this.form = form;
	this.errorContainer = errorContainer;

	this.suggestBox = new SuggestBox();
	this.suggestBox.init(suggestSearchURL, form, queryInput, instanceName);

	var self = this;
	$(submitButton).mouseup(function() { return self.submitSearchForm(); return false; });
	$(queryInput).keypress(function(e) {
		
		 var code = (e.keyCode ? e.keyCode : e.which);
		 if (code == 13) { 
			 self.submitSearchForm(); 
			 return false; 
		 } else {
			 self.resetErrors();
			 return true;
		 }
	});
}
	
Search.prototype.submitSearchForm = function()
{
	var keywords = $(".keywords", this.form);
	if (keywords.val().length <= 0)
	{
		// blink if already present
		$(this.errorContainer).hide();
		$(document.body).append(this.errorContainer)
		var rightPos = ($("#website").offset().left + $("#website").width()) - $(this.errorContainer).width()-1;
		$(this.errorContainer).css("left", rightPos+"px");
		$(this.errorContainer).css("top", ($("#searchfield").offset().top+21)+"px");
		$(this.errorContainer).fadeIn();
		keywords.addClass("error");		
	} else {
		this.resetErrors();
		this.form.submit();
	}
}

Search.prototype.resetErrors = function()
{
	var keywords = $(".keywords", this.form);
	$(this.errorContainer).fadeOut();
	keywords.removeClass("error");		
}

