function asmMenuFieldStyle()
{
	this._field_gap = 0;

	this._is_image = 0;
	this._image_out = 0;
	this._image_over = 0;
	this._image_click = 0;

	this._field_width = 400;
	this._field_height = 30;

	this._field_over_color = "#000080";
	this._field_out_color = "#000040";
	this._field_click_color = "#0000ff";

	this._font_over_color = "#ffffff";
	this._font_out_color = "#ffffff";
	this._font_click_color = "#ffffff";

	this._font_size = 10;
	this._font_family = "Verdana";
	this._font_weight = 400;
}

function asmMenu(element_id)
{
	this._field_style = new asmMenuFieldStyle();

	var element_to_add_to = document.getElementById(element_id);
	this._table = document.createElement("table");
	this._table.border = "0";
	this._table.cellPadding = "0px";
	this._table.cellSpacing = "0px";

	element_to_add_to.appendChild(this._table);
}

asmMenu.prototype.addField = function(field_name, callback_function_name)
{
	var _tr = this._table.insertRow(-1);
	var _td = _tr.insertCell(-1);

	this.restyle(_td);

	_td.innerHTML = field_name;

	_td.onmouseover = function()
	{
		this.style.cursor = 'pointer';
		this.style.backgroundColor = this._field_style._field_over_color;
		this.style.backgroundImage = 'url(' + this._field_style._image_over + ')';
		this.style.color = this._field_style._font_over_color;
	}

	_td.onmouseout = function()
	{
		this.style.backgroundColor = this._field_style._field_out_color;
		this.style.backgroundImage = 'url(' + this._field_style._image_out + ')';
		this.style.color = this._field_style._font_out_color;
	}

	_td.onmousedown = function()
	{
		this.style.backgroundColor = this._field_style._field_click_color;
		this.style.backgroundImage = 'url(' + this._field_style._image_click + ')';
		this.style.color = this._field_style._font_click_color;
	}

	_td.onmouseup = function()
	{
		this.style.backgroundColor = this._field_style._field_over_color;
		this.style.backgroundImage = 'url(' + this._field_style._image_over + ')';
		this.style.color = this._field_style._font_over_color;
	}

	_td.onclick = function()
	{
		eval(callback_function_name);
	}
}

asmMenu.prototype.setFieldColor = function(over_color, out_color, click_color)
{
	this._field_style._field_over_color = over_color;
	this._field_style._field_out_color = out_color;
	this._field_style._field_click_color = click_color;

	for (var i = 0; i < this._table.rows.length; i++)
	{
		this.restyle(this._table.rows[i].cells[0]);
	}
}

asmMenu.prototype.setFontColor = function(over_color, out_color, click_color)
{
	this._field_style._font_over_color = over_color;
	this._field_style._font_out_color = out_color;
	this._field_style._font_click_color = click_color;

	for (var i = 0; i < this._table.rows.length; i++)
	{
		this.restyle(this._table.rows[i].cells[0]);
	}
}

asmMenu.prototype.setFontStyle = function(font_size, font_family, font_width)
{
	this._field_style._font_size = font_size;
	this._field_style._font_family = font_family;
	this._field_style._font_width = font_width;

	for (var i = 0; i < this._table.rows.length; i++)
	{
		this.restyle(this._table.rows[i].cells[0]);
	}
}

asmMenu.prototype.setImage = function(image_over, image_out, image_click)
{
	this._field_style._is_image = true;
	this._field_style._image_out = image_out;
	this._field_style._image_over = image_over;
	this._field_style._image_click = image_click;

	for (var i = 0; i < this._table.rows.length; i++)
	{
		this.restyle(this._table.rows[i].cells[0]);
	}
}

asmMenu.prototype.setFieldSize = function(field_width, field_height)
{
	this._field_style._field_width = field_width;
	this._field_style._field_height = field_height;

	for (var i = 0; i < this._table.rows.length; i++)
	{
		this.restyle(this._table.rows[i].cells[0]);
	}
}

asmMenu.prototype.setFieldsGap = function(gap)
{
	this._table.cellSpacing = gap;
}

asmMenu.prototype.restyle = function(_td)
{
	_td._field_style = this._field_style;

	_td.style.width = _td._field_style._field_width;
	_td.style.height = _td._field_style._field_height;

	_td.style.backgroundColor = _td._field_style._field_out_color;
	_td.style.backgroundImage = 'url(' + _td._field_style._image_out + ')';
	_td.style.color = _td._field_style._font_out_color;
	_td.style.fontSize = _td._field_style._font_size;
	_td.style.fontFamily = _td._field_style._font_family;
	_td.style.fontWeight = _td._field_style._font_weight;
}


