function newsstyle(typeid)
{
	document.getElementById("newsdetail").className = "NewsConText" + typeid;
	var linkObjs = document.getElementsByName("SelFont");
	if (!linkObjs)
		return;

	for (var i = 0; i < linkObjs.length; i++)
	{
		var fontSize = linkObjs[i].getAttribute("qlFontSize");
		var disVal = linkObjs[i].getAttribute("dispVal");
		if (fontSize == typeid) // 选中的项目
		{
			linkObjs[i].innerHTML = "<span class=\"CurrentContentSel\">" + disVal + "</span>";
		}
		else
		{
			linkObjs[i].innerHTML = disVal;
		}
	}
}

function newsstyle_get()
{
	if (typeof(client_data_load_json) == "undefined")
		return "Mid";

	var style = client_data_load_json("www_newstext", null, 0);
	if (typeof(style) == "undefined")
		return "Mid";
	if (style == null || style == "")
		return "Mid";
	return style;
}

function newsstyle_set(typeid)
{
	if (typeof(client_data_save_json) == "undefined")
		return;
	newsstyle(typeid);
	client_data_save_json("www_newstext", typeid, 0);
}

function newsstyle_default()
{
	newsstyle(newsstyle_get());
}

function html_lockmouse()
{
	document.body.onmousewheel = function()
	{
		var Body = document.compatMode != "BackCompat" ? document.documentElement : document.body;

		if (event.wheelDelta > 0)
		{
			if (Body.scrollTop <= 0)
				return false;
			scrollBy(0, -event.wheelDelta);
		}
		else if (event.wheelDelta < 0)
		{
			if ((Body.scrollTop + Body.clientHeight) >= Body.scrollHeight)
				return false;
			scrollBy(0, -event.wheelDelta);
		}
		return false;
	};
}

// client json data start!------------------------------------------
function client_data_save_json(datakey, dataobj, regionType)
{
	if (typeof(dataobj) == "undefined")
	{
		_clientdata_del(datakey, regionType);
		return;
	}

	var datastr = JSON.stringify(dataobj);
	_clientdata_set(datakey, datastr, regionType);
}

function client_data_load_json(datakey, dataobj, regionType)
{
	var datastr = _clientdata_get(datakey, regionType);

	if (typeof(datastr) == "undefined" || datastr == null)
		return dataobj;

	var tmpobj = JSON.parse(datastr);

	if (typeof(tmpobj) == "undefined" || tmpobj == null)
		return dataobj;

	if (typeof(tmpobj) == "object")
	{
		if (dataobj == null || typeof(dataobj) == "undefined")
			dataobj = new Object();
		for (p in tmpobj)
		{
			dataobj[p] = tmpobj[p];
		}
		return dataobj;
	}

	return tmpobj;
}

function client_data_delete_json(datakey, regionType)
{
	_clientdata_del(datakey, regionType);
}

function client_data_exist_json(datakey, regionType)
{
	var datastr = _clientdata_get(datakey, regionType);
	return typeof(datastr) != "undefined";
}
// client json data complete!------------------------------------------

function _clientdata_set(datakey, datastr, regionType)
{
	if (typeof(client_data_save) == "undefined")
		return;
	client_data_save(datakey, 1, datastr, regionType);
	return;
}

function _clientdata_get(datakey, regionType)
{
	if (typeof(client_data_load) == "undefined")
		return null;
	var dataObj = client_data_load(datakey, regionType);
	if (dataObj == null)
		return null;
	if (typeof(dataObj.dValue) == "undefined")
		return null;
	return dataObj.dValue;
}

function _clientdata_del(datakey, regionType)
{
	if (typeof(client_data_save) == "undefined")
		return;
	client_data_save(datakey, 0, "", regionType);
}

function client_data_save(keyName, opType, dataValue, regionType)
{
	try
	{
		var obj = client_core_interface();
		var stkData = obj.r("S_Etc_SaveData", keyName + "\r\n" + opType + "\r\n" + dataValue.replace(/\r\n/g, "\n\n")
				+ "\r\n" + regionType);
		return stkData;
	}
	catch (e)
	{
		_trace("出错(client_data_save()):" + e.message);
		return "0" + e.message;
	}
}

function client_data_load(keyName, regionType)
{
	try
	{
		var obj = client_core_interface();
		var stkData = obj.r("S_Etc_LoadData", keyName + "\r\n" + regionType);
		if (stkData == null || stkData.length == 0)
			return null;
		var iPos = stkData.indexOf("\r\n"); // 查看附带的时间戳
		if (iPos <= 0)
			return null;
		var timeStamp = stkData.substring(0, iPos);
		var pData = stkData.substring(iPos + 2, stkData.length);
		// 时间戳的格式 YYYYMMDD HH:MM:SS
		if (timeStamp.length != 17)
			return null;

		var rltObj = new Object();
		// 特别注意，javascript中，mm月份的定义为(0-11)，所以这里必须做 -1 操作
		rltObj.TimeStamp = new Date(timeStamp.substring(0, 4), timeStamp.substring(4, 6) - 1,
			timeStamp.substring(6, 8), timeStamp.substring(9, 11), timeStamp.substring(12, 14), timeStamp.substring(15,
				17
			)
		);
		rltObj.dValue = pData.replace(/\n\n/g, "\r\n");
		return rltObj;
	}
	catch (e)
	{
		_trace("出错(client_data_load()):" + e.message);
		return null;
	}
}

function client_core_interface()
{
	try
	{
		return window.external.qlC;
	}
	catch (e)
	{
	}
}