1 | window.onload = init;
|
---|
2 |
|
---|
3 | var langElements = new Array();
|
---|
4 |
|
---|
5 | function init() {
|
---|
6 | var els = document.getElementsByTagName( 'pre' );
|
---|
7 | var elsLen = els.length;
|
---|
8 | var pattern = new RegExp('(^|\\s)(cs|vb|mc|js)(\\s|$)');
|
---|
9 | for (i = 0, j = 0; i < elsLen; i++) {
|
---|
10 | if ( pattern.test(els[i].className) ) {
|
---|
11 | //els[i].style.background = "#fcc";
|
---|
12 | langElements[j] = els[i];
|
---|
13 | j++;
|
---|
14 | }
|
---|
15 | }
|
---|
16 |
|
---|
17 | var lang = getCookie( "lang" );
|
---|
18 | if ( lang == null ) lang = "cs";
|
---|
19 | showLang(lang);
|
---|
20 | }
|
---|
21 |
|
---|
22 | function getCookie(name) {
|
---|
23 | var cname = name + "=";
|
---|
24 | var dc = document.cookie;
|
---|
25 | if ( dc.length > 0 ) {
|
---|
26 | begin = dc.indexOf(cname);
|
---|
27 | if ( begin != -1 ) {
|
---|
28 | begin += cname.length;
|
---|
29 | end = dc.indexOf(";",begin);
|
---|
30 | if (end == -1) end = dc.length;
|
---|
31 | return unescape(dc.substring(begin, end) );
|
---|
32 | }
|
---|
33 | }
|
---|
34 | }
|
---|
35 |
|
---|
36 | function setCookie(name,value,expires) {
|
---|
37 | document.cookie = name + "=" + escape(value) + "; path=/" +
|
---|
38 | ((expires == null) ? "" : "; expires=" + expires.toGMTString());
|
---|
39 | }
|
---|
40 |
|
---|
41 | function showLang(lang) {
|
---|
42 | var pattern = new RegExp('(^|\\s)'+lang+'(\\s|$)');
|
---|
43 | var elsLen = langElements.length;
|
---|
44 | for (i = 0; i < elsLen; i++ )
|
---|
45 | {
|
---|
46 | var el = langElements[i];
|
---|
47 | if ( pattern.test( el.className ) )
|
---|
48 | el.style.display = "";
|
---|
49 | else
|
---|
50 | el.style.display = "none";
|
---|
51 | }
|
---|
52 | setCookie("lang",lang);
|
---|
53 | }
|
---|
54 |
|
---|
55 | function Show( id ) {
|
---|
56 | document.getElementById(id).style.display = "";
|
---|
57 | }
|
---|
58 |
|
---|
59 | function Hide( id ) {
|
---|
60 | document.getElementById(id).style.display = "none";
|
---|
61 | }
|
---|
62 |
|
---|
63 | function ShowCS() {
|
---|
64 | showLang('cs');
|
---|
65 | }
|
---|
66 |
|
---|
67 | function ShowVB() {
|
---|
68 | showLang('vb');
|
---|
69 | }
|
---|
70 |
|
---|
71 | function ShowMC() {
|
---|
72 | showLang('mc');
|
---|
73 | }
|
---|
74 |
|
---|
75 | function ShowJS() {
|
---|
76 | showLang('js');
|
---|
77 | }
|
---|