function init()
{
	setupNavEvents();
	
	$('#signUp').click(function()
	{
		window.location = 'http://www.racingoptics.com/newsletter.php';
	});
}

function setupNavEvents()
{
	$('#menu li').each(function(index, element)
	{
		eachMenuItem(index, element);
	});
}

function eachMenuItem(index, element)
{
	var uris = ['/', '/partners.php', '/shop.php', '/dealer_locator.php', '/about_us.php', '/contact.php', '', '/blog', '/press.php'];
	var btnWidths = [56, 84, 54, 120, 80, 79, 327, 57, 87];
	if (BrowserDetect.OS != 'iPhone' && BrowserDetect.OS != 'iPad')
	{
		$(element).mouseover(function()
		{
			var btnX = 0;
			for (var i = 0; i < index; i++) btnX += btnWidths[i];
			var name = $(element).attr('id');
			var html = '<div id="navBtnOver' + index + '" style="margin: 0 18px; cursor: pointer; width: ' + btnWidths[index] + 'px; height: 33px; position: absolute; top: ' + $(element).offset().top + 'px; left: ' + btnX + 'px; background: url(images/' + name + 'BtnOver.png) 0 0 no-repeat"></div>';
			$('#top').append(html);
			$('#navBtnOver' + index).hide().fadeIn();
		
			$('#navBtnOver' + index).mouseout(function()
			{
				$('#navBtnOver' + index).fadeOut(400, function()
				{
					$('#navBtnOver' + index).remove();
				})
			});
		
			$('#navBtnOver' + index).click(function()
			{
				window.location = 'http://www.racingoptics.com' + uris[index];
			});
		});
	} else
	{
		$(element).click(function()
		{
			window.location = 'http://www.racingoptics.com' + uris[index];
		});
	}
}

$().ready(init);
