var isNS = (navigator.appName.toLowerCase().indexOf('netscape') >= 0 ? true : false);
var isIE = (navigator.appName.toLowerCase().indexOf('microsoft') >= 0 ? true : false);

function selectLine(iStyle, sKey, sFlag)
{ 
	btn = document.getElementById(sKey+"BTN");
	txt = document.getElementById(sKey+"TXT");
	
	switch (iStyle)
	{
		case 0: // mouseout					
			if (sFlag == 1) {
				btn.className = 'menubuttons';
				txt.className = 'menuentry';
			}
			if (sFlag == 2) {
				btn.className = 'temasbutton';
				txt.className = 'temasentry';
			}
			break;
		case 1: // mouseover			
			if (sFlag == 1) {
				btn.className = 'lineoverbtn';
				txt.className = 'lineoverent';
			}
			if (sFlag == 2) {
				btn.className = 'temasoverbtn';
				txt.className = 'temasoverent';
			}
			break;
	}
}

/*******************************************************/
/* SelectLine - Altera as cores das linhas das tabelas */
/*  0 - mouseout */
/*  1 - mouseover */
/*  2 - onclick */
/**/
/*  FLAGS   */
/*  1 - menu principal     */
/*  2 - temas de interesse */
/*******************************************************/

var menuRegex = new RegExp("menu-item");
var mnbtn = new RegExp("menubuttons");
var tibtn = new RegExp("temasbutton");
var mnovr = new RegExp("lineoverbtn");
var tiovr = new RegExp("temasoverbtn");

function initFXMenus()
{
    var listItems = document.getElementsByTagName('tr');
    for (var i = 0; i < listItems.length; i++)
    {
        if (listItems[i].className && listItems[i].className.match(menuRegex))
        {
            initFXMenu(listItems[i]);
        }
    }
}

function initFXMenu(item)
{
	addEventToElement(item, "mouseover", menuRollIn, true);
	addEventToElement(item, "mouseout", menuRollOut, true);
	addEventToElement(item, "focus", menuRollIn, true);
	addEventToElement(item, "blur", menuRollOut, true);
}

function getItem(listItem)
{
    var item;
    var items = listItem.getElementsByTagName("td");

    if (items && items.length == 2)
    {
        item = items;
    }

    return item;
}

function menuRollIn(event)
{
    var item = getEventSource(getEvent(event));
	if (isIE)
	{
		item = item.parentNode;
	}

    if (item)
    {
		var both = getItem(item);
    	
    	if (both)
    	{
    		if (both[0].className.match(mnbtn))
    		{
	    		both[0].className = 'lineoverbtn';
				both[1].className = 'lineoverent';
			}
    		if (both[0].className.match(tibtn))
    		{
	    		both[0].className = 'temasoverbtn';
				both[1].className = 'temasoverent';
			}
    	}
	}
}

function menuRollOut(event)
{
    var item = getEventSource(getEvent(event));
	if (isIE)
	{
		item = item.parentNode;
	}
    
    if (item)
    {
    	var both = getItem(item);
    	
    	if (both)
    	{
    		if (both[0].className.match(mnovr))
    		{
	    		both[0].className = 'menubuttons';
				both[1].className = 'menuentry';
			}
    		if (both[0].className.match(tiovr))
    		{
	    		both[0].className = 'temasbutton';
				both[1].className = 'temasentry';
			}
    	}
	}
}

function menuRollInTab(item)
{
    var both = getItem(item);
    
    if (both)
    {
        if (both[0].className.match(mnbtn))
        {
            both[0].className = 'lineoverbtn';
            both[1].className = 'lineoverent';
        }
        if (both[0].className.match(tibtn))
        {
            both[0].className = 'temasoverbtn';
            both[1].className = 'temasoverent';
        }
    }
}

function menuRollOutTab(item)
{
    var both = getItem(item);
    
    if (both)
    {
        if (both[0].className.match(mnovr))
        {
            both[0].className = 'menubuttons';
            both[1].className = 'menuentry';
        }
        if (both[0].className.match(tiovr))
        {
            both[0].className = 'temasbutton';
            both[1].className = 'temasentry';
        }
    }
}
