 		define ["angular"], getModule
 	else
 		getModule angular
-)(window)
+)(window, document)

This version adds the ability to call $scope.startedLoading() and $scope.finishedLoading() many times,
in the event that you have multiple controllers making seperate HTTP requests.
###
(->
	getModule = (angular) ->
		angular.module("seo", [])
			   .run ["$rootScope", ($rootScope) ->
			   		thingsLoading = 0

			   		$rootScope.startedLoading = ->
			   			thingsLoading += 1

			   		$rootScope.finishedLoading = ->
			   			thingsLoading -= 1

			   			if thingsLoading < 1
			   				$rootScope.htmlReady()

					$rootScope.htmlReady = ->


							# fire after DOM rendering
							setTimeout ->
								if typeof window.callPhantom is "function"
									window.callPhantom rendered: document.documentElement.outerHTML
							, 0
				]

