function countChange(ile) {
  
  if(IsNumeric(ile.value)) {
      document.getElementById('cartaction').value= 'cart-przelicz' ;
      document.getElementById('razem').innerHTML = '<input class="przelicz-button" type="submit" value="przelicz">';  
  } else {
      ile.value = 1;
      alert('tylko cyfry');
      countChange(ile);      
  }
}
function IsNumeric(inputVal) {
  
     if (isNaN(parseFloat(inputVal))) {
          return false;
     }
     return true
}
function ajax_przesylka(cena,typ_przesylki) {
  total = document.getElementById('TOTAL');
  
  advAJAX.get({
    url: "/cms/_actions/przelicz_koszyk.php?c="+cena+"&t="+typ_przesylki,
    onSuccess : function(obj) { total.innerHTML = obj.responseText; },
    onError : function(obj) { alert("Error: " + obj.status); }
});
  
}

/*function ajax_faktura() {
  var nazwa = document.getElementById('name_f').value;
  var ulica = document.getElementById('street_f').value;
  var nr_domu = document.getElementById('house_nr_f').value;
  var kod = document.getElementById('postcode_f').value;
  var miasto = document.getElementById('city_f').value;
  var nip = document.getElementById('nip_f').value;
  fakturaKomunikat = document.getElementById('fakturaKomunikat');
  
  advAJAX.post({
          url : "/cms/_actions/zapisz_fakture.php",
          parameters:{
              nazwa: nazwa,
              ulica: ulica,
              nr_domu: nr_domu,
              kod: kod,
              miasto: miasto,
              nip: nip
  },
  onSuccess : function(obj) { return true; },
  onError : function(obj) { return false; }
});
  //document.getElementById('fakturaKomunikat').innerHTML += miasto;
}*/

function czytaRegulamin() {
  
  var uwagi = document.getElementById('uwagiZamowienie').value;
  
  uwagiKomunikat = document.getElementById('uwagiKomunikat');
  
  advAJAX.post({
    url : "/cms/_actions/zapisz_uwagi.php",
    parameters:{
      uwagiZamowienie: uwagi
    },
    onSuccess : function(obj) { 
      //if (obj.responseText=="0") return false;
      
      var nazwa = document.getElementById('name_f').value;
      var ulica = document.getElementById('street_f').value;
      var nr_domu = document.getElementById('house_nr_f').value;
      var kod = document.getElementById('postcode_f').value;
      var miasto = document.getElementById('city_f').value;
      var nip = document.getElementById('nip_f').value;
      fakturaKomunikat = document.getElementById('fakturaKomunikat');
    
      advAJAX.post({
        url : "/cms/_actions/zapisz_fakture.php",
        parameters:{
          nazwa: nazwa,
          ulica: ulica,
          nr_domu: nr_domu,
          kod: kod,
          miasto: miasto,
          nip: nip
        },
        onSuccess : function(obj) {
          //alert("DZIAŁA");
          //if (obj.responseText=="0") return false;
          
          if(document.getElementById('czyt_reg').checked == true) {
            location.href='?mod=shop&f=zakoncz';
          } else {
            alert('W celu złożenia zamówienia, prosze zapoznać się wcześniej z regulaminem sklepu');
          }  
        },
        onError : function(obj) { return false; }
      });
    },
    onError : function(obj) { return false; }
  });
}

function pokazFakture(act) {
  if (act) document.getElementById('daneDoFaktury').style.display = "";
  else document.getElementById('daneDoFaktury').style.display = "none";
  
  fakturaKomunikat = document.getElementById('fakturaKomunikat');
  
  advAJAX.get({
    url: "/cms/_actions/zapisz_fakture.php?czyFaktura="+act,
    onSuccess : function(obj) { fakturaKomunikat.innerHTML = obj.responseText; },
    onError : function(obj) { alert("Error: " + obj.status); }
});
}

/*function ajax_uwagi() {
  var uwagi = document.getElementById('uwagiZamowienie').value;
  
  uwagiKomunikat = document.getElementById('uwagiKomunikat');
  
  advAJAX.post({
          url : "/cms/_actions/zapisz_uwagi.php",
          parameters:{
              uwagiZamowienie: uwagi
  },
  onSuccess : function(obj) { return 1; },
  onError : function(obj) { return 2; }
});
}*/