function CUI()
{
	//variables
	this.onLayer = false;
	this.timerID;
	this.oBrwInfo = new CBrowserInfo();
	this.hovercolor = "#F0E4E9";
	this.offColor = "#DEC3CE";
	this.IE_CSS = "css/dc_ie.css";
	this.NS_CSS = "css/dc_ns.css";
	
	
	//methods
	this.setCSS = CUI_SetCSS;
	this.setMenuVisible = CUI_SetMenuVisible;
	this.timedClose = CUI_TimedClose;
	this.setBGColor = CUI_SetBGColor;
	this.onLayerColor = CUI_OnLayerColor;
	this.offLayerColor = CUI_OffLayerColor;
	this.onRootMenu = CUI_OnRootMenu;
	this.offRootMenu = CUI_OffRootMenu;
		
	this.getObject = CUI_GetObject;
	
	//initialize User Interface
	this.initialize = CUI_Initialize;
}


function CUI_Initialize()
{
	//set CSS
	this.setCSS(this.IE_CSS, this.NS_CSS);
	
	//create menus
	

}

function CUI_SetCSS(IE, NS)
{
	if(this.oBrwInfo.browser == 'ie' || this.oBrwInfo.browser == 'ns6')
	{
		document.writeln("<LINK REL=\"stylesheet\" type=\"text/css\" href=\"" + IE + "\">\n");
	}
	else
	{
		document.writeln("<LINK REL=\"stylesheet\" type=\"text/css\" href=\"" + NS + "\">\n");	
	}
}

function CUI_SetMenuVisible(mID, mState)
{
	var obj;
	
	obj = this.getObject(mID);
	if(obj)
	{
		if(mState == 'on')
		{
			if (this.oBrwInfo.browser =='ie' || this.oBrwInfo.browser == 'ns6')
			{
				obj.visibility = "visible";
			}
			else
			{
				obj.visibility = "show";
			}
		}
		else
		{
			if (this.oBrwInfo.browser =='ie' || this.oBrwInfo.browser == 'ns6')
			{
				obj.visibility = "hidden";
			}
			else
			{
				obj.visibility = "hide";
			}
	
		}	
	}

}

function CUI_TimedClose(mID, mState, iSeconds)
{
	if(!this.onLayer)
	{
		var sCmd = "UI.setMenuVisible('" + mID + "', '" + mState + "')";
		this.timerID = setTimeout(sCmd, 1000 * iSeconds);
	}
}

function CUI_GetObject(obj)
{
	if(typeof obj == "string")
	{
		if(document.getElementById)
		{
			//netscape 6+ and IE 5+
			return document.getElementById(obj).style;

		}
		else if(document.all)
		{
			//ie 4+
			return document.all[obj].style;
		}
		else if(document.layers)
		{
			//netscape 4+
			return document.layers[obj];
		}
	}
	else
	{
		return obj;
	}

}

function CUI_OnLayerColor(mItem, layerName)
{
	if(this.oBrwInfo.browser == 'ns')
	{
		layerName = eval("document.MENU_" + mItem + ".document.i_" + layerName + ".document." + layerName);
	}

	this.setBGColor(layerName, this.hovercolor);

}

function CUI_OffLayerColor(mItem, layerName)
{
	if(this.oBrwInfo.browser == 'ns')
	{
		layerName = eval("document.MENU_" + mItem + ".document.i_" + layerName + ".document." + layerName);
	}

	this.setBGColor(layerName, this.offColor);
}

function CUI_OnRootMenu(mItem, onImg)
{
	//mItem = menu item
	eval('document.' + mItem + '.src = "images/' + onImg + '"');
}

function CUI_OffRootMenu(mItem, offImg)
{
	//mItem - menu item
	eval('document.' + mItem + '.src = "images/' + offImg + '"');	
}

function CUI_SetBGColor(obj, color)
{
	var oLayer = this.getObject(obj);
	if (this.oBrwInfo.browser == 'ie' || this.oBrwInfo.browser == 'ns6')
	{
		oLayer.backgroundColor = color;	
	}
	else if(this.oBrwInfo.browser == 'ns')
	{
		oLayer.bgColor = color;
	}
}