TzFonts.js
2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
function locateASP()
//Returns the location of the ASP relative to the page
{
var fullpath = location.pathname;
var lastSlash;
var path;
var ASPlocation = "";
var backslash = "../"
var count = 0;
lastSlash = fullpath.lastIndexOf("/");
path = fullpath.substring(0, lastSlash);
while (path.toLowerCase() != "" && path.toLowerCase() != "/"){
count++;
lastSlash = path.lastIndexOf("/");
path = path.substring(0, lastSlash);
}
for(var j = 1; j <= count; j++){
ASPlocation = backslash + ASPlocation;
}
return ASPlocation;
}
Tz = new function(){}
Tz.Fonts = new function() {
this.FontElement = "TzSelectors";
this.RenderContainer = "TzFontContent";
this.CookieName = "TzLibroFontClass";
this.prevEl = "TzNorm";
this.switchFont = function(strId) {
var content = document.getElementById(Tz.Fonts.RenderContainer);
if (typeof content !== 'undefined' && content !== null) {
var prevelement = document.getElementById(Tz.Cookie.read(Tz.Fonts.CookieName));
if (prevelement !== null) { prevelement.style.color = "#5D9732"; }
content.className = strId;
Tz.Cookie.create(this.CookieName, strId);
var fontelement = document.getElementById(strId);
fontelement.style.color = "#006857";
}
}
window.onload = function() {
var fontcookie = Tz.Cookie.read(Tz.Fonts.CookieName);
if(!fontcookie) {
Tz.Cookie.create(Tz.Fonts.CookieName, Tz.Fonts.prevEl);
} else {
Tz.Fonts.prevEl = fontcookie;
}
var content = document.getElementById(Tz.Fonts.RenderContainer);
if (typeof content !== 'undefined' && content !== null) {
content.className = fontcookie;
var fontelement = document.getElementById(Tz.Fonts.prevEl);
if(typeof fontelement !== 'undefined' && fontelement !== null) {
fontelement.style.color = "#006857";
}
}
}
}
Tz.Cookie = new function() {
this.create = function(name, value, days) {
var expires = '';
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
expires = '; expires= ' + date.toGMTString();
}
document.cookie = name + '=' + value + expires + '; path=/';
}
this.read = function read(name) {
var nameEQ = name + '=';
var ca = document.cookie.split(';');
for(var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') {
c = c.substring(1,c.length);
}
if (c.indexOf(nameEQ) == 0) {
return c.substring(nameEQ.length,c.length);
}
}
return null;
}
this.erase = function(name) {
Tz.Cookie.create(name, '', -1);
}
}