var base_path = '/';

$(function(){
  /* Cart products ************************************************************/
  $('.product a.buy').click(function(){
    var id  = this.id.split('_')[1];
    var img = $(this).children('img');
    $.post(
      base_path + 'shop/add-to-cart.html',
      {'product_id' : id},
      function(data){
        $('#cart_list').html(data);
        img.attr('src', base_path + 'images/buy_ok.png');
      }
    );
    return false;
  });
  /* Compare products *********************************************************/
  $('p a.compare').click(function(){
    var id = this.id.split('_')[1];
    $.post(
      base_path + 'shop/add-to-compare.html',
      {'product_id' : id},
      function(data){$('#compare_list').html(data);}
    );
    return false;
  });
  
  $('#search_form').submit(function(){
    window.location = (base_path + 'shop/search/' + encodeURIComponent($('#search_string').val()) + '.html');
    return false;
  });
});

Shadowbox.loadSkin('classic', base_path + 'js/shadowbox/skin');
Shadowbox.loadLanguage('en', base_path + 'js/shadowbox/lang');
Shadowbox.loadPlayer(['flv', 'html', 'iframe', 'img', 'qt', 'swf', 'wmp'], base_path + 'js/shadowbox/player');
$(window).load(function(){
  var options = {};
  Shadowbox.init(options);
});


function remove_from_cart(id, reload)
{
    $.post(
      base_path + 'shop/remove-from-cart.html',
      {'product_id' : id},
      function(data){
        $('#cart_list').html(data);
        if(reload == true){window.location = window.location;}
      }
    );
}

function remove_from_compare(id, reload)
{
    $.post(
      base_path + 'shop/remove-from-compare.html',
      {'product_id' : id},
      function(data){
        $('#compare_list').html(data);
        if(reload == true){window.location = window.location;}
      }
    );
}