// THIS IS ACTUALLY VERSION 20 BUT NOT RENAMED IT TOUGH (SIM CLICK FUNCITON ADDED)
function bindMenuEffect(objName, container_id, css_default, css_over, css_selected, option_type, callback_function, isSelected)
{
	this.objName = objName;
	this.container_id = container_id;
	
	this.OPTIONS = new Array ();
	
	this.option_type = option_type ? option_type : 'DIV';
	this.callback_function = callback_function;
	this.options_index = 0;
	this.isSelected = isSelected ? isSelected : 0;

	this.css = new Array();
	this.css['default'] = css_default;
	this.css['over'] = css_over;
	this.css['selected'] = css_selected;

	this.last_selected = null;
	this.last_hovered = null;
	this.last_hovered_class = null;
	
	this.options_container = document.getElementById(this.container_id);
	
	this.options_container.setAttribute("bmeObj", objName);

	this.event_over = function(el)
	{

		if(this.last_hovered)
		{
			this.last_hovered.className = this.last_hovered_class;
		}

		this.last_hovered_class = el.className;

		el.className = this.css['over'];

		this.last_hovered = el;
		
		if(callback_function)
		{
			callback_function(el, "over");
		}

	};

	this.event_out = function(el)
	{

		if(this.last_hovered)
		{
			this.last_hovered.className = this.last_hovered_class;
		}


		this.last_hovered = null;
		this.last_hovered_class = null;
		

		if(callback_function)
		{
			callback_function(el, "out");
		}
	};

	this.event_click = function(el)
	{
		if(this.last_selected)
		{
			this.last_selected.className = this.css['default'];
		}
		this.last_hovered_class = this.css['selected'];
		el.className = this.css['selected'];
		this.last_selected = el;
		if(callback_function)
		{
			callback_function(el, "click");
		}
	};
	
	this.sim_click = function(index)
	{
		var idx = index - 1;
		this.event_click (this.OPTIONS[idx]);
	}
	
	for (node_index=0; node_index < this.options_container.childNodes.length; node_index++)
	{
		if (this.options_container.childNodes[node_index].nodeName == option_type)
		{	
			this.OPTIONS[this.options_index] = this.options_container.childNodes[node_index];
		
			this.options_container.childNodes[node_index].setAttribute("optionIndex", this.options_index);
			
			this.options_container.childNodes[node_index].className = this.css['default'];
			
			this.options_container.childNodes[node_index].onmouseover = function()
			{
				eval(this.parentNode.getAttribute("bmeObj") + ".event_over(this);");
			};
			
			this.options_container.childNodes[node_index].onmouseout = function()
			{
				eval(this.parentNode.getAttribute("bmeObj") + ".event_out(this);");
			};
			
			this.options_container.childNodes[node_index].onclick = function()
			{
				eval(this.parentNode.getAttribute("bmeObj") + ".event_click(this);");
			};
			
			var goSelect = false;
			
			if (this.isSelected)
			{
				if (this.isSelected - 1 == this.options_index)
				{
					goSelect = true;
				}
			}
			else if (this.options_container.childNodes[node_index].getAttribute("isSelected") == "yes")
			{
				goSelect = true;
			}
			
			if (goSelect)
			{
				this.last_hovered_class = this.css['selected'];
				this.options_container.childNodes[node_index].className = this.css['selected'];
				this.last_selected = this.options_container.childNodes[node_index];	
			}
			
			this.options_index++;
		}
	}
}
