
var Store;

jQuery.noConflict();
jQuery(document).ready(function($)
{

	$('a#nav-eat.unselected')
		.css({backgroundPosition: "73px 10px"})
		.mouseover(function() { $(this).stop().animate({backgroundPosition:"(83px 10px)"}, {duration:100}); })
		.mouseout(function() { $(this).stop().animate({backgroundPosition:"(73px 10px)"}, {duration:500}) });
		
	$('a#nav-shop.unselected')
		.css({backgroundPosition: "90px 10px"})
		.mouseover(function() { $(this).stop().animate({backgroundPosition:"(100px 10px)"}, {duration:100}); })
		.mouseout(function() { $(this).stop().animate({backgroundPosition:"(90px 10px)"}, {duration:500}) });
	
	$('a#nav-experience.unselected')
		.css({backgroundPosition: "115px 10px"})
		.mouseover(function() { $(this).stop().animate({backgroundPosition:"(125px 10px)"}, {duration:100}); })
		.mouseout(function() { $(this).stop().animate({backgroundPosition:"(115px 10px)"}, {duration:500}) });
	
	$("#slider .scroller").scrollable({vertical:true, circular:true, speed:500, next:'#slider-down', prev:'#slider-up'}).autoscroll(5000);
	
	$('#featured-articles').cycle(
	{
		fx			: 'fade',
		speed		: 800,
		timeout		: 6000,
		slideExpr	: 'li',
		pause		: true,
		pager		: '#featured-articles-nav' 
	});
	
	$('#directory-callout .vignette').css({opacity:0});
	$('#directory-callout')
		.mouseover(function() 
		{
			$(this).find('.vignette').stop().animate({opacity: 0.5}, {duration:250})
		})
		.mouseout(function()
		{
			$(this).find('.vignette').stop().animate({opacity:0}, {duration:500})
		});
	
	$('form input[type="text"], form textarea').clearOnFocus();
	
	// ----------------------------------------------------------------------------------- directory
	
	Store = 
	{
		show: function(plot) 
		{
			$('#trigger').attr('href', '/wp-content/themes/galleria/includes/store.php?plot='+plot);
			$('#trigger').trigger('click');
		},
		close: function()
		{
			$.fancybox.close();
		}
	}
	
	$('#trigger').fancybox(
	{
		'type'					: 'ajax',
		'padding'				: 0,
		'margin'				: 0,
		'transitionIn'			: 'fade',
		'transitionOut'			: 'fade',
		'speedIn'				: 600, 
		'speedOut'				: 200, 
		'overlayShow'			: true,
		'overlayColor'			: '#000000',
		'overlayOpacity'		: 0.5,
		'titleShow'				: false,
		'showCloseButton'		: false
	});
	
	
});

(function($) 
{
	$.fn.clearOnFocus = function() 
	{	
		function clearOnFocusFocus(event)
		{
			if($(this).val() == $(this).data('clearOnFocus'))
			{
				$(this).val('');
			}
		}
		
		function clearOnFocusBlur(event)
		{
			if($.trim($(this).val()) == '')
			{
				$(this).val($(this).data('clearOnFocus'));
			}
		}
		
		return this.each(function()
			{
				$(this).data('clearOnFocus', $(this).attr('value'));
				
				//	unbind any previous listeners
				$(this).unbind('focus', clearOnFocusFocus);
				$(this).unbind('blur', clearOnFocusBlur);
				
				//	bind listeners to the functions
				$(this).bind('focus', clearOnFocusFocus);
				$(this).bind('blur', clearOnFocusBlur);
			}
		);
	};
	
})(jQuery);
