var SysClose = (function(){
	$('.softLogo').dblclick(function(){
		if(!pur5.Cfg.pur5Uid) window.close();
		pur5.Pages.alert($('#sysClose')[0]);
	});
	$('.signOutBtn, .closeSoftBtn').click(function(){
		if(!pur5.Cfg.pur5Uid) window.close();
		pur5.Pages.alert($('#sysClose')[0]);
	});
	return {
		init: function(){
			var self = this;
			$('#sysCloseBtn').click(function(){
				self.close();
			});
		},
		close: function(){
			var arr = [
					pur5.Cfg.sysInterval,
					pur5.Cfg.sysPopInterval,
					pur5.Cfg.sysRunTimeInterval,
					pur5.Cfg.ReadTBOrdersInterval,
					pur5.Cfg.TBSendOrdersInterval,
					pur5.Cfg.TBReDeliverInterval,
					pur5.Cfg.ReadPPOrdersInterval,
					pur5.Cfg.sysUserMoneyInterval
				];
			for(var i = 0, l = arr.length; i < l; i++) {
				clearInterval(arr[i]);
			}
			
			UI.immovable();
			
			pur5.Cfg.FSTray = pur5.Cfg.pur5Ax = pur5.Cfg.Ds = null;
			CollectGarbage();
			
			pur5.Pages.logout(function(){
				window.close();
			});
		}
	}
})();
$(function(){
	SysClose.init();
});