function DynamicMenu(elements)
{	
	var that = this;
	var timeout = 500;
	var closeTimer = 0;
	var holder = null;
	var subMenu = null;
	var image = null;
	var imageSource = null;
	var elements = $(elements);
	elements.find('ul').css('visibility', 'visible').hide();
	elements.find('div').css('visibility', 'visible').hide();
			
	function hoverImage()
	{
		if (!image) return;
		imageSource = image.attr('src');
		var path = imageSource.split('.');		
		if (imageSource.indexOf('_') == -1)
		{
			imageSource = path[0] + '_.' + path[1];
			image.attr('src', imageSource);
		}		
	}
	
	function normalImage()
	{
		if (image) image.attr('src', imageSource.replace('_', ''));	
	}
	
	this.show = function()
	{
		cancelTimer();
		that.hide();
		image = $(this).find('img');
		var pos = image.position();
		hoverImage();		
		holder = $(this).find('div').eq(0).css(
		{
			position: "absolute",
			top: pos.top + 22,
			left: pos.left + 6,
			width: image.width() - 15,
			height: image.height()
		}).show();		
		subMenu = $(this).find('ul').eq(0).css(
		{
			position: "absolute",
			top: pos.top + 32,
			left: pos.left + 6
		}).show();
	}
	
	this.hide = function()
	{
		if(holder) holder.hide();
		if(subMenu) subMenu.hide();
		normalImage();
	}
	
	this.timer = function()
	{
		closeTimer = window.setTimeout(that.hide, timeout);
	}
	
	function cancelTimer()
	{
		if(closeTimer)
		{
			window.clearTimeout(closeTimer);
			closeTimer = null;
		}
	}
	
	elements.bind('mouseover', this.show);
	elements.bind('mouseout',  this.timer);
	document.onclick = this.hide;
}
