var Menus = {
	Initialize: function() {
		var images = {};
		$('img[over]').each(function() {
			var over = new Image();
			over.src = $(this).attr('over');

			var out = new Image();
			out.src = $(this).attr('out');

			images[$(this).attr('alt')] = {
				Over: over,
				Out: out,
				Selected: $(this).attr('selected') == 1
			};

			//if ($(this).attr('selected') == 0) {
				$(this).bind('mouseover', function() {
					$(this).attr('src', images[$(this).attr('alt')].Over.src);
				});

				$(this).bind('mouseout', function() {
					if (images[$(this).attr('alt')].Selected) { return; }
					$(this).attr('src', images[$(this).attr('alt')].Out.src);
				});

				$(this).css({
					cursor: 'pointer'
				}).click(function() {
					window.location = $(this).attr('link');
				});
			//}
		});

		$('#menu img').hover(
			function() {
				$('.submenu[data-type="' + $(this).attr('alt') + '"]').css({
					display: 'block',
					left: $(this).offset().left,
					top: $(this).offset().top + 40
				});
			},
			function() {
				$('.submenu[data-type="' + $(this).attr('alt') + '"]').css({
					display: 'none'
				});
			}
		);

		$('#menu .submenu').hover(
			function() {
				$(this).css({ display: 'block' });
				$('img[alt="' + $(this).attr('data-type') + '"]').trigger('mouseover');
			},
			function() {
				$(this).css({ display: 'none' });
				$('img[alt="' + $(this).attr('data-type') + '"]').trigger('mouseout');
			}
		)
	}
};
