text: angular.module("umbraco")
      .controller("Umbraco.Dialogs.HelpController", function ($scope, $location, $routeParams, helpService, userService) {
          $scope.section = $routeParams.section;
          if(!$scope.section){
              $scope.section ="content";
          }
  
          var rq = {};
          rq.section = $scope.section;
          
          userService.getCurrentUser().then(function(user){
          	
          	rq.usertype = user.userType;
          	rq.lang = user.locale;
  
      	    if($routeParams.url){
      	    	rq.path = decodeURIComponent($routeParams.url);
      	    	
      	    	if(rq.path.indexOf(Umbraco.Sys.ServerVariables.umbracoSettings.umbracoPath) === 0){
      				rq.path = rq.path.substring(Umbraco.Sys.ServerVariables.umbracoSettings.umbracoPath.length);	
      			}
  
      			if(rq.path.indexOf(".aspx") > 0){
      				rq.path = rq.path.substring(0, rq.path.indexOf(".aspx"));
      			}
      					
      	    }else{
      	    	rq.path = rq.section + "/" + $routeParams.tree + "/" + $routeParams.method;
      	    }
  
      	    helpService.findHelp(rq).then(function(topics){
      	    	$scope.topics = topics;
      	    });
  
      	    helpService.findVideos(rq).then(function(videos){
      	    	$scope.videos = videos;
      	    });
  
          });
  
          
      });