Menu = Class.create();
Menu.prototype =
{
	initialize: function(classname)
	{
		this.activeItems = new Array();
		this.clayers = new Array();
		this.menuItems = $$("."+classname);
		for (i=0; i<this.menuItems.length; i++)
		{
			this.clayers[i] = this.menuItems[i].select(".clayer").first();
			Event.observe(this.menuItems[i], "mouseover", this.overCallback.bindAsEventListener(this, i), true);
			Event.observe(this.menuItems[i], "mouseout", this.outCallback.bindAsEventListener(this, i), true);
		}
	},
	
	killMotion: function(i)
	{
		delete this.activeItems[i];
	},
	
	overCallback: function(event, i)
	{
		if (this.activeItems[i])
			this.activeItems[i].cancel();
		this.activeItems[i] = new Effect.Parallel(
			[
				new Effect.Morph(this.menuItems[i], { sync: true, style: { top: "550px", height: "50px" } }),
				new Effect.Morph(this.clayers[i], { sync: true, style: { opacity: "0.95", height: "50px" } })
			],
			{
				duration: 0.3,
				afterFinish: this.killMotion.bind(this, i)
			}	
		);
		
		if ($(this.clayers[i]).hasClassName("block2"))
			$("thumb_block2").show();
		else if ($(this.clayers[i]).hasClassName("block3"))
			$("thumb_block3").show();
		else if ($(this.clayers[i]).hasClassName("block4"))
			$("thumb_block4").show();
		else if ($(this.clayers[i]).hasClassName("block5"))
			$("thumb_block5").show();
	},
	
	outCallback: function(event, i)
	{
		if (this.activeItems[i])
			this.activeItems[i].cancel();
		this.activeItems[i] = new Effect.Parallel(
			[
				new Effect.Morph(this.menuItems[i], { sync: true, style: { top: "575px", height: "50px" } }),
				new Effect.Morph(this.clayers[i], { sync: true, style: { opacity: "0.5", height: "50px" } })
			],
			{
				duration: 0.3,
				afterFinish: this.killMotion.bind(this, i)
			}	
		);
		if ($(this.clayers[i]).hasClassName("block2"))
			$("thumb_block2").hide();
		else if ($(this.clayers[i]).hasClassName("block3"))
			$("thumb_block3").hide();
		else if ($(this.clayers[i]).hasClassName("block4"))
			$("thumb_block4").hide();
		else if ($(this.clayers[i]).hasClassName("block5"))
			$("thumb_block5").hide();
	}
}

