$(document).ready(function(){ 
	
	$(".single_image").fancybox({'titlePosition':'inside'});

	$("#basketItemsWrap li:first").hide();
	
	$(".productPriceWrapRight a img").click(function() {
		var productIDValSplitter 	= (this.id).split("_");
		var productIDVal 			= productIDValSplitter[1];
	
		$("#notificationsLoader").html('<img src="images/loader.gif">');
	
		$.ajax({  
		type: "POST",  
		url: "/top10parfum.nl/ajax/basket_functions.php",  
		data: { productID: productIDVal, action: "addToBasket"},  
		success: function(theResponse) 
		{
			$("#mandje_items").html(theResponse+" items");
//			if( $("#productID_" + productIDVal).length > 0){
//				$("#productID_" + productIDVal).animate({ opacity: 0 }, 500, function() {
//					$("#productID_" + productIDVal).before(theResponse).remove();
//				});				
//				$("#productID_" + productIDVal).animate({ opacity: 0 }, 500);
//				$("#productID_" + productIDVal).animate({ opacity: 1 }, 500);
//				$("#notificationsLoader").empty();			
//			} else {
//				$("#basketItemsWrap li:first").before(theResponse);
//				$("#basketItemsWrap li:first").hide();
//				$("#basketItemsWrap li:first").show("slow");  
//				$("#notificationsLoader").empty();			
//			}
			
		}  
		});  
		
	});
	
	
	
	$(".basketItemDelete").live("click", function(event) { 
														
		var productIDValSplitter 	= (this.id).split("_");
		var productIDVal 			= productIDValSplitter[1];	
	
		$("#notificationsLoader").html('<img src="images/loader.gif">');
	
		$.ajax({  
		type: "POST",  
		url: "/top10parfum.nl/ajax/basket_functions.php",  
		data: { productID: productIDVal, action: "deleteFromBasket"},  
		success: function(theResponse) {
			
			$("#productLine_" + productIDVal).hide("slow",  function() {$(this).remove();});
			
			$("#mandje_items").html(theResponse+" items");
			
			reset_total_prijs();
		}  
		});  
		
	});

});

function reset_total_prijs()
{
	$.ajax({  
		type: "POST",  
		url: "/top10parfum.nl/ajax/basket_functions.php",  
		data: { action: "getNewTotal"},  
		success: function(theResponse) 
		{
			$("#wm_totaal_prijs").html("&euro; "+theResponse);
			
		
		}  
	});
}
