var g_color_tab_sel;
var g_color_tab_unsel;
var g_color_tab_unsel_hover;
var g_color_tab_bk;
var g_pngcapability;
var g_pageloaded = 0;

function navtab_init(color_tab_sel, color_tab_unsel, color_tab_unsel_hover, color_tab_bk, pngcapability)
{
	g_color_tab_sel = color_tab_sel;
	g_color_tab_unsel = color_tab_unsel;
	g_color_tab_unsel_hover = color_tab_unsel_hover;
	g_color_tab_bk = color_tab_bk;
	g_pngcapability = pngcapability;
	g_pageloaded = 1;
}

function mv(oElem)
{
	fliptab(oElem,true)
}

function mt(oElem)
{
	fliptab(oElem,false)
}

function fliptab(oElem,bState)
{
	if( (g_pageloaded == null) || (g_pageloaded == 0) ) return;	// page must have finished loading

	var bk_suffix = "";
	if(g_pngcapability == 2) bk_suffix = "_bk_" + g_color_tab_bk;

	oChild = oElem.firstChild;
	while(oChild != null)
	{
		if(oChild.attributes != null)
		{
			oAttrs = oChild.attributes;
			oClass = oAttrs.getNamedItem("class");
			if(oClass != null)
			{
				strClass = oClass.nodeValue;
				if(strClass.indexOf("navtab-l") > -1)
				{
					if(bState) oChild.style.backgroundImage = "url('img/tab_l_" + g_color_tab_unsel_hover + bk_suffix + ".png')";
					else oChild.style.backgroundImage = "url('img/tab_l_" + g_color_tab_unsel + bk_suffix + ".png')";
				}
				else if(strClass.indexOf("navtab-r") > -1)
				{
					if(bState) oChild.style.backgroundImage = "url('img/tab_r_" + g_color_tab_unsel_hover + bk_suffix + ".png')";
					else oChild.style.backgroundImage = "url('img/tab_r_" + g_color_tab_unsel + bk_suffix + ".png')";
				}
				else if(strClass.indexOf("navtab-center") > -1)
				{
					/* if(bState) oChild.style.backgroundColor = "#" + g_color_tab_unsel_hover;
					else oChild.style.backgroundColor = "#" + g_color_tab_unsel; */
					if(bState) oChild.style.backgroundImage = "url('img/tab_bk_" + g_color_tab_unsel_hover + "_48x48.png')";
					else oChild.style.backgroundImage = "url('img/tab_bk_" + g_color_tab_unsel + "_48x48.png')";
				}
			}
		}
		oChild = oChild.nextSibling;
	}
}

function md(strURL)
{	// navigate to new page
	if(strURL.length > 0)
	{
		self.location.href = strURL;
	}
}
