function RollMenu(num, cname)
{
	this._name = cname;
	this._element = null;
	this._size = num;
	this._pointer = 0;
	this._names = new Array(num);
	this._values = new Array(num);
	this._targets = new Array(num);
	this._showing = false;
	this._field = null;
}

RollMenu.prototype.create = function(el)
{
	var firstBorder;
	var secondBorder;
	var thirdBorder;
	var item;
	var a;
	var text;
	var table;
	var tbody;
	var tr;
	var td;
	var menu = this;

	this._element = el;

	this._field = document.createElement("div");
	this._field.className = "rollMenu";
	this._field.style.position = "absolute";
	//this._field.style.visibility = "hidden";
	this._field.style.display = "none";
	this._field.style.zIndex = "400";

	firstBorder = document.createElement("div");
	firstBorder.className = "firstBorder";

	secondBorder = document.createElement("div");
	secondBorder.className = "secondBorder";

	table = document.createElement("table");
	table.className = "table";

	tbody = document.createElement("tbody");

	for(i = 0; i < this._pointer; i++)
	{
		tr = document.createElement("tr");
		td = document.createElement("td");
		td.style.textAlign = "center";
		a = document.createElement("a");
		a.href = this._values[i];
		a.style.display = "block";
		a.style.textAlign = "left";
		if(this._targets[i] != "#")
		{
		    a.target = this._targets[i];
		}
		td.style.whiteSpace = "nowrap";
		text = document.createTextNode(this._names[i]);
		a.appendChild(text);
		td.appendChild(a);
		tr.appendChild(td);
		tbody.appendChild(tr);
	}


	table.appendChild(tbody);
	secondBorder.appendChild(table);
	firstBorder.appendChild(secondBorder);
	this._field.appendChild(firstBorder);
	this._element.appendChild(this._field);
}

RollMenu.prototype.show = function()
{
    if(!this._showing)
    {
	    this._field.style.display = 'block';
	    this._showing = true;
	}
}

RollMenu.prototype.hide = function()
{
	if(this._showing)
    {
	    this._showing = false;
	    setTimeout("if(!" + this._name +"._showing) " + this._name + "._field.style.display = 'none';", 100);
	}
}

RollMenu.prototype.addItem = function(name, value, target)
{
	if(this._pointer < this._size)
	{
		this._names[this._pointer] = name;
		this._values[this._pointer] = value;
		this._targets[this._pointer] = target;
		this._pointer++;
	}
}


