// JavaScript Document

function changeAmount( amount, price, totalValue, currentAmount )
{
  var current = $('#'+currentAmount).val()*1; 
  if(amount==1)current=current+1;
  if(amount==-1&&current>1)current=current-1;
  $('#'+currentAmount).val(current);
  $('#'+totalValue).html(price*current);
}


function recountBasket()
{
  var total = 0;
  $('.product').each( function() {
    var proid = $(this).val();
    var price = $('#product-' + proid + '-price' ).val();
    var count = $('#product-' + proid + '-count' ).val();
    if(isNaN(count))
    {
      count=1;
      $('#product-' + proid + '-count' ).val(count);
    }
    $('#product-' + proid + '-value' ).html( price * count );
    total = total + price * count;
  });
  
  $('#totalValue').html( total );
}

