function catalogueListing(catalogueId) {
	var pDiv = $('#catalogue-products-container');
	$('<div/>')
		.attr('id', 'loader-products')
		.width(pDiv.width())
		.height(pDiv.height())
		.addClass('loader loader2')
		.appendTo(pDiv);
	
	var sendData = (catalogueId != null) ? {id:catalogueId} : null;
	$.get('catalogue_listing.action', sendData, function(data, status, xhr) {
		$('#catalogue-xhr-response-container').html(data);
		$('#catalogue-listing-container').html($('ul#catalogue-listing-container-xhr').html());
		$('#catalogue-products-container').html($('div#catalogue-products-container-xhr').html());
		$('#loader-products').remove();
	});
}

function addToCart(id, big) {
	var cartDiv = $('#shopping-cart-container');
	if (cartDiv != null) {
	$('<div/>')
		.attr('id', 'loader-cart')
		.width(cartDiv.width())
		.height(cartDiv.height() - $('#shopping-cart-container > h2').height())
		.addClass('loader')
		.appendTo(cartDiv);
	}
	
	$.ajax({
		url: 'catalogue_addCart.action',
		type: 'POST',
      	data: { productId: id, big: big },
      	success: function(data, status, xhr) {
      		$('#shopping-cart-items-container').replaceWith(data);
      		$('#loader-cart').remove();
      	}
	});
}

var intID = 0;
function scrollCard(){
	var point = ($(document).scrollTop() - 411 ) + 50;
	
	$('#shopping-cart-container').stop(true, false);
	
	$('#shopping-cart-container').animate({
		top: point < 0 ? 0 : point 
	}, 1000);
}

$(window).scroll(function () {
	clearTimeout(intID);
	if ( $(window).height() > $('#shopping-cart-container').height() + 50) {
		intID = setTimeout('scrollCard()', 300);
	} else { 
		$('#shopping-cart-container').css('top', 0); 
	}
});




