 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.
 ###
-(->
+((window, document) ->
 	getModule = (angular) ->
 		angular.module("seo", [])
 			   .run ["$rootScope", ($rootScope) ->
-			   		thingsLoading = 0
+					thingsLoading = 0
 
-			   		$rootScope.startedLoading = ->
-			   			thingsLoading += 1
+					$rootScope.startedLoading = ->
+						thingsLoading += 1
 
-			   		$rootScope.finishedLoading = ->
-			   			thingsLoading -= 1
+					$rootScope.finishedLoading = ->
+						thingsLoading -= 1
 
-			   			if thingsLoading < 1
-			   				$rootScope.htmlReady()
+						if thingsLoading < 1
+							$rootScope.htmlReady()
 
 					$rootScope.htmlReady = ->
 

							# fire after DOM rendering
							setTimeout ->
								if typeof window.callPhantom is "function"
									window.callPhantom()
							, 0
				]


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