Apparently no longer looking for `agents'.
[www.jankratochvil.net.git] / product / hotelgate / Order.js
1 /* $Id$
2  * HotelGate Order helper.
3  * Copyright (C) 2005 Jan Kratochvil <project-www.jankratochvil.net@jankratochvil.net>
4  * 
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; exactly version 2 of June 1991 is required
8  * 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  * 
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19
20 // Double-run protection due to the My::Web "text/javascript" compatibility hack.
21 if (!window.var_product_hotelgate_Order_done) {
22         var var_product_hotelgate_Order_done=1;
23
24 function Order_validate(form)
25 {
26         var e_types_array=form.elements["type"];
27         var checked=0;
28         for (var typei=0;typei<e_types_array.length;typei++)
29                 if (e_types_array[typei].checked)
30                         checked++;
31         if (1!=checked) {
32                 // FIXME: Unify with: $product::hotelgate::Order::error{"type_missing"}
33                 alert("Please fill in the {Device casing type} field!");
34                 return false;
35                 }
36         return true;
37 }
38
39 function Order_error_check()
40 {
41         var e_error;
42         if (document.getElementById)
43                 e_error=document.getElementById("error");
44         if (e_error && e_error.textContent)
45                 alert(e_error.textContent);
46 }
47
48 function Order_error_check_delayed()
49 {
50         // HACK: 0ms - wait for 'css_inherit.js' finalization.
51         setTimeout('Order_error_check();',0);
52 }
53
54 /* Origin: http://simon.incutio.com/archive/2004/05/26/addLoadEvent */
55 function addLoadEvent(func)
56 {
57         var onload_orig=window.onload;
58         if (typeof(onload_orig)!='function')
59                 window.onload = func;
60         else
61                 window.onload = function()
62                 {
63                         onload_orig();
64                         func();
65                 };
66 }
67
68 addLoadEvent(Order_error_check_delayed);
69
70 }