NEWS[4.20.1]: Samba 4.20.1 Available for Download
[samba-web.git] / js / pageTweaks.js
1 /* 
2    pageTweaks.js
3    Copyright (C) 2005 Deryck Hodge <deryck@samba.org>
4
5    JS functions for tweaking page styles, forms, etc.
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11    
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16    
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22 function changeMirror(mirrorChoice)
23 {
24         mirrorSite = mirrorChoice.options[mirrorChoice.selectedIndex].value;
25
26         if (mirrorSite != "") {
27                 document.location.href = mirrorSite;
28         }
29 }
30
31 function setContentLen()
32 {
33         var content = document.getElementById('content');
34         var sidebar;
35         var contentY;
36         var sidebarY;
37
38         if (document.getElementById('links')) {
39                 sidebar = document.getElementById('links');
40         } else if (document.getElementById('countries')) {
41                 sidebar = document.getElementById('countries'); 
42         } else if (document.getElementById('nav')) {
43                 sidebar = document.getElementById('nav');
44         }
45
46         // Get the sidebar height as integer
47         if (is_ie) {
48                 contentY = content.offsetHeight;
49                 sidebarY = sidebar.offsetHeight;
50         } else {
51                 contentY = window.getComputedStyle(content, '').getPropertyValue('height');
52                 sidebarY = window.getComputedStyle(sidebar, '').getPropertyValue('height');
53                 contentY = parseInt(contentY.slice(0,-2));
54                 sidebarY = parseInt(sidebarY.slice(0,-2));
55         }
56
57         // Allow for the extra top margin value
58         if (document.getElementById('links') || 
59                     document.getElementById('nav')) {
60                 sidebarY = sidebarY + 115;
61         } else if (document.getElementById('countries')) {
62                 sidebarY = sidebarY + 240; 
63         }
64         
65         if (sidebarY + 50 > contentY) {
66                 content.style.height = sidebarY.toString() + 'px';
67         }
68 }