var csMenu = function()
{
	// Color Settings
	this.colorBGMainItemActive = '#666';
	this.colorBGMainItemReset = '#333';
	this.colorFontMainItemActive = '#fff';
	this.colorFontMainItemReset = '#fff';

	this.colorBGSubItemActive = '#999';
	this.colorBGSubItemReset = '#666';
	this.colorFontSubItemActive = '#fff';
	this.colorFontSubItemReset = '#fff';

	this.timerResetMenu;

	this.objTempMainItem;
	this.objTempSubItem;
	this.objTempSub2Item;
}

csMenu.prototype.stopTimer = function()
{
	window.clearTimeout(objMenu.timerResetMenu);
}

csMenu.prototype.overMain = function(objItem, strSubnav)
{
	this.stopTimer();
	this.resetAll();
	this.objTempMainItem = objItem;
	this.objTempMainItem.style.backgroundColor = this.colorBGMainItemActive;
	this.objTempMainItem.style.color = this.colorFontMainItemActive;
	if (this.objTempMainItem.className == 'hasSub')
	{
		this.objTempMainItem.style.backgroundImage = 'url("img/arrow_on.gif")';
	}
	if(typeof(strSubnav) != 'undefined')
	{
		document.getElementById('sub1area').style.display = 'block';
		document.getElementById(strSubnav).style.paddingTop = objItem.offsetTop;
		document.getElementById(strSubnav).style.display = 'block';
	}
}

csMenu.prototype.outMain = function(numLevel)
{
	this.timerResetMenu = window.setTimeout('objMenu.resetAll();', 500);
}

csMenu.prototype.overSub = function(objItem, strName)
{
	this.stopTimer();
	this.clearProduct();
	if (typeof(this.objTempSubItem) != 'undefined')
	{
		this.outSub(this.tempStrName);
	}
	if(typeof(strName) != 'undefined')
	{
		this.tempStrName = strName;
	}
	this.objTempSubItem = objItem;
	this.objTempSubItem.style.backgroundColor = this.colorBGSubItemActive;
	this.objTempSubItem.style.color = this.colorFontSubItemActive;
	if (this.objTempSubItem.className == 'hasSub')
	{
		this.objTempSubItem.style.backgroundImage = 'url("img/arrow_on.gif")';
		document.getElementById('sub2area').style.display = 'block';
		document.getElementById(strName).style.paddingTop = objItem.offsetTop;
		document.getElementById(strName).style.display = 'block';
	}
}

csMenu.prototype.outSub = function(strName)
{
	this.objTempSubItem.style.backgroundColor = this.colorBGSubItemReset;
	this.objTempSubItem.style.color = this.colorFontSubItemReset;
	if (this.objTempSubItem.className == 'hasSub')
	{
		this.objTempSubItem.style.backgroundImage = 'url("img/arrow.gif")';
		document.getElementById('sub2area').style.display = 'none';
		document.getElementById(strName).style.display = 'none';
	}
}

csMenu.prototype.overSub2 = function(objItem)
{
	this.stopTimer();
	this.clearProduct();
	if (typeof(this.objTempSub2Item) != 'undefined')
	{
		this.outSub2();
	}
	this.objTempSub2Item = objItem;
	this.objTempSub2Item.style.backgroundColor = this.colorBGSubItemActive;
	this.objTempSub2Item.style.color = this.colorFontSubItemActive;
	if (this.objTempSub2Item.className == 'hasSub')
	{
		this.objTempSub2Item.style.backgroundImage = 'url("img/arrow_on.gif")';
	}
}

csMenu.prototype.outSub2 = function()
{
	this.objTempSub2Item.style.backgroundColor = this.colorBGSubItemReset;
	this.objTempSub2Item.style.color = this.colorFontSubItemReset;
	if (this.objTempSub2Item.className == 'hasSub')
	{
		this.objTempSub2Item.style.backgroundImage = 'url("img/arrow.gif")';
	}
}

csMenu.prototype.resetAll = function()
{
	if(typeof(this.objTempMainItem) != 'undefined')
	{
		this.objTempMainItem.style.backgroundColor = this.colorBGMainItemReset;
		this.objTempMainItem.style.color = this.colorFontMainItemReset;
		if (this.objTempMainItem.className == 'hasSub')
		{
			this.objTempMainItem.style.backgroundImage = 'url("img/arrow.gif")';
		}
		document.getElementById('sub1area').style.display = 'none';
		document.getElementById('sub2area').style.display = 'none';
		for (var i = 0; i < document.getElementById('sub1').childNodes.length; i++)
		{
			try
			{
				document.getElementById('sub1').childNodes[i].style.display = 'none';
			}
			catch(e) {}
		}
		for (var i = 0; i < document.getElementById('sub2').childNodes.length; i++)
		{
			try
			{
				document.getElementById('sub2').childNodes[i].style.display = 'none';
			}
			catch(e) {}
		}
		if(typeof(this.objTempSubItem) != 'undefined')
		{
			this.objTempSubItem.style.backgroundColor = this.colorBGSubItemReset;
			this.objTempSubItem.style.color = this.colorFontSubItemReset;
				if (this.objTempSubItem.className == 'hasSub')
				{
					this.objTempSubItem.style.backgroundImage = 'url("img/arrow.gif")';	
				}
		}
		if(typeof(this.objTempSub2Item) != 'undefined')
		{
			this.objTempSub2Item.style.backgroundColor = this.colorBGSubItemReset;
			this.objTempSub2Item.style.color = this.colorFontSubItemReset;
				if (this.objTempSub2Item.className == 'hasSub')
				{
					this.objTempSub2Item.style.backgroundImage = 'url("img/arrow.gif")';	
				}
		}
		this.clearProduct();
	}
}

csMenu.prototype.showContent = function(strData, strElement)
{
	this.stopTimer();
	if (strElement == 'content')
	{
		this.resetAll();
	}
	this.clearContent();
	getData(strData, strElement);
	document.getElementById(strElement + "BG").style.display = 'block';
	document.getElementById(strElement).style.display = 'block';
}

csMenu.prototype.clearContent = function()
{
	document.getElementById('content').style.display = 'none';
	document.getElementById('contentBG').style.display = 'none';
}

csMenu.prototype.clearProduct = function()
{
	document.getElementById('product').style.display = 'none';
	document.getElementById('productBG').style.display = 'none';
}

var objMenu = new csMenu();
