	// ========== SEND SEARCH TO DATABASE
	// This code creates the functionality to send all webhelp searches to an InfoDev database.
	
	// Add function to search button
	insertSearchClickEvent();

	function insertSearchClickEvent(){
		// - Add id to Search button with class "wh_search_button"
		// $( ".wh_search_button" ).css( "border", "3px solid red" );
		$( ".wh_search_button" ).attr('id', 'btnSearchWebHelp');
		// document.getElementById('btnSearchWebHelp').addEventListener("click", saveSearchCriteria);
		$('#btnSearchWebHelp').click(saveSearchCriteria);
	}

	function saveSearchCriteria() {
		var searchTerm = $("#textToSearch").val().trim();
		// alert(searchTerm);
		if (searchTerm) {
			var url = window.location.href;
			var data = { "text": searchTerm, "url": url }
			//alert(JSON.stringify(data));
			$.ajax({
				type: 'POST',
				contentType: "application/json",
				url: '/resources/webhelp-includes/SaveSearchHandler.php',
				dataType: 'json',
				data: JSON.stringify(data),
				success: function(result) {
					alert("Response: " + result);
					// $('#searchForm').submit();
				},
				// error: function (xhr, ajaxOptions, thrownError) {
				// 	alert("Error: " + thrownError);
				// 	// $('#searchForm').submit();
				// }
			});
		}
		// return false;
	}