rt 4.2.16
[freeside.git] / rt / share / static / js / titlebox-state.js
1 function createCookie(name,value,days) {
2     var path = RT.Config.WebPath ? RT.Config.WebPath : "/";
3
4     if (days) {
5         var date = new Date();
6         date.setTime(date.getTime()+(days*24*60*60*1000));
7         var expires = "; expires="+date.toGMTString();
8     }
9     else
10         expires = "";
11     
12     document.cookie = name+"="+value+expires+"; path="+path;
13 }
14
15 function loadTitleBoxStates() {
16     var cookies = document.cookie.split(/;\s*/);
17     var len     = cookies.length;
18
19     for (var i = 0; i < len; i++) {
20         var c = cookies[i].split('=');
21         
22         if (c[0].match(/^TitleBox--/)) {
23             var e   = document.getElementById(c[0]);
24             if (e) {
25                 var e2  = e.parentNode;
26     
27                 if (c[1] != 0) {
28                     set_rollup_state(e,e2,'shown');
29                 }
30                 else {
31                     set_rollup_state(e,e2,'hidden');
32                 }
33             }
34         }
35     }
36 }