Imported Upstream version 1.5.1
[routino] / web / www / routino / page-elements.js
1 //
2 // Javascript for page elements.
3 //
4 // Part of the Routino routing software.
5 //
6 // This file Copyright 2008,2009 Andrew M. Bishop
7 //
8 // This program is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU Affero General Public License as published by
10 // the Free Software Foundation, either version 3 of the License, or
11 // (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU Affero General Public License for more details.
17 //
18 // You should have received a copy of the GNU Affero General Public License
19 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 //
21
22
23 //
24 // Display one of the tabs and associated DIV and hide the others
25 //
26
27 function tab_select(name)
28 {
29  var tab=document.getElementById("tab_" + name);
30
31  if(tab.className=="tab_selected")
32    {return;}
33
34  // Hide the deslected tabs and DIVs
35
36  var parent=tab.parentNode;
37  var child=parent.firstChild;
38
39  do
40    {
41     if(String(child.id).substr(0,4)=="tab_")
42       {
43        var div=document.getElementById(child.id + "_div");
44
45        child.className="tab_unselected";
46        div.style.display="none";
47       }
48
49     child=child.nextSibling;
50    }
51  while(child!=null);
52
53  // Display the newly selected tab and DIV
54
55  var div=document.getElementById(tab.id + "_div");
56
57  tab.className="tab_selected";
58  div.style.display="";
59 }
60
61
62 //
63 // Show the associated DIV
64 //
65
66 function hideshow_show(name)
67 {
68  var span1=document.getElementById("hideshow_" + name + "_show");
69  var span2=document.getElementById("hideshow_" + name + "_hide");
70  var div=document.getElementById("hideshow_" + name + "_div");
71
72  div.style.display="";
73  span1.className="hideshow_hide";
74  span2.className="hideshow_show";
75 }
76
77
78 //
79 // Hide the associated DIV
80 //
81
82 function hideshow_hide(name)
83 {
84  var span1=document.getElementById("hideshow_" + name + "_show");
85  var span2=document.getElementById("hideshow_" + name + "_hide");
86  var div=document.getElementById("hideshow_" + name + "_div");
87
88  div.style.display="none";
89  span2.className="hideshow_hide";
90  span1.className="hideshow_show";
91 }