var isNN4 = (document.layers) ? true : false;
var isIE4 = (document.all && !(document.getElementById)) ? true : false;
var isW3C = (document.getElementById) ? true : false;
var pc = navigator.appVersion.indexOf("Windows")>-1 || navigator.appVersion.indexOf("Win")>-1;
var mac = navigator.appVersion.indexOf("Macintosh") > -1;
var NS = browserName.indexOf("NETSCAPE") > -1;

var menuNames = new Array();
var topMenuNames = new Array();

var activeMenuLayerName = "";

var topLevelMenuItems = new Array();
var subLevelMenuItems = new Array();
 
var active_menu = "";
var active_submenu = "";
var atActiveMenu = false;
var current_menu_start_y_pos = 0;
var at_menu = 1;
var total_menus = 0;

var start_x = 0;
var start_y = 0;
var img_path = "/images/";

var slideSpeed = 100;

var onSuffix = "_on.gif";
var offSuffix = "_off.gif";
var activeSuffix = "_on.gif";

var transparent_image = "/images/spacer.gif";

var menuItemTimerID;
var menuTimerID;

////////////////////////////////////////////////////////////////////////////////////////
////////////////////////// Tool tip layers /////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
var curToolTip = null;
var toolTipNames = new Array();
var toolTipWidth = new Array();
var toolTipStr = new Array();
//var toolTipOffset = new Array();
var toolTipInc = 0;
var curToolTipIndex = 0;

function activateMouseEvent() {
	if (document.layers){
		document.captureEvents(Event.MOUSEMOVE);
	}
	document.onmousemove = moveToolTip;
	
}
function showToolTip(name) {
	var layer = getLayer(name);
	curToolTipIndex = findToolTipIndex(name);
	/*if (document.layers || document.getElementById &amp;&amp; NS)
		moveLayer(layer,e.pageX+10,e.pageY+10)
	else
		moveLayer(layer,event.clientX+10, event.clientY+10)*/
	curToolTip = layer;
	showLayer(layer);
}

function findToolTipIndex(name) {
	var i;
	for (i=0;i<toolTipNames.length;i++){
		if (toolTipNames[i] == name)
			return i;
	}
	return 0;
}

function hideToolTip(name) {
	hideLayer(getLayer(name));
	curToolTip = null;
}

function moveToolTip(evnt) {
	
	//var offset = toolTipOffset[curToolTipIndex] ? toolTipOffset[curToolTipIndex] : 0;
	if (curToolTip != null) {
		if ((document.layers || document.getElementById) && NS) {
			//moveLayer(curToolTip,evnt.pageX-100 + offset,evnt.pageY-25)
			moveLayer(curToolTip,evnt.pageX-(toolTipWidth[curToolTipIndex]/2),evnt.pageY-25)
			//alert(evnt.pageY);
		}
		else {
			//moveLayer(curToolTip,event.clientX-100 + offset,event.clientY-25)
			moveLayer(curToolTip,event.clientX-(toolTipWidth[curToolTipIndex]/2),event.clientY-25)
			//alert(event.clientY);
		}
	}
	
}

function createToolTip(name, tip, width) {
	var str = '<table cellpadding="1" cellspacing="0" border="0" bgcolor="#C2C2C2" background="/images/spacer.gif">'
	str += '<tr>'
	str += '<td valign="middle" align="center">'
	str += '<table cellpadding="1" cellspacing="0" border="0" bgcolor="#FFFFFF">'
	str += '<tr>'
	str += '<td class="default"><nobr><img src="/images/spacer.gif" width="2"/>'
	str += tip
	str += '<img src="/images/spacer.gif" width="2"/></nobr></td>'
	str += '</tr>'
	str += '</table>'
	str += '</td>'
	str += '</tr>'
	str += '</table>'
	createLayer(name,100,600,width,20,false,str);
}

function addToolTip(name, tip, width) {
	toolTipNames[toolTipInc] = name;
	toolTipWidth[toolTipInc] = width;
	toolTipStr[toolTipInc] = tip;
	//toolTipOffset[toolTipInc] = offset;
		
	toolTipInc ++;
}


/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
///////	This portion of the script has been placed here instead of an
/////// external js file because of Netscape's problem when loading multiple
/////// js files from cache.
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
function createLayer(name, left, top, width, height, visible, content) {
	var layer;

	if (document.layers) {
		document.writeln('<layer name="' + name + '" left=' + left + ' top=' + top + ' width=' + width + ' height=' + height +  ' visibility=' + (visible ? '"show"' : '"hide"') + '>');
		document.writeln(content);
		document.writeln('</layer>');
		layer = getLayer(name);
		layer.width = width;
		layer.height = height;
	}

	if (isIE4 || isW3C) {
		document.writeln('<div id="' + name + '" style="position:absolute; overflow:hidden; left:' + left + 'px; top:' + top + 'px; width:' + width + 'px; height:' + height + 'px;' + ' visibility:' + (visible ? 'visible;' : 'hidden;') + '">');
		document.writeln(content);
		document.writeln('</div>');
	}

	clipLayer(getLayer(name), 0, 0, width, height);
}

function createLayer2(name, left, top, width, height, visible, content, position) {
	var layer;

	if (document.layers) {
		document.writeln('<layer name="' + name + '" position="' + position + '" left=' + left + ' top=' + top + ' width=' + width + ' height=' + height +  ' visibility=' + (visible ? '"show"' : '"hide"') + '>');
		document.writeln(content);
		document.writeln('</layer>');
		layer = getLayer(name);
		layer.width = width;
		layer.height = height;
	}

	if (isIE4 || isW3C) {
		document.writeln('<div id="' + name + '" style="position:' + position + '; overflow:hidden; left:' + left + 'px; top:' + top + 'px; width:' + width + 'px; height:' + height + 'px;' + ' visibility:' + (visible ? 'visible;' : 'hidden;') + '">');
		document.writeln(content);
		document.writeln('</div>');
	}

	clipLayer(getLayer(name), 0, 0, width, height);
}


function clipLayer(layer, clipleft, cliptop, clipright, clipbottom) {
	if (document.layers) {
		layer.clip.left   = clipleft;
		layer.clip.top    = cliptop;
		layer.clip.right  = clipright;
		layer.clip.bottom = clipbottom;
	}

	if (isIE4 || isW3C)
		layer.clip = 'rect(' + cliptop + ' ' +  clipright + ' ' + clipbottom + ' ' + clipleft +')';
}

function getWinWidth() {

	if(document.layers)
		return (window.innerWidth);
	else{
		if(document.body.clientWidth)
			return document.body.clientWidth;

		if(innerWidth)
			return innerWidth;
	}

	return null;
}

function replaceContent(name, content, fontFace, fontSize) {
	var target = document.getElementById(name);

	if (target) {
		target.innerHTML = content;
	}
}

function replace(stringValue, oldValue, newValue){
	var tempValue = new Array();
	tempValue = stringValue.split( oldValue );
		
	stringValue = "";
	
	for(i = 0; i <= tempValue.length - 1; i++){
		if(i != tempValue.length - 1)
			stringValue += tempValue[i] + newValue;
		else
			stringValue += tempValue[i];
	}
	
	return stringValue;
}

function getLayer(name) {
	if (isIE4) return(eval('document.all.' + name));
	else if (document.layers)	return(findLayer(name, document));
	else if (isW3C) return(document.getElementById(name));
	return null;
}

function findLayer(name, doc) {

  var i, layer;

  for (i = 0; doc.layers.length > i ; i++) {
    layer = doc.layers[i];
    if (layer.name == name)
      return layer;
    if (layer.document.layers.length > 0) {
      layer = findLayer(name, layer.document);
      if (layer != null)
        return layer;
    }
  }

  return null;
}

function invisibleLayer(layer) {	
	if (isIE4 || isW3C) layer.style.visibility = "hidden";
	else if (document.layers) layer.visibility = "hide";  
}

function displayLayer(layer) {
	if (isIE4 || isW3C) layer.style.visibility = "visible";
	else if (document.layers) layer.visibility = "show";    
}
function hideLayer(layer) {	
	//if (isIE4 || isW3C) layer.style.visibility = "hidden";
	//else if (document.layers) layer.visibility = "hide";  
}

function showLayer(layer) {
	//if (isIE4 || isW3C) layer.style.visibility = "visible";
	//else if (document.layers) layer.visibility = "show";    
}

function moveLayer(layer, x, y) {
	if (isIE4 || isW3C){
		layer.style.left = x;
	    layer.style.top  = y;
	}
	else if(document.layers)
	    layer.moveTo(x, y);
}

function getTop(layer) {
	if (isIE4 || isW3C)
		return(layer.style.pixelTop);
	else if (document.layers)
		return(layer.top);
	else
		return(null);
}

function makeArray(a) {
	var temp;

	if (!a.join){
		temp = a;
		a = new Array();
		a[0] = temp;
	}

	return a;
}

var animRate = 10;
function slideLayer(name, x, y, speed, code) {
	var layer = getLayer(name);

	// If the layer is currently being moved, cancel it.
	if (layer.slideID && layer.slideID != null)
		clearTimeout(layer.slideID);

	// Fix up all parameters.
	if (!code)
		code = "";

	// If any parameter other than 'name' is not an Array, make it one.
	x     = makeArray(x);
	y     = makeArray(y);
	speed = makeArray(speed);
	code  = makeArray(code);

	// Pad all arrays to the same length.
	var max = Math.max(x.length, Math.max(y.length, Math.max(speed.length, code.length)));
	while (max > x.length)
		x[x.length] = x[x.length - 1];
	while (max > y.length)
		y[y.length] = y[y.length - 1];
	while (max > speed.length)
		speed[speed.length] = speed[speed.length - 1];
	while (max > code.length)
		code[code.length] = code[code.length - 1];

	// Call the slide function with array parameters.
	doSlide(name, x, y, speed, code);
}

function doSlide(name, x, y, speed, code) {
	var layer = getLayer(name);
	var hrzn, vert, left, top, steps;
	
	if (document.layers) {
		hrzn = x[0] - layer.left;
		vert = y[0] - layer.top;
		left = layer.left;
		top  = layer.top;
	}

	if (isIE4 || isW3C) {		
		hrzn = x[0] - parseInt(layer.style.left);
		vert = y[0] - parseInt(layer.style.top);
		left = parseInt(layer.style.left);
		top  = parseInt(layer.style.top);
	}

	// Calculate how many steps it will take and the size of each step.
	steps = (Math.max(Math.abs(hrzn), Math.abs(vert)) / speed[0]) * (1000 / animRate);
	
	if (0 >= steps)
		return;
		
	// Save remaining array values.
	layer.slideX     = x.slice(1, x.length);
	layer.slideY     = y.slice(1, y.length);
	layer.slideSpeed = speed.slice(1, speed.length);
	layer.slideCode  = code.slice(1, code.length);

	// Set up movement values.
	layer.slideLeft   = left;
	layer.slideTop    = top;
	layer.slideDx     = hrzn / steps;
	layer.slideDy     = vert / steps;
	layer.slideFinalX = x[0];
	layer.slideFinalY = y[0];
	layer.slideSteps  = Math.floor(steps);
	layer.slideAction = code[0];
	
	// Start the slide.
	slideStep(name);
}

function slideStep(name) {

	// Moves the layer one step.
	var layer = getLayer(name);

	layer.slideLeft += layer.slideDx;
	layer.slideTop  += layer.slideDy;
	
	if (document.layers)
		layer.moveTo(layer.slideLeft, layer.slideTop);
	if (isIE4 || isW3C) {
		layer.style.left = layer.slideLeft;
		layer.style.top  = layer.slideTop;
	}

	// If more steps remain, call this function again.

	if (layer.slideSteps-- > 0)
		layer.slideID = setTimeout('slideStep("' + name + '")', animRate);

	// Otherwise, move layer to final position, execute any code and look for more slide parameters.
	else {
		if (document.layers)
			layer.moveTo(layer.slideFinalX, layer.slideFinalY);
		if (isIE4 || isW3C) {
			layer.style.left = layer.slideFinalX;
			layer.style.top  = layer.slideFinalY;
		}

		// Execute code, if any.

		layer.slideID = null;
		if (layer.slideAction != "")
			eval(layer.slideAction);

		// If any more slide parameters are left, start a new slide.
		if (layer.slideX.length > 0)
			doSlide(name, layer.slideX, layer.slideY, layer.slideSpeed, layer.slideCode);
		else
			layer.slideID = null;
	}
}

function getResolutionWidth(){
	if(document.layers || isIE4 || isW3C)
		return screen.width;
	else
		return 0;
}

function getResolutionHeight(){
	if(document.layers || isIE4 || isW3C)
		return screen.height
	else
		return 0;
}

/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////



/////////////////////////////////////////////////////////////////////////////////////////
// Top menu functions
///////////////////////////////////////////////////////////////////////////////////////
function createTopMenu(name, child, x, y, menuItemWidth, menuItemHeight, borderWidth, menuItemColors, menuImage_on, menuImage_off, menuValues, image_on){
	var menuStr = "";

	var transparentContent = '';
		
	if(isIE4 || isW3C)
		transparentContent = '<img src="/images/spacer.gif" width=150 height=18 border=0 alt="">';
		
	menuStr += getMenuItemStr(name + "_item_off", borderWidth+10, borderWidth, menuItemWidth, menuItemHeight-borderWidth, true, '<img src="/images/spacer.gif" width="1" height="1" border="0" alt="">', menuValues, menuItemColors[0], "topmenuoff");
	menuStr += getMenuItemStr(name + "_item_on", borderWidth+10, borderWidth, menuItemWidth, menuItemHeight-borderWidth, false, '<img src="/images/spacer.gif" width="1" height="1" border="0" alt="">', menuValues, menuItemColors[1], "topmenuon");
	menuStr += getMenuItemStr(name + "_item_transparent", borderWidth, borderWidth, menuItemWidth, menuItemHeight-borderWidth, true, "", transparentContent,  "", "");
	
	menuStr += getMenuItemStr(name + "_img_on", borderWidth, borderWidth+2, 12, 13, image_on, '<img src="' + menuImage_on + '" border="0" name="img1"/>', "",  "", "");
	
	menuStr += getMenuItemStr(name + "_img_off", borderWidth, borderWidth+2, 12, 13, !image_on, '<img src="' + menuImage_off + '" border="0" name="img1"/>', "",  "", "");
	
	menuStr = getMenuStr(name, x, y, menuItemWidth + (borderWidth * 2), borderWidth + menuItemHeight, true, menuStr, menuItemColors[2]);
	
	
	/* ****** At this point the menu layer is ready to be created and therefore is written to the document  ****** */
	
	document.write(menuStr);  
	
	transparentLayer = getLayer(name + "_item_transparent");
	transparentLayer.OFFLAYER = name + "_item_off";
	transparentLayer.ONLAYER = name + "_item_on";
	
	transparentLayer.OFFIMGLAYER = name + "_img_off";
	transparentLayer.ONIMGLAYER = name + "_img_on";
	
	transparentLayer.CHILD = child;
	transparentLayer.onmouseover = topMenuItemOn;
	transparentLayer.onmouseout = topMenuItemOff;
		
	if(isNN4){
//			transparentLayer.document.STATUSLINE = menuItemValues[i - 1][1];
			//transparentLayer.document.URLTOGOTO = menuItemValues[i - 1][2];
			
		transparentLayer.document.onclick = new Function('showLayer(getLayer("' + transparentLayer.OFFIMGLAYER + '")); showLayer(getLayer("'+child+'")); return false;')
	}
	else if(isIE4 || isW3C){
//			transparentLayer.STATUSLINE = menuItemValues[i - 1][1];
			//transparentLayer.URLTOGOTO = menuItemValues[i - 1][2];
		//transparentLayer.onclick = showChildLayer; 
		transparentLayer.onclick = new Function('showLayer(getLayer("' + transparentLayer.OFFIMGLAYER + '"));showLayer(getLayer("'+child+'")); return false;')
	}
		
	
}


function createTopMenuItems(name, parent, x, y, menuItemWidth, menuItemHeight, borderWidth, menuItemColors, menuItemValues){
	var menuStr = "";

	for (i = 1; i <= menuItemValues.length; i++){
		var transparentContent = '';
		
		if(isIE4 || isW3C)
			//transparentContent = '<a href="' + menuItemValues[i - 1][2] + '"><img src="/images/spacer.gif" width="' + (menuItemWidth - (borderWidth*2) - 5) + '" height="' + (menuItemHeight - (borderWidth*2) - 5) + '" border=0 alt=""></a>';
			transparentContent = '<img src="/images/spacer.gif" width="' + (menuItemWidth - (borderWidth*2) - 5) + '" height="' + (menuItemHeight - (borderWidth*2) - 5) + '" border=0 alt="">';
			//transparentContent = '<img src="/images/spacer.gif" width=150 height=18 border=0 alt="">';
			
		menuStr += getMenuItemStr(name + "_item" + i + "_off", borderWidth, borderWidth + ((i - 1) * menuItemHeight), menuItemWidth, menuItemHeight-borderWidth, true, menuItemValues[i - 1][3], menuItemValues[i - 1][0], menuItemColors[0], "topmenuoff");
		menuStr += getMenuItemStr(name + "_item" + i + "_on", borderWidth, borderWidth + ((i - 1) * menuItemHeight), menuItemWidth, menuItemHeight-borderWidth, false, menuItemValues[i - 1][3], menuItemValues[i - 1][0],  menuItemColors[1], "topmenuon");
		menuStr += getMenuItemStr(name + "_item" + i + "_transparent", borderWidth, borderWidth + ((i - 1) * menuItemHeight), menuItemWidth, menuItemHeight-borderWidth, true, "", transparentContent, "", "");
	}

	menuStr = getMenuStr(name, x, y, menuItemWidth + (borderWidth * 2), (borderWidth) + (menuItemValues.length * menuItemHeight), false, menuStr, menuItemColors[2]);
	
	
	/* ****** At this point the menu layer is ready to be created and therefore is written to the document  ****** */
	
	document.write(menuStr);  
	
	for (i = 1; i <= menuItemValues.length; i++){
		transparentLayer = getLayer(name + "_item" + i + "_transparent");

		transparentLayer.OFFLAYER = name + "_item" + i + "_off";
		transparentLayer.ONLAYER = name + "_item" + i + "_on";
		transparentLayer.PARENT = parent;
		transparentLayer.onmouseover = topMenuItemOn;
		transparentLayer.onmouseout = topMenuItemOff;
		
		if(isNN4){
//			transparentLayer.document.STATUSLINE = menuItemValues[i - 1][1];
			//transparentLayer.document.URLTOGOTO = menuItemValues[i - 1][2];
			transparentLayer.document.onclick =  new Function('location.href = "' + menuItemValues[i - 1][2] + '"; return false;'); 
		}
		else if(isIE4 || isW3C){
//			transparentLayer.STATUSLINE = menuItemValues[i - 1][1];
			//transparentLayer.URLTOGOTO = menuItemValues[i - 1][2];
			transparentLayer.onclick =  new Function('location.href = "' + menuItemValues[i - 1][2] + '"; return false;'); 
		}
	}
	
	/* **************** The following lines assign event handlers to the entire menu layer ************************** */
	menuLayer = getLayer(name);
	//menuLayer.ACTIVE = false;
	menuLayer.onmouseover = showMenuLayer;
	menuLayer.onmouseout = hideMenuLayer;
	/* *************************** add new created menu to menuNames ********************************************** */
	topMenuNames[menuNames.length] = name;
	/* ************************************************************************************************************************ */
	
}

function hideTopMenuItem(name, img){
	hideLayer(getLayer(name));
}

function hideAllTopMenuItemsLayers(){
	for(i = 0; i <= topMenuNames.length - 1; i++)
		hideTopMenuItem(topMenuNames[i]);
}

function showTopMenuItem(name, img){
	hideAllTopMenuItemsLayers();
	showLayer(getLayer(name));
}


function topMenuItemOn(){
	
	showLayer(getLayer(this.ONLAYER));
	
	// For childs
	//if (this.PARENT && !topMenuStatus[this.PARENT]) { showLayer(getLayer(this.PARENT + '_item_on')); topMenuStatus[this.PARENT] = true;}
	
	if (menuItemTimerID) clearTimeout(menuItemTimerID);
	
	if (menuTimerID)  clearTimeout(menuTimerID);
}

function topMenuItemOff(){
	
	if (this.PARENT)
		menuTimerID = setTimeout("hideLayer(getLayer('"+ this.PARENT + "_item_on'))", 100); 
	
	if (this.CHILD) { 
		menuTimerID = setTimeout("hideLayer(getLayer('"+ this.ONLAYER + "'))", 100); 
		menuItemTimerID = setTimeout("hideLayer(getLayer('"+ this.CHILD + "'))", 100);
	}
	else 
		hideLayer(getLayer(this.ONLAYER));
	
	//if (this.CHILD) 
	
	//if (this.PARENT && topMenuStatus[this.PARENT]) { hideLayer(getLayer(this.PARENT + '_item_on')); topMenuStatus[this.PARENT] = false; }
}


//////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////

function createMenu(menuItemValues){
	var name = "menu" + this.at_menu;
	var menuStr = "";
	var transparentContent = '';
	
	var menu_width = 0;
	var menu_height = 0;
	var y_at = 0;

	for (i = 1; i <= menuItemValues.length; i++){
		transparentContent = '';

		if (!document.layers){
			if (pc)
				transparentContent = '<a href="#" onClick="return false;"><img src="' + this.transparent_image + '" width=' + menuItemValues[i - 1][3] + ' height=' + menuItemValues[i - 1][4] + ' border=0 alt=""></a>';
			else
				transparentContent = '<img src="' + this.transparent_image + '" width=' + menuItemValues[i - 1][3] + ' height=' + menuItemValues[i - 1][4] + ' border=0 alt="">';
		}

//		if(this.active_menu == menuItemValues[i - 1][0] || this.active_submenu == menuItemValues[i - 1][0])
		if(this.active_submenu == menuItemValues[i - 1][0])
			menuStr += getMenuItemStr(name + "_item" + i + "_off", 0, y_at, menuItemValues[i - 1][3], menuItemValues[i - 1][4], true, "<img src=\"" + this.img_path + menuItemValues[i - 1][0] + activeSuffix + "\" width=\"" + menuItemValues[i - 1][3] + "\" height=\"" + menuItemValues[i - 1][4] + "\" border=\"0\"" + ">");
		else
			menuStr += getMenuItemStr(name + "_item" + i + "_off", 0, y_at, menuItemValues[i - 1][3], menuItemValues[i - 1][4], true, "<img src=\"" + this.img_path + menuItemValues[i - 1][0] + offSuffix + "\" width=\"" + menuItemValues[i - 1][3] + "\" height=\"" + menuItemValues[i - 1][4] + "\" border=\"0\"" + ">");

		menuStr += getMenuItemStr(name + "_item" + i + "_on", 0, y_at, menuItemValues[i - 1][3], menuItemValues[i - 1][4], false, "<img src=\"" + this.img_path + menuItemValues[i - 1][0] + onSuffix + "\" width=\"" + menuItemValues[i - 1][3] + "\" height=\"" + menuItemValues[i - 1][4] + "\" border=\"0\"" + ">");
		menuStr += getMenuItemStr(name + "_item" + i + "_transparent", 0, y_at, menuItemValues[i - 1][3], menuItemValues[i - 1][4], true, transparentContent);
		
		y_at += menuItemValues[i - 1][4];
		menu_width = getMax(menu_width, menuItemValues[i - 1][3]);
	}
	
	menu_height = y_at;

	menuStr = getMenuStr(name, start_x, start_y, menu_width, menu_height, true, menuStr);

	if(this.active_menu == menuItemValues[0][0])
		this.atActiveMenu = true;
	else
		this.atActiveMenu = false;
	
	if(this.atActiveMenu)
		this.start_y = this.start_y + menu_height;
	else
		this.start_y = this.start_y + menuItemValues[0][4];

// At this point the menu layer is ready to be created and therefore is written to the document
	
	document.write(menuStr); 
	
//The transparent layer will be used to handle the event handlers.
	
	for (i = 1; i <= menuItemValues.length; i++){
		
		transparentLayer = getLayer(name + "_item" + i + "_transparent");	
		
		transparentLayer.onmouseover = menuItemOn;
		transparentLayer.onmouseout = menuItemOff;
				
		if(isIE4 || isW3C){
			transparentLayer.OFFLAYER = name + "_item" + i + "_off";
			transparentLayer.ONLAYER = name + "_item" + i + "_on";
			transparentLayer.TRANSPARENT = name + "_item" + i + "_transparent";
			transparentLayer.STATUSLINE = menuItemValues[i - 1][1];
			transparentLayer.URLTOGOTO = menuItemValues[i - 1][2];
			transparentLayer.PARENTNAME = name;
			transparentLayer.PARENTMENUHEIGHT = menu_height;
			transparentLayer.PARENTMENUSTART_X = start_x;
			transparentLayer.PARENTMENUSTART_Y = current_menu_start_y_pos;
			transparentLayer.INDEX = i;
			transparentLayer.TOTALMENUS = this.total_menus;
			transparentLayer.onclick = handleClick;


/* ****************************************************************** */
/* ***************** Temporary solution ***************************** */
/* ****************************************************************** */
			if(i == 1 && menuItemValues[0][0] == active_menu){
				transparentLayer.ACTIVE = true;
				showLayer(getLayer(transparentLayer.ONLAYER));
			}
			else
				transparentLayer.ACTIVE = false;
				
//			transparentLayer.ACTIVE = false;
/* ****************************************************************** */
			
			if(i == 1){
				transparentLayer.DOSLIDE = menuItemValues[i - 1][5];
				transparentLayer.TOP_LEVEL_MENU = true;
				transparentLayer.TOP_LEVEL_MENU_ON = false;
				transparentLayer.SUB_LEVEL_MENU = false;
				transparentLayer.SUB_LEVEL_MENU_ON = false;
				this.topLevelMenuItems[this.topLevelMenuItems.length] = name + "_item" + i + "_transparent";
			}
			else{
				transparentLayer.DOSLIDE = false;
				transparentLayer.TOP_LEVEL_MENU = false;
				transparentLayer.TOP_LEVEL_MENU_ON = false;
				transparentLayer.SUB_LEVEL_MENU = true;
				transparentLayer.SUB_LEVEL_MENU_ON = false;
				this.subLevelMenuItems[this.subLevelMenuItems.length] = name + "_item" + i + "_transparent";
			}
		}
		else if(document.layers){
			transparentLayer.document.NAME = name + "_item" + i + "_transparent";
			transparentLayer.document.OFFLAYER = name + "_item" + i + "_off";
			transparentLayer.document.ONLAYER = name + "_item" + i + "_on";
			transparentLayer.document.TRANSPARENT = name + "_item" + i + "_transparent";
			transparentLayer.document.STATUSLINE = menuItemValues[i - 1][1];
			transparentLayer.document.URLTOGOTO = menuItemValues[i - 1][2];
			transparentLayer.document.PARENTNAME = name;
			transparentLayer.document.PARENTMENUHEIGHT = menu_height;
			transparentLayer.document.PARENTMENUSTART_X = start_x;
			transparentLayer.document.PARENTMENUSTART_Y = current_menu_start_y_pos;
			transparentLayer.document.INDEX = i;
			transparentLayer.document.TOTALMENUS = this.total_menus;
			if(pc)
				transparentLayer.document.onclick = handleClick;
			else
				transparentLayer.document.onmousedown = handleClick;
			
/* ****************************************************************** */
/* ***************** Temporary solution ***************************** */
/* ****************************************************************** */
			if(i == 1 && menuItemValues[0][0] == active_menu){
				transparentLayer.document.ACTIVE = true;
				showLayer(getLayer(transparentLayer.document.ONLAYER));
			}
			else
				transparentLayer.document.ACTIVE = false;
				
//			transparentLayer.document.ACTIVE = false;
/* ****************************************************************** */

			
			
			if(i == 1){
				transparentLayer.document.DOSLIDE = menuItemValues[i - 1][5];
				transparentLayer.document.TOP_LEVEL_MENU = true;
				transparentLayer.document.TOP_LEVEL_MENU_ON = false;
				transparentLayer.document.SUB_LEVEL_MENU = false;
				transparentLayer.document.SUB_LEVEL_MENU_ON = false;
				this.topLevelMenuItems[this.topLevelMenuItems.length] = name + "_item" + i + "_transparent";
			}
			else{
				transparentLayer.document.DOSLIDE = false;
				transparentLayer.document.TOP_LEVEL_MENU = false;
				transparentLayer.document.TOP_LEVEL_MENU_ON = false;
				transparentLayer.document.SUB_LEVEL_MENU = true;
				transparentLayer.document.SUB_LEVEL_MENU_ON = false;
				this.subLevelMenuItems[this.subLevelMenuItems.length] = name + "_item" + i + "_transparent";
			}
		}
		
	}
	
	// The following lines assign event handlers to the entire menu layer 
	menuLayer = getLayer(name);
	
	menuLayer.NAME = name;
	menuLayer.START_X = start_x;
	menuLayer.START_Y = current_menu_start_y_pos;
	menuLayer.MENUHEIGHT = menu_height;
	menuLayer.FIRSTMENUITEM_HEIGHT = menuItemValues[0][4];
	menuNames[menuNames.length] = name;

	current_menu_start_y_pos += menuItemValues[0][4];		
	this.at_menu++;
}

function createMenuItemEntry(arrayName, text, statusline, hyperlink, width, height, slide){
	var index = arrayName.length;
	arrayName[index] = new Array();
	
	arrayName[index][0] = text;
	arrayName[index][1] = statusline;
	arrayName[index][2] = hyperlink;
	arrayName[index][3] = width;
	arrayName[index][4] = height;
	arrayName[index][5] = slide;
}

function getCurrentActiveTopMenuLayer(){
	var layer = null;
	var activeLayer = null;
	
	if(isIE4 || isW3C){
		for(i = 0; i <= this.topLevelMenuItems.length -1; i++){
			layer = getLayer(this.topLevelMenuItems[i]);

			if(layer.ACTIVE)
				activeLayer = layer;
		}
	}
	else if(document.layers){
		for(i = 0; i <= this.topLevelMenuItems.length -1; i++){
			layer = getLayer(this.topLevelMenuItems[i]);

			if(layer.document.ACTIVE)
				activeLayer = layer;
		}
	}
	
	return activeLayer;
}

function getCurrentActiveSubMenuLayer(){
	var layer = null;
	var activeLayer = null;
	
	if(isIE4 || isW3C){
		for(i = 0; i <= this.subLevelMenuItems.length -1; i++){
			layer = getLayer(this.subLevelMenuItems[i]);

			if(layer.ACTIVE)
				activeLayer = layer;
		}
	}
	else if(document.layers){
		for(i = 0; i <= this.subLevelMenuItems.length -1; i++){
			layer = getLayer(this.subLevelMenuItems[i]);

			if(layer.document.ACTIVE)
				activeLayer = layer;
		}
	}

	return activeLayer;
}

function turnOffAllTopMenuLayers(){
	var layer = null;
	
	if(isIE4 || isW3C){
		for(i = 0; i <= this.topLevelMenuItems.length -1; i++){
			layer = getLayer(this.topLevelMenuItems[i]);
			hideLayer(getLayer(layer.ONLAYER));
		}
	}
	else if(document.layers){
		for(i = 0; i <= this.topLevelMenuItems.length -1; i++){
			layer = getLayer(this.topLevelMenuItems[i]);
			hideLayer(getLayer(layer.document.ONLAYER));
		}
	}
}

function turnOffAllSubMenuLayers(){
	var layer = null;
	
	if(isIE4 || isW3C){
		for(i = 0; i <= this.subLevelMenuItems.length -1; i++){
			layer = getLayer(this.subLevelMenuItems[i]);
			hideLayer(getLayer(layer.ONLAYER));
		}
	}
	else if(document.layers){
		for(i = 0; i <= this.subLevelMenuItems.length -1; i++){
			layer = getLayer(this.subLevelMenuItems[i]);
			hideLayer(getLayer(layer.document.ONLAYER));
		}
	}
}

function menuItemOn(){
	if(isIE4 || isW3C){
		if(this.TOP_LEVEL_MENU && !this.ACTIVE)
			showLayer(getLayer(this.ONLAYER));
		else if(this.SUB_LEVEL_MENU && !this.ACTIVE)
			showLayer(getLayer(this.ONLAYER));

		window.status = this.STATUSLINE;
	}
	else if(document.layers){
		if(this.document.TOP_LEVEL_MENU && !this.document.ACTIVE)
			showLayer(getLayer(this.document.ONLAYER));
		else if(this.document.SUB_LEVEL_MENU && !this.document.ACTIVE)
			showLayer(getLayer(this.document.ONLAYER));

		window.status = this.document.STATUSLINE;
	}
}

function menuItemOff(){
	if(isIE4 || isW3C){
		if(!this.ACTIVE)
			hideLayer(getLayer(this.ONLAYER));
	}
	else if(document.layers){
		if(!this.document.ACTIVE)
			hideLayer(getLayer(this.document.ONLAYER));
	}	
}


function setActiveState(layer, state){
	if(isIE4 || isW3C)
		layer.ACTIVE = state;
	else if (document.layers)
		layer.ACTIVE = state;
}

function showMenuLayer(){
//	this.ACTIVE = true;
	showLayer(this);
	
}

function hideMenuLayer(){
//	this.ACTIVE = false;
	hideLayer(this);
}

function handleClick(){
	/* *********************************************************************************** */
	/* *********************** Handle Top Level Menu Roll Overs ************************** */
	/* *********************************************************************************** */
	if(isIE4 || isW3C){
		if(this.TOP_LEVEL_MENU){
			turnOffAllTopMenuLayers();
			turnOffAllSubMenuLayers();
			var activeTopLayer = getCurrentActiveTopMenuLayer();
			var activeSubLayer = getCurrentActiveSubMenuLayer();

			if(activeTopLayer != null)
				activeTopLayer.ACTIVE = false;

			if(activeSubLayer != null)
				activeSubLayer.ACTIVE = false;

			this.ACTIVE = true;
			showLayer(getLayer(this.ONLAYER));
		}
		else if(this.SUB_LEVEL_MENU){
			turnOffAllSubMenuLayers();
			var activeSubLayer = getCurrentActiveSubMenuLayer();
			
			if(activeSubLayer != null)
				activeSubLayer.ACTIVE = false;

			this.ACTIVE = true;
			showLayer(getLayer(this.ONLAYER));
		}
	}
	else if(document.layers){
		if(this.TOP_LEVEL_MENU){
			turnOffAllTopMenuLayers();
			turnOffAllSubMenuLayers();
			var activeTopLayer = getCurrentActiveTopMenuLayer();
			var activeSubLayer = getCurrentActiveSubMenuLayer();

			if(activeTopLayer != null)
				activeTopLayer.document.ACTIVE = false;

			if(activeSubLayer != null)
				activeSubLayer.document.ACTIVE = false;

			this.ACTIVE = true;
			showLayer(getLayer(this.ONLAYER));
		}
		else if(this.SUB_LEVEL_MENU){
			turnOffAllSubMenuLayers();
			var activeSubLayer = getCurrentActiveSubMenuLayer();
			
			if(activeSubLayer != null)
				activeSubLayer.document.ACTIVE = false;
			
			this.ACTIVE = true;
			showLayer(getLayer(this.ONLAYER));
		}
	}
	/* *********************************************************************************** */
	/* *********************** End of Top Level Menu Roll Overs ************************** */
	/* *********************************************************************************** */


	/* *********************************************************************************** */
	/* ******** PERFORM SLIDING IF USER SELECTS MAIN MENU (FIRST MENU ITEM) ************** */
	/* *********************************************************************************** */

	if(this.DOSLIDE){
		var currentLayerFound = false;
		var atCurrentLayer = false;
		var currentParentMenuLayer = getLayer(this.PARENTNAME);
		
		var next_y = 0;
		
		for(i = 1; i <= this.TOTALMENUS; i++){
			var layer = getLayer("menu" + i);
			
			if(currentParentMenuLayer.NAME == layer.NAME){
				currentLayerFound = true;
				atCurrentLayer = true;
			}
			else
				atCurrentLayer = false;
			
			if(!currentLayerFound || atCurrentLayer){
				if(mac && (isIE4 || isW3C))
					moveLayer(layer, layer.START_X, layer.START_Y);
				else
					slideLayer(layer.NAME, layer.START_X, layer.START_Y, slideSpeed, '');

				next_y = layer.START_Y + layer.MENUHEIGHT;
			}
			else{
				if(mac && (isIE4 || isW3C))
					moveLayer(layer, layer.START_X, next_y);
				else
					slideLayer(layer.NAME, layer.START_X, next_y, slideSpeed, '');

				next_y = next_y + layer.FIRSTMENUITEM_HEIGHT;
			}
		}
	}
	/* *********************************************************************************** */
	/* ***************************** END OF SLIDING ************************************** */
	/* *********************************************************************************** */

	if(this.URLTOGOTO != "#")
		top.location.href = this.URLTOGOTO;
}

function setActiveMenus(active_menu, active_submenu){
	this.active_menu = active_menu;
	
	if(active_submenu == "ED192P" || active_submenu == "BD192M")
		this.active_submenu = "BD192P";
	else if(active_submenu == "BD69SP" || active_submenu == "BL69SP" || active_submenu == "CH96ST" || active_submenu == "BN96ST")
		this.active_submenu = "BH96ST";
	else
		this.active_submenu = active_submenu;
}

function setImagesPath(path){
	this.img_path = path;
}

function getMax(a, b){
	if(a >= b)
		return a;
	else
		return b;
}

function setXY(x, y){
	this.start_x = x;
	this.start_y = y;
	this.current_menu_start_y_pos = y;
}

function setTotalMenu(total){
	this.total_menus = total;
}

function setTransparentImage(img){
	this.transparent_image = img;
}

function setSlideSpeed(speed){
	this.slideSpeed = speed;
}

function setOnSuffix(suffix){
	this.onSuffix = suffix;
}

function setOffSuffix(suffix){
	this.offSuffix = suffix;
}

function setActiveSuffix(suffix){
	this.activeSuffix = suffix;
}


/* *********************************************************************************** */
/* *********************************************************************************** */
// The following function is incomplete. It only moves the menu based on
// the x coordinate. The y coordinate is ignored but captured for later completion
// of the function.
/* *********************************************************************************** */
/* *********************************************************************************** */
function moveMenu(x, y){
	var layer;
	
	for(i = 1; i <= this.total_menus; i++){
		layer = getLayer("menu" + i);
		layer.START_X = x;
		moveLayer(layer, layer.START_X, getTop(layer));
	}
}
/* *********************************************************************************** */
/* *********************************************************************************** */

function getMenuItemStr(name, x, y, width, height, visible, content) {
	var layerStr;
	if (arguments.length > 8) {
		if (isNN4) {
    		layerStr = '<layer name="' + name + '" bgcolor="#' + arguments[8] + '" left=' + x + ' top=' + y + ' width=' + width +  ' height=' + height + ' visibility=' + (visible ? '"inherit"' : '"hide"') + '>\n';
			layerStr = layerStr +'<table cellspacing=0 cellpadding=2 border=0 height=' + height + ' align="top" valign="top">\n';
			layerStr = layerStr + '<tr><td valign="middle" class="'+ arguments[9] + '">';	
		    layerStr = layerStr + content;
			layerStr = layerStr + '</td><td valign="middle" class="'+ arguments[9] + '">' + arguments[7] + '</td></tr>\n';
			layerStr = layerStr + '</table>\n';
		    layerStr = layerStr + '</layer>\n';
		}

  		if (isIE4 || isW3C) {
		    layerStr = '<div id="' + name + '" style="position:absolute; z-index:2; overflow:hidden; background-color:#' + arguments[8] + '; left:' + x + 'px; top:' + y +'px; width:' + width + 'px;' + ' height:' + height +'px; visibility:' + (visible ? 'inherit;' : 'hidden;') + '">\n';
			layerStr = layerStr +'<table cellspacing=0 cellpadding=2 border=0 height=' + height + '>\n';
			layerStr = layerStr + '<tr><td valign="middle" class="'+ arguments[9] + '">';	
			layerStr = layerStr +  content 
			layerStr = layerStr + '</td><td valign="middle" class="'+ arguments[9] + '">' + arguments[7] + '</td></tr>\n';
			layerStr = layerStr + '</table>\n';
		    layerStr = layerStr + '</div>\n';
		}
	}
	else {
		if (isIE4 || isW3C) {
			layerStr = '<div id="' + name + '" style="position:absolute; z-index:2; overflow:hidden; left:' + x + 'px; top:' + y +'px; width:' + width + 'px;' + ' height:' + height +'px; visibility:' + (visible ? 'inherit;' : 'hidden;') + '">';
			layerStr += content;
			layerStr += '</div>\n';
		}
		else if (isNN4) {
			layerStr = '<layer name="' + name + '" left=' + x + ' top=' + y + ' width=' + width +  ' height=' + height + ' visibility=' + (visible ? '"inherit"' : '"hide"') + '>';
			layerStr += content;
			layerStr += '</layer>\n';
		}
	}
	return layerStr;
}

function getMenuStr(name, x, y, width, height, visible, content, bgColor){
	var layerStr;
	var background_clr = ''
	
	if (isNN4)
		background_clr = (bgColor == null?"":' bgcolor="#' + bgColor + '" ')
	else 
		background_clr = (bgColor == null?"":'background-color:#' + bgColor + '; ')
		
	if (isIE4 || isW3C) {
		layerStr = '<div id="' + name + '" style="' + background_clr + 'position:absolute; overflow:hidden; z-index:2; left:' + x + 'px; top:' + y + 'px; width:' + width + 'px; height:' + height + 'px;' + ' visibility:' + (visible ? 'visible;' : 'hidden;') + '">\n';
		layerStr += content + '\n';
		layerStr += '</div>\n';
	}
	else if (isNN4) {
		layerStr = '<layer name="' + name + '" left=' + x + ' top=' + y + ' width=' + width + ' height=' + height +  ' visibility=' + (visible ? '"show"' : '"hide"') + background_clr + '>\n';
		layerStr += content + '\n';
		layerStr += '</layer>\n\n';
	}

	return layerStr;
}

function showLayer3(id)
{
	var obj = document.getElementById(id);
	obj.style.visibility = 'visible';
}

function hideLayer3(id)
{
	var obj = document.getElementById(id);
	obj.style.visibility = 'hidden';
}
