function Menu(strObject_Name, str_ID, Callback) {
	this.items_num = 0;	this.items = Array();	this.cur_Sel = 0;	this.objName = strObject_Name;	this.elt_ID = str_ID;	this.callback = Callback;
	this.chClass_name = "selton";this.unchClass_name="seltoff";
		if (arguments.length >= 5){	this.chClass_name = arguments[3];this.unchClass_name = arguments[4];if (arguments.length == 5) {this.maxSelection = arguments[5];}}
		}

Menu.prototype.clear = function() {$(this.elt_ID).innerHTML = "";	this.items_num = 0;	this.items.clear();	this.cur_Sel = 0;}

Menu.prototype.add_item = function($content) {
	$(this.elt_ID).innerHTML += '<div style="cursor:pointer" class="' + this.unchClass_name + '" onmouseover="' + this.objName + '.highlight(\'' + this.items_num + '\')" onmouseout="' + this.objName +'.highlight(\'' + this.items_num + '\')" onblur="Element.hide (\''+this.elementID+'\');" onclick="' + this.callback + '(\'' + this.items_num + '\')" id="MENU_ITEM_' + this.items_num + '" onContextMenu="mouse_submit()">' + $content + '</div>';
	this.items.push ($content);
	this.items_num ++;
}
Menu.prototype.add_item_h = function($content) {
	$(this.elt_ID).innerHTML += '<div style="cursor:pointer;display:none;" class="' + this.unchClass_name + '" onmouseover="' + this.objName + '.highlight(\'' + this.items_num + '\')" onmouseout="' + this.objName +'.highlight(\'' + this.items_num + '\')" onblur="Element.hide (\''+this.elementID+'\');" onclick="' + this.callback + '(\'' + this.items_num + '\')" id="MENU_ITEM_' + this.items_num + '" onContextMenu="mouse_submit()">' + $content + '</div>';
	this.items.push ($content);
	this.items_num ++;
}
Menu.prototype.add_item_add = function($content) {
	$(this.elt_ID).innerHTML += '<div style="cursor:pointer" class="' + this.unchClass_name + '" onblur="Element.hide (\''+this.elementID+'\');" onmouseover="' + this.objName + '.highlight_add(\'' + this.items_num + '\')" onmouseout="' + this.objName +'.highlight_add(\'' + this.items_num + '\')" onclick="' + this.callback + '(\'' + this.items_num + '\')" id="MENU_ITEM_add_' + this.items_num + '" onContextMenu="mouse_submit()">' + $content + '</div>';
	this.items.push ($content);
	this.items_num ++;
}
Menu.prototype.add_item_add_h = function($content) {
	$(this.elt_ID).innerHTML += '<div style="cursor:pointer;display:none;" class="' + this.unchClass_name + '" onblur="Element.hide (\''+this.elementID+'\');" onmouseover="' + this.objName + '.highlight_add(\'' + this.items_num + '\')" onmouseout="' + this.objName +'.highlight_add(\'' + this.items_num + '\')" onclick="' + this.callback + '(\'' + this.items_num + '\')" id="MENU_ITEM_add_' + this.items_num + '" onContextMenu="mouse_submit()">' + $content + '</div>';
	this.items.push ($content);
	this.items_num ++;
}

Menu.prototype.highlight = function (id) {
	for (var i = 0; i < this.items_num; i++) {
		var d = $('MENU_ITEM_' + i);
		if (id == i) {
			d.className = this.chClass_name;
			this.cur_Sel = i;
		} else {
			d.className = this.unchClass_name;
		}
	}
}
Menu.prototype.highlight_add = function (id) {
	for (var i = 0; i < this.items_num; i++) {
		var d = $('MENU_ITEM_add_' + i);
		if (id == i) {
			d.className = this.chClass_name;
			this.cur_Sel = i;
		} else {
			d.className = this.unchClass_name;
		}
	}
}

Menu.prototype.sel_next = function () {
	if (this.items_num == 0)
		return;
	if (this.cur_Sel < this.items_num - 1) {
		this.highlight (this.cur_Sel + 1);
	}
}

Menu.prototype.sel_prev = function () {
	if (this.items_num == 0)
		return;
	if (this.cur_Sel > 0) {
		this.highlight (this.cur_Sel - 1);
	}
}
Menu.prototype.sel_next_add = function () {
	if (this.items_num == 0)
		return;
	if (this.cur_Sel < this.items_num - 1) {
		this.highlight_add (this.cur_Sel + 1);
	}
}

Menu.prototype.sel_prev_add = function () {
	if (this.items_num == 0)
		return;
	if (this.cur_Sel > 0) {
		this.highlight_add (this.cur_Sel - 1);
	}
}

Menu.prototype.get_content = function (id) {
	if (id >= 0 && id < this.items_num) {
		return $('MENU_ITEM_' + id).innerHTML;
	} else {
		return false;
	}
}
Menu.prototype.get_content_add = function (id) {
	if (id >= 0 && id < this.items_num) {
		return $('MENU_ITEM_add_' + id).innerHTML;
	} else {
		return false;
	}
}
Menu.prototype.getkey_content = function () {
	//alert(this.cur_Sel);
	if (this.cur_Sel >= 0 && this.cur_Sel < this.items_num) {
		return $('MENU_ITEM_' + this.cur_Sel).innerHTML;
	} else {
		return false;
	}
}
Menu.prototype.getkey_content_add = function () {
	//alert(this.cur_Sel);
	if (this.cur_Sel >= 0 && this.cur_Sel < this.items_num) {
		return $('MENU_ITEM_add_' + this.cur_Sel).innerHTML;
	} else {
		return false;
	}
}

Menu.prototype.get_current_content = function () {
	return this.get_content(this.cur_Sel);
}
Menu.prototype.get_current_content_add = function () {
	return this.get_content_add(this.cur_Sel);
}
