var b_sum = 0;

$(document).ready(function () {

//  $("#shop h2").click(function () {
//    $(this).toggleClass("close");
//    var id = $(this).attr('id');
//    $('#table_'+id).toggle();
//  });

  $("input.articleCount").keyup(function () {
    var count     = $(this).val();
    var articleId = $(this).attr('id');
    var articleId = articleId.replace(/articleCount_/g, "");
    
    getRequest( articleId, count );
  });
  
  $('.blur').focus(function(){
    $(this).blur();
  });

});

//Aktualisierung des Konfigurators und der Sidebar
function getRequest( articleId, articleCount )
{
  $.ajax({
    type    : 'POST',
    async   : false,
    global  : false,
    url     : '/shop/change',
    data    : { articleId: articleId, articleCount: articleCount },
    dataType: 'html',
    cache   : false,
    timeout: 30000,
    beforeSend: function(){
      //$('#loaderContainer').show();
    },
    success : function(html) {
      $('#small-basket').replaceWith( html );
//      $('#shop-basket').replaceWith( '<div id="shop-basket">' + html + '</div>');
      //$('#loaderContainer').hide();
    },
    error   : function(html, error){
      //$('#loaderContainer').hide();
    }
  });
}

function showDesc(id)
{
  $.nyroModalManual({
    content: $('#desc_'+id).html()
  });
  
//  $('#desc_'+id).toggle();
}

function articlePlus( articleId )
{
  var value = $('#articleCount_'+articleId).val();
  if ( value == '' || isNaN( parseInt( value ) ) )
  {
    value = 0;
  }
  
  value++;
  $('#articleCount_'+articleId).val(value);
  getRequest( articleId, value );
}

function articleMinus( articleId )
{
  var value = $('#articleCount_'+articleId).val();
  
  if ( value > 0 &&  !isNaN( parseInt( value ) ) )
  {
    value--;
    $('#articleCount_'+articleId).val(value);
    getRequest( articleId, value );
  }
}

