	// Preload the images.
        jQuery("<img>").attr("src", "/images/global/controllers/cart_remove_sm.gif");
        jQuery("<img>").attr("src", "/images/global/controllers/cart_add_sm.gif");

        jQuery("<img>").attr("src", "/images/global/controllers/bin_remove_sm.gif");
        jQuery("<img>").attr("src", "/images/global/controllers/bin_add_sm.gif");


 $(document).ready(function() {
	
   //	
   // Replace the 'add' link on each 'add to cart' item
   //

//   alert("running on ready from search_cart_ajax");


   $(".add_rem_cart").click(function(e) {
     this; // dom element

//     alert("running on add_rem_cart  from search_cart_ajax");
     // stop normal link click
     e.preventDefault();

     var linkobj = this;
     
     // send request
     $.post("/action", 
	{screen:'ajax_toggle_cart',product:this.name},

	function (data) {

	// Determine if it is now in the cart or not.
	// if it is in the cart put the 'remove' button in the div.
	if ( data[0].added ) {
            $(linkobj).html('<img  title="Remove from Cart" alt="Clipbin" src="/images/global/controllers/cart_remove_sm.gif" border="0"    style="margin-left:2px; margin-right:2px;" >');
	} else {
            $(linkobj).html('<img  title="Add to Cart" alt="Clipbin" src="/images/global/controllers/cart_add_sm.gif" border="0"    style="margin-left:2px; margin-right:2px;" >');
	}
	},
	"json"
      );
	

   });

   //
   // Replace the 'add' link on each 'add to bin' item  
   //

   $(".add_rem_bin").click(function(e) {
     this; // dom element

     // stop normal link click
     e.preventDefault();

     var linkobj = this;

     // send request
     $.post("/action", 
	{screen:'ajax_toggle_default',product:this.name},
	function (data) {

	if ( data[0].added ) {
            $(linkobj).html('<img  title="Remove from Clipbin" alt="Clipbin" src="/images/global/controllers/bin_remove_sm.gif" border="0"    style="margin-left:2px; margin-right:2px;"  >');
	} else {
            $(linkobj).html('<img  title="Add to Clipbin" alt="Clipbin" src="/images/global/controllers/bin_add_sm.gif" border="0"    style="margin-left:2px; margin-right:2px;" >');

	}
	},
	"json"
      );
   });

 });
