function cpu(partID, sign) {
  update(partID, sign, "upgrade");
}    

function cp(partID, sign) {
  update(partID, sign, "configure");
}
    
function update(partID, sign, func){
  tb_show_conf('Czekaj ...', 'plugins/jquery/jquery.thickbox.wait.jpg', '');
  $("#v_"+partID).val(($("#v_"+partID).val()*1) + (sign*1));
  if($("#v_"+partID).val()<1){
    $("#imv_"+partID).attr('class','i1');
    $("#v_"+partID).val(0);
  }

  $.ajax({
    type: "POST",
    url: "ajax.php",
    data: "action="+func+"&language=" +$("#i_language").val()+ "&zestaw=" +$("#i_zestaw").val()+ "&komp=" +$("#i_komp").val()+ "&" + $("#konfigurator").serialize(),
    dataType: "json",
    cache: false,
    timeout:3000,
    success: function(msg){
      $.each(msg['v'], function(i, value) {
        $("#im"+i).attr('class','i'+value[0]);
        $("#"+i).attr('class','v'+value[1]);
        $("#ip"+i).attr('class','i'+value[2]);
      });
      if(msg['done']){
        $("#summary").attr('class',"summary_complete");
        $("#summary").html(msg["language"]);
        $("#path").attr('class',"path_ok");
      } else {
        $("#summary").attr('class',"summary_incomplete");
        $("#summary").html(msg["language"]);
        $("#path").attr('class',"path_no");
      }
      $("#cc_summary").html(msg["html"]);
      $("#cc_complete").html(msg["html2"]);
      $("#path").html(msg["html3"]);
      $("#path2").html(msg["html4"]);
      $("#output").html();
      tb_remove();
    },
    error: function(msg, error, errorThrown){
      $("#output").html("ERROR: "+error+"<br />----------<br />"+msg.responseText+"<br />"+errorThrown+"<br />----------<br />");
      tb_remove();
    }
  });
}
