
$(document).ready(function() { 
 
 
	
	
	function chainAnim(e,s) {
    var $fade = $(e);
    $fade.each(function( i ){
        $(this).delay(i * s).fadeTo(s,1);
    });
	} 
		
	chainAnim('.section',500); 

	//Make columns on wines page align
	$('#wineList ul').columnize({width: 230, buildOnce : true, lastNeverTallest: true});
	
	
	//Use label property for default value
	$(".mailingListfield.first_name input").DefaultValue();
	$(".mailingListfield.last_name input").DefaultValue();
	$(".mailingListfield.email input").DefaultValue();
	$(".mailingListfield.postcode input").DefaultValue();
	
	//Home banner
	$("#banner").CarouSlide({
		animType:"fade",
		showBackNext:false,
		animInfinity:true,
		showPauseButton:false,
		autoAnim:true,
		animTime:1000,
		slideTime:5000
	});
	
	//News/Events slider
	$("#NewsEventsFeed").CarouSlide({
	animType:"slide",
	showBackNext:true,
	animInfinity:true,
	autoAnim:true,
	animTime:1200,
	slideTime:5000
	});
	
	
	//Fade between wine items on Our wines page
	$('#wineList a').mouseenter(function() {
		var bottleName = $(this).attr('rel');
		/* alert(bottleName); */
		$('.current').fadeOut(200);
		$('.current').removeClass('current');
		$('.' + bottleName).addClass('current');
		$('.' + bottleName).fadeIn(200);
	}).mouseleave(function(){
		$('.current').fadeOut(200);
	});
	
	//Truncate summary for news/events
	$('.truncate').truncatable({
			limit:200,
			more: '...',
			less: true,
			hideText: '[hide]'
		});
	 		
	$('.jqmClose').click(function() {
		$('#productAdded').hide();
		$.fancybox.close();
	});


	$('.lightbox.wine_login').fancybox({
			'href': '/LoginForm',
			'overlayColor': '#000',
			'overlayOpacity': 0.7,
			'transitionIn': 'fade',
			'transitionOut': 'fade',
			'width' 		: 376,
			'height'		: 351,
			'scrolling'		: 'no',
			'padding'		: 0,
			'showCloseButton': false,
			'centerOnScroll': true,
			'hideOnOverlayClick':true,
			'type': 'iframe'
		});

	 		
});

