Update of the ordering list for the year 2005.
[www.energie.vellum.cz.git] / objednavka.js
1 // $Id$
2 // <-see common.php:/if (!($s=trim($s)))/
3 var want_price=new Array();
4 want_price['phys_2005']=480;
5 want_price['phys_2004']=480;
6 want_price['phys_2003']=480;
7 want_price[  'cd_2004']=480;
8 want_price[  'cd_2003']=480;
9 want_price[  'cd_2002']=280;
10 want_price[  'cd_2001']=280;
11 want_price[  'cd_2000']=280;
12 want_price[  'cd_1999']=280;
13 want_price[  'cd_1998']=280;
14 want_price[  'cd_1997']=120;
15 want_price[  'cd_1996']=120;
16
17 function validate(form)
18 {
19 // want_ numeric check
20 var want_tot=0;
21         for (var elementi=0;elementi<form.elements.length;elementi++) {
22 var element=form.elements[elementi];
23                 if (-1==element.name.search(/^want_/))
24                         continue;
25                 if (-1!=element.value.search(/[^0-9]/)) {
26                         element.select();
27                         element.focus();
28                         alert('Jako poèet je mo¾no povoleno zadat jen èíselnou hodnotu!');
29                         return(false);
30                         }
31                 want_tot+=element.value;
32                 }
33         if (0==want_tot) {
34                 alert('Musíte si objednat alespoò jeden èasopis, napi¹te 1 do dané polo¾ky!');
35                 return(false);
36                 }
37
38         return(true);
39 }
40
41 function sum_price(field)
42 {
43 var form=field.form;
44 var price=0;
45
46         for (var elementi=0;elementi<form.elements.length;elementi++) {
47 var element=form.elements[elementi];
48                 if (-1==element.name.search(/^want_/))
49                         continue;
50                 if (element.value.search(/^[0-9]+$/))
51                         continue;
52                 price+=element.value * want_price[element.name.substr(5)];
53                 }
54
55         form.elements['price'].value=price;
56 }