define(function(require, exports, module) {
	var global = require("../../js/global");
	var jGlobal = require("./faultDiagGlobal");
	
	function init() {
		initGlobalEvent();
		initEvent();
		initDom();
		
		function initEvent() {
			//默认加载设备管理页面
//			$(".selectDeviceContent").load("./faultDiagMenu/html/selectDevice.html");
			var curElement = ".selectDeviceContent", nextPageUrl = "./faultDiagMenu/html/selectDevice.html";
			global.enterPageCallback(curElement, nextPageUrl);

			//注册菜单切换事件
		    $(".faultDiagItem").on("click", function() {
				$(".faultDiagItem").removeClass("curSelectItem");
				$(this).addClass("curSelectItem");
			});
		    
			$("#intelligentDiag").click(function() {		
//				$(".selectDeviceContent").load("./faultDiagMenu/html/selectDevice.html");
				global.curClickPageId = ".selectDeviceContent|#intelligentDiag";
				var curElement = ".selectDeviceContent", nextPageUrl = "./faultDiagMenu/html/selectDevice.html";
				global.enterPageCallback(curElement, nextPageUrl);
			});
			
			$("#diagLog").click(function() {		
//				$(".selectDeviceContent").load("./faultDiagMenu/html/diagLog.html");
				global.curClickPageId = ".selectDeviceContent|#diagLog";
				var curElement = ".selectDeviceContent", nextPageUrl = "./faultDiagMenu/html/diagLog.html";
				global.enterPageCallback(curElement, nextPageUrl);
			});
			
			$("#definedCollect").click(function() {	
		
				global.curClickPageId = ".selectDeviceContent|#definedCollect";
				var curElement = ".selectDeviceContent", nextPageUrl = "./faultDiagMenu/html/selectDevice.html";
				global.enterPageCallback(curElement, nextPageUrl);
				return false;
			});
			
			//$("#uploadLog").click(function() {
			//	global.curClickPageId = ".selectDeviceContent|#uploadLog";
			//	var curElement = ".selectDeviceContent", nextPageUrl = "./faultDiagMenu/html/uploadLog.html";
			//	global.enterPageCallback(curElement, nextPageUrl);
			//});
			
			$("#diagLegend").click(function() {
				global.curClickPageId = ".selectDeviceContent|#diagLegend";
				var curElement = ".selectDeviceContent", nextPageUrl = "./faultDiagMenu/html/diagLegend.html";
				global.enterPageCallback(curElement, nextPageUrl);
			});
			
			$("#logDownload").click(function() {
				global.curClickPageId = ".selectDeviceContent|#logDownload";
				var curElement = ".selectDeviceContent", nextPageUrl = "./faultDiagMenu/html/logDownload.html";
				global.enterPageCallback(curElement, nextPageUrl);
			});

			
//			$('#claimModal').on('show.bs.modal', function() {
//				$('#claimModal .modal-body').load("../../common/html/disclaim.html");
//			});
		}
		function initDom() {	
			$('#uploadModal').modal({
				backdrop: 'static',
				show: false
            });

            if (global.userMgrIns.hasPermission('downloadLog')) {
                $('#logDownload').show();
            }
		}
		function initGlobalEvent() {
			global.exitPageCallback.exitFun = function () {
				return true;
			}
		}
	}
	exports.init = init;
});