(function($) {
	// removes submit button on search
	$.fn.remove_search_button = function() {
		$(this).find('input.search').each(function() {
			if ( !$(this).attr('placeholder') ) {
				$(this).attr('placeholder','Search');
			}
		
			$(this).parents('form:first').find(':submit').hide();
		});
	
		// Checks if the browser supports placeholder text and then adds functionality if not
		var supports_placeholder = function() {
			var i = document.createElement('input');			
			return 'placeholder' in i;
		}
			
		if ( !supports_placeholder() ) {
			$(this).each(function() {
				$(this).find('input.search')
					.check_search_value()
					.focus(function() {
						placeholder_val = $(this).attr('placeholder');
						cur_val = $(this).val();

						if ( placeholder_val == cur_val)
							$(this).val('');

						$(this).removeClass('no_term');
					})
					.blur(function(){
						// Checks the value of a text field against its placeholder value
						$(this).each(function() {
							var placeholder_val = $(this).attr('placeholder');
							var cur_val = $(this).val();

							if ( cur_val == placeholder_val || cur_val == '')
								$(this).addClass('no_term').val(placeholder_val);
							else
								$(this).removeClass('no_term');
						});
					});
			});
		}
		return this;
	}
})(jQuery);
