var menu_img1 = new Image(); menu_img1.src = '/common/img/lbar_left_on.gif'; var menu_img2 = new Image(); menu_img2.src = '/common/img/lbar_right_on.gif';
var menu_all_layers = new Array(); var menu_to; var menu_opened;

start_menu();
read_menu_items();
stop_menu();

function start_menu() {
	document.write('<DIV ID="menu_container" STYLE="position:relative; width:1px; height:1px; z-index:1">');
}

function read_menu_items(level, rm_main) {
	if (!level) level = 'menu_items';
	var i = 0; var rm_sub = 0
	while (i < eval(level).length) {
		if (typeof(eval(level)[i]) == 'object') {
			rm_sub++; rm_pos = (rm_main)?(rm_main + '_' + rm_sub):(rm_sub + '');
			build_menu_item(rm_pos, eval(level)[i][0], eval(level)[i][1], eval(level)[i][2]);
			menu_all_layers[menu_all_layers.length] = rm_pos;
			if (eval(level)[i].length != 3) read_menu_items(level + '[' + i + ']', rm_pos);
		}
	i++;
	}
}

function stop_menu() {
	document.write('</DIV>');
}

function build_menu_item(position, name, link, target) {
	document.write('<DIV ID="menu' + position + '" ALIGN=CENTER STYLE="position:absolute; ');
	if (position.indexOf('_') == -1) {
		document.write('left:' + (((position-1)*menu_cell_width)+((position-1)*menu_cell_h_interspace)) + 'px; top:0px; ');
		(link != '')?(document.write('cursor:pointer; ')):(document.write('cursor:default; '));
		document.write('width:' + menu_cell_width + 'px; height:' + menu_cell_height + 'px" onMouseOver="open_menu(\'' + position + '\')" onMouseOut="delay_close_menu(\'' + position + '\')"' + ((link != '')?(' onClick="menu_open_link(\'' + link + '\', \'' + target + '\')"'):('')) + '>');
		document.write('<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><TR><TD><IMG SRC="/common/img/dbar_left.gif" WIDTH=7 HEIGHT=16></TD><TD BACKGROUND="/common/img/dbar_bg.gif" WIDTH=' + (menu_cell_width-14) + ' ALIGN=RIGHT STYLE="color:#FFFFFF"><B>' + name + '</B></TD><TD><IMG SRC="/common/img/dbar_right.gif" WIDTH=7 HEIGHT=16></TD></TR></TABLE>');
	} else {
		document.write('left:' + (((position.substr(0, position.indexOf('_'))-1)*menu_cell_width)+((position.substr(0, position.indexOf('_'))-1)*menu_cell_h_interspace)-(position.substr(position.indexOf('_')+1)*9)) + 'px; top:' + (((position.substr(position.indexOf('_')+1))*(menu_cell_height+menu_cell_v_interspace))-menu_cell_v_interspace) + 'px; visibility:hidden; ');
		(link != '')?(document.write('cursor:pointer; ')):(document.write('cursor:default; '));
		document.write('width:' + (menu_cell_width+1) + 'px; height:' + (menu_cell_height+menu_cell_v_interspace) + 'px" onMouseOver="open_menu(\'' + position + '\'); highlight_menu(\'on\', \'' + position + '\')" onMouseOut="delay_close_menu(\'' + position + '\'); highlight_menu(\'off\', \'' + position + '\')"' + ((link != '')?(' onClick="menu_open_link(\'' + link + '\', \'' + target + '\')"'):('')) + '>');
		document.write('<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><TR><TD><IMG SRC="/common/img/dummy.gif" WIDTH=9 HEIGHT=1></TD><TD BGCOLOR="#FFFFFF"><IMG SRC="/common/img/dummy.gif" WIDTH=' + (menu_cell_width-7) + ' HEIGHT=' + menu_cell_v_interspace + '></TD></TR></TABLE>');
		document.write('<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><TR><TD><IMG SRC="/common/img/dummy.gif" WIDTH=1 HEIGHT=1></TD><TD><IMG SRC="/common/img/lbar_left_off.gif" WIDTH=7 HEIGHT=16 ID="lbar_left_' + position + '"></TD><TD BGCOLOR="#8CCFB1" WIDTH=' + (menu_cell_width-14) + ' ALIGN=RIGHT STYLE="color:#000000" ID="lbar_main_' + position + '">' + name + '</TD><TD><IMG SRC="/common/img/lbar_right_off.gif" WIDTH=7 HEIGHT=16 ID="lbar_right_' + position + '"></TD></TR></TABLE>');
	}
	document.write('</DIV>');
}

function open_menu(position) {
	if (menu_to) clearTimeout(menu_to); if (menu_opened) close_menu(menu_opened); menu_opened = position;
	for (i=0; i<menu_all_layers.length; i++) {
		mal_main = (menu_all_layers[i].indexOf('_') != -1)?(menu_all_layers[i].substr(0, menu_all_layers[i].indexOf('_'))):(menu_all_layers[i]);
		position_main = (position.indexOf('_') != -1)?(par_pos = position.substr(0, position.indexOf('_'))):(position);
		if (mal_main == position_main) document.getElementById('menu' + menu_all_layers[i]).style.visibility = 'visible';
	}
}

function delay_close_menu(position) {
	if (menu_to) clearTimeout(menu_to);
	menu_to = setTimeout('close_menu(\'' + position + '\')', menu_delay);
}

function close_menu(position) {
	for (i=0; i<menu_all_layers.length; i++) {
		mal_main = (menu_all_layers[i].indexOf('_') != -1)?(menu_all_layers[i].substr(0, menu_all_layers[i].indexOf('_'))):(menu_all_layers[i]);
		position_main = (position.indexOf('_') != -1)?(par_pos = position.substr(0, position.indexOf('_'))):(position);
		if (mal_main == position_main && menu_all_layers[i].indexOf('_') != -1) document.getElementById('menu' + menu_all_layers[i]).style.visibility = 'hidden';
	}
}

function menu_open_link(link, target) {
	if (!target || target == '_self') document.location.href = link;
	else {
		if (window.parent.frames[target]) window.parent.frames[target].location.href = link;
		else if (target == '_top') top.location.href = link;
		else if (target == '_parent') parent.location.href = link;
		else window.open (link);
	}
}

function highlight_menu(status, position) {
	document.getElementById('lbar_left_' + position).src = '/common/img/lbar_left_' + status + '.gif';
	document.getElementById('lbar_right_' + position).src = '/common/img/lbar_right_' + status + '.gif';
	document.getElementById('lbar_main_' + position).style.backgroundColor = (status == 'on')?('#00B18B'):('#8CCFB1');
	document.getElementById('lbar_main_' + position).style.color = (status == 'on')?('#FFFFFF'):('#000000');
}