$(function(){
	//
	// Navigation rollovers
	//
	$('#navigation li:has(ul)').each(function(e){

		$offset = $(this).position();
		$ul = $(this).find('ul:first');
		
		$ul.offset({ 
			left : $offset.left, 
			top : $offset.top + $(this).outerHeight() 
		}).addClass('movedUL');
		
		$(this).hoverIntent(function(){
			$('.movedUL:eq('+e+')').slideDown();
		},function(){
			$('.movedUL:eq('+e+')').slideUp();
		});
	});
	//
	// Overlay rollovers
	//
	$('.overlay').each(function(e){
		$(this).hide();
		$(this).parent().hoverIntent(function(){
			$(this).find('.overlay:first').slideDown();
		},function(){
			$(this).find('.overlay:first').slideUp();
		}).click(function(){
			$href = $(this).find('.overlay a:first').attr('href');
			window.location.href = $href;
		});
	});
	//
	// Slideshow
	//
	if ($('#slideshow').length > 0)
	{
		$num_images = $('#slideshow').length;
		$('#slideshow img:gt(0)').hide();
		var $autoscroller = setInterval ( function(){
			$curImage = $('#slideshow img:visible');
			if ($curImage.next().length == 1)
			{
				$nextImage = $curImage.next();				
			}
			else
			{
				$nextImage = $('#slideshow img:eq(0)');
			}
			$curImage.fadeOut(1000,function(){
				$nextImage.fadeIn(1000);				
			});
		}, 5500 );
	}
	//
	// Cocktail thumbnails
	//
	if ( $('#cocktail-thumbnails ul').length > 1 )
	{
		$('#cocktail-thumbnails > ul').hide();
		
		$page = $.query.get('p');
		if (!$page)
		{
			$page = '0';
		}
		$('#cocktail-thumbnails ul:eq('+$page+')').show();
		$('#cocktail_navigation a:eq('+$page+')').addClass('selected');
		
		$('#cocktail_navigation a').each(function(e){
			$(this).click(function(){
				$('#cocktail_navigation a').removeClass('selected');
				$(this).addClass('selected');
				$('#cocktail-thumbnails ul:visible').fadeOut(400,function(){
					$('#cocktail-thumbnails ul:eq('+e+')').fadeIn(400);
				});
				return false;
			});
		});
	}
	//
	// Add This
	//
	if ( $('.addthis').length > 0 )
	{
		$.addthis('fontaineabsinthe');
	}
	//
	// Newsletter placeholder
	//
	if ( $('input#email-address') && $.browser.safari != true )
	{
		$placeholder = $('input#email-address').attr('placeholder');
		$('input#email-address').focus(function(){
			if ($(this).val() == $placeholder)
			{
				$(this).val('');
			}
		}).blur(function(){
			if ($(this).val() == '')
			{
				$(this).val($placeholder);
			}
		}).val($placeholder);
	}
});
