// JavaScript Document
function Menu(id) {
	this.obj = document.getElementById(id);
	this.initialized = false;
	this.children = new Array();
}

Menu.prototype.obj;
Menu.prototype.type = "Menu";
Menu.prototype.children;

Menu.prototype.getObject = function() {
	return this.obj;
}

Menu.prototype.initialize = function () {
	this.obj.innerHTML = "";
	this.children = new Array();
	this.initialized = true;
}

Menu.prototype.appendChild = function(menuItem) {
	if (menuItem.type != "MenuItem") throw("Parameter is not MenuItem type");
	this.children.push(menuItem);
}

Menu.prototype.contains = function(menuItem) {
	if (menuItem.type != "MenuItem") throw("Parameter is not MenuItem type");
	for (var i=0; i<this.children.length; i++) {
		if (this.children[i] == menuItem) return true;
	}
	return false;
}

Menu.prototype.draw = function() {
	if (!this.initialized) throw("Menu has not been initialized");
	for (var i=0; i<this.children.length; i++) {
		this.obj.appendChild(this.children[i].toDOMObject());
	}
	return this.obj;
}
