function cart()
{
	if (FC && FC.json)
	{
		if(FC.json.product_count == 0)
		{
			$('div#cart').replaceWith('<div id="cart"></div>');
		}
		else
		{
			var cart = '<div id="cart" style="padding-top: 2px; border-top: 1px solid #e0e0e0; padding-bottom: 8px; border-bottom: 1px solid #e0e0e0; margin-top: 24px;"><div>Your Selection</div><table class="cart">';

			for(var key in FC.json.products)
			{
				var product = FC.json.products[key];

				if (product.url != "")
				{
					cart += '<tr><td' + (product.quantity > 1 ? ' style="text-align: right;">' + product.quantity + ' ×' : '>') + '</td><td><a href="' + product.url + '">' + product.name + '</a></td></tr>';
				}
				else
				{
					cart += '<tr><td>' + (product.quantity > 1 ? ' style="text-align: right;">' + product.quantity + ' ×' : '>') + '</td><td>' + product.name + '</td></tr>';
				}
			}
			cart += '<tr class="total"><td colspan="2">€' + FC.json.total_price + '</td></tr>';
			cart += '</table><div style="margin-top: 16px;"><a id="modify" href="https://claudiahill.foxycart.com/cart?fcsid=' + FC.json.session_id + '" class="subtle" style="margin-right: 12px;">Modify</a><a id="checkout" href="https://claudiahill.foxycart.com/checkout?fcsid=' + FC.json.session_id + '" class="subtle">Checkout</a></div></div>'

			$('div#cart').replaceWith(cart);

			$('a#modify').colorbox(
				{
					a:$(this).attr('href'),
					iframe: true,
					current:"",
					close:"",
					previous:"",
					next:"",
					width: 700,
					height: "75%",
					onClosed: function()
						{
							FC.client.prototype.cart_update();
						},
					returnFocus:false,
				});
		}
	}
}

FC.client.prototype.cart_update = function()
{
	var self = this;
	jQuery.getJSON('https://' + fcc.storedomain + '/cart?cart=get&output=json' + fcc.session_get() + '&callback=?', function(data)
		{
			FC.json = data;

			cart();

			if ( ! self.session_initialized == true)
			{
				self.session_initialized = true;
				FC.session_id = data.session_id;
				self.session_set();
				self.session_get();
			}
			self.session_apply();
		});
};

FC.client.prototype.init = function()
{
	this.cart_update();
};

// Initialize the fcc object
var fcc = new FC.client(storedomain, sitedomain, cookiepath);
fcc.events.cart.preprocess = new FC.client.event();
fcc.events.cart.process = new FC.client.event();
fcc.events.cart.postprocess = new FC.client.event();

jQuery(document).ready(function()
{
	fcc.init();
});

$('a.addtocart').click( function()
	{
		$.getJSON( $(this).attr('href') + '&output=json&callback=?' + fcc.session_get(), function(data)
			{
				FC.json = data;
				cart();
			});

		_gaq.push(['_trackEvent', 'Store', 'Add', $(this).attr('rel')]);
		GoSquared.DefaultTracker.TrackEvent('Add to Cart', $(this).attr('rel'));

		return false;
	});

