$(function() {

	$(".tooltip").ezpz_tooltip({
		contentPosition: 'belowStatic',
		stayOnContent: true,
		offset: 0
	});


	$("A.cartajax").click(ajaxCartLinks);

	function ajaxCartLinks() {

		$(".cartloader").show();
		$(".cart .items").css('opacity','0.2');

		var url = $(this).attr("href");
		$(this).parent().parent().find(".message .cartalert").attr("rel","loading");

		$.get(url + "?c=" + myTimestamp(), {}, function (data) {

			// Was dus blijkbaar succesvol toegevoegd aan de cart. Vernieuwd het mandje in de interface
			$("DIV.cart").html(data);

			// Reset loading indication
			$(".cart .items").css('opacity','1');
			$(".cartloader").hide();

			$("A.cartajax").click(ajaxCartLinks);

			$(".message .cartalert[rel='loading']").fadeIn('slow').html("<img src='/img/cartsuccess.png'> Winkelwagen is vernieuwd");
			setTimeout(function () {
				$(".message .cartalert[rel='loading']").fadeOut('slow');
				$(".message .cartalert").attr('rel','');
			}, 10000);

		});

		return false;

	}

	// Use this example, or...
	$('a[@rel*=largebox]').lightBox(); // Select all links that contains lightbox in the attribute rel

});

//lreturns a timestamp. Used to avoid IE caching Ajax requests
function myTimestamp(){
    tstmp = new Date();
    return tstmp.getTime();
}
