// +---------------------------------------------------
// | 动态接口地址；内网：192.168.3.188:8299；外网180.153.140.215:8080
// +---------------------------------------------------
// 'http://192.168.3.188:8299/investAnalysisPlateTest/inter/',
var dyn_inter_base_path = G_TGPATH() + 'inter/',

	// +---------------------------------------------------
	// | 静态txt内容基地址
	// +---------------------------------------------------
	static_txt_base_path = G_TGPATH() + 'file/',

	// +---------------------------------------------------
	// | 标签用户组(每个标签包含哪些用户)[{id,nm,num,color,cids}]
	// +---------------------------------------------------
	G_groups_users = [],

	// +---------------------------------------------------
	// | 用户标签组(每个用户拥有哪些标签)[{userid,seqs}]
	// +---------------------------------------------------
	G_users_groups = {},

	// +---------------------------------------------------
	// | 当前经纪人的所有用户的基本和统计数据对象
	// +---------------------------------------------------
	G_users = [],

	// +---------------------------------------------------
	// | 用户最新资料和服务包信息
	// +---------------------------------------------------
	G_user_info_srvs = [],

	// +---------------------------------------------------
	// | 经纪人
	// +---------------------------------------------------
	G_broker = {},

	// +---------------------------------------------------
	// | 经纪人最新信息和权限
	// +---------------------------------------------------
	G_broker_info_servs = {},

	// +---------------------------------------------------
	// | 当前统计状态
	// +---------------------------------------------------
	G_status = {},

	// +---------------------------------------------------
	// | 筛选条件数组
	// +---------------------------------------------------
	G_filter_condition = {
		character		: '全部',
		LoginStatus		: '不限',
		ClientRights	: [],
		Tendency		: [],
		ClientManager	: [],
		Lable			: [],
		sort			: '0|',
		open			: 0
	},

	// +---------------------------------------------------
	// | 筛选后的用户组列表
	// +---------------------------------------------------
	G_filter = [],

	G_curUserID = '',
	G_all_stocks = [],
	G_khlb_stock = '|',
	G_Dictionary = null,
	G_curPage = 0,
	G_scrollTop = 0,
	G_MailType = {
		'0'	: '普通',
		'1'	: '回执',
		'2'	: '回复',
		'3'	: '长期权限',
		'4'	: '短期产品',
		'6'	: '试用产品'
	},
	G_ErrorMsg = {
		'-1'	: '缺少参数',
		'-2'	: '无效参数',
		'-3'	: '服务包过期',
		'-8'	: '操作失败',
		'-9'	: '系统错误',
		'0'		: '操作完成',
		'1'		: '操作成功'
	},
	G_LastReqFlag = {
		'binfosrvs'		: JJR_MIN_DATE,
		'cinfosrvssng'	: JJR_MIN_DATE,
		'cinfosrvslst'	: 0
	};

function ajax_load_cache_data(url, isJSON)
{
	var tmpret = '';
	ajax_load_cache(
		url, false, function (data)
		{
			tmpret = data;
		}
	);
	if (!tmpret)
	{
		return null;
	}
	if (!isJSON)
	{
		return tmpret;
	}
	try
	{
		return eval('(' + tmpret + ')');
	}
	catch (e)
	{
		var obj = client_core_interface();
		obj.r("S_SYS_WRITELOG","[jjrl.js]解析缓存数据出错，请联系管理员后重试!");
		return null;
	}
	finally
	{
		tmpret = null;
	}
}

function ajax_load_real_data(url, isJSON)
{
	var tmpret = '';
	ajax_load(
		url, false, function (res)
		{
			tmpret = res;
		}
	);
	if (!tmpret)
	{
		var obj = client_core_interface();
		obj.r("S_SYS_WRITELOG","[jjrl.js]请求实时数据出错，请联系管理员后重试!");
		return null;
	}
	if (!isJSON)
	{
		return tmpret;
	}
	try
	{
		return eval('(' + tmpret + ')');
	}
	catch (e)
	{
		var obj = client_core_interface();
		obj.r("S_SYS_WRITELOG","[jjrl.js]解析实时数据出错，请联系管理员后重试!");
		return null;
	}
	finally
	{
		url = null;
		tmpret = null;
	}
}

// +---------------------------------------------------
// | 加载股票基本信息（txt文件），本地Cache
// +---------------------------------------------------
function loadStockInfo()
{
	var url = static_txt_base_path + 'stock.do?qsid=' + getQsId();
	G_all_stocks = ajax_load_cache_data(url, true);
}

// +---------------------------------------------------
// | 加载经纪人的统计文件（txt文件），本地Cache
// +---------------------------------------------------
function loadBrokerStatistics()
{
	var url = static_txt_base_path + 'broker.do?bid=' + getSysUserId() + '&qsid=' + getQsId();
	return ajax_load_cache_data(url, true);
}

// +---------------------------------------------------
// | 同步加载经纪人最新基本信息和服务包信息
// +---------------------------------------------------
function loadBInfoSrvs()
{
	var lastReqTime = G_LastReqFlag.binfosrvs;
	if (G_broker && G_broker.hasOwnProperty('info') && G_broker.info && G_broker.info.hasOwnProperty('udt'))
	{
		lastReqTime = G_broker.info.udt;
	}
	var url = dyn_inter_base_path + 'qurbroker.do?type=2&qsid=' + getQsId() + '&bid=' + getSysUserId() + '&udt='
		+ lastReqTime + '&random=' + Math.random();
	var tmpret = ajax_load_real_data(url, true);
	if (tmpret && typeof (tmpret) == 'object' && tmpret.hasOwnProperty('scd'))
	{
		switch (tmpret.scd)
		{
			case '0':
			case '1':
				break;
			default:
				alert('加载投顾人员基本信息出错：' + G_ErrorMsg[tmpret.scd]);
		}
		return;
	}
	G_broker_info_servs = tmpret;
}

// +---------------------------------------------------
// | 同步加载数据字典
// +---------------------------------------------------
function loadDictionary()
{
	if (!G_Dictionary)
	{
		var url = dyn_inter_base_path + 'qursysset.do?qsid=' + getQsId() + '&random=' + Math.random();
		G_Dictionary = ajax_load_real_data(url, true);
		//兼容产品中心，过滤产品中心产品
		if(G_Dictionary !=null){
			productList = G_Dictionary.p;
			$.each(productList,function(key,info){
				if(parseInt(key.substring(0,1))>=6){
					delete productList[key];
				}
			});
		}
	}
}

// +---------------------------------------------------
// | 客户列表数据(资料+权限)，增量查询
// +---------------------------------------------------
function loadCInfoSrvsList()
{
	var lastReqVer = G_LastReqFlag.cinfosrvslst;
	var url = dyn_inter_base_path + 'qurcustomerlist.do?type=1&qsid=' + getQsId() + '&bid=' + getSysUserId() + '&ver='
		+ lastReqVer + '&random=' + Math.random();
	var tmpret = ajax_load_real_data(url, true);
	if (tmpret && typeof (tmpret) == 'object' && tmpret.hasOwnProperty('scd'))
	{
		switch (tmpret.scd)
		{
			// scd=0，表示无增量数据；scd=1：表示更新成功！
			case '0':
			case '1':
				break;
			default:
				alert('加载客户资料数据出错：' + G_ErrorMsg[tmpret.scd]);
		}
	}
	else
	{
		G_user_info_srvs = tmpret;

		if (G_broker && typeof (G_broker) == 'object' && G_broker.hasOwnProperty('info') && G_broker.info
			&& typeof (G_broker.info) == 'object' && G_broker.info.hasOwnProperty('ver'))
		{
			G_LastReqFlag.cinfosrvslst = G_broker.info.ver;
		}
	}
}

// +---------------------------------------------------
// | 经纪人下所有用户在线状态（返回数组）
// +---------------------------------------------------
function GetAllCustomersLoginStatus()
{
	var url = dyn_inter_base_path + 'onlinecuslist.do?qsid=' + getQsId() + '&bid=' + getSysUserId() + '&random='
		+ Math.random();
	var tmpret = ajax_load_real_data(url, true);
	if (tmpret && typeof (tmpret) == 'object' && tmpret.hasOwnProperty('scd'))
	{
		return null;
	}
	return tmpret;
}

// +---------------------------------------------------
// | 加载页面初始化数据
// +---------------------------------------------------
function load_DemoData()
{
	sysUserInit();
	// 加载数据字典
	loadDictionary();

	// 加载股票信息并格式化
	loadStockInfo();
	stkDataFormat(G_all_stocks);

	// 加载投顾统计文件并初始化投顾对象G_broker
	var tmpBrokerSts = loadBrokerStatistics();
	G_broker = initBrokerData(
		tmpBrokerSts, G_all_stocks
	);

	// 加载经纪人实时数据(基本资料+服务包)，设置G_broker_info_servs对象
	loadBInfoSrvs();
	G_broker.id = G_broker_info_servs.id;
	G_broker.info = G_broker_info_servs.info;
	G_broker.srv = G_broker_info_servs.srv;

	// 加载客户列表数据(资料+权限)， 设置G_user_info_srvs对象（数组），增量查询
	loadCInfoSrvsList();

	// 把用户ID、姓名注册到快捷键盘！
	var cinfo = ""; // 数据格式：id,name\r\nid,name\r\n
	$.each(
		G_user_info_srvs, function(i, user)
		{
			cinfo += user.info.id + "," + user.info.nm + "\r\n";
		}
	);
	// 往智能键盘里，加载最新用户信息
	MSG_SYS_REGSMARTKB(cinfo);

	G_users = initCustomerData(
		G_broker, G_all_stocks
	);

	// 加载投顾标签用户信息（G_groups_users对象）！
	loadGroupsUsers();
}

// +---------------------------------------------------
// | 查询投顾标签信息
// +---------------------------------------------------
function loadGroupsUsers()
{
	var url = dyn_inter_base_path + 'qurLabel.do?&qsid=' + getQsId() + '&bid=' + getSysUserId() + '&random='
		+ Math.random();
	G_groups_users = ajax_load_real_data(url, true);
}

function uptCusLabel(param, bcFun)
{
	var url = dyn_inter_base_path + 'uptCusLabel.do?qsid=' + getQsId() + '&bid=' + getSysUserId() + '&seq=' + param.seq
		+ '&cid=' + param.cid + '&color=' + param.color + '&random=' + Math.random();
	ajax_load(
		url, false, bcFun
	);
}

function uptLabel(param, bcFun)
{
	var url = dyn_inter_base_path + 'uptLabel.do?qsid=' + getQsId() + '&bid=' + getSysUserId() + '&nm=' + param.nm
		+ '&cid=' + param.cid + '&color=' + param.color + '&random=' + Math.random();
	ajax_load(
		url, false, bcFun
	);
}

function delUserGroups(seq, cid, bcFun)
{
	var url = dyn_inter_base_path + 'delCusLabel.do?qsid=' + getQsId() + '&bid=' + getSysUserId() + '&seq=' + seq
		+ '&cid=' + cid + '&random=' + Math.random();
	ajax_load(
		url, false, bcFun
	);
}

// +---------------------------------------------------
// | 股票数据格式化
// +---------------------------------------------------
function stkDataFormat(stock)
{
	for (var key in stock)
	{
		var obj = stock[key];
		obj.rzfA = transform(
			obj.rzf, true
		);
		obj.zzfA = transform(
			obj.zzf, true
		);
		obj.yzfA = transform(
			obj.yzf, true
		);

		obj.rzfD = transform(
			obj.rzf, false
		);
		obj.zzfD = transform(
			obj.zzf, false
		);
		obj.yzfD = transform(
			obj.yzf, false
		);
	}
}

// +---------------------------------------------------
// | 初始化经纪人统计数据
// | broker：投顾人员静态统计文件
// | stock：所有股票涨跌幅Json对象
// +---------------------------------------------------
function initBrokerData(broker, stock)
{
	if (broker != null)
	{
		var yesUsersObj = "['" + broker.yesUsers.replace(
			/,/g, "','"
		).replace(
			/','$/g, ""
		) + "']",
			highusersObj = "['" + broker.highUsers.replace(
				/,/g, "','"
			).replace(
				/','$/g, ""
			) + "']",
			lowusersObj = "['" + broker.lowUsers.replace(
				/,/g, "','"
			).replace(
				/','$/g, ""
			) + "']",
			nearusersObj = "['" + broker.nearUsers.replace(
				/,/g, "','"
			).replace(
				/','$/g, ""
			) + "']";

		// 昨日登陆用户列表
		broker.yesUsers = eval('(' + yesUsersObj + ')');
		// 远高于均值的用户列表
		broker.highUsers = eval('(' + highusersObj + ')');
		// 远低于均值的用户列表
		broker.lowUsers = eval('(' + lowusersObj + ')');
		// 接近均值的用户列表
		broker.nearUsers = eval('(' + nearusersObj + ')');

		// 用户行为相关统计
		$.each(
			G_Dictionary['a'], function(actId, actInfo)
			{
				if (broker[actId])
				{
					var userObj = "['" + broker[actId].users.replace(
						/,/g, "','"
					).replace(
						/','$/g, ""
					) + "']";
					broker[actId].users = eval('(' + userObj + ')');
					userObj = null;
				}
			}
		);

		// 推荐股列表
		var recommStockObj = broker.tjstocks,
			i = recommStockObj.length - 1;
		while (i >= 0)
		{
			var obj = recommStockObj[i--],
				stockObj = stock[obj.mktCode];
			obj.zxrs = parseFloat(obj.zxrs);
			obj.gzrs = parseFloat(obj.gzrs);

			if (typeof(stockObj) !== 'undefined')
			{
				obj.mkt = stockObj.mkt;
				obj.code = stockObj.code;
				obj.name = stockObj.name;

				obj.qjzfA = transform(
					obj.qjzf, true
				);
				obj.zrzfA = transform(
					obj.zrzf, true
				);

				obj.qjzfD = transform(
					obj.qjzf, false
				);
				obj.zrzfD = transform(
					obj.zrzf, false
				);

			}
			else
			{
				obj.mkt = obj.mktCode.substr(
					0, 2
				);
				obj.code = obj.mktCode.substr(2);
				obj.name = '---';
				obj.qjzf = '---';
				obj.zrzf = '---';

				obj.qjzfA = '---';
				obj.zrzfA = '---';

				obj.qjzfD = '---';
				obj.zrzfD = '---';
			}
			var gzuserObj = "['" + obj.gzusers.replace(
				/,/g, "','"
			).replace(
				/','$/g, ""
			) + "']",
				zxusersObj = "['" + obj.zxusers.replace(
					/,/g, "','"
				).replace(
					/','$/g, ""
				) + "']";
			obj.gzusers = eval('(' + gzuserObj + ')');
			obj.zxusers = eval('(' + zxusersObj + ')');
			gzuserObj = null;
			zxusersObj = null;
			stockObj = null;
			obj = null;
		}

		// 自选股列表
		var selfStockObj = broker.zxstocks;
		i = selfStockObj.length - 1;
		while (i >= 0)
		{
			var obj = selfStockObj[i--],
				stockObj = stock[obj.mktCode];
			if (typeof(stockObj) !== 'undefined')
			{
				obj.mkt = stockObj.mkt;
				obj.code = stockObj.code;
				obj.name = stockObj.name;
				obj.rzf = stockObj.rzf;
				obj.zzf = stockObj.zzf;
				obj.yzf = stockObj.yzf;
			}
			else
			{
				obj.mkt = obj.mktCode.substr(
					0, 2
				);
				obj.code = obj.mktCode.substr(2);
				obj.name = '---';
				obj.rzf = '---';
				obj.zzf = '---';
				obj.yzf = '---';
			}
			var gzuserObj = "['" + obj.zxusers.replace(
				/,/g, "','"
			).replace(
				/','$/g, ""
			) + "']";
			obj.zxusers = eval('(' + gzuserObj + ')');
			gzuserObj = null;
			stockObj = null;
			obj = null;
		}
		broker.zxstocks = selfStockObj;

		// 关注股列表
		var focusStockObj = broker.gzstocks;
		i = focusStockObj.length - 1;
		while (i >= 0)
		{
			var obj = focusStockObj[i--];
			var stockObj = stock[obj.mktCode];
			if (typeof(stockObj) !== 'undefined')
			{
				obj.mkt = stockObj.mkt;
				obj.code = stockObj.code;
				obj.name = stockObj.name;
				obj.rzf = stockObj.rzf;
				obj.zzf = stockObj.zzf;
				obj.yzf = stockObj.yzf;
			}
			else
			{
				obj.mkt = obj.mktCode.substr(
					0, 2
				);
				obj.code = obj.mktCode.substr(2);
				obj.name = '---';
				obj.rzf = '---';
				obj.zzf = '---';
				obj.yzf = '---';
			}
			var gzuserObj = "['" + obj.gzusers.replace(
				/,/g, "','"
			).replace(
				/','$/g, ""
			) + "']",
				zxusersObj = "['" + obj.zxusers.replace(
					/,/g, "','"
				).replace(
					/','$/g, ""
				) + "']";
			obj.gzusers = eval('(' + gzuserObj + ')');
			obj.zxusers = eval('(' + zxusersObj + ')');
			zxusersObj = null;
			gzuserObj = null;
			stockObj = null;
			obj = null;
		}
		broker.gzstocks = focusStockObj;
	}
	else
	{
		// 新建的投顾账号，没有统计文件等相关信息
		broker = {};
		broker.startD = (new Date()).DateAdd(
			"d", -7
		).format("yyyy/MM/dd");
		broker.endD = (new Date()).DateAdd(
			"d", -1
		).format("yyyy/MM/dd");
		broker.yesAmt = 0;
		broker.yesUsers = '';
		broker.l30Amt = 0;
		broker.l30Avg = 0;
		broker.yesTiAvg = 0;
		broker.l30TiAvg = 0;
		broker.actLvlMax = 0;
		broker.actLvlMin = 0;
		broker.actLvlAvg = 0;
		broker.interactLvlMax = 0;
		broker.interactLvlMin = 0;
		broker.interactLvlAvg = 0;
		broker.highAmt = 0;
		broker.lowAmt = 0;
		broker.nearAmt = 0;
		broker.highUsers = '';
		broker.lowUsers = '';
		broker.nearUsers = '';
		broker.totalAmt = 0;
		// 行为
		$.each(
			G_Dictionary['a'], function(actId, actInfo)
			{
				broker[actId] = {
					"num"		: "0",
					"name"		: G_Dictionary['a'][actId].nm,
					"mkt7avg"	: "0",
					"users"		: ""
				};
			}
		);
		broker.tjgpNum = 0;
		broker.jrzxNum = 0;
		broker.yhllNum = 0;
		broker.tjstocks = [];
		broker.zxstocks = [];
		broker.gzstocks = [];
		broker.send = {
			"amt"	: "0",
			"child"	: []
		};
		broker.unread = {
			"amt"	: "0",
			"child"	: []
		};
		broker.reply = {
			"amt"	: "0",
			"child"	: []
		};
		broker.hit = {
			"amt"	: "0",
			"child"	: []
		};
	}

	try
	{
		return broker;
	}
	finally
	{
		focusStockObj = null;
		i = null;
		recommStockObj = null;
		nearusersObj = null;
		lowusersObj = null;
		highusersObj = null;
		yesUsersObj = null;
	}
}

// +---------------------------------------------------
// | 初始化经纪人下所有用户数据，包括：
// | 1、统计数据
// | 2、实时数据（用户信息、服务包和在线状态）
// | broker：投顾人员的静态统计数据对象
// | stock：所有股票的涨跌幅信息Json对象
// +---------------------------------------------------
function initCustomerData(broker, stock)
{
	var customerList = [],
		statusList = GetAllCustomersLoginStatus(),
		// 加载所有用户最新状态
		i = G_user_info_srvs.length - 1,
		client_ctl = client_core_interface();

	while (i >= 0)
	{
		var tmpCInfoSrvs = G_user_info_srvs[i--],
			tmpcid = tmpCInfoSrvs.info.id,
			customer = {};
		if (tmpCInfoSrvs.info.hasOwnProperty('qp') && !tmpCInfoSrvs.info.qp)
		{
			if (tmpCInfoSrvs.info.nm)
			{
				// 获取用户姓名的区位码
				var tmpqp = "";
				var reString = client_ctl.r(
					"G_SYS_CHARINFO", tmpCInfoSrvs.info.nm
				);

				var tmp1 = reString.split("|");
				for (var jj = 0; jj < tmp1.length; jj++)
				{
					var tmp2 = tmp1[jj].split(",");
					tmpqp += padLeft(
						tmp2[1], 5
					);
				}
				tmpCInfoSrvs.info.qp = tmpqp;
			}
			else
			{
				tmpCInfoSrvs.info.qp = tmpcid;
			}
		}

		if (broker[tmpcid] !== undefined)
		{
			customer = broker[tmpcid]; // 当前用户的统计数据
			customer['id'] = tmpcid;

			customer['info'] = tmpCInfoSrvs.info;
			customer['status'] = statusList[tmpcid];
			customer['srv'] = tmpCInfoSrvs.srv;

			customer['lRank'] = parseFloat(customer.lRank);
			customer['lRankA'] = parseFloat(customer.lRank);
			customer['lRankD'] = parseFloat(customer.lRank);

			customer['mailrank'] = parseFloat(customer.mailrank);
			customer['mailrankA'] = parseFloat(customer.mailrank);
			customer['mailrankD'] = parseFloat(customer.mailrank);

			customer['actLvl'] = parseFloat(customer.actLvl);
			customer['interactLvl'] = parseFloat(customer.interactLvl);
			customer['zxgA'] = transform(
				customer.zxg, true
			);
			customer['zxgD'] = transform(
				customer.zxg, false
			);

			// 推荐股列表
			var recommStockObj = customer.tjstocks;
			for (var j = 0; j < recommStockObj.length; j++)
			{
				var obj = recommStockObj[j],
					stockObj = stock[obj.mktCode];
				obj.gzd = parseFloat(obj.gzd);
				if (typeof(stockObj) !== 'undefined')
				{
					obj.mkt = stockObj.mkt;
					obj.code = stockObj.code;
					obj.name = stockObj.name;

					obj.gzrs = stockObj.gzrs;
					obj.zxrs = stockObj.zxrs;
					obj.gzrsA = stockObj.gzrsA;
					obj.zxrsA = stockObj.zxrsA;
					obj.gzrsD = stockObj.gzrsD;
					obj.zxrsD = stockObj.zxrsD;

					obj.qjzfA = transform(
						obj.qjzf, true
					);
					obj.zrzfA = transform(
						obj.zrzf, true
					);
					obj.qjzfD = transform(
						obj.qjzf, false
					);
					obj.zrzfD = transform(
						obj.zrzf, false
					);

				}
				else
				{
					obj.mkt = obj.mktCode.substr(
						0, 2
					);
					obj.code = obj.mktCode.substr(2);
					obj.name = '---';
					obj.qjzf = '---';
					obj.zrzf = '---';
					obj.qjzfA = '---';
					obj.zrzfA = '---';
					obj.qjzfD = '---';
					obj.zrzfD = '---';

					obj.gzrs = '---';
					obj.zxrs = '---';
					obj.gzrsA = '---';
					obj.zxrsA = '---';
					obj.gzrsD = '---';
					obj.zxrsD = '---';

				}
				stockObj = null;
				obj = null;
			}

			// 客户的自选最多列表
			initCustomerStkData(
				customer.zxzdstocks, stock
			);

			// 客户的自选股新增列表
			initCustomerStkData(
				customer.zxxzstocks, stock
			);

			// 客户的自选股删除列表
			initCustomerStkData(
				customer.zxscstocks, stock
			);

			// 客户的关注最多注列表
			initCustomerStkData(
				customer.gzzdstocks, stock
			);

			// 客户的关注新增列表
			initCustomerStkData(
				customer.gzxzstocks, stock
			);

			// 客户的关注删除列表
			initCustomerStkData(
				customer.gzscstocks, stock
			);

			// 最关注股票数据转换
			if (!customer.zgzStock)
			{
				var zgzObj = {};
				zgzObj.rzfA = Number.MAX_VALUE;
				zgzObj.rzfD = Number.MAX_VALUE * (-1);
				customer.zgz = zgzObj;
				zgzObj = null;
			}
			else
			{
				customer.zgz = stock[customer.zgzStock];
			}
			if (G_users_groups[tmpcid] !== undefined)
			{
				customer.groups = G_users_groups[tmpcid];
			}
		}
		else
		{
			customer['id'] = tmpcid;
			customer['info'] = tmpCInfoSrvs.info;
			customer['status'] = statusList[tmpcid];
			customer['srv'] = tmpCInfoSrvs.srv;

			// 新增用户的统计数据初始化
			customer['lRank'] = '';
			customer['lRankA'] = Number.MAX_VALUE * (-1); // 排名前 数字小，跟其他相反
			customer['lRankD'] = Number.MAX_VALUE;

			customer['actLvl'] = 0;
			customer['interactLvl'] = 0;
			customer['online30avg'] = 0;
			customer["login30avg"] = 0;
			customer['hisRights'] = [];

			customer['mailrank'] = '';
			customer['mailrankA'] = Number.MAX_VALUE * (-1); // 排名前 数字小，跟其他相反
			customer['mailrankD'] = Number.MAX_VALUE;

			customer['send'] = {
				'amt'		: 0,
				'ids'		: [],
				'child'		: [],
				'amta'		: 0,
				'childa'	: []
			};
			customer['unread'] = {
				'amt'		: 0,
				'ids'		: [],
				'child'		: [],
				'amta'		: 0,
				'childa'	: []
			};
			customer['reply'] = {
				'amt'		: 0,
				'ids'		: [],
				'child'		: [],
				'amta'		: 0,
				'childa'	: []
			};
			customer['hit'] = {
				'amt'		: 0,
				'ids'		: [],
				'child'		: [],
				'amta'		: 0,
				'childa'	: []
			};
			customer['tjgpNum'] = 0;
			customer['yhllNum'] = 0;
			customer['jrzxNum'] = 0;
			customer['tjstocks'] = [];
			customer['zxzdstocks'] = [];
			customer['zxxzstocks'] = [];
			customer['zxscstocks'] = [];
			customer['gzzdstocks'] = [];
			customer['gzxzstocks'] = [];
			customer['gzscstocks'] = [];
			customer['zxg'] = '---';
			customer['zxgA'] = transform(
				customer.zxg, true
			);
			customer['zxgD'] = transform(
				customer.zxg, false
			);
			var zgzObj = {};
			zgzObj['rzfA'] = Number.MAX_VALUE;
			zgzObj['rzfD'] = Number.MAX_VALUE * (-1);
			customer['zgz'] = zgzObj;
			zgzObj = null;
		}
		customerList.push(customer);
		recommStockObj = null;
		customer = null;
		tmpcid = null;
		tmpCInfoSrvs = null;
	}
	try
	{
		return customerList;
	}
	finally
	{
		i = null;
		statusList = null;
		customerList = null;
	}
}

// +---------------------------------------------------
// | 初始化用户股票数据
// +---------------------------------------------------
function initCustomerStkData(stockList, stock)
{
	var i = stockList.length - 1;
	while (i >= 0)
	{
		var obj = stockList[i--],
			stockObj = stock[obj.mktCode];
		if (typeof(stockObj) !== 'undefined')
		{
			obj.mkt = stockObj.mkt;
			obj.code = stockObj.code;
			obj.name = stockObj.name;
			obj.rzf = stockObj.rzf;
			obj.zzf = stockObj.zzf;
			obj.yzf = stockObj.yzf;
		}
		else
		{
			obj.mkt = obj.mktCode.substr(
				0, 2
			);
			obj.code = obj.mktCode.substr(2);
			obj.name = '---';
			obj.rzf = '---';
			obj.zzf = '---';
			obj.yzf = '---';
		}
	}
}

// +---------------------------------------------------
// | 数据转换
// +---------------------------------------------------
function transform(value, order)
{
	if (order)
	{
		return value === '---' ? Number.MAX_VALUE : parseFloat(value.replace(
			/,/g, ''
		));
	}
	return value === '---' ? Number.MAX_VALUE * (-1) : parseFloat(value.replace(
		/,/g, ''
	));
}

// ////////////////////////////////////////////////////读取实时数据方法\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// +---------------------------------------------------
// | 加载单个用户的在线状态
// +---------------------------------------------------
function GetLoginStatus(id)
{
	var url = dyn_inter_base_path + 'onlinecus.do?qsid=' + getQsId() + '&cid=' + id + '&random=' + Math.random();
	return ajax_load_real_data(
		url, true
	);
}

// +---------------------------------------------------
// | 单个客户权限信息
// +---------------------------------------------------
function GetCustomerSrv(id)
{
	var url = dyn_inter_base_path + 'qurcustomer.do?type=1&qsid=' + getQsId() + '&cid=' + id + '&random='
		+ Math.random();
	return ajax_load_real_data(
		url, true
	);
}

// +---------------------------------------------------
// | 单个客户历史权限信息
// +---------------------------------------------------
function GetHisUserSrv(id)
{
	var url = dyn_inter_base_path + 'qurcustomer.do?type=2&qsid=' + getQsId() + '&cid=' + id + '&random='
		+ Math.random();
	return ajax_load_real_data(
		url, true
	);
}

// +---------------------------------------------------
// | 保存客户权限
// +---------------------------------------------------
function SaveCustomerSrv(param)
{
	var url = dyn_inter_base_path + 'procus.do?qsid=' + getQsId() + '&bid=' + getSysUserId() + param;
	return ajax_load_real_data(
		url, false
	);
}

// +---------------------------------------------------
// | 重置客户密码
// +---------------------------------------------------
function ResetCustomPwd(id)
{
	var url = dyn_inter_base_path + 'uptpwd.do?qsid=' + getQsId() + '&cid=' + id;
	var returnVal = ajax_load_real_data(
		url, true
	);
	if (returnVal && returnVal.hasOwnProperty('scd'))
	{
		return returnVal.scd;
	}
	return "-9";
}

function GetCustomerRemark(cid)
{
	var remark = null,
		url = dyn_inter_base_path + 'qurRemarks.do?qsid=' + getQsId() + '&bid=' + getSysUserId()
			+ "&cid=" + cid + '&random=' + Math.random();
	remark = ajax_load_real_data(url, true);
	if (remark && typeof (remark) == 'object' && remark.hasOwnProperty('scd'))
	{
		switch (remark.scd)
		{
			case '0':
			case '1':
				break;
			default:
				alert(G_ErrorMsg[remark.scd]);
		}
		return [];
	}
	return remark;
}

function addRemark(cid, remark, callback)
{
	var urlAddRemark = dyn_inter_base_path + 'instRemarks.do';
	// urlAddRemark =
	// "http://192.168.3.188:9021/investAnalysisPlate/inter/instRemarks.do";

	var querystring = 'qsid=' + getQsId() + '&bid=' + getSysUserId() + '&cid=' + cid + '&ct=' + remark;

	var xmlhttp = null;
	if (window.XMLHttpRequest)
	{
		xmlhttp = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (!xmlhttp)
	{
		throw "request object initialize fail!";
	}

	xmlhttp.onreadystatechange = function ()
	{
		if (xmlhttp.readyState == 4)
		{
			if (xmlhttp.status == 200)
			{
				var tmpRet = eval('(' + xmlhttp.responseText + ')');
				if (tmpRet && tmpRet.hasOwnProperty("scd"))
				{
					switch (tmpRet.scd)
					{
						case '1':
							if (typeof callback === "function")
							{
								alert('添加成功！');
								callback();
							}
							break;
						default:
							alert("添加失败!原因：" + G_ErrorMsg[tmpRet.scd]);
					}
				}
				else
				{
					alert("添加失败!");
				}
				tmpRet = null;
			}
		}
	};
	xmlhttp.open(
		"POST", urlAddRemark, false
	);
	xmlhttp.setRequestHeader(
		"Content-Type", "application/x-www-form-urlencoded"
	);
	xmlhttp.send(querystring);
	urlAddRemark = null;
	querystring = null;
	xmlhttp = null;
}

function delRemark(seq, callback)
{
	var urldelRemark = dyn_inter_base_path + 'delRemarks.do';
	var querystring = 'qsid=' + getQsId() + '&seq=' + seq;

	var xmlhttp = null;
	if (window.XMLHttpRequest)
	{
		xmlhttp = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (!xmlhttp)
	{
		throw "request object initialize fail!";
	}

	xmlhttp.onreadystatechange = function ()
	{
		if (xmlhttp.readyState == 4)
		{
			if (xmlhttp.status == 200)
			{
				var tmpRet = eval('(' + xmlhttp.responseText + ')');
				if (tmpRet && typeof (tmpRet) == 'object' && tmpRet.hasOwnProperty("scd"))
				{
					switch (tmpRet.scd)
					{
						case '1':
							alert('删除成功！');
							if (typeof callback === "function")
							{
								callback();
							}
							break;
						default:
							alert("删除失败!原因：" + G_ErrorMsg[tmpRet.scd]);
					}
				}
				else
				{
					alert("删除失败，请与管理员联系!");
				}
				tmpRet = null;
			}
		}
	};
	xmlhttp.open(
		"POST", urldelRemark, false
	);
	xmlhttp.setRequestHeader(
		"Content-Type", "application/x-www-form-urlencoded"
	);
	xmlhttp.send(querystring);
	urldelRemark = null;
	querystring = null;
	xmlhttp = null;
}