        //allow only int in input
            function allowInt(id)
            {
                $("#pola"+id).keydown(function(event) {
                    // Allow only backspace and delete
                    if ( event.keyCode == 46 || event.keyCode == 8 ) {
                            // let it happen, don't do anything
                            
                    }
                    else {
                            // Ensure that it is a number and stop the keypress
                            if (event.keyCode < 48 || event.keyCode > 57 ) {
                                    event.preventDefault(); 
                            }
                            else
                            {
                                $("#pola"+id).keyup(function(event) {
                                    if($("#pola"+id).val() == "")
                                    {
                                        $("#pola"+id).val() = 1;

                                    }   
                                        
                                    price = $("#itemPrice"+id).html();
                                    price = parseFloat(price);
                                    quantity = $("#pola"+id).val();   
                                    sum = (price * quantity ).toFixed(2);
                                    $("#itemPriceAll"+id).html(sum+" zł");
                                    //alert( sum );   
                                });
                            }       
                    }
                });
            }
            
            function reCalc(id)
            {
 
                price = $("#itemPrice"+id).html();
                price = parseFloat(price);
                quantity = $("#pola"+id).val();   
                sum = (price * quantity ).toFixed(2);
                $("#itemPriceAll"+id).html(sum+" zł");
                //alert( sum );       
            }  
            
            
            function countElement(array)
            {
                var count = 0;
                $.each(array, function(i,v){ count++});
                return count;
            }
            
            
            function addToBasket(pid, id)
            {
                acc = $('#accessories_id').val(); 
                acc_arr = acc.split('-');
                var tablica = [];
                //alert(countElement(acc_arr));
                 i=0;
                 for(i=0; i<=countElement(acc_arr); i++)
                    if($('#lol'+acc_arr[i]).val() == 1 )
                        tablica.push(acc_arr[i]);
                        
                $.ajax({
                    type: "POST",
                    url: 'index.php?c=Cart&a=add',
                    data: 'pid='+pid+'&priceid='+id+'&q='+$('#pola'+id).val()+'&acc='+tablica ,
                    success: function(data) {
                    //    $('#ress').html(data);
                        $('#res'+id).show();
                        window.location = "index.php?c=Product&a=show&id="+pid+"&msg=1014";
                        //setTimeout(location.reload(), 2000);
                    }
                });
                
            }   
