3 * Copyright(c) 2006-2010 Ext JS, Inc.
5 * http://www.extjs.com/license
7 function setActiveStyleSheet(title) {
10 links = document.getElementsByTagName("link"),
12 for (i = 0; i < len; i++) {
14 if (a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
16 if (a.getAttribute("title") == title) a.disabled = false;
21 function getActiveStyleSheet() {
24 links = document.getElementsByTagName("link"),
26 for (i = 0; i < len; i++) {
28 if (a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) {
29 return a.getAttribute("title");
35 function getPreferredStyleSheet() {
38 links = document.getElementsByTagName("link"),
40 for (i = 0; i < len; i++) {
42 if (a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("rel").indexOf("alt") == -1 && a.getAttribute("title")) {
43 return a.getAttribute("title");
49 function createCookie(name, value, days) {
51 var date = new Date();
52 date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
53 var expires = "; expires=" + date.toGMTString();
57 document.cookie = name + "=" + value + expires + "; path=/";
60 function readCookie(name) {
61 var nameEQ = name + "=",
62 ca = document.cookie.split(';'),
66 for ( i = 0; i < len; i++) {
68 while (c.charAt(0) == ' ') {
69 c = c.substring(1, c.length);
71 if (c.indexOf(nameEQ) == 0) {
72 return c.substring(nameEQ.length, c.length);
78 window.onload = function (e) {
79 var cookie = readCookie("style");
80 var title = cookie ? cookie : getPreferredStyleSheet();
81 setActiveStyleSheet(title);
84 window.onunload = function (e) {
85 var title = getActiveStyleSheet();
86 createCookie("style", title, 365);
89 var cookie = readCookie("style");
90 var title = cookie ? cookie : getPreferredStyleSheet();
91 setActiveStyleSheet(title);