styles='<STYLE>.subText {' +
		'font-family:' + fontFamily + ';' +
		'font-weight:' + fontWeight + ';' +
		'font-size:' + fontSize + ';' +
		'text-decoration:none;' +
		'color:' + subTextColor + ';' + 
		'}.subSubText {' +
		'font-family:' + fontFamily + ';' +
		'font-weight:' + fontWeight + ';' +
		'font-size:' + fontSize + ';' +
		'text-decoration:none;' +
		'color:' + subSubTextColor + ';' + 
		'}.subTextOver {' +
		'font-family:' + fontFamily + ';' +
		'font-weight:' + fontWeight + ';' +
		'font-size:' + fontSize + ';' +
		'text-decoration:none;' +
		'color:' + subTextOverColor + ';' + 
		'}.subSubTextOver {' +
		'font-family:' + fontFamily + ';' +
		'font-weight:' + fontWeight + ';' +
		'font-size:' + fontSize + ';' +
		'text-decoration:none;' +
		'color:' + subSubTextOverColor + ';' + 
		'}</STYLE>';
document.write(styles)

function populateMenu()
{	
	for(i=0; i<lefts.length - 1; i++)
	{
		if((Global_Max_Width - lefts[i]) < entryWidth)
		{
			lefts[i] = Global_Max_Width - entryWidth;
		}
		
	}
	lefts[lefts.length - 1] = Global_Max_Width - entryWidth;
	
	subLefts = new Array()
	for(i=0; i<lefts.length; i++)
	{
		subLefts[i] = lefts[i] + (entryWidth - menuLeftOffset);
		if((Global_Max_Width - subLefts[i]) < entryWidth)
		{
			subLefts[i] = lefts[i] - entryWidth + menuLeftOffset;
		}
	}
	spacer = (ns4up) ?  '<IMG SRC="spacer.gif" BORDER="0" WIDTH="' + (entryWidth-27) + '" HEIGHT="1"><br>' : "";
	spacer1 = (ns4up) ? '<IMG SRC="spacer.gif" BORDER="0" WIDTH="' + (entryWidth-32) + '" HEIGHT="1"><br>' : "";
	// Write SubMenus
	//bottom text layer
	for(i=0; i<menu.length; i++) //loop through all menus
	{	
		if(menu[i].length > 0)
		{
			if(ns4up) {
				toWrite = '<LAYER NAME="nav_top_' + i + '" PAGEX="' + lefts[i] + '" PAGEY="' + menuTopOffset + '" VISIBILITY="HIDE" Z-INDEX="12">';
			} else {
				toWrite = '<DIV ID="nav_top_' + i + '" STYLE="position:absolute;left:' + lefts[i] + 'px;top:' + menuTopOffset + 'px;z-index:12;visibility:hidden;">';
			}
			toWrite += '<TABLE CELLSPACING="0" CELLPADDING="0" BORDER="0" WIDTH="' + entryWidth + '" HEIGHT="1" BGCOLOR="white">';
			toWrite += '<TR>';
			toWrite += '	<TD BGCOLOR="' + SubMenuEdge + '"><IMG SRC="spacer.gif" BORDER="0" WIDTH="' + entryWidth + '" HEIGHT="1"></TD>';
			toWrite += '</TR>';
			toWrite += '</TABLE>';
			
			for(j=0; j<menu[i].length; j++) //loop through all sub menus
			{
				toWrite += '<TABLE CELLSPACING="0" CELLPADDING="0" BORDER="0" WIDTH="' + entryWidth + '" HEIGHT="' + entryHeight + '" BGCOLOR="' + SubMenuBG + '">';
				toWrite += '<TBODY ID="tbody_' + i + '_' + j + '"><TR>';
				toWrite += '	<TD BGCOLOR="' + SubMenuEdge + '" WIDTH="1"><IMG SRC="spacer.gif" BORDER="0" WIDTH="1" HEIGHT="' + (entryHeight-1) + '"></TD>';
				
				if (menu[i][j].length < 1) {
					toWrite += '	<TD WIDTH="20" ID="subMenuBG1_' + i + '_' + j + '"><IMG SRC="spacer.gif" WIDTH="20" HEIGHT="2" BORDER="0"></TD>';
					toWrite += '	<TD WIDTH="' + (entryWidth-27) + '" CLASS="subText" BGCOLOR="' + SubMenuBG + '" ID="subMenuBG2_' + i + '_' + j + '">' + spacer + subMenuDetail[i][j][0] + '</TD>';
					toWrite += '	<TD WIDTH="5" ID="subMenuBG3_' + i + '_' + j + '"><IMG SRC="spacer.gif" WIDTH="5" HEIGHT="2" BORDER="0"></TD>';
				} else {
					toWrite += '	<TD WIDTH="20" ID="subMenuBG1_' + i + '_' + j + '"><IMG SRC="spacer.gif" WIDTH="20" HEIGHT="2" BORDER="0"></TD>';
					toWrite += '	<TD WIDTH="' + (entryWidth-32) + '" CLASS="subText" BGCOLOR="' + SubMenuBG + '" ID="subMenuBG2_' + i + '_' + j + '">' + spacer1 + subMenuDetail[i][j][0] + '</TD>';
					toWrite += '	<TD WIDTH="10" ALIGN="right" ID="subMenuBG3_' + i + '_' + j + '"><IMG SRC="' + imagePath + 'global-common-arrow-small.gif" WIDTH="10" HEIGHT="10" BORDER="0"></TD>';
				}
				
				toWrite += '	<TD BGCOLOR="' + SubMenuEdge + '" WIDTH="1"><IMG SRC="spacer.gif" BORDER="0" WIDTH="1" HEIGHT="' + (entryHeight-1) + '"></TD>';
				toWrite += '</TR>';
				toWrite += '<TR>';
						
				(menu[i].length == (j + 1)) ? hColor =  SubMenuEdge : hColor = SubMenuGap;
				toWrite += '	<TD BGCOLOR="' + hColor + '" COLSPAN="4" WIDTH="' + (entryWidth-1) + '"><IMG SRC="spacer.gif" BORDER="0" WIDTH="' + (entryWidth-1) + '" HEIGHT="1"></TD>';
				toWrite += '	<TD BGCOLOR="' + SubMenuBG + '" WIDTH="1"><IMG SRC="spacer.gif" BORDER="0" WIDTH="1" HEIGHT="1"></TD>';
				toWrite += '</TR></TBODY>';
				toWrite += '</TABLE>';
			}
			document.write(toWrite);
			closeLayer()
		}
	}
	
	//top links - clear gif layer
	for(i=0; i<menu.length; i++)
	{
		if(menu[i].length > 0)
		{
			if(ns4up) {
				document.write('<LAYER NAME="nav_top_over_' + i + '" PAGEX="' + lefts[i] + '" PAGEY="' + menuTopOffset + '" VISIBILITY="HIDE" Z-INDEX="14">');
			} else {
			document.write('<DIV ID="nav_top_over_' + i + '" STYLE="position:absolute;left:' + lefts[i] + 'px;top:' + menuTopOffset + 'px;z-index:14;visibility:hidden;">');
			}
			document.write('<IMG SRC="spacer.gif" BORDER="0" WIDTH="1" HEIGHT="1">');
			for(j=0; j<menu[i].length; j++)
			{
				if (menu[i][j].length < 1) {
					document.write('<A HREF="' + subMenuDetail[i][j][1] + '" ONMOUSEOVER="subOver(true,\'' + i + '\',\'' + j + '\');addToVisibility(' + i + ');" ONMOUSEOUT="subOver(false,\'' + i + '\',\'' + j + '\');slowLayerOff(' + i + ');" TARGET="' + subMenuDetail[i][j][2] + '"><IMG SRC="spacer.gif" BORDER="0" WIDTH="' + entryWidth + '" HEIGHT="' + entryHeight + '"></A><BR>');
				} else {
					document.write('<A HREF="' + subMenuDetail[i][j][1] + '" ONMOUSEOVER="subOver(true,\'' + i + '\',\'' + j + '\');layerOn(\'' + i + '\',\'' + j + '\');addToVisibility(\'' + i + '\');" ONMOUSEOUT="subOver(false,\'' + i + '\',\'' + j + '\');slowLayerOff(\'' + i + '\',\'' + j + '\');slowLayerOff(' + i + ');" TARGET="' + subMenuDetail[i][j][2] + '"><IMG SRC="spacer.gif" BORDER="0" WIDTH="' + entryWidth + '" HEIGHT="' + entryHeight + '"></A><BR>');
				}
			}
			document.write('<IMG SRC="spacer.gif" BORDER="0" WIDTH="1" HEIGHT="1">');
			closeLayer()
		}
	}
	//rollover state
	if(ns4up)
	{
		for(i=0; i<menu.length; i++)
		{
			if(menu[i].length > 0)
			{
				for(j=0; j<menu[i].length; j++)
				{
					navTop = menuTopOffset + (entryHeight * j)
					toWrite = '<LAYER NAME="nav_over_' + i + '_' + j + '" PAGEX="' + lefts[i] + '" PAGEY="' + navTop + '" VISIBILITY="HIDE" Z-INDEX="13">';
					toWrite += '<TABLE CELLSPACING="0" CELLPADDING="0" BORDER="0" WIDTH="' + entryWidth + '" HEIGHT="' + entryHeight + '" BGCOLOR="' + SubMenuBGOver + '">';
					toWrite += '<TR>';
					toWrite += '	<TD BGCOLOR="' + SubMenuEdge + '" WIDTH="1"><IMG SRC="spacer.gif" BORDER="0" WIDTH="1" HEIGHT="' + (entryHeight-1) + '"></TD>';
					
					if (menu[i][j].length < 1) {
						toWrite += '	<TD WIDTH="20"><IMG SRC="spacer.gif" WIDTH="20" HEIGHT="2" BORDER="0"></TD>';
						toWrite += '	<TD WIDTH="' + (entryWidth-27) + '" CLASS="subTextOver" BGCOLOR="' + SubMenuBGOver + '">' + spacer + subMenuDetail[i][j][0] + '</TD>';
						toWrite += '	<TD WIDTH="5"><IMG SRC="spacer.gif" WIDTH="5" HEIGHT="2" BORDER="0"></TD>';
					} else {
						toWrite += '	<TD WIDTH="20"><IMG SRC="spacer.gif" WIDTH="20" HEIGHT="2" BORDER="0"></TD>';
						toWrite += '	<TD WIDTH="' + (entryWidth-32) + '" CLASS="subTextOver" BGCOLOR="' + SubMenuBGOver + '">' + spacer1 + subMenuDetail[i][j][0] + '</TD>';
						toWrite += '	<TD WIDTH="10" ALIGN="right"><IMG SRC="' + imagePath + 'global-common-arrow-small.gif" WIDTH="10" HEIGHT="10" BORDER="0"></TD>';
					}
					
					toWrite += '	<TD BGCOLOR="' + SubMenuEdge + '" WIDTH="1"><IMG SRC="spacer.gif" BORDER="0" WIDTH="1" HEIGHT="' + (entryHeight-1) + '"></TD>';
					toWrite += '</TR>';
					toWrite += '<TR>';
					(menu[i].length == (j + 1)) ? hColor =  SubMenuEdge : hColor = SubMenuGap;
					toWrite += '	<TD BGCOLOR="' + hColor + '" COLSPAN="4" WIDTH="' + (entryWidth-1) + '"><IMG SRC="spacer.gif" BORDER="0" WIDTH="' + (entryWidth-1) + '" HEIGHT="1"></TD>';
					toWrite += '	<TD BGCOLOR="' + SubMenuBG + '" WIDTH="1"><IMG SRC="spacer.gif" BORDER="0" WIDTH="1" HEIGHT="1"></TD>';
					toWrite += '</TR>';
					toWrite += '</TABLE>';
					toWrite += '</LAYER>';
					document.write(toWrite)
				}
			}
		}
	} //end if(ns4up)
	// End Submenus
	// Start SubSub Menus
	for(i=0; i<menu.length; i++)
	{
		for(j=0; j<menu[i].length; j++)
		{
			if (menu[i][j].length >= 1) {
				subMenuTop = menuTopOffset + (j * entryHeight);
				if(ns4up) {
					toWrite = '<LAYER NAME="nav_sub_' + i + '_' + j + '" PAGEX="' + subLefts[i] + '" PAGEY="' + subMenuTop + '" VISIBILITY="HIDE" Z-INDEX="15">';
				} else {
					toWrite = '<DIV ID="nav_sub_' + i + '_' + j + '" STYLE="position:absolute;left:' + subLefts[i] + 'px;top:' + subMenuTop + 'px;z-index:15;visibility:hidden;">';
				}
				toWrite += '<TABLE CELLSPACING="0" CELLPADDING="0" BORDER="0" WIDTH="' + entryWidth + '" HEIGHT="1" BGCOLOR="white">';
				toWrite += '<TR>';
				toWrite += '	<TD BGCOLOR="' + SubSubMenuEdge + '"><IMG SRC="spacer.gif" BORDER="0" WIDTH="' + entryWidth + '" HEIGHT="1"></TD>';
				toWrite += '</TR>';
				toWrite += '</TABLE>';
				document.write(toWrite);
				for(k=0; k<menu[i][j].length; k++) //loop through all sub sub menus
				{
					toWrite = '<TABLE CELLSPACING="0" CELLPADDING="0" BORDER="0" WIDTH="' + entryWidth + '" HEIGHT="' + entryHeight + '" BGCOLOR="' + SubMenuBG + '">';
					toWrite += '<TBODY ID="tbody_' + i + '_' + j + '_' + k + '"><TR>';
					toWrite += '	<TD BGCOLOR="' + SubSubMenuEdge + '" WIDTH="1"><IMG SRC="spacer.gif" BORDER="0" WIDTH="1" HEIGHT="' + (entryHeight-1) + '"></TD>';
					toWrite += '	<TD WIDTH="20" BGCOLOR="' + SubSubMenuBG + '" ID="subSubMenuBG1_' + i + '_' + j + '_' + k + '"><IMG SRC="spacer.gif" WIDTH="20" HEIGHT="2" BORDER="0"></TD>';
					toWrite += '	<TD WIDTH="' + (entryWidth-27) + '" CLASS="subSubText" BGCOLOR="' + SubSubMenuBG + '" ID="subSubMenuBG2_' + i + '_' + j + '_' + k + '">' + spacer + menu[i][j][k][0] + '</TD>';
					toWrite += '	<TD WIDTH="5" BGCOLOR="' + SubSubMenuBG + '" ID="subSubMenuBG3_' + i + '_' + j + '_' + k + '"><IMG SRC="spacer.gif" WIDTH="5" HEIGHT="2" BORDER="0"></TD>';
					toWrite += '	<TD BGCOLOR="' + SubSubMenuEdge + '" WIDTH="1"><IMG SRC="spacer.gif" BORDER="0" WIDTH="1" HEIGHT="' + (entryHeight-1) + '"></TD>';
					toWrite += '</TR>';
					toWrite += '<TR>';
					(menu[i][j].length == (k + 1)) ? hColor =  SubSubMenuEdge : hColor = SubSubMenuGap;
					toWrite += '	<TD BGCOLOR="' + hColor + '" COLSPAN="4" WIDTH="' + (entryWidth-1) + '"><IMG SRC="spacer.gif" BORDER="0" WIDTH="' + (entryWidth-1) + '" HEIGHT="1"></TD>';
					toWrite += '	<TD BGCOLOR="' + SubSubMenuBG + '" WIDTH="1"><IMG SRC="spacer.gif" BORDER="0" WIDTH="1" HEIGHT="1"></TD>';
					toWrite += '</TR>';
					toWrite += '</TBODY></TABLE>';
					document.write(toWrite);
				}
				closeLayer()
			}
		}
	}
	//top links - clear gif layer
	for(i=0; i<menu.length; i++)
	{
		for(j=0; j<menu[i].length; j++)
		{
			if (menu[i][j].length >= 1) {
				subMenuTop = menuTopOffset + (j * entryHeight);
				if(ns4up)	{
					document.write('<LAYER NAME="nav_sub_over_' + i + '_' + j + '" PAGEX="' + subLefts[i] + '" PAGEY="' + subMenuTop + '" VISIBILITY="HIDE" Z-INDEX="17">');
				} else {
					document.write('<DIV ID="nav_sub_over_' + i + '_' + j + '" STYLE="position:absolute;left:' + subLefts[i] + 'px;top:' + subMenuTop + 'px;z-index:17;visibility:hidden;">');
				}
				for(k=0; k<menu[i][j].length; k++)
				{
					document.write('<A HREF="' + menu[i][j][k][1] + '" ONMOUSEOVER="addToVisibility(\'' + i + '\',\'' + j + '\');addToVisibility(\'' + i + '\');subOver(true,\'' + i + '\',\'' + j + '\',\'' + k + '\');subOver(true,\'' + i + '\',\'' + j + '\')" ONMOUSEOUT="slowLayerOff(\'' + i + '\',\'' + j + '\');slowLayerOff(\'' + i + '\');subOver(false,\'' + i + '\',\'' + j + '\',\'' + k + '\');subOver(false,\'' + i + '\',\'' + j + '\')" TARGET="' + menu[i][j][k][2] + '"><IMG SRC="spacer.gif" BORDER="0" WIDTH="' + entryWidth + '" HEIGHT="' + entryHeight + '"></A><BR>');
				}
				
				closeLayer()
			}
		}
	}
	if(ns4up)
	{
		// middle  roll over state
		for(i=0; i<menu.length; i++) //loop through all menus
		{
			for(j=0; j<menu[i].length; j++) //loop through all sub menus
			{
				if (menu[i][j].length >= 1)
				{
					for(k=0; k<menu[i][j].length; k++) //loop through all sub sub menus
					{
						subMenuTop = menuTopOffset + (j * entryHeight) + (k * entryHeight) + 1;
						toWrite = '<LAYER NAME="nav_over_' + i + '_' + j + '_' + k + '" PAGEX="' + subLefts[i] + '" PAGEY="' + subMenuTop + '" VISIBILITY="HIDE" Z-INDEX="16">';
						toWrite += '<TABLE CELLSPACING="0" CELLPADDING="0" BORDER="0" WIDTH="' + entryWidth + '" HEIGHT="' + entryHeight + '" BGCOLOR="' + SubSubMenuBGOver + '">';
						toWrite += '<TR>';
						toWrite += '	<TD BGCOLOR="' + SubSubMenuEdge + '" WIDTH="1"><IMG SRC="spacer.gif" BORDER="0" WIDTH="1" HEIGHT="' + (entryHeight-1) + '"></TD>';
						toWrite += '	<TD WIDTH="20"><IMG SRC="spacer.gif" WIDTH="20" HEIGHT="2" BORDER="0"></TD>';
						toWrite += '	<TD WIDTH="' + (entryWidth-27) + '" CLASS="subSubTextOver" BGCOLOR="' + SubSubMenuBGOver + '">' + spacer + menu[i][j][k][0] + '</TD>';
						toWrite += '	<TD WIDTH="5"><IMG SRC="spacer.gif" WIDTH="5" HEIGHT="2" BORDER="0"></TD>';
						toWrite += '	<TD BGCOLOR="' + SubSubMenuEdge + '" WIDTH="1"><IMG SRC="spacer.gif" BORDER="0" WIDTH="1" HEIGHT="' + (entryHeight-1) + '"></TD>';
						toWrite += '</TR>';
						toWrite += '<TR>';
						(menu[i][j].length == (k + 1)) ? hColor =  SubSubMenuEdge : hColor = SubSubMenuGap;
						toWrite += '	<TD BGCOLOR="' + hColor + '" COLSPAN="4" WIDTH="' + (entryWidth-1) + '"><IMG SRC="spacer.gif" BORDER="0" WIDTH="' + (entryWidth-1) + '" HEIGHT="1"></TD>';
						toWrite += '	<TD BGCOLOR="' + SubSubMenuBG + '" WIDTH="1"><IMG SRC="spacer.gif" BORDER="0" WIDTH="0" HEIGHT="1"></TD>';
						toWrite += '</TR>';
						toWrite += '</TABLE>';
						toWrite += '</LAYER>';
						document.write(toWrite)
					}
				}
			}
		}
	} // end if(ns4up)
	// end subSubMenus
} // end populateMenu()

var menuOffDelay = 2;
function slowLayerOff(i,j)
{
	if(j) {
		removeFromVisibility(i,j);
		setTimeout("togleVisible('" + i + "','" + j + "')",menuOffDelay);
	} else {
		removeFromVisibility(i);
		setTimeout("togleVisible('" + i + "')",menuOffDelay);
	}
}

function layerOn(i,j)
{
	if(j) {
		addToVisibility(i,j);
		togleVisible(i,j);
	} else {
		addToVisibility(i);
		togleVisible(i);
	}
}

// visible navigation array
visibility = new Array();
var tmp, which, toBeVisible;
hasFlash = false;
function removeFromVisibility(i,j)
{
	if(j != null) {
		which = "nav_sub_" + i + "_" + j;
	} else {
		which = "nav_top_" + i;
	}
	for(i=0; i<visibility.length; i++)
	{
		if(visibility[i] == which)
		{
			tmp = visibility[visibility.length - 1];
			visibility[visibility.length - 1] = visibility[i];
			visibility[i] = tmp;
			visibility.length = visibility.length - 1;
		}
	}
}

function addToVisibility(i,j)
{	
	if(j != null) {
		which = "nav_sub_" + i + "_" + j;
	} else {
		which = "nav_top_" + i;
	}
	visibility[visibility.length] = which;
}


function togleVisible(i,j)
{
	if(j != null) {
		which = "nav_sub_" + i + "_" + j;
		whichOver = "nav_sub_over_" + i + "_" + j;
	} else {
		which = "nav_top_" + i;
		whichOver = "nav_top_over_" + i;
	}
	
	toBeVisible = false;
	for(i=0; i<visibility.length; i++)
	{
		if(visibility[i] == which)
		{
			toBeVisible = true;
		}
	}
	// Flash object should have wmode="opaque" to prevend the menu going beneath
	// So homapage-2 template for example
	//if(hasFlash){
	//	(visibility.length == 0) ? showEmbedObject() : hideEmbedObject();
	//}
	if(ns4up)
	{
		if(document.layers[which])
		{
			if((document.layers[which].visibility == "show")&&(toBeVisible == false))
			{
				document.layers[which].visibility = "hide";
				document.layers[whichOver].visibility = "hide";
			}
			else if((document.layers[which].visibility == "hide")&&(toBeVisible == true))
			{
				document.layers[which].visibility = "show";
				document.layers[whichOver].visibility = "show";
			}
		}
	}
	else if(dom)
	{
		if(document.getElementById(which))
		{
			if((document.getElementById(which).style.visibility == "visible")&&(toBeVisible == false))
			{
				document.getElementById(which).style.visibility = "hidden";
				document.getElementById(whichOver).style.visibility = "hidden";
			}
			else if((document.getElementById(which).style.visibility == "hidden")&&(toBeVisible == true))
			{
				document.getElementById(which).style.visibility = "visible";
				document.getElementById(whichOver).style.visibility = "visible";
			}
		}
	}
	else
	{ 
		if(document.all[which])
		{
			if((document.all[which].style.visibility == "visible")&&(toBeVisible == false))
			{
				document.all[which].style.visibility = "hidden";
				document.all[whichOver].style.visibility = "hidden";
			}
			else if((document.all[which].style.visibility == "hidden")&&(toBeVisible == true))
			{
				document.all[which].style.visibility = "visible";
				document.all[whichOver].style.visibility = "visible";
			}
		}
	}
}
function subOver(show,i,j,k)
{
	if(k != null) {
		which = "nav_over_" + i + "_" + j + '_' + k;
		cellNames = ['subSubMenuBG1_' + i + '_' + j + '_' + k,'subSubMenuBG2_' + i + '_' + j + '_' + k,'subSubMenuBG3_' + i + '_' + j + '_' + k	];
		overBG = SubSubMenuBGOver; underBG = SubSubMenuBG;
		overText = subSubTextOverColor; underText = subSubTextColor;
	} else {
		which = "nav_over_" + i + "_" + j;
		cellNames = ['subMenuBG1_' + i + '_' + j,'subMenuBG2_' + i + '_' + j,'subMenuBG3_' + i + '_' + j];
		overBG = SubMenuBGOver; underBG = SubMenuBG;
		overText = subTextOverColor; underText = subTextColor;
	}
	if(ns4up)
	{
		if((document.layers[which].visibility == "show")&&(show == false))
		{
			document.layers[which].visibility = "hide";
		}
		else if((document.layers[which].visibility == "hide")&&(show == true))
		{
			document.layers[which].visibility = "show";
		}
	}
	else if(dom)
	{ 
		for(l = 0; l < cellNames.length; l++)
		{
			document.getElementById(cellNames[l]).style.backgroundColor = (show) ? overBG : underBG;
			document.getElementById(cellNames[l]).style.color = (show) ? overText : underText;
		}
	}
	else //ie4up
	{
		for(l = 0; l < cellNames.length; l++)
		{
		document.all[cellNames[l]].style.backgroundColor = (show) ? overBG : underBG;
		document.all[cellNames[l]].style.color = (show) ? overText : underText;
		}
	}
}

function showEmbedObject(){
	if(dom){
		if(document.getElementById("showPlugin")){
			document.getElementById("showPlugin").style.top = 101; //74;
		}
	}else if(ns4up){
		if(document.layers["showPlugin"]){
			document.layers["showPlugin"].visibility = "show";
		}
	}else{
		if(document.all["showPlugin"]){
			document.all["showPlugin"].style.visibility = "visible";
		}
	}
}

function hideEmbedObject(){
	if(dom){
		if(document.getElementById("showPlugin")){
			document.getElementById("showPlugin").style.top = window.innerHeight + window.pageYOffset;
		}
	}else if(ns4up){
		if(document.layers["showPlugin"]){
			document.layers["showPlugin"].visibility = "hide";
		}
	}else{
		if(document.all["showPlugin"]){
			document.all["showPlugin"].style.visibility = "hidden";
		}
	}
}

var mac = (navigator.userAgent.indexOf("Mac") > 0) ? 1 : 0;
var ns4up = (document.layers) ? 1 : 0;
var ie4up = (document.all) ? 1 : 0;
var dom = (document.getElementById&&!document.all) ? 1 : 0;

var lefts = new Array();
var widths = new Array();

function closeLayer()	{
	if (ns4up) {
		document.write('</LAYER>\n');
	} else {
		document.write('</DIV>\n');
	}
}

function initNavigation()	{

	var padding = 7; // total letter padding in a button e.g. 5 = 2.5 each side
	var docContent = "";
	var letterCount = 0;
	var widthTotal = 0;
	
	for (i=0; i<navItems.length; i++)
	{
		letterCount+= navItems[i].replace(/&.+?;/ig, "#").length + padding;
	}
	
	for (i=0; i<navItems.length; i++)
	{
		thisWidth = ((navItems[i].replace(/&.+?;/ig, "#").length + padding) / letterCount) * Global_Max_Width;
		thisWidth = Math.floor(thisWidth);
		if(i == (navItems.length-1))
		{
			thisWidth = (Global_Max_Width - widthTotal);
		}
		widths[i] = thisWidth;
		lefts[i] = widthTotal;
		widthTotal += thisWidth;
		
		var thisName = navNames[i] + "tab";
		var thisNav = navNames[i];
		if (ns4up) {
			toWrite = '<LAYER NAME="' + thisNav + '" LEFT="' + lefts[i] + '" TOP="' + TopNavigationGlobalTop + '" VISIBILITY="SHOW" Z-INDEX="10">\n';
		} else {
			toWrite = '<DIV ID="' + thisNav + '" STYLE="position:absolute;left:' + lefts[i] + 'px; top:' + TopNavigationGlobalTop + 'px;z-index:10;visibility:visible;">\n';
		}
		toWrite += '<TABLE WIDTH="' + thisWidth + '" CELLPADDING="0" CELLSPACING="0" BORDER="0" BGCOLOR="' + TopNavButtonBG + '" HEIGHT="' + navHeight + '" ID="TopNavButtonBG0' + thisNav + '">\n';
		toWrite += '<TR>\n';
		toWrite += '<TD BGCOLOR="' + TopNavButtonTop + '" WIDTH="1" COLSPAN="3" ID="TopNavButtonTop0' + thisNav + '"><IMG SRC="spacer.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD>\n';
		toWrite += '</TR>\n';
		toWrite += '<TR>\n';
		toWrite += '<TD BGCOLOR="' + TopNavButtonHighlight1 + '" WIDTH="1" COLSPAN="2" ID="TopNavHighlight10' + thisNav + '"><IMG SRC="spacer.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD>\n';
		toWrite += '<TD BGCOLOR="' + TopNavButtonBG + '" WIDTH="1"><IMG SRC="spacer.gif" WIDTH="1" HEIGHT="1" BORDER="0" ID="TopNavButtonBG1' + thisNav + '"></TD>\n';
		toWrite += '</TR>\n';
		toWrite += '<TR>\n';
		toWrite += '<TD BGCOLOR="' + TopNavButtonHighlight2 + '" HEIGHT="' + (navHeight-3) + '" ID="TopNavHighlight20' + thisNav + '"><IMG SRC="spacer.gif" WIDTH="1" HEIGHT="' + (navHeight-3) + '" BORDER="0"></TD>\n';
		toWrite += '<TD WIDTH="' + thisWidth + '" BGCOLOR="' + TopNavButtonBG + '" VALIGN="middle" ALIGN="center" HEIGHT="' + (navHeight-3) + '" ID="TopNavButtonBG2' + thisNav + '" class="buttonLink">' + navItems[i] + '</TD>\n';
		toWrite += '<TD BGCOLOR="' + TopNavButtonDimlight + '" HEIGHT="' + (navHeight-3) + '" ID="TopNavDimlight0' + thisNav + '"><IMG SRC="spacer.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD>\n';
		toWrite += '</TR>\n';
		toWrite += '<TR>\n';
		toWrite += '<TD BGCOLOR="' + TopNavButtonBG + '" WIDTH="1" ID="TopNavButtonBG3' + thisNav + '"><IMG SRC="spacer.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD>\n';
		toWrite += '<TD BGCOLOR="' + TopNavButtonDimlight + '" WIDTH="1" COLSPAN="2" ID="TopNavDimlight1' + thisNav + '"><IMG SRC="spacer.gif" WIDTH="1" HEIGHT="1" BORDER="0"></TD>\n';
		toWrite += '</TR>\n';
		toWrite += '</TABLE>\n';
		document.write(toWrite);
		closeLayer();
	}
}
function navBarActivate()	{
	if (ns4up) {
		document.write('<LAYER NAME="topClear" LEFT="' + lefts[0] + '" TOP="' + TopNavigationGlobalTop + '" VISIBILITY="SHOW" Z-INDEX="11">\n');
document.write('<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR><TD NOWRAP>\n');
	} else {
		document.write('<DIV ID="topClear" STYLE="position:absolute;left:' + lefts[0] + 'px; top:' + TopNavigationGlobalTop + 'px;z-index:11;visibility:visible;">\n');
document.write('<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR><TD NOWRAP>\n');
	}
	for (i=0; i<navItems.length; i++)
	{
		var thisNav = navNames[i];
		if(menu[i].length > 0) document.write('<A HREF="' + topLevelLinks[i] + '" ONMOUSEOVER="layerOn(\'' + i + '\');topNavOn(true,\'' + thisNav + '\');" ONMOUSEOUT="slowLayerOff(\'' + i + '\');topNavOn(false,\'' + thisNav + '\');" TARGET="' + topLevelTargets[i] + '">');
		else document.write('<A HREF="' + topLevelLinks[i] + '" ONMOUSEOVER="topNavOn(true,\'' + thisNav + '\');" ONMOUSEOUT="topNavOn(false,\'' + thisNav + '\');" TARGET="' + topLevelTargets[i] + '">');
		document.write('<IMG SRC="spacer.gif" BORDER="0" WIDTH="' + widths[i] + '" HEIGHT="' + navHeight + '"></A>');
	}
	document.write('</TD></TR></TABLE>\n');
	closeLayer()
}

function topNavOn(on,nav) {
	if (ie4up)
	{
		document.all["TopNavButtonBG0" + nav].style.backgroundColor = (on) ? TopNavButtonOverBG : TopNavButtonBG;
		document.all["TopNavButtonBG1" + nav].style.backgroundColor = (on) ? TopNavButtonOverBG : TopNavButtonBG;
		document.all["TopNavButtonBG2" + nav].style.backgroundColor = (on) ? TopNavButtonOverBG : TopNavButtonBG;
		document.all["TopNavButtonBG3" + nav].style.backgroundColor = (on) ? TopNavButtonOverBG : TopNavButtonBG;
		document.all["TopNavButtonTop0" + nav].style.backgroundColor = (on) ? TopNavButtonOverTop : TopNavButtonTop;
		document.all["TopNavHighlight10" + nav].style.backgroundColor = (on) ? TopNavButtonOverHighlight1 : TopNavButtonHighlight1;
		document.all["TopNavHighlight20" + nav].style.backgroundColor = (on) ? TopNavButtonOverHighlight2 : TopNavButtonHighlight2;
		document.all["TopNavDimlight0" + nav].style.backgroundColor = (on) ? TopNavButtonOverDimlight : TopNavButtonDimlight;
		document.all["TopNavDimlight1" + nav].style.backgroundColor = (on) ? TopNavButtonOverDimlight : TopNavButtonDimlight;
	}
	else if(dom)
	{
		document.getElementById("TopNavButtonBG0" + nav).style.backgroundColor = (on) ? TopNavButtonOverBG : TopNavButtonBG;;
		document.getElementById("TopNavButtonBG1" + nav).style.backgroundColor = (on) ? TopNavButtonOverBG : TopNavButtonBG;;
		document.getElementById("TopNavButtonBG2" + nav).style.backgroundColor = (on) ? TopNavButtonOverBG : TopNavButtonBG;;
		document.getElementById("TopNavButtonBG3" + nav).style.backgroundColor = (on) ? TopNavButtonOverBG : TopNavButtonBG;
		document.getElementById("TopNavButtonTop0" + nav).style.backgroundColor = (on) ? TopNavButtonOverTop : TopNavButtonTop;
		document.getElementById("TopNavHighlight10" + nav).style.backgroundColor = (on) ? TopNavButtonOverHighlight1 : TopNavButtonHighlight1;
		document.getElementById("TopNavHighlight20" + nav).style.backgroundColor = (on) ? TopNavButtonOverHighlight2 : TopNavButtonHighlight2;
		document.getElementById("TopNavDimlight0" + nav).style.backgroundColor = (on) ? TopNavButtonOverDimlight : TopNavButtonDimlight;
		document.getElementById("TopNavDimlight1" + nav).style.backgroundColor = (on) ? TopNavButtonOverDimlight : TopNavButtonDimlight;
	}
}

// browser sniffer
var ns4up = (document.layers) ? 1 : 0;
var ie4up = (document.all) ? 1 : 0;
var ns6up = (document.getElementById&&!document.all) ? 1 : 0;

var browserDir ;
var styleString ;

if(ie4up){
	browserDir = ""
}
if(ns4up || ns6up){
	//browserDir = "nn/"
	browserDir = ""
}
//alert(browserDir) ; 
/*
styleString = "<LINK REL='STYLESHEET' TYPE='TEXT/CSS' HREF='" + browserDir + "'>\n" ;
styleString += "<LINK REL='STYLESHEET' TYPE='TEXT/CSS' HREF='" + browserDir + "'>\n" ;
document.writeln(styleString);
*/

function swap_image(image, new_src) {
	changeImage(image, new_src);
}

function changeImage(image_name, new_src) {
  if(image_name!=null) {
        image_name.src = new_src;
  }
}

function popup_window(theUrl,theWidth,theHeight,theBorder,theScroll,theResize,theToolbar,theMenubar) {
  var winProp = "toolbar="+ theToolbar +",location=no,directories=no,status=yes,menubar="+ theMenubar +",scrollbars="+ theScroll +",resizable="+ theResize +",copyhistory=no,width=" + theWidth + ",height=" + theHeight;
  popWindow=window.open(theUrl, 'popupWindow', winProp);
  popWindow.focus();
}

function openPopup(linkObj,height,width) { 
	window.open(linkObj.href,"","height="+height+",width="+width+",status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no,left=75,top=60");
}
function openPopup_NoScrollbars(linkObj,height,width) { 
	window.open(linkObj.href,"","height="+height+",width="+width+",status=no,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=yes,titlebar=no,left=75,top=60");
}
function openFlashPopup(linkObj,height,width) { 
	window.open(linkObj.href,"","height="+height+",width="+width+",status=no,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,titlebar=no,left=75,top=60");
}
function openFAQPopup(linkObj,height,width) { 
	window.open(linkObj.href,"","height="+height+",width="+width+",status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no,titlebar=no,left=75,top=60");
}
function openTextPopup(linkObj,height,width) { 
	window.open(linkObj.href,"","height="+height+",width="+width+",status=no,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,titlebar=no,left=75,top=60");
}
function openNewWindow(linkObj, height, width, window) {
	window.open(linkObj.href,"","height="+height+",width="+width +",top='0',left='0'");
}
function openNewWindow(linkObj){
	window.open(linkObj.href,"","top='0',left='0'");
}

function loadImage(image_name, image_src){
	image_name = new Image();
	image_name.src = image_src ;
}

function showContent(elemName,imgName, imgExpanded, imgCollapsed) {
	if (document.all || document.getElementById) {
		if (elemName.style.display == '') {
			elemName.style.display = 'none';
			imgName.src = imgCollapsed;
		}
		else {
			elemName.style.display = '';
			imgName.src = imgExpanded;
		}
	}
}
function dynamicPopUp(myObj){
	var str = "\"width=10,height=10,left=75,top=60,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no\"";
	window.open("dynamic-popup.htm?img="+myObj.href, "myPopup", str);	
	return false;	
}
function dynamicPagePopUp(myObj){	
	var str = "\"left=10,top=60,height=550,width=10,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no\"";
	window.open(myObj.href, "myPopup", str);	
	return false;
}

function modelesswin(url, mwidth, mheight){
	if (document.all && window.print) //if iexplorer
    	eval('window.showModelessDialog(url, "", "help:0;resizable:0;scroll:0;dialogWidth:'+mwidth+'px;dialogHeight:'+mheight+'px")')
    else //else netscape
    	eval('window.open(url, "", "width='+mwidth+'px, height='+mheight+'px, resizable=1, scrollbars=1")')
}
function openJam(){
	window.open('http://www.learnenglish.org.uk/profs_jam/interface.htm','J','width=600,height=490');
}

function changeLocation(url)
{
	if (url!="")
	{
		var redirectURL = url.substr(0, url.indexOf(";"));
		var re = new RegExp("_blank");
		if ( url.match(re) )
		{
			window.open(redirectURL,"_blank");
		}else{
			document.location=redirectURL;
		}
	}
}