// JavaScript Document
var nConstDisplayTime = 3000;//3s
/*
功能：显示隐藏层
作者：巍巍乎
OICQ：3509375
参数说明：
	strName：菜单选项名字为strName1 strName2 strName3等
	strDivName：新闻选项名字
	nLength：选项个数
	strClass：样式表名  选中的为strClass 未选中的为 UnstrClass
	bHaveMore：是否含有更多 为true时 More选项的名字为 strNameMore_1 strNameMore_2 等
	fnCallBack：回叫函数 参数为当前索引
*/
function DisplayClass(strName, strDivName, nLength, strClass, bHaveMore, fnCallBack)
{
	var _strName    = strName;
	var _nLength    = nLength;
	var _strClass   = strClass;
	var _bCanPlay   = true;
	var _nCurrent   = 0;
	var _strDivName = strDivName;
	var _bHaveMore  = bHaveMore;
	var _nTimeID    = 0;
	var _fnCallBack = null;
	if(typeof(fnCallBack) != "undefined" && typeof(fnCallBack) == "function")
	{
		_fnCallBack = fnCallBack;
	}
	this.Play = function()
	{
		if(_bCanPlay)
		{
			var nIndex = _nCurrent + 1;
			if(nIndex == _nLength)
			{
				nIndex = 0;
			}
			oSetSelect(nIndex);
		}
	}
	var oSetSelect = null;
	this.SetSelect = function(nIndex)
	{
		_getObj(_strDivName + _nCurrent.toString()).style.display = "none";
		_getObj(_strName + _nCurrent.toString()).className = "Un" + strClass;
		if(_bHaveMore)
		{
			_getObj(_strName + "More_" + _nCurrent.toString()).style.display = "none";
		}
		_nCurrent = nIndex;
		_getObj(_strDivName + _nCurrent.toString()).style.display = "";
		_getObj(_strName + _nCurrent.toString()).className = strClass;
		if(_bHaveMore)
		{
			_getObj(_strName + "More_" + _nCurrent.toString()).style.display = "";
		}
		if(_fnCallBack != null)
		{
			_fnCallBack(nIndex);
		}
	}
	oSetSelect = this.SetSelect;
	this._onMouseOver = function(e)
	{
		_bCanPlay = false;
	}
	this._onMouseOut = function(e)
	{
		_bCanPlay = true;
	}
	this._onMouseOverMenu = function(e)
	{
		_bCanPlay = false;
		var src = oGetElementByEvent(e);
		for(var i=0; i<_nLength; i++)
		{
			if(_getObj(_strName + i.toString()) == src)
			{
				if(_nCurrent != i)
				{
					oSetSelect(i);
				}
				break;
			}
		}
	}
	var oGetElementByEvent = null;
	this.GetElementByEvent = function(e)
	{
		return window.document.all != null ? e.srcElement : e.target;
	}
	oGetElementByEvent = this.GetElementByEvent;
	//window.setInterval(this.Play, nConstDisplayTime);
	for(var i=0; i<nLength; i++)
	{
		AttachEvent(_getObj(_strDivName + i.toString()), "mouseover", this._onMouseOver);
		AttachEvent(_getObj(_strDivName + i.toString()), "mouseout",  this._onMouseOut);
		AttachEvent(_getObj(_strName + i.toString()),    "mouseover", this._onMouseOverMenu);
		AttachEvent(_getObj(_strName + i.toString()),    "mouseout",  this._onMouseOut);
	}
	this.fnClearTime = function()
	{
		//window.clearInterval(_nTimeID);
	}
	//AttachEvent(window, "unload",  this.fnClearTime);
}
