/*===========================================================================
|                                                                           |
|          A creative solution of LINXSTUDIO.COM by Gergo Varsanyi.         |
|                             version 2.01                                  |
|                                                                           |
|          It's free to use, in case you keep this block untouched!         |
|                                                                           |
|                 http://linxstudio.com/jsmenu/manual.html                  |
|                                                                           |
===========================================================================*/


/*===========================================================================
|                                                                           |
|           Base code file. Please, do not mess with the code.              |
|                                                                           |
|     For personalization you can use menu_defaults.js and menu_tree.js     |
|       Found a bug? Send a mail to the author: gergo@linxstudio.com        |
|                                                                           |
===========================================================================*/


var menu_def = new Array();
var menu_hdef = new Array();

function isUndefined(property)
{
	return (typeof property == 'undefined');
}

if (isUndefined(Array.prototype.cp) == true)
{
	Array.prototype.cp = function()
	{
		var copy = new Array();

		copy['font']			= this['font'];
		copy['font_size']		= this['font_size'];
		copy['tx_align']		= this['tx_align'];
		copy['tx_color']		= this['tx_color'];
		copy['tx_color_hi']		= this['tx_color_hi'];
		copy['bg_color']		= this['bg_color'];
		copy['bg_color_hi']		= this['bg_color_hi'];
		copy['if_sub_left']		= this['if_sub_left'];
		copy['if_sub_right']		= this['if_sub_right'];
		copy['align_subtop_to']		= this['align_subtop_to'];
		copy['align_subtop_by']		= this['align_subtop_by'];
		copy['align_subleft_to']	= this['align_subleft_to'];
		copy['align_subleft_by']	= this['align_subleft_by'];
		copy['padding']			= this['padding'];
		copy['border_width']		= this['border_width'];
		copy['border_color']		= this['border_color'];
		copy['link_underline']		= this['link_underline'];
		copy['outset']			= this['outset'];
		copy['frame_width']		= this['frame_width'];
		copy['frame_height']		= this['frame_height'];
		copy['border_width_subblock']	= this['border_width_subblock'];
		copy['border_color_subblock']	= this['border_color_subblock'];
		copy['parent_object']		= this['parent_object'];

		return copy;
	}
}

function menu_true(cond)
{
	if (cond !== false && cond != undefined)
		return true;
	else
		return false;
}

function menu_default_pointer(p1, p2)		{ menu_def['pointer'] = p1;		if (!menu_true(p2)) { p2 = p1; }	menu_hdef['pointer'] = p2; }
function menu_default_pointer_link(p1, p2)	{ menu_def['pointer_link'] = p1;	if (!menu_true(p2)) { p2 = p1; }	menu_hdef['pointer_link'] = p2; }
function menu_default_font(p1, p2)		{ menu_def['font'] = p1;		if (!menu_true(p2)) { p2 = p1; }	menu_hdef['font'] = p2; }
function menu_default_font_size(p1, p2)		{ menu_def['font_size'] = p1;		if (!menu_true(p2)) { p2 = p1; }	menu_hdef['font_size'] = p2; }
function menu_default_tx_align(p1, p2)		{ menu_def['tx_align'] = p1;		if (!menu_true(p2)) { p2 = p1; }	menu_hdef['tx_align'] = p2; }
function menu_default_tx_color(p1, p2)		{ menu_def['tx_color'] = p1;		if (!menu_true(p2)) { p2 = p1; }	menu_hdef['tx_color'] = p2; }
function menu_default_tx_color_hi(p1, p2)	{ menu_def['tx_color_hi'] = p1;		if (!menu_true(p2)) { p2 = p1; }	menu_hdef['tx_color_hi'] = p2; }
function menu_default_bg_color(p1, p2)		{ menu_def['bg_color'] = p1;		if (!menu_true(p2)) { p2 = p1; }	menu_hdef['bg_color'] = p2; }
function menu_default_bg_color_hi(p1, p2)	{ menu_def['bg_color_hi'] = p1;		if (!menu_true(p2)) { p2 = p1; }	menu_hdef['bg_color_hi'] = p2; }
function menu_default_if_sub_left(p1, p2)	{ menu_def['if_sub_left'] = p1;		if (!menu_true(p2)) { p2 = p1; }	menu_hdef['if_sub_left'] = p2; }
function menu_default_if_sub_right(p1, p2)	{ menu_def['if_sub_right'] = p1;	if (!menu_true(p2)) { p2 = p1; }	menu_hdef['if_sub_right'] = p2; }
function menu_default_frame_width(p1, p2)	{ menu_def['frame_width'] = p1;		if (!menu_true(p2)) { p2 = p1; }	menu_hdef['frame_width'] = p2; }
function menu_default_frame_height(p1, p2)	{ menu_def['frame_height'] = p1;	if (!menu_true(p2)) { p2 = p1; }	menu_hdef['frame_height'] = p2; }
function menu_default_align_subtop_to(p1, p2)	{ menu_def['align_subtop_to'] = p1;	if (!menu_true(p2)) { p2 = p1; }	menu_hdef['align_subtop_to'] = p2; }
function menu_default_align_subtop_by(p1, p2)	{ menu_def['align_subtop_by'] = p1;	if (!menu_true(p2)) { p2 = p1; }	menu_hdef['align_subtop_by'] = p2; }
function menu_default_align_subleft_to(p1, p2)	{ menu_def['align_subleft_to'] = p1;	if (!menu_true(p2)) { p2 = p1; }	menu_hdef['align_subleft_to'] = p2; }
function menu_default_align_subleft_by(p1, p2)	{ menu_def['align_subleft_by'] = p1;	if (!menu_true(p2)) { p2 = p1; }	menu_hdef['align_subleft_by'] = p2; }
function menu_default_padding(p1, p2)		{ menu_def['padding'] = p1;		if (!menu_true(p2)) { p2 = p1; }	menu_hdef['padding'] = p2; }
function menu_default_border_width(p1, p2)	{ menu_def['border_width'] = p1;	if (!menu_true(p2)) { p2 = p1; }	menu_hdef['border_width'] = p2; }
function menu_default_border_color(p1, p2)	{ menu_def['border_color'] = p1;	if (!menu_true(p2)) { p2 = p1; }	menu_hdef['border_color'] = p2; }
function menu_default_link_underline(p1, p2)	{ menu_def['link_underline'] = p1;	if (!menu_true(p2)) { p2 = p1; }	menu_hdef['link_underline'] = p2;}
function menu_default_outset(p1, p2)		{ menu_def['outset'] = p1;		if (!menu_true(p2)) { p2 = p1; }	menu_hdef['outset'] = p2;}
function menu_default_parent_object(p1, p2)	{ menu_def['parent_object'] = p1;	if (!menu_true(p2)) { p2 = p1; }	menu_hdef['parent_object'] = p2; }

function menu_default_border_width_subblock(p)	{ menu_def['border_width_subblock'] = p; }
function menu_default_border_color_subblock(p)	{ menu_def['border_color_subblock'] = p; }

function menu_set_spacer_image(p)		{ menu_spacer_image = p; }

menu_default_font('Veranda');
menu_default_font_size(10);
menu_default_tx_align('left');
menu_default_tx_color('#000000');
menu_default_tx_color_hi('#f00000');
menu_default_bg_color('#f0f0f0');
menu_default_bg_color_hi('#f0f0f0');
menu_default_if_sub_left('');
menu_default_if_sub_right('');
menu_default_frame_width(100);
menu_default_frame_height(18);
menu_default_align_subtop_to('top');
menu_default_align_subtop_by(1);
menu_default_align_subleft_to('right');
menu_default_align_subleft_by(-1);
menu_default_padding(2);
menu_default_border_width(0);
menu_default_border_color('#d0d0d0');
menu_default_link_underline('no');
menu_default_outset(33);
menu_default_pointer('default');
menu_default_pointer_link('pointer');
menu_default_border_width_subblock(0);
menu_default_border_color_subblock('#707070');

var menu_autocheck_started = false;

var menu_each = new Array();
var menu_sub = new Array();

var menu_parent = new Array();
var menu_text = new Array();
var menu_link = new Array();
var menu_level = new Array();
var menu_contains_submenu = new Array();
var menu_last_parent_on_level = new Array();
var menu_num_on_level = new Array();
var menu_line_on_level = new Array();
var menu_to_close = new Array();

var menu_heads = new Array();
var menu_head_x = new Array();
var menu_head_y = new Array();

var menu_counter = 0;
var menu_head_counter = 0;

var menu_to_hex = new Array();
var menu_hex = new Array();

for (var i = 0; i < 10; i++)
{
	menu_hex[i] = i;
	menu_to_hex[i] = i;
}
menu_hex['a'] = 10; menu_to_hex[10] = 'a';
menu_hex['b'] = 11; menu_to_hex[11] = 'b';
menu_hex['c'] = 12; menu_to_hex[12] = 'c';
menu_hex['d'] = 13; menu_to_hex[13] = 'd';
menu_hex['e'] = 14; menu_to_hex[14] = 'e';
menu_hex['f'] = 15; menu_to_hex[15] = 'f';
menu_hex['A'] = 10;
menu_hex['B'] = 11;
menu_hex['C'] = 12;
menu_hex['D'] = 13;
menu_hex['E'] = 14;
menu_hex['F'] = 15;


function menu_mover(id)
{
	menu_to_close[id] = 1;

	var c = 0;

	for (c = 0; c < menu_counter; c ++)
	{
		if (menu_parent[id] == c || id == c || menu_parent[menu_parent[id]] == c || menu_parent[menu_parent[menu_parent[id]]] == c || menu_parent[menu_parent[menu_parent[menu_parent[id]]]] == c || menu_parent[menu_parent[menu_parent[menu_parent[menu_parent[c]]]]])
		{
			if (menu_each[c]['tx_color_hi'] != menu_each[c]['tx_color']) document.getElementById("menu_item_" + c).style.color = menu_each[c]['tx_color_hi'];
			if (menu_each[c]['bg_color_hi'] != menu_each[c]['bg_color']) document.getElementById("menu_item_" + c).style.background = menu_each[c]['bg_color_hi'];
		}
		else if (menu_parent[c] == id)
		{
			if (menu_each[c]['tx_color_hi'] != menu_each[c]['tx_color']) document.getElementById("menu_item_" + c).style.color = menu_each[c]['tx_color'];
			if (menu_each[c]['bg_color_hi'] != menu_each[c]['bg_color']) document.getElementById("menu_item_" + c).style.background = menu_each[c]['bg_color'];
		}
		else
		{
			if (menu_each[c]['tx_color_hi'] != menu_each[c]['tx_color']) document.getElementById("menu_item_" + c).style.color = menu_each[c]['tx_color'];
			if (menu_each[c]['bg_color_hi'] != menu_each[c]['bg_color']) document.getElementById("menu_item_" + c).style.background = menu_each[c]['bg_color'];
			if (menu_contains_submenu[c] > 0)
			{
				document.getElementById('menu_block_' + c).style.display = 'none';
			}
			menu_to_close[c] = 0;
		}
	}

	var place_x = 0;
	var place_y = 0;

	idp = menu_parent[id];
	if (idp < 0)
		idp = "m" + id;

	var aff_img = document.getElementById('menu_block_' + idp);
	if (menu_contains_submenu[id] > 0)
	{
		var aff_block = document.getElementById('menu_block_' + id);

		var i = 0;
		var x = aff_img.style.left;
		var res_x = "";
		while (i < x.length && x.substring(i, i + 2) != "px")
		{
			res_x += x.substring(i, i + 1);
			i ++;
		}

		i = 0;
		var y = aff_img.style.top;
		var res_y = "";
		while (i < y.length && y.substring(i, i + 2) != "px")
		{
			res_y += y.substring(i, i + 1);
			i ++;
		}

		place_x += (+res_x) + (+menu_each[id]['align_subleft_by']);
		if (menu_each[id]['align_subleft_to'] == "right")
			place_x += (+menu_sub[menu_parent[id]]['frame_width']);

		if (menu_parent[id] >= 0)
		{
			place_y += (+res_y) + (+menu_sub[id]['border_width']) * (+menu_line_on_level[id]) + (+menu_each[id]['align_subtop_by']);
			for (i = id -1; i >= 0; i --)
				if (menu_parent[i] == menu_parent[id])
					place_y += (+menu_each[i]['frame_height']);
		}
		else
			place_y += (+res_y) + (+menu_each[id]['align_subtop_by']);

		if (menu_each[id]['align_subtop_to'] == "bottom")
			place_y += (+menu_each[id]['frame_height']);

		aff_block.style.top = place_y;
		aff_block.style.left = place_x;
		aff_block.style.display = "block";
	}
	setTimeout("menu_check_to_close(" + id + ")", 667);
	if (!menu_autocheck_started)
	{
		setTimeout("menu_autocheck_to_close();", 667);
		menu_autocheck_started = true;
	}
}

function menu_mout(id)
{
	menu_to_close[id] = 2;
}

function menu_autocheck_to_close()
{
	var i = 0;

	for (i = 0; i < menu_counter; i ++)
		if (menu_to_close[i] == 2)
			menu_check_to_close(i);

	setTimeout("menu_autocheck_to_close();", 667);
}

function menu_check_to_close(id)
{
	if (menu_to_close[id] == 2)
	{
		var i = id + 1;
		var x = 0;
		while (menu_level[i] > menu_level[id])
		{
			if (menu_to_close[i] == 1)
				x = 1;
			i ++;
		}

		if (x == 1)
			setTimeout("menu_check_to_close(" + id + ")", 667);
		else
		{
			i = id + 1;
			while (menu_level[i] > menu_level[id])
			{
				if (menu_contains_submenu[i] > 0)
				{
					document.getElementById('menu_block_' + i).style.display = 'none';
					menu_to_close[i] = 0;
				}
				i ++;
			}
			if (menu_contains_submenu[id] > 0)
				document.getElementById('menu_block_' + id).style.display = 'none';
			menu_to_close[id] = 0;
		}
	}

	var c = 0;
	var x = 0;
	for (c = 0; c < menu_counter; c ++)
		if (menu_to_close[c] > 0)
			x = 1;

	if (x == 0)
	{
		for (c = 0; c < menu_counter; c ++)
		{
			var item = document.getElementById("menu_item_" + c);

			if (item.style.color != menu_each[c]['tx_color'])
					item.style.color = menu_each[c]['tx_color'];

			if (item.style.background != menu_each[c]['bg_color'])
				item.style.background = menu_each[c]['bg_color'];
		}
	}
}

function menu_prepare()
{
	var i = 0;

	for (i = 0; i < menu_counter; i ++)
		if (menu_level[i] == 0)
			menu_add_HTML_block(i, "head");

	for (i = 0; i < menu_counter; i ++)
		if (menu_contains_submenu[i] > 0)
			menu_add_HTML_block(i, "");

	for (i = 0; i < menu_head_counter; i ++)
	{
		document.getElementById("menu_block_m" + menu_heads[i]).style.display = "block";
		if(menu_each[i]["parent_object"] != '')
		{
			document.getElementById("menu_block_m" + menu_heads[i]).style.left = (1 * menu_head_x[i] + find_pos2_x(menu_each[i]["parent_object"])) + "px";
			document.getElementById("menu_block_m" + menu_heads[i]).style.top = (1 * menu_head_y[i] + find_pos2_y(menu_each[i]["parent_object"])) + "px";
		} else {
			document.getElementById("menu_block_m" + menu_heads[i]).style.left = menu_head_x[i] + "px";
			document.getElementById("menu_block_m" + menu_heads[i]).style.top = menu_head_y[i] + "px";
		}
		menu_mover(menu_heads[i]);
//		if(menu_each[i]["frame_width"] > 0) alert((menu_head_x[i] * 1 + find_pos2_x(menu_each[i]["parent_object"])) + "px");
	}
	menu_mover(-1);

	menu_to_close[0] = 2;
	menu_check_to_close(0);
}

function menu_onresize()
{
	var i = 0;

	for (i = 0; i < menu_head_counter; i ++)
	{
		if(menu_each[i]["parent_object"] != '')
		{
			document.getElementById("menu_block_m" + menu_heads[i]).style.left = (1 * menu_head_x[i] + find_pos2_x(menu_each[i]["parent_object"])) + "px";
			document.getElementById("menu_block_m" + menu_heads[i]).style.top = (1 * menu_head_y[i] + find_pos2_y(menu_each[i]["parent_object"])) + "px";
		} else {
			document.getElementById("menu_block_m" + menu_heads[i]).style.left = menu_head_x[i] + "px";
			document.getElementById("menu_block_m" + menu_heads[i]).style.top = menu_head_y[i] + "px";
		}
//		menu_mover(menu_heads[i]);
	}
//	menu_mover(-1);

	menu_to_close[0] = 2;
	menu_check_to_close(0);
}

function menu_instaff(ch)
{
	var staff = "_-abcdefghijklmnopqrstuvwxyz";
	var r = false;
	var i = 0;

	while (i < staff.length && !r)
	{
		if (ch == staff.substring(i, i + 1))
			r = true;
		i ++;
	}

	return r;
}

function menu_get_typedas(temper)
{
	var i = temper.length - 2;

	while (i >= 0 && menu_instaff(temper.substring(i, i + 1)))
	{
		i --;
	}

	typedas = temper.substring(i + 1, temper.length - 1);

	return typedas;
}

function menu_add_new(content)
{
	var i = 0;

	menu_each[menu_counter] = new Array();
	menu_sub[menu_counter] = new Array();

	var title = "";
	var pos_x = "";
	var pos_y = "";
	var pointerset = false;

	var realtitle = 0;
	var typedas = "text";
	var tabs = 0;
	var temper = "";
	var posstate = 0;
	var issub = 0;

	var ch = content.substring(i, i + 1);
	while (i < content.length && ch != "	")
	{
		if (typedas == "text")
		{
			if (ch == "-" && realtitle == 0) 	tabs ++;
			else if (ch != "-")		 	{ realtitle = 1; title = title + ch; }
		}

		i ++;
		if (i < content.length)
			ch = content.substring(i, i + 1);
	}

	menu_text[menu_counter] = title;

	menu_level[menu_counter] = tabs;

	if (tabs < 1)
		menu_parent[menu_counter] = -1;
	else
		menu_parent[menu_counter] = menu_last_parent_on_level[tabs - 1];

	menu_contains_submenu[menu_parent[menu_counter]] ++;
	menu_last_parent_on_level[tabs] = menu_counter;
	menu_contains_submenu[menu_counter] = 0;

	if (!menu_num_on_level[tabs] && menu_num_on_level[tabs] != 0)
		menu_num_on_level[tabs] = -1;

	menu_num_on_level[tabs] ++;
	menu_line_on_level[menu_counter] = menu_num_on_level[tabs];

	if (tabs == 0)
		menu_each[menu_counter] = menu_hdef.cp();
	else
	{
		menu_each[menu_counter] = menu_def.cp();

		var pc = menu_parent[menu_counter];
		menu_each[menu_counter]['font']			= menu_sub[pc]['font'];
		menu_each[menu_counter]['font_size']		= menu_sub[pc]['font_size'];
		menu_each[menu_counter]['tx_align']		= menu_sub[pc]['tx_align'];
		menu_each[menu_counter]['tx_color']		= menu_sub[pc]['tx_color'];
		menu_each[menu_counter]['tx_color_hi']		= menu_sub[pc]['tx_color_hi'];
		menu_each[menu_counter]['bg_color']		= menu_sub[pc]['bg_color'];
		menu_each[menu_counter]['bg_color_hi']		= menu_sub[pc]['bg_color_hi'];
		menu_each[menu_counter]['if_sub_left']		= menu_sub[pc]['if_sub_left'];
		menu_each[menu_counter]['if_sub_right']		= menu_sub[pc]['if_sub_right'];
		menu_each[menu_counter]['align_subtop_to']	= menu_sub[pc]['align_subtop_to'];
		menu_each[menu_counter]['align_subtop_by']	= menu_sub[pc]['align_subtop_by'];
		menu_each[menu_counter]['align_subleft_to']	= menu_sub[pc]['align_subleft_to'];
		menu_each[menu_counter]['align_subleft_by']	= menu_sub[pc]['align_subleft_by'];
		menu_each[menu_counter]['padding']		= menu_sub[pc]['padding'];
		menu_each[menu_counter]['border_width']		= menu_sub[pc]['border_width'];
		menu_each[menu_counter]['border_color']		= menu_sub[pc]['border_color'];
		menu_each[menu_counter]['link_underline']	= menu_sub[pc]['link_underline'];
		menu_each[menu_counter]['outset']		= menu_sub[pc]['outset'];
	}

	menu_sub[menu_counter] = menu_def.cp();

	typedas = "temp";
	while (i < content.length)
	{
		ch = content.substring(i, i + 1);

		if (typedas == "pos")
		{
			if (ch != "}" && ch != " " && ch != "	" && ch != "," && ch != ";")
			{
				if (posstate == 0)
					pos_x = pos_x + ch;
				if (posstate == 1)
					pos_y = pos_y + ch;
			}
			else if (ch == "," || ch == ";")
				posstate ++;
			else if (ch != " " && ch != "	" && ch != "," && ch != ";")
			{
				typedas = "temp"; temper = "";
			}
		}

		if (typedas != "pos" && typedas !="temp")
		{
			if (ch != "}")
			{
				if (issub == 0)
					menu_each[menu_counter][typedas] = menu_each[menu_counter][typedas] + ch;
				else
					menu_sub[menu_counter][typedas] = menu_sub[menu_counter][typedas] + ch;
			}
			else
			{
				typedas = "temp";
				temper = "}";
			}
		}

		if (typedas == "temp")
		{
			temper = temper + ch.toLowerCase();

			if (ch == "{")
			{
				typedas = menu_get_typedas(temper);

				var lag1 = "", lag2 = "";
				if (typedas.length > 4)
					lag1 = typedas.substring(typedas.length - 4, typedas.length);
				if (typedas.length > 9)
					lag2 = typedas.substring(typedas.length - 9, typedas.length);
				if (lag1 == "-sub")
				{
					typedas = typedas.substring(0, typedas.length - 4);
					issub = 1;
 					menu_sub[menu_counter][typedas] = "";
				}
				else if (lag2 == "_subblock")
				{
					issub = 1;
 					menu_sub[menu_counter][typedas] = "";
				}
				else
				{
					if (typedas == "pointer")
						pointerset = true;
					issub = 0;
					menu_each[menu_counter][typedas] = "";
				}

				if (typedas == "pos")
				{
					pos_x = "";
					pos_y = "";
				}
			}
		}

		i ++;
	}

	menu_link[menu_counter] = menu_each[menu_counter]['link'];

	if (!pointerset)
	{
		if (tabs == 0)
		{
			if (!menu_link[menu_counter])
				menu_each[menu_counter]['pointer'] = menu_hdef['pointer'];
			if (menu_link[menu_counter])
				menu_each[menu_counter]['pointer'] = menu_hdef['pointer_link'];
		}
		else
		{
			if (!menu_link[menu_counter])
				menu_each[menu_counter]['pointer'] = menu_def['pointer'];
			if (menu_link[menu_counter])
				menu_each[menu_counter]['pointer'] = menu_def['pointer_link'];
		}
	}

	if (tabs == 0)
	{
		menu_head_x[menu_head_counter] = pos_x;
		menu_head_y[menu_head_counter] = pos_y;
		menu_heads[menu_head_counter] = menu_counter;
		menu_head_counter ++;
	}

	var l = tabs;
	l ++;
	menu_num_on_level[l] = -1;

	menu_counter ++;
}

function menu_add_HTML_block(id, mid)
{
	var out = "";
	var i = 0;

	if (mid == "")
	{
		out += '<div id="menu_block_' + id + '" style="position:absolute;display:none;width:' + menu_sub[id]['frame_width'] + 'px;">';
		out += '<table cellspacing=0 cellpadding=0 border=0><tr>';
		if (menu_sub[id]['border_width_subblock'] > 0)
		{
			var spc = '<img src=' + menu_spacer_image + ' width=' + menu_sub[id]['border_width_subblock'] + ' height=' + menu_sub[id]['border_width_subblock'] + ' border=0>';
			var c1 = menu_sub[id]['border_color_subblock'];
			var c2 = menu_sub[id]['border_color_subblock'];
			if (menu_sub[id]['outset'] != 0)
			{
				c1 = menu_get_outset_color(c1, ((+menu_sub[id]['outset']) / 100));
				c2 = menu_get_outset_color(c2, (((+menu_sub[id]['outset']) / 100) * -1));
			}
			var bg1 = 'bgcolor="' + c1 + '"';
			var bg2 = 'bgcolor="' + c2 + '"';
			out += '<td width=' + menu_sub[id]['border_width_subblock'] + ' ' + bg1 + '>' + spc + '</td><td ' + bg1 + '></td><td width=' + menu_sub[id]['border_width_subblock'] + ' ' + bg1 + '>' + spc + '</td></tr><tr><td ' + bg1 + '></td>';
		}
		out += '<td>';
	}
	else
	{
		var xid = "m" + id;
		out += '<div id="menu_block_' + xid + '" style="position:absolute;display:none;width:' + menu_each[id]['frame_width'] + 'px;">';
		out += '<table cellspacing=0 cellpadding=0 border=0 width=' + menu_each[id]['frame_width'] + '><tr>';
		if (menu_sub[id]['border_width'] > 0)
		{
			var spc = '<img src=' + menu_spacer_image + ' width=' + menu_each[id]['border_width'] + ' height=' + menu_each[id]['border_width'] + ' border=0>';
			var c1 = menu_each[id]['border_color'];
			var c2 = menu_each[id]['border_color'];
			if (menu_each[id]['outset'] != 0)
			{
				c1 = menu_get_outset_color(c1, ((+menu_each[id]['outset']) / 100));
				c2 = menu_get_outset_color(c2, (((+menu_each[id]['outset']) / 100) * -1));
			}
			var bg1 = 'bgcolor="' + c1 + '"';
			var bg2 = 'bgcolor="' + c2 + '"';
			out += '<td width=' + menu_each[id]['border_width'] + ' ' + bg1 + '>' + spc + '</td><td ' + bg1 + '></td><td width=' + menu_each[id]['border_width'] + ' ' + bg1 + '>' + spc + '</td></tr><tr height=' + menu_each[id]['frame_height'] + '><td ' + bg1 + '></td>';
		}
	}

	if (mid == "")
	{
	//this is a child
		var firstline = 1;
		for (i = 0; i < menu_counter; i ++)
		{
			if (id == menu_parent[i])
			{
				if (firstline != 1 && menu_sub[menu_parent[i]]['border_width'] > 0)
					out += '<table cellspacing=0 cellpadding=0 border=0 width=' + menu_sub[menu_parent[i]]['frame_width'] + '><tr><td bgcolor="' + menu_sub[menu_parent[i]]['border_color'] + '" onMouseOver="menu_mover(' + menu_parent[i] + ')" onMouseOut="menu_mout(' + menu_parent[i] + ')"><img src="' + menu_spacer_image + '" width=1 height=' + menu_sub[menu_parent[i]]['border_width'] + ' border=0></td></tr></table>';
				else
					firstline = 0;

				out += '<table cellspacing=0 cellpadding=' + menu_sub[menu_parent[i]]['padding'] + ' border=0 width=' + menu_sub[menu_parent[i]]['frame_width'] + ' onMouseOver="menu_mover(' + i + ')" onMouseOut="menu_mout(' + i + ')" >';
				out += '<tr height=' + menu_sub[menu_parent[i]]['frame_height'] + '><td id="menu_item_' + i + '"';
				if (menu_link[i])
					out += ' onClick="document.location=\'' + menu_link[i] + '\';"';
				out += ' style="';
				if (menu_each[i]['bg_color'] && menu_each[i]['bg_color'].toLowerCase() != "transparent")
					out += 'background:' + menu_each[i]['bg_color'] + ';';
				if (menu_link[i] && (menu_each[i]['link_underline'] == "yes" || menu_each[i]['link_underline'] == 1))
					out += 'text-decoration:underline;';
				if (menu_each[i]['tx_align'] == "center" || menu_each[i]['tx_align'] == "right")
					out += 'text-align:' + menu_each[i]['tx_align'] + ';';
				out += 'font-family:' + menu_each[i]['font'] + ';font-size:' + menu_each[i]['font_size'] + 'px;cursor:' + menu_each[i]['pointer'] + ';color:' + menu_each[i]['tx_color'] + ';"';
				out += ' nowrap>';
				if (menu_contains_submenu[i] > 0 && menu_each[i]['if_sub_left'])
					out += menu_each[i]['if_sub_left'];
				out += menu_text[i];
				if (menu_contains_submenu[i] > 0 && menu_each[i]['if_sub_right'])
					out += menu_each[i]['if_sub_right'];
				out += '</td></tr></table>';
			}
		}
	}
	else
	{
	//this is a parent
		//if (menu_each[id]['padding'] > 0)
			out += '<td onMouseOver="menu_mover(' + id + ')" onMouseOut="menu_mout(' + id + ')"><table cellspacing=0 cellpadding=' + menu_each[id]['padding']+ ' width=' + menu_each[id]['frame_width']+ '><tr>';
		out += '<td id="menu_item_' + id + '"';
		if (menu_link[id])
			out += ' onClick="document.location=\'' + menu_link[id] + '\';"';
		out += ' style="height:' + menu_each[i]['frame_height'] + 'px;';
		if (menu_each[id]['bg_color'] && menu_each[i]['bg_color'].toLowerCase() != "transparent")
			out += 'background:' + menu_each[id]['bg_color'] + ';';
		if (menu_link[id] && (menu_each[id]['link_underline'] == "yes" || menu_each[id]['link_underline'] == 1))
			out += 'text-decoration:underline;';
		if (menu_each[id]['tx_align'] == "center" || menu_each[id]['tx_align'] == "right")
			out += 'text-align:' + menu_each[id]['tx_align'] + ';';
		out += 'font-family:' + menu_each[id]['font'] + ';font-size:' + menu_each[id]['font_size'] + 'px;cursor:' + menu_each[id]['pointer'] + ';color:' + menu_each[id]['tx_color'] + ';"';
		out += '  nowrap>';
		if (menu_contains_submenu[id] > 0 && menu_each[id]['if_sub_left'])
			out += menu_each[id]['if_sub_left'];
		out += menu_text[id];
		if (menu_contains_submenu[id] > 0 && menu_each[id]['if_sub_right'])
			out += menu_each[id]['if_sub_right'];
		out += '</td>';
		//if (menu_each[id]['padding'] > 0)
			out += '</tr></table></td>';
	}

	if (mid == "")
	{
		if (menu_sub[id]['border_width_subblock'] > 0)
		{
			var spc = '<img src=' + menu_spacer_image + ' width=' + menu_sub[id]['border_width_subblock'] + ' height=' + menu_sub[id]['border_width_subblock'] + ' border=0>';
			var c1 = menu_sub[id]['border_color_subblock'];
			var c2 = menu_sub[id]['border_color_subblock'];
			if (menu_sub[id]['outset'] != 0)
			{
				c1 = menu_get_outset_color(c1, ((+menu_sub[id]['outset']) / 100));
				c2 = menu_get_outset_color(c2, (((+menu_sub[id]['outset']) / 100) * -1));
			}
			var bg1 = 'bgcolor="' + c1 + '"';
			var bg2 = 'bgcolor="' + c2 + '"';
			out += '</td><td ' + bg2 + '></td></tr><tr><td ' + bg2 + '>' + spc + '</td><td ' + bg2 + '></td><td ' + bg2 + '>';
		}
		out += '</td></tr>';
	}
	else
	{
		if (menu_sub[id]['border_width'] > 0)
		{
			var spc = '<img src=' + menu_spacer_image + ' width=' + menu_sub[id]['border_width'] + ' height=' + menu_sub[id]['border_width'] + ' border=0>';
			var c1 = menu_sub[id]['border_color'];
			var c2 = menu_sub[id]['border_color'];
			if (menu_each[id]['outset'] != 0)
			{
				c1 = menu_get_outset_color(c1, ((+menu_each[id]['outset']) / 100));
				c2 = menu_get_outset_color(c2, (((+menu_each[id]['outset']) / 100) * -1));
			}
			var bg1 = 'bgcolor="' + c1 + '"';
			var bg2 = 'bgcolor="' + c2 + '"';
			out += '</td><td ' + bg2 + '></td></tr><tr><td ' + bg2 + '>' + spc + '</td><td ' + bg2 + '></td><td ' + bg2 + '>';
		}
		out += '</td></tr>';
	}

	out += '</table>';
	out += '</div>';

	document.write(out);
}

function menu_get_outset_color(c, m)
{
	var ret = "";
	var r = 0, r1 = 0, r2 = 0, g = 0, g1 = 0, g2 = 0, b = 0, b1 = 0, b2 = 0;

	r1 = c.substring(1, 2);
	r2 = c.substring(2, 3);
	r = (+menu_hex[r1]) * 16 + (+menu_hex[r2]);
	g1 = c.substring(3, 4);
	g2 = c.substring(4, 5);
	g = (+menu_hex[g1]) * 16 + (+menu_hex[g2]);
	b1 = c.substring(5, 6);
	b2 = c.substring(6, 7);
	b = (+menu_hex[b1]) * 16 + (+menu_hex[b2]);

	if (m > 1)
		m = 1;
	if (m < -1)
		m = -1;

	if (m > 0)
	{
		r = (255 - (+r)) * m + (+r); 
		g = (255 - (+g)) * m + (+g); 
		b = (255 - (+b)) * m + (+b); 
	}
	else
	{
		r = ((+r) * (1 + m)); 
		r = ((+g) * (1 + m)); 
		r = ((+b) * (1 + m)); 
	}

	r1 = Math.floor((+r) / 16);
	g1 = Math.floor((+g) / 16);
	b1 = Math.floor((+b) / 16);
	r2 = Math.floor((+r) - (+r1) * 16);
	g2 = Math.floor((+g) - (+g1) * 16);
	b2 = Math.floor((+b) - (+b1) * 16);

	ret = ret + menu_to_hex[r1];
	ret = ret + menu_to_hex[r2];
	ret = ret + menu_to_hex[g1];
	ret = ret + menu_to_hex[g2];
	ret = ret + menu_to_hex[b1];
	ret = ret + menu_to_hex[b2];

	return '#' + ret;
}

function menu_add_insider_block(id)
{
	var out = "";

	out += menu_text[id];

	return out;
}

function menu_head_set(id, x, y, w)
{
	menu_width_head_each[id] = w;
	menu_head_x[menu_head_counter] = x;
	menu_head_y[menu_head_counter] = y;
	menu_heads[menu_head_counter] = id;

	menu_head_counter ++;
}
