 				controller: "SupportModalController"
 			)
 
-	App.controller 'SupportModalController', ($scope, $modalInstance) ->
+	App.controller 'SupportModalController', ($scope, $modalInstance, algoliaSearch) ->
 		$scope.form = {}
 		$scope.sent = false
 		$scope.sending = false
+		$scope.suggestions = [];
+
+		_handleSearchResults = (success, results) ->			
+			suggestions = for hit in results.hits
+				page_underscored = hit.pageName.replace(/\s/g,'_')
+				section_underscored = hit.sectionName.replace(/\s/g,'_')
+
+				suggestion = 
+					url :"/learn/#{page_underscored}##{section_underscored}"
+					name : hit._highlightResult.pageName.value + " - " + hit._highlightResult.sectionName.value
+
+			$scope.$applyAsync () -> 
+				$scope.suggestions = suggestions
+
 		$scope.contactUs = ->
 			if !$scope.form.email?
 				console.log "email not set"

	"base"
	"libs/platform"
], (App, platform) ->


	App.controller 'ContactModal', ($scope, $modal) ->

				$scope.sent = true
				$scope.$apply()

		$scope.$watch "form.subject", (newVal, oldVal) ->
			if newVal and newVal != oldVal
				algoliaSearch.searchWiki newVal, _handleSearchResults

		$scope.$watch "suggestions", (newVal) -> console.log newVal

		$scope.close = () ->
			$modalInstance.close()
