$.format.locale({ number: { groupingSeparator: ' ', decimalSeparator: ',' } }); var index = 0; var numDays = 30; $(window.document).ready(function () { countPrice(index, numDays); var calc = $('#calc'); var days = $('#days'); if(calc) { for(i=0; i < pricelist0.length; i++) { if(pricelist0[i] != null) { calc.append(''); } } calc.change(function() { $("#calc option:selected").each(function () { index = $(this).val(); countPrice(index, numDays); }); }); } if(days) { days.change(function() { $("#days option:selected").each(function () { numDays = $(this).val(); countPrice(index, numDays); }); }); } $('#acc input[type=checkbox]').click(function() { countPrice(index, numDays); }); }); function countPrice(index, numDays) { var dayPrice = getDayPrice(numDays, pricelist0[index].price); var accPrice = 0; $("#acc input:checked").each(function () { var accPr = eval($(this).val()); accPrice += numDays*getDayPrice(numDays, accPr); }); $('#price-acc').text($.format.number(Math.round(accPrice), '#,###')); $('#price-car').text($.format.number(Math.round(dayPrice*numDays), '#,###')); $('#price').text($.format.number(Math.round(dayPrice*numDays + accPrice), '#,###')); } function getDayPrice(days, prices) { if(days < 3) { return prices[1]; } if(days < 11) { return prices[2]; } if(days < 20) { return prices[3]; } if(days < 30) { return prices[4]; } return prices[6]/30; } function reservation(form) { form.carid.value = pricelist0[form.car.selectedIndex].id; form.submit(); } var pricelist0 = [ {title: 'Thalia', id: '125', price: [0, 550, 450, 400, 350, 1100, 8990]}, {title: 'Citigo 1.0 AC 3dv.', id: '520', price: [0, 590, 550, 450, 400, 1180, 9990]}, {title: 'Fabia II 1.2 ', id: '996', price: [0, 690, 590, 490, 450, 1380, 10990]}, {title: 'Citigo 1.0 Automat AC 3dv.', id: '10', price: [0, 750, 650, 550, 500, 1500, 11990]}, {title: 'Fabia II 1.2 AC', id: '965', price: [0, 750, 650, 550, 500, 1500, 11990]}, {title: 'Fabia III 1.0 AC', id: '3660', price: [0, 800, 700, 600, 550, 1600, 12990]}, {title: 'Fabia Combi II 1.4 AC', id: '14', price: [0, 800, 700, 600, 550, 1600, 12990]}, {title: 'Roomster 1.4 AC', id: '1552', price: [0, 850, 750, 650, 580, 1700, 13990]}, {title: 'Rapid 1.2 TSI AC', id: '7801', price: [0, 900, 800, 700, 600, 1800, 14990]}, {title: '301 1.6 Automat AC', id: '1551', price: [0, 900, 800, 700, 600, 1800, 14990]}, {title: 'Octavia II 1.6 AC', id: '15', price: [0, 900, 800, 700, 600, 1800, 14990]}, {title: 'Octavia Combi II 1.6 AC', id: '2759', price: [0, 1000, 900, 800, 700, 2000, 16990]}, {title: 'Octavia II 1.6 TDI AC', id: '17', price: [0, 1000, 900, 800, 700, 2000, 16990]}, {title: 'Rapid 1.4 TSI Automat AC', id: '1729', price: [0, 1000, 900, 800, 700, 2000, 16990]}, {title: 'Octavia III 1.6 TDI AC', id: '5657', price: [0, 1100, 1000, 900, 800, 2200, 17990]}, ];