function BrowseMenu(menu)
{
	this.menu = menu;
	var that = this;
	
	this.Show = function ()
	{
		that.menu.setStyle({'display':'block'});
		var parent = that.menu.up(0);
		var x = find_x_pos(parent) + parent.getWidth() - 75 + 'px';
		var y = find_y_pos(parent) - that.menu.getHeight() + parent.getHeight() + 'px';
		that.menu.setStyle({'left':x,'top':y});
	};
	
	this.Hide = function () { that.menu.setStyle({'display':'none'}); };
}

function find_x_pos(elem)
{
	if(elem.offsetParent == null)
		return 0;
	else
		return elem.offsetLeft + find_x_pos(elem.offsetParent);
}

function find_y_pos(elem)
{
	if(elem.offsetParent == null)
		return 0;
	else
		return elem.offsetTop + find_y_pos(elem.offsetParent);
}

var fix_height = function (height)
{
	var page = $('page');
	var nav = $('nav');
	var nav_height = nav.getHeight();
	var content = $('content');
	var content_height = content.getHeight();
	
	height = height == null ? (nav_height > content_height ? nav_height : content_height) : height;
		
	nav.setStyle({'height':height+20+'px'});
	content.setStyle({'height':height+'px'});
	page.setStyle({'height':height+20+'px'});
};

var remove_non_alphanumeric = function (value) { return value.replace(/[^A-Za-z0-9]/g, ""); };

var find_select_index = function (select, value)
{
	var found = false;
	
	for(var i=0; i<select.options.length && found === false; i++)
	{
		if(select.options[i].value == value)
		{
			found = i;
		}
	}
	
	return found;
}