/*
JavaScript Document for FlavourOnline.co.uk
Coded by Chris Stanyon - December 2010
*/
function bannerRotation() {

	setInterval(function () {
		var $active = $('#rotation A.active');

	    if ( $active.length == 0 ) $active = $('#rotation A:last');

	    var $next =  $active.next().length ? $active.next() : $('#rotation A:first');

	    $active.addClass('last-active');

	    $next.css({opacity: 0.0})
    	    .addClass('active')
        	.animate({opacity: 1.0}, 1000, function() {
            	$active.removeClass('active last-active');
	        });
	}, 3500 );
}



function basketDelete() {
	
	
	
}

function externalLinks() {
	$('a[rel=external]').attr('target','_blank');
}


function addToBasket() {
	//Set up the Ajax call to add the product to the basket.
	$('#addToBasket').click(function(event) {
		event.preventDefault();
		$('#SubmitMethod').val('ajax');
		var $myForm = $('#addProduct');
		
		$.ajax({
			type: 'POST',
			url: $myForm.attr('action'),
			data: $myForm.serialize(),
			success: function(data){
				$('#qc_subtotal').html(data.basketValue);
				$('#qc_items').html(data.basketItems);
				$("<p class='success'>Thank you. This item has been added to your basket.</p>").hide().appendTo("#addProduct").fadeIn().delay(1500).fadeOut();
			},
			dataType: 'json'
		});
	});
}

