function number_format( number, decimals, dec_point, thousands_sep ) { var n = number, prec = decimals; n = !isFinite(+n) ? 0 : +n; prec = !isFinite(+prec) ? 0 : Math.abs(prec); var sep = (typeof thousands_sep == "undefined") ? ',' : thousands_sep; var dec = (typeof dec_point == "undefined") ? '.' : dec_point; var s = (prec > 0) ? n.toFixed(prec) : Math.round(n).toFixed(prec); //fix for IE parseFloat(0.55).toFixed(0) = 0; var abs = Math.abs(n).toFixed(prec); var _, i; if (abs >= 1000) { _ = abs.split(/\D/); i = _[0].length % 3 || 3; _[0] = s.slice(0,i + (n < 0)) + _[0].slice(i).replace(/(\d{3})/g, sep+'$1'); s = _.join(dec); } else { s = s.replace('.', dec); } return s; } function doKoszyka() { var cena=document.getElementById('cena'); var icena=document.getElementById('icena').value; var iilosc=document.getElementById('iilosc').value; var icenapromo=document.getElementById('icenapromo').value; var ilosc=parseInt(document.getElementById('ilosc').value); var nowacena=0; if(isNaN(ilosc)) { nowacena='???'; cena.innerHTML=nowacena; return; } if((icenapromo>0)&&(iilosc<=ilosc)) nowacena=icenapromo*ilosc; else nowacena=icena*ilosc; cena.innerHTML=number_format(nowacena,2,',',''); } function prepareDoKoszyka() { var ilosc=document.getElementById('ilosc'); if(ilosc!=undefined) ilosc.onkeyup=doKoszyka; var form=document.getElementById('doKoszyka'); if(form!=undefined) form.onsubmit=function(e) { if(e==undefined) e=window.event; if((e.preventDefault)&&(e.cancellable)) e.preventDefault(); var ilosc=document.getElementById('ilosc'); var imaxilosc=document.getElementById('imaxilosc').value; var error=''; if(ilosc) { var i=parseInt(ilosc.value); if(!isNaN(i)) { if(i<=0) error='Podaj ilość produktów większą od 0!'; else if((i>imaxilosc)&&(imaxilosc>0)) error='Maksymalna ilość dostępnych produktów to '+imaxilosc+'!'; } else error='Ilość musi być liczbą całkowitą!'; } else error='Błąd formularza!'; if(error.length==0) { //this.submit(); return true; } else { ilosc.style.background="#fcc"; alert(error); } return false; } } function expandMenu() { var menu=document.getElementById('topmenuinside'); if(menu) { menu.style.height="92px"; } } function collapseMenu() { var menu=document.getElementById('topmenuinside'); if(menu) { menu.style.height="60px"; } }