app.controller('helpCtrl', ['$rootScope','$scope','$timeout',
	function($rootScope,$scope, $timeout) {
		$scope.platform="";
		$scope.isXR=false;
		var imageName="";
		$scope.helpImageUrl='';
		var platform = "";
		$timeout(function(){
			if($rootScope.deviceInfo){
				var deviceVersion=$rootScope.deviceInfo.type.split('-');
				platform = deviceVersion[1];
				var prefix = deviceVersion[0]+"-";
				if($rootScope.deviceInfo.type.indexOf("CDB")!=-1){
					prefix = "";
					platform = deviceVersion[0];
				}else if($rootScope.deviceInfo.type.indexOf("2960+")!=-1){
                        		platform = "C2960";
                		}else if($rootScope.deviceInfo.type.indexOf("2960C")!=-1 && $rootScope.deviceInfo.type.indexOf("2960CX") == -1){
                        		platform = "C2960C405";
                		}else if(platform == "C2960XR"){
                        		platform = "C2960X";
                		}
				var dir = platform;

				//Calculate image name
				if(platform == "C2960L" || platform == "CDB"){
					if($rootScope.deviceInfo.isUPoECapable)
						imageName=dir+"/"+prefix+platform+"-"+$rootScope.deviceInfo.numberOfPorts+"U.jpg";
					else if($rootScope.deviceInfo.isPoECapable)
						imageName=dir+"/"+prefix+platform+"-"+$rootScope.deviceInfo.numberOfPorts+"P.jpg";
					else 	
						imageName=dir+"/"+prefix+platform+"-"+$rootScope.deviceInfo.numberOfPorts+".jpg";
				}else{
					$scope.isXR = ($rootScope.deviceInfo.type.indexOf("2960XR") != -1);
					if($rootScope.deviceInfo.type == "WS-C2960CX-8PC-L" || $rootScope.deviceInfo.type == "WS-C3560CX-12PD-S" ||
						$rootScope.deviceInfo.type == "WS-C3560CX-8XPD-S" || $rootScope.deviceInfo.type == "WS-C3560CX-8PT-S" ||
						$rootScope.deviceInfo.type == "WS-C2960CPD-8PT-L" ){
							imageName=dir+"/"+ $rootScope.deviceInfo.type + ".jpg";	
					} else {
						imageName=dir+"/"+platform+".jpg";
					}
				}
			}
			var imageUrl="resources/images/"+ $.trim(imageName);
			$scope.helpImageUrl=imageUrl;
			$scope.platform = platform;
			console.log($scope.helpImageUrl);
		},150);
}]);
