
$(document).ready(function(){ 

	$("#basketItemsWrap li:first").hide();
	$("#basketItemsWrap2 li:first").hide();
	
	$(".productPriceWrapRight a img").click(function() {
		var IdProducteValSplitter 	= (this.id).split("_");
		var IdProducteVal 			= IdProducteValSplitter[1];
		var idioma 					= IdProducteValSplitter[2];

		
		$("#notificationsLoader").html('<img src="js/cart/images/loader.gif">');
		var valor = document.getElementById('qt_'+IdProducteVal).value;
		
	
		$.ajax({  
		type: "POST",  
		url: "js/cart/inc/functions.php",  
		data: { IdProducte: IdProducteVal, action: "afegeixCistella",idioma: idioma,quantitat:valor},  
		success: function(theResponse) {
			
			if( $("#IdProducte_" + IdProducteVal).length > 0){
				$("#IdProducte_" + IdProducteVal).animate({ opacity: 0 }, 100, function() {
					$("#IdProducte_" + IdProducteVal).before(theResponse).remove();
				});				
				$("#IdProducte_" + IdProducteVal).animate({ opacity: 0 }, 500);
				$("#IdProducte_" + IdProducteVal).animate({ opacity: 0 }, 500);
				$("#notificationsLoader").empty();			
			} else {
				$("#basketItemsWrap li:first").before(theResponse);
				$("#basketItemsWrap li:first").hide();
				$("#basketItemsWrap li:first").show();  
				$("#notificationsLoader").empty();			
			}
			
		}  
		});  
		
	});
	
	$(".productPriceWrapRight2 a img").click(function() {
		var IdProducteValSplitter 	= (this.id).split("_");
		var IdProducteVal 			= IdProducteValSplitter[1];
		var idioma 					= IdProducteValSplitter[2];

		
		$("#notificationsLoader").html('<img src="js/cart/images/loader.gif">');
		var valor = document.getElementById('qt_'+IdProducteVal).value;
		
	
		$.ajax({  
		type: "POST",  
		url: "js/cart/inc/functions.php",  
		data: { IdProducte: IdProducteVal, action: "afegeixCistella2",idioma: idioma,quantitat:valor},  
		success: function(theResponse) {
			
			if( $("#IdProducte_" + IdProducteVal).length > 0){
				$("#IdProducte_" + IdProducteVal).animate({ opacity: 0 }, 100, function() {
					$("#IdProducte_" + IdProducteVal).before(theResponse).remove();
				});				
				$("#IdProducte_" + IdProducteVal).animate({ opacity: 0 }, 500);
				$("#IdProducte_" + IdProducteVal).animate({ opacity: 0 }, 500);
				$("#notificationsLoader").empty();			
			} else {
				$("#basketItemsWrap2 li:first").before(theResponse);
				$("#basketItemsWrap2 li:first").hide();
				$("#basketItemsWrap2 li:first").show();  
				$("#notificationsLoader").empty();			
			}
			
		}  
		});  
		
	});
	
	
	$("#basketItemsWrap li img").live("click", function(event) { 
														
		var IdProducteValSplitter 	= (this.id).split("_");
		var IdProducteVal 			= IdProducteValSplitter[1];
		var idioma 					= IdProducteValSplitter[2];

		$("#notificationsLoader").html('<img src="js/cart/images/loader.gif">');
		
		
		$.ajax({  
		type: "POST",  
		url: "js/cart/inc/functions.php",  
		data: { IdProducte: IdProducteVal, idioma: idioma,action: "eliminaCistella"},  
		success: function(theResponse) {
			
			$("#IdProducte_" + IdProducteVal).hide();
			$("#notificationsLoader").empty();
			//alert(theResponse);
			$("#productescistella").html(theResponse);
			
		}  
		});  
		
	});
	
		$("#basketItemsWrap2 li img").live("click", function(event) { 
														
		var IdProducteValSplitter 	= (this.id).split("_");
		var IdProducteVal 			= IdProducteValSplitter[1];
		var idioma 					= IdProducteValSplitter[2];

		$("#notificationsLoader").html('<img src="js/cart/images/loader.gif">');
		
		
		$.ajax({  
		type: "POST",  
		url: "js/cart/inc/functions.php",  
		data: { IdProducte: IdProducteVal, idioma: idioma,action: "eliminaCistella"},  
		success: function(theResponse) {
			
			$("#IdProducte_" + IdProducteVal).hide();
			$("#notificationsLoader").empty();
			//alert(theResponse);
			$("#productescistella").html(theResponse);
			
		}  
		});  
		
	});

});
