
function add2cart( prod, params ){
   url = base_url+"ajax-product_add2cart-"+prod;
   $.ajax({
       type: "POST",
       url: url,
       data: params,
       async: false,
       success: function( html ){
         if ( params.indexOf("CD") >= 0 ){
          reload_shopping_cart("CD");
         }else{
          reload_shopping_cart("MP3");
         }
       }
   });
}


function remove_from_cart(id){
  url = base_url+"box-product_remove_from_cart-"+id;

  $.ajax({
    url: url,
    async: false,
    type: "POST",
    dataType: "text",
    success: function( html ){
      reload_shopping_cart("CD");
    }
  });
}

function remove_from_cartmp3(id){
  url = base_url+"box-product_remove_from_cartmp3-"+id;

  $.ajax({
    url: url,
    async: false,
    type: "POST",
    dataType: "text",
    success: function( html ){
      reload_shopping_cart("MP3");
    }
  });

}

function reload_shopping_cart( type ){

  if ( type == "MP3"){
    selector = "#shopping-cart-mp3";
    url = base_url+"box-product_show_shopping_cart_mp3";
  }else if ( type == "CD"){
    selector = "#shopping-cart-cd";
    url = base_url+"box-product_show_shopping_cart_cd";
  }else if ( type == "ALL"){
    selector = "#shopping-cart";
    url = base_url+"box-product_show_shopping_cart";
  }

  $.ajax({
     type: "POST",
     url: url,
     dataType: "html",
     async: false,
     success: function( html ){

      $(selector).html( html );
      $(selector).fadeOut(500);
      $(selector).fadeIn(500);

     }
   });
}


function empty_shopping_cart( type_car ){
  url = base_url+"ajax-product_clear_shopping_cart";
  params = "type_car="+type_car;

  $.ajax({
    type: "POST",
    url: url,
    data: params,
    async: false,
    dataType: "text",
    success: function( html ){
      reload_shopping_cart(type_car);
    }
  });

}
