basket = {};

basket.load = function()
 {
  $.post('/order', 
   { 
    post_action: 'load'
   },
      
   function(data, textStatus)
    {
     basket._set_content(data);
    } 
  ); 
 }

basket.add = function(product_id)
{
 $.post('/order', 
  { 
   product_id: product_id,
   post_action: 'add'
  },
   
  function(data, textStatus)
   {
    if (data == 0)
     {
      
     }
    
    document.location.href = '/order';
   } 
  );    
}

basket.remove = function(product_id)
 {
  $.post('/order', 
   { 
    product_id: product_id,
    post_action: 'remove'
   },
    
   function(data, textStatus)
    {
     basket._set_content(data); 
    } 
   );    
 }     

basket.finish = function()
 { 
  post('sid=<?=$sid?>', 'https://www.bruil.info/finish');    
 }      
 
basket.two_year_subscription = function(product_id)
 { 
  $.post('/order', 
   { 
    product_id: product_id,
    post_action: '2year'
   },
      
   function(data, textStatus)
    {
     basket._set_content(data);
    } 
  );    
 } 

basket.change_count = function(product_id)
 {
  eval('var count = document.orderline_count_'+ product_id + '.count.value');
  
  $.post('/order', 
   { 
    product_id: product_id,
    count: count, 
    post_action: 'change_count'
   },
    
   function(data, textStatus)
    {
     basket._set_content(data);
    } 
   );
 }

basket._set_content = function(html)
 {
  $('#content').html(html);
 } 
