function czyNumeryczne(v) { var ValidChars = "0123456789"; var IsNumber=true; var Char; var j=0; for (i = 0; i < v.length && IsNumber == true; i++) { Char = v.charAt(i); if (ValidChars.indexOf(Char) == -1) { return false; } if (Char==".") { j++; if (j>1) { return false; } } if (v.charAt(v.length-1)=="." || v.charAt(0)=="." ) { return false; } } return true; } function czyPuste(v) { var re = /^\s{1,}$/g; if ((v.length==0) || (v==null) || ((v.search(re)) > -1)) { return false; } else { return true; } } String.prototype.trim = function () { return this.replace(/^\s*/, "").replace(/\s*$/, ""); } function dodajProdukt(id) { document.getElementById("id").value = id; document.formularz_koszyk.action = "dodaj.php"; document.formularz_koszyk.submit(); } function usunProdukt(id) { document.getElementById("id").value = id; document.formularz_koszyk.action = "usun.php"; document.formularz_koszyk.submit(); } function kasujProdukt(id) { document.getElementById("id").value = id; document.formularz_koszyk.action = "kasuj.php"; document.formularz_koszyk.submit(); } function zmienIlosc(id) { document.getElementById("id").value = id; document.getElementById("pakiety").value = document.getElementById("pakiety_"+id).value; document.formularz_koszyk.action = "zmien.php"; document.formularz_koszyk.submit(); } function sprawdzRabat() { v = document.getElementById("rabat_kod").value; if ( !czyPuste ( v ) ) { document.getElementById("rabat_info").innerHTML = ""; } } /* function chbxSprawdzBledy() { if ( document.getElementById("checkbox_dane_osobowe").checked && document.getElementById("checkbox_regulamin").checked ) { document.getElementById("zamowienie_bledy").innerHTML = ""; } } */ function chbxSprawdzBledy() { if ( document.getElementById("checkbox_regulamin").checked ) { document.getElementById("zamowienie_bledy").innerHTML = ""; } } function wyczyscKomunikat() { document.getElementById("rabat_kod").value = ""; document.getElementById("rabat_info").innerHTML = ""; } function wyswietlDaneKlienta(co) { document.getElementById("wypelnij_formularze").style.display = "block"; if ( co == "firma" ) { document.getElementById("dane_do_faktury").innerHTML = "Dane do faktury (* pola obowiązkowe)"; document.getElementById("nip_ph").style.display = "block"; document.getElementById("nip").value = ""; document.getElementById("wysylka_area").style.display = "block"; if ( document.getElementById("wysylka_checkbox").checked ) { document.getElementById("blok_5_dane_wysylka").style.display = "block"; document.getElementById('uwagi').className='uwagi'; } else { document.getElementById('uwagi').className='uwagi_full'; } } else if ( co == "osoba_prywatna" ) { document.getElementById("dane_do_faktury").innerHTML = "Dane do wysyłki (* pola obowiązkowe)"; document.getElementById("nip_ph").style.display = "none"; document.getElementById("nip").value = "PARAGON"; document.getElementById("wysylka_area").style.display = "none"; document.getElementById("blok_5_dane_wysylka").style.display = "none"; document.getElementById('uwagi').className='uwagi_full'; } } function expressProdukt(id) { document.getElementById("id").value = id; document.formularz_koszyk.action = "express.php"; document.formularz_koszyk.submit(); } function sprawdz(id,opis) { var co = document.getElementById(id); co.value = co.value.trim(); if ( !czyPuste ( co.value ) ) { document.getElementById(id).placeholder = 'Wypełnij pole: '+opis; document.getElementById(id+'_ph').style.borderColor = '#ff0000'; return false; } else { if ( id == "email" ) { chars = /^[^\s()<>@,;:\/]+@\w[\w\.-]+\.[a-z]{2,}$/i; if (!chars.test(co.value) || co.value.lastIndexOf("@")!= co.value.indexOf("@") ) { document.getElementById(id).placeholder = 'Adres e-mail nie jest prawidłowy'; document.getElementById(id+'_ph').style.borderColor = '#ff0000'; return false; } else { return true; } } else { return true; } } } function sprawdzPlatnosc() { if ( document.getElementById("przedplata").checked != true && document.getElementById("pobranie").checked != true ) { document.getElementById("rodzaj_platnosci_bledy").innerHTML = '
Proszę wybrać rodzaj płatności, w celu przeliczenia kwoty do zapłaty
'; return false; } else { return true; } } function wyslijZamowienie(co) { var errors = false; if ( co == "przelicz" ) { document.formularz_koszyk.action = "index.php"; document.formularz_koszyk.submit(); } else { if ( !sprawdz('imie','Imię') ) errors = true; if ( !sprawdz('nazwisko','Nazwisko') ) errors = true; if ( !sprawdz('email','e-mail') ) errors = true; if ( !sprawdz('tel','Telefon') ) errors = true; if ( !sprawdz('firma','Firma lub Imię i Nazwisko') ) errors = true; if ( !sprawdz('ulica','Ulica') ) errors = true; if ( !sprawdz('nr_budynku','Nr budynku') ) errors = true; if ( !sprawdz('kod','Kod pocztowy') ) errors = true; if ( !sprawdz('miasto','Miasto') ) errors = true; if ( document.getElementById("zamawiajacy_firma").checked ) { if ( !sprawdz('nip','NIP') ) errors = true; } if ( document.getElementById("wysylka_checkbox").checked ) { if ( !sprawdz('firma_wysylka','Firma lub Imię i Nazwisko') ) errors = true; if ( !sprawdz('ulica_wysylka','Ulica') ) errors = true; if ( !sprawdz('nr_budynku_wysylka','Nr budynku') ) errors = true; if ( !sprawdz('miasto_wysylka','Miasto') ) errors = true; if ( !sprawdz('kod_wysylka','Kod þocztowy') ) errors = true; } if ( errors == true ) { document.getElementById("zamowienie_bledy").innerHTML = 'W formularzu występują błędy. Popraw pola oznaczone na czerwono.'; return; } /* if ( document.formularz_koszyk.checkbox_dane_osobowe.checked != true ) { errors = true; document.formularz_koszyk.checkbox_dane_osobowe.focus(); document.getElementById("zamowienie_bledy").innerHTML = '* Akceptacja regulaminu jest konieczna dla realizacji zamówienia'; return; } */ if ( document.formularz_koszyk.checkbox_regulamin.checked != true ) { errors = true; document.formularz_koszyk.checkbox_regulamin.focus(); document.getElementById("zamowienie_bledy").innerHTML = '* Aby złożyć zamówienie, konieczna jest akceptacja regulaminu.'; return; } if ( errors == false ) { document.formularz_koszyk.action = "wyslij_zamowienie.php"; setTimeout("document.formularz_koszyk.submit();",100); } else { document.getElementById("zamowienie_bledy").innerHTML = 'Wystąpiły błędy, popraw je i kliknij ponownie w przycisk'; } } } function wysylkaBoxToggle(id) { var vis = document.getElementById(id); if ( vis.style.display == 'none' ) { vis.style.display = 'block'; } else if ( vis.style.display == 'block' ) { vis.style.display = 'none'; } }