/*
 * Ham thuc hien chuc nang cai dat ActiveMenu
 * Type:	function
 * Name:	TNComActiveMenu
 * Date:	21/06/2008
 * @author:	Tri Do <tridn@von-inc.com>
 * @param strBoxMenuId la id cua phan tu chua menu
 */
var hasSub=0;
function TNComActiveMenu(strBoxMenuId,hasSub)
{	
	var objCurTab;
	var objRoot;
	function _initialize() 
	{
		objRoot = document.getElementById(strBoxMenuId);
		if(objRoot){
			if(hasSub){
				parseNodeHasSub(objRoot.childNodes);
			}
			else{
				parseNode(objRoot.childNodes);
			}
		}
		return false;
	}
	/*
	* Ham thuc fix nodetype=3 va 8 cho firefox, tra ve nodetype khac 3 va 8
	* Type:	function
	* Name:	fixFF_PrevSibling,fixFF_NextSibling
	* Date:	21/06/2008
	* @author:	Tri Do <tridn@von-inc.com>
	* @param objNode node hien tai
	*/
	function fixFF_PrevSibling(objNode)
	{
		while((objNode.nodeType==3 || objNode.nodeType==8)) 
		{
		 objNode=objNode.previousSibling;
		 if(!objNode) return false;;
		}
		return objNode;
		
	}
	function fixFF_NextSibling(objNode)
	{
		while(objNode.nodeType==3 || objNode.nodeType==8)
		{
			objNode=objNode.nextSibling;
			if(!objNode) return false;;
		}
		return objNode;
			
	}
	/*
	* Ham thuc hien chuc nang tu thay doi class khi node active
	* Type:	function
	* Name:	parseNode
	* Date:	
	* @author:	Tri Do <tridn@von-inc.com>
	* @param arrNodes la mang cac phan tu cua objRoot
	*/
	function parseNode(arrNodes) 
	{
		for (var i = 0; i < arrNodes.length; i++) 
		{
			
			if (arrNodes[i].nodeType==3 || arrNodes[i].nodeType==8) 
			{
				continue;
			}
			if (arrNodes[i].nodeName=="LI" )
			{
				if(arrNodes[i].className=="active")
				{
					objCurTab=arrNodes[i];
					if(objCurTab.previousSibling) {
						if(fixFF_PrevSibling(objCurTab.previousSibling)){
							fixFF_PrevSibling(objCurTab.previousSibling).className="pre_active";
						}
						else{
							objCurTab.className+=" other";
							objRoot.className+=" other";
						}
					}
					else{
						objCurTab.className+=" other";
						objRoot.className+=" other";
					}
				}
	
			}
		}
	}
	/*
	* Ham thuc hien chuc nang set cac su kien cho nodes
	* Type:	function
	* Name:	parseNodeHasSub
	* Date:	
	* @author:	Tri Do <tridn@von-inc.com>
	* @param arrNodes la mang cac phan tu cua objRoot
	*/
	function parseNodeHasSub(arrNodes) 
	{
		for (var i = 0; i < arrNodes.length; i++) 
		{
			
			if (arrNodes[i].nodeType==3 || arrNodes[i].nodeType==8) 
			{
				continue;
			}
			if (arrNodes[i].nodeName=="LI" )
			{
				arrNodes[i].onmouseover = function() 
				{
					this.className +=" over";
				}
				arrNodes[i].onmouseout =function()
				{
					this.className=this.className.replace(/\s*over/,"");
				}
	
			}
		}
	}
	return _initialize();
}
