
simpleCart.cartHeaders = [ "Name", "Colour", "Design" , "Price" , "Quantity" , "Total" ]
simpleCart.email = "orders@mooseandme.com.au";
simpleCart.checkoutTo = PayPal;
simpleCart.currency = AUD;

$(document).ready(function(){	

	$('.toggleBasket').click(function(){
		$('#basket').slideToggle('slow');
	});

	$('.item_add').click(highlightBasket);

	$('#product-view .close').click(function(e){
		$('#product-view').animate({
			top: '-310px',
			opacity: 0
			}, 800, 'easeInCirc');
		e.preventDefault();
	});

	$('[data-product-name]').click(function(e){
		$('.thumbnail').stop().css({opacity: 1});
		//find the product's div
		name = $(this).attr("data-product-name");
		//move it to the top
		$('#product-view').prepend($('div[name="'+name+'"]'));
		//and show the overlay
		$('#product-view').animate({
			top: '0px',
			opacity: 1
			}, 800, 'easeOutCirc');
		e.preventDefault();
	});

	$('.thumbnail').hover(
		function(){
			$('.thumbnail').not(this).stop().animate({opacity: 0.5}, 400);
			$(this).stop().animate({opacity: 1	}, 400);
		}, 
		function(){
			$('.thumbnail').stop().animate({opacity: 1}, 700);
		}
	);

	/* basket pluralization */
	$('.simpleCart_quantity').bind('contentchange', basketPluralization);
	basketPluralization();
});

(function(){
        var interval;
        jQuery.event.special.contentchange = {
        setup: function(){
            var self = this,
            $this = $(this),
            $originalContent = $this.text();
            interval = setInterval(function(){
                if($originalContent != $this.text()) {
                        $originalContent = $this.text();
                    jQuery.event.handle.call(self, {type:'contentchange'});
                }
            },100);
        },
        teardown: function(){
            clearInterval(interval);
        }
    };
})();
function basketPluralization(){
	if($('.simpleCart_quantity').text() == '1'){
		$('.areis').text('is')
		$('.itemitems').text('item')
	}else{
		$('.areis').text('are')
		$('.itemitems').text('items')
	}		
}

function highlightBasket(){
	$('.toggleBasket').animate({ backgroundColor : '#FFF58F'}, 500, function(){
		$('.toggleBasket').delay(1000).animate({ backgroundColor : '#fff'}, 500	);
	});
}

