
function init_menu()
{
	var menu_count = 0;
	$('.frontMenu').each(function(){
		var obj = $(this);

		obj.attr('menu_timer_id', 0);
		
		var iOffset = obj.offset();
		
		var robj = document.createElement('DIV');
		if(this.id == '')
			this.id = 'mainmenu'+ (menu_count+1);
		robj.id = this.id + '_shadow';
		robj.trueid = this.id;
		obj.parent().append(robj);
		robj = $(robj);
		robj.addClass('frontMenuShadow');
		
		var imgfile = obj.attr('src');
		if(!imgfile)
			imgfile = obj.attr('originalSrc');
		imgfile = imgfile.replace('.png', '_on.png');

		if (navigator.userAgent.indexOf("MSIE")!= -1 && navigator.appVersion.indexOf("MSIE 6.0")!= -1)
			robj.css('filter', "progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+imgfile+",sizingMethod='crop')");
		else
			robj.css('background-image', "url('"+ imgfile +"')");
		
		robj.width(0);
		robj.height(obj.height());
		robj.hide();

		obj.parent().bind('mouseover', menuMouseOver).bind('mouseout', menuMouseOut);
		
		menu_count++;
	});
	
}

var menu_timer_id = 0;

function menuMouseOver()
{
	var obj = $('img', this);
	var robj = $('#' + obj.attr('id') + '_shadow');
	
	
	if(obj.attr('menu_timer_id') == 0)
	{
		robj.stop();
		robj.animate({'width': obj.width() + 'px'}, {'duration':400 , 'easing':'easeIn', 'complete':menuMouseComplete});
	}
	else
	{
		clearTimeout(obj.attr('menu_timer_id'));
		obj.attr('menu_timer_id', 0);
	}

	return true;
}


function menuMouseOut()
{
	var obj = $('img', this);
	var robj = $('#' + obj.attr('id') + '_shadow');
	
	obj.attr('menu_timer_id', setTimeout(function(){
		robj.stop();
		robj.width(0);
		robj.hide();
		obj.attr('menu_timer_id', 0);
	}, 1));
	return true;
}


function menuMouseComplete()
{
	var robj = $(this);
	
	if(typeof show_submenu != 'undefined')
		show_submenu(wait_submenuno);
	
}

jQuery(document).ready(function() {
	init_menu();
});



