var htmlType='li';//元素类型
var thmlClassName='mainUlLi';//类名
var thmlClassNameSelected='mainUlLiMouseOver';//选择类名
var timeoutid=null;
var curObj=null;
var heightArr=[0,0,0,0,0,0,0,0,0,0];
var userAgentType=0;
if(navigator.userAgent.indexOf('Firefox')>0)
{
	userAgentType=1;
}
if(navigator.userAgent.indexOf('Chrome')>0)
{
	userAgentType=2;
}
/*
	初始化菜单
*/
function intMenu(htmlType,thmlClassName)
{
	var objArr=document.getElementsByTagName(htmlType)	
	var tempObj=null;
	var subObj=null;
	var objLen=objArr.length;
	var arrIndex=null;
	var i=0;
	var j=0;
	var childArr=null;
	for( i=0 ; i<objLen ; i++ )
	{
		tempObj=objArr[i];
		if(tempObj.className==thmlClassName)
		{
			tempObj.onmouseover=menuMouseover;
			tempObj.onmouseout=menuMouseout;
			
			arrIndex=_substr(tempObj.id);
			
			subObj=document.getElementById(tempObj.id+'_sub');
			subObj.style['top']=heightArr[arrIndex]+'px';
			subObj.onmouseover=SubMenuMouseOver;
			subObj.onmouseout=SubMenuMouseOut;
			if( userAgentType>0 )
			{
				childArr=subObj.childNodes;
				for( j=0 ; j< childArr.length ; j++){
					childArr[j].onmouseover=subMenuAmouseOver;
				}
			}
		}
	}
}
function menuMouseover()
{
	var subObj=null;
	if(timeoutid)
	{
		clearTimeout(timeoutid);
		timeoutid=null;
		if(curObj){
			subObj=document.getElementById(curObj.id+'_sub');
			subObj.style.display='none';
			curObj.className=thmlClassName;
		}
		curObj=null;
	}
	this.className=thmlClassNameSelected;	
	subObj=document.getElementById(this.id+'_sub');
	subObj.style.display='';
	curObj = this;
}
function menuMouseout()
{
	var subObj=null;
	timeoutid=setTimeout(timeoutHiddenSubMenu,1000);
}
function SubMenuMouseOver()
{
//	if(timeoutid)
//	{
//		clearTimeout(timeoutid);
//		timeoutid=null;
//	}
//	this.style.display='';
//	if(curObj){
//		curObj.className=thmlClassNameSelected;
//	}
}
function SubMenuMouseOut()
{
//	this.style.display='none';
//	if(curObj){
//		curObj.className=thmlClassName;
//	}
}
function timeoutHiddenSubMenu()
{
	var subObj=null;
	if(curObj){
		curObj.className=thmlClassName;
		subObj=document.getElementById(curObj.id+'_sub');
		subObj.style.display='none';
	}
}
function subMenuAmouseOver()//非IE浏览器 使用
{
	var tempObj=this.parentNode;
	tempObj.style.display='';
	if(curObj){
		curObj.className='mainUlLiMouseOver';
	}
}
function _substr(str)
{
	return str.substr(str.length-1,1);
}
/*
	运行菜单初始化程序
*/
intMenu(htmlType,thmlClassName);