2 function fontsizeup(event)
4 // Skip tabs; 9 being the ASCII code for a tab
5 if (event && getKeyCode(event) == 9)
10 var active = getActiveStyleSheet();
15 setActiveStyleSheet('A-');
19 setActiveStyleSheet('A');
23 setActiveStyleSheet('A+');
27 setActiveStyleSheet('A++');
31 setActiveStyleSheet('A');
35 setActiveStyleSheet('A');
42 function fontsizedown(event)
45 if (event && getKeyCode(event) == 9)
50 var active = getActiveStyleSheet();
55 setActiveStyleSheet('A+');
59 setActiveStyleSheet('A');
63 setActiveStyleSheet('A-');
67 setActiveStyleSheet('A--');
74 setActiveStyleSheet('A--');
81 function getKeyCode(event)
83 // IE doesn't fire the onkeypress event for tabs
84 // Reference: http://www.quirksmode.org/js/keys.html
86 var code = (event.keyCode) ? event.keyCode : 0;
89 if (!code && event.charCode)
91 code = event.charCode;
97 function setActiveStyleSheet(title)
101 for (i = 0; (a = document.getElementsByTagName('link')[i]); i++)
103 if (a.getAttribute('rel').indexOf('style') != -1 && a.getAttribute('title'))
106 if (a.getAttribute('title') == title)
114 function getActiveStyleSheet()
118 for (i = 0; (a = document.getElementsByTagName('link')[i]); i++)
120 if (a.getAttribute('rel').indexOf('style') != -1 && a.getAttribute('title') && !a.disabled)
122 return a.getAttribute('title');
129 function getPreferredStyleSheet()
134 function createCookie(name, value, days)
138 var date = new Date();
139 date.setTime(date.getTime() + (days*24*60*60*1000));
140 var expires = '; expires=' + date.toGMTString();
147 document.cookie = name + '=' + value + expires + style_cookie_settings;
150 function readCookie(name)
152 var nameEQ = name + '=';
153 var ca = document.cookie.split(';');
155 for (var i = 0; i < ca.length; i++)
159 while (c.charAt(0) == ' ')
161 c = c.substring(1, c.length);
164 if (c.indexOf(nameEQ) == 0)
166 return c.substring(nameEQ.length, c.length);
173 function load_cookie()
175 var cookie = readCookie('style_cookie');
176 var title = cookie ? cookie : getPreferredStyleSheet();
177 setActiveStyleSheet(title);
180 function unload_cookie()
182 var title = getActiveStyleSheet();
183 createCookie('style_cookie', title, 365);
186 onload_functions.push('load_cookie()');
187 onunload_functions.push('unload_cookie()');
190 var cookie = readCookie("style");
191 var title = cookie ? cookie : getPreferredStyleSheet();
192 setActiveStyleSheet(title);