jQuery.noConflict();
jQuery(document).ready(function(){ 
//load total items
  jQuery("#basketContainerTotal").load("assets/templates/delphi/inc/total.php?q=total");
	
	jQuery("#basketItemsWrap li:first").hide();
	
	jQuery(".productPriceWrapRight a img").click(function() {

		
		var productIDValSplitter 	= (this.id).split("_");
		var productIDVal 			= productIDValSplitter[1];
	
		jQuery("#notificationsLoader").html('<img src="assets/templates/delphi/images/loader.gif">');
	
		jQuery.ajax({  
		type: "POST",  
		url: "assets/templates/delphi/inc/functions.php",  
		data: { productID: productIDVal, action: "addToBasket"},  
		success: function(theResponse) {
			
			if( jQuery("#productID_" + productIDVal).length > 0){
				jQuery("#productID_" + productIDVal).animate({ opacity: 0 }, 500, function() {
					jQuery("#productID_" + productIDVal).before(theResponse).remove();
				});				
				jQuery("#productID_" + productIDVal).animate({ opacity: 0 }, 500);
				jQuery("#productID_" + productIDVal).animate({ opacity: 1 }, 500);
				jQuery("#notificationsLoader").empty();			
			} else {
				jQuery("#basketItemsWrap li:first").before(theResponse);
				jQuery("#basketItemsWrap li:first").hide();
				jQuery("#basketItemsWrap li:first").show("slow");  
				jQuery("#notificationsLoader").empty();			
			}
			
		}  
		});  
		
	  //load total items
	  jQuery("#basketContainerTotal").load("assets/templates/delphi/inc/total.php?q=total");
		
	});
	
	
	
	jQuery("#basketItemsWrap li img").live("click", function(event) { 
														
		var productIDValSplitter 	= (this.id).split("_");
		var productIDVal 			= productIDValSplitter[1];	
	
		jQuery("#notificationsLoader").html('<img src="assets/templates/delphi/images/loader.gif">');
	
		jQuery.ajax({  
		type: "POST",  
		url: "assets/templates/delphi/inc/functions.php",  
		data: { productID: productIDVal, action: "deleteFromBasket"},  
		success: function(theResponse) {
			
			jQuery("#productID_" + productIDVal).hide("slow",  function() {jQuery(this).remove();});
			jQuery("#notificationsLoader").empty();
			
			 //load total items on succes delete
			jQuery("#basketContainerTotal").load("assets/templates/delphi/inc/total.php?q=total");
		
		}  
		});  
		
	});

});
