//***************************************************
// Java Script Menu Dept2
//***************************************************
function _YahooStyleMenu(l_sID,l_sBackColor,l_sOverColor,l_sLink,l_sCookie)
{
	this.ID = l_sID;
	//this._This = _GetDiv(l_sID);
	this._This = _getElementByID(l_sID)
	this.BC = l_sBackColor;
	this.OC = l_sOverColor;
	this.flag = l_sCookie;
	this.aData = new Array();
	this.Length = -1;
	this.Link = l_sLink;
	this.parent = null;
	this.closed  = true;
	this.Val1 = "";
	this.Val2 = "";
	this.BStyle = new Array();
	this.OStyle = new Array();

	var refThis = this;

	var fnClick = function (l_oEvt) {
			var oElm = l_oEvt.srcElement;
			while (oElm.nodeName.toLowerCase() != 'div')
			{
				oElm = oElm.parentNode;
			}
			refThis.ClickEvent(oElm);
		};
	var fnOver = function (l_oEvt) {
			var oElm = l_oEvt.srcElement;
			while (oElm.nodeName.toLowerCase() != 'div')
			{
				oElm = oElm.parentNode;
			}
			refThis.OverEvent(oElm);
		};
	var fnOut = function (l_oEvt) {
			var oElm = l_oEvt.srcElement;
			while (oElm.nodeName.toLowerCase() != 'div')
			{
				oElm = oElm.parentNode;
			}
			refThis.OutEvent(oElm);
		};
	

	if (this._This.addEventListener)
	{
		this._This.addEventListener("click",fnClick, false);
		this._This.addEventListener("mouseover",fnOver, false);
		this._This.addEventListener("mouseout",fnOut, false);
	}
	else if (this._This.attachEvent)
	{
		this._This.attachEvent("onclick",fnClick);
		this._This.attachEvent("onmouseover",fnOver);
		this._This.attachEvent("onmouseout",fnOut);
	}

	var oCookie = new CBCookie();
	var sVal = oCookie.Get(this.flag);

	if (this.flag != '')
	{
		var aVal = sVal.split(",");
		this.Val1 = aVal[0];
		this.Val2 = aVal[1];

		if(this.Val1 == this.ID)
		{
			//alert('+' + this.Val1 + this.ID);
			this.Open();
		}
		else
		{
			//alert('-' + this.Val1 + this.ID);
			this.Close();
		}

		if(this.Val2 == this.ID)
		{
			this.setSelected();
		}
		else this.setUnSelected();
	}

}

_YahooStyleMenu.prototype.AddBS = function(l_sName,l_sVal)
{
	this.BStyle.push(l_sName + ":" + l_sVal);
}
_YahooStyleMenu.prototype.AddOS = function(l_sName,l_sVal)
{
	this.OStyle.push(l_sName + ":" + l_sVal);
}

_YahooStyleMenu.prototype.AddDiv = function(l_oNode)
{
	l_oNode.setParent(this);
	this.aData.push(l_oNode);
	this.Length++;
	if(this.Length >= 0 && this.Val1 == this.ID)
	{
		l_oNode.SetVisible(true);
	}
}

_YahooStyleMenu.prototype.SetVisible = function(l_IsShow)
{
	if(l_IsShow)
	{
		this._This.style.display = "block";
		this.closed = false;
	}
	else
	{
		this._This.style.display = "none";
		this.closed = true;
	}
}

_YahooStyleMenu.prototype.ClickEvent = function(oEvt)
{
	if(this.Length >= 0)
	{
		if(this.closed)this.Open();
		else this.Close();
		this.OtherClose();
	}

	if(this.Length < 0)
	{
		var oP = this.parent;
		var oCookie = new CBCookie();
		oCookie.Set(this.flag,oP.ID + "," + this.ID,1);
		if(this.Link != "") document.location.href = this.Link;
	}
}

_YahooStyleMenu.prototype.OverEvent = function(oEvt)
{
	_SetMouseCursor(2);
}

_YahooStyleMenu.prototype.OutEvent = function(oEvt)
{
	_SetMouseCursor(1);
}
_YahooStyleMenu.prototype.setSelected = function()
{
	this.SetOStyle();
}
_YahooStyleMenu.prototype.setUnSelected = function()
{
	this.SetBStyle();
}
_YahooStyleMenu.prototype.setLink = function(l_sLink)
{
	this.Link = l_sLink;
}
_YahooStyleMenu.prototype.setParent = function(l_oNode)
{
	this.parent = l_oNode;
}
_YahooStyleMenu.prototype.getParent = function()
{
	return this.parent;
}
_YahooStyleMenu.prototype.Open = function()
{
	for (var i=0 ; i <= this.Length ; i++)
	{
		var oDiv = this.aData[i];
		oDiv.SetVisible(true);
		
		//alert(this.Length);
		
	}
	this.closed = false;

	//alert(this.ID + ' IS Opened');

}
_YahooStyleMenu.prototype.Close = function()
{
	for (var i=0 ; i <= this.Length ; i++)
	{
		var oDiv = this.aData[i];
		oDiv.SetVisible(false);
	}
	this.closed = true;

	//alert(this.ID + ' IS Closed');
}
_YahooStyleMenu.prototype.OtherClose = function()
{
	var oP1 = this.getParent();
	for (var i=0; i <= oP1.Length ; i++)
	{
		var aNode = oP1.aData[i];
		if(aNode.ID != this.ID) aNode.Close();
	}	
}

_YahooStyleMenu.prototype.SetBStyle = function()
{
	this.SetTableBGColor(this.BC);
			
}

_YahooStyleMenu.prototype.SetOStyle = function()
{
	this.SetTableBGColor(this.OC);
	this.SetAnchorBold();
}

_YahooStyleMenu.prototype.SetAnchorBold = function()
{
	var oElm = this._This;
	var oSch = new _SearchTag();
	oSch.FindTag(oElm,'a');
	var aData = oSch.aData;
	
	if(oSch.Length < 0) return;

	for (var i=0;i < aData.length ;i++ )
	{
		var oVal = aData[i];
		oVal.style.fontWeight = 'bold';
		oVal.style.fontSize = '9pt';
		oVal.style.color = '#000000';
	}
}
_YahooStyleMenu.prototype.SetTableBGColor = function(l_sColor)
{
	if(l_sColor == "") return;
	var oElm = this._This;
	var oSch = new _SearchTag();
	oSch.FindTag(oElm,'table');
	var aData = oSch.aData;
	
	if(oSch.Length < 0) return;

	for (var i=0;i < aData.length ;i++ )
	{
		var oVal = aData[i];
		oVal.style.background = l_sColor;
		
	}
}



//***************************************************
// Java Script Menu Dept2
//***************************************************
function _YStyleMenu(l_sID,l_sKey)
{
	this.BC = "";
	this.OC = "";
	this.Key = l_sKey;
	this.Length = -1;
	this.PDiv = new _YahooStyleMenu(l_sID,"","","",this.Key);
	this.CDiv = new _YStyleItem(this.Key);
}
_YStyleMenu.prototype.Add = function (l_oDiv)
{
	this.PDiv.AddDiv(l_oDiv);
	this.Length++;
}
_YStyleMenu.prototype.AddItem = function (l_sID)
{
	this.CDiv.Add(l_sID);
}
_YStyleMenu.prototype.SetItemBC = function (l_sC)
{
	this.CDiv.setBC(l_sC);
}
_YStyleMenu.prototype.SetItemOC = function (l_sC)
{
	this.CDiv.setOC(l_sC);
}
_YStyleMenu.prototype.AddMenu = function(l_sID)
{
	this.Add(this.CDiv.toDiv(l_sID));
	this.CDiv.flush();
}


//***************************************************
// Java Script Menu Dept3
//***************************************************
function _YStyleItem(l_sKey)
{
	this.aData = new Array();
	this.BC = "";
	this.OC = "";
	this.Length = -1;
	this.Key = l_sKey;
}
_YStyleItem.prototype.setBC = function (l_sColor)
{
	this.BC = l_sColor;
}
_YStyleItem.prototype.setOC = function (l_sColor)
{
	this.OC = l_sColor;
}
_YStyleItem.prototype.Add = function (l_sID)
{
	this.aData.push(new _YahooStyleMenu(l_sID,this.BC,this.OC,"",this.Key));
	this.Length++;
}
_YStyleItem.prototype.toDiv = function (l_sID)
{
	var oDiv = new _YahooStyleMenu(l_sID,"","","",this.Key);
	if(this.Length < 0) return oDiv;
	for (var i=0; i <= this.Length ; i++)
	{
		var oD = this.aData[i];
		oDiv.AddDiv(oD);
	}
	return oDiv;
}
_YStyleItem.prototype.flush = function ()
{
	this.Length = -1;
	this.aData = null;
	this.aData = new Array();
}

