1//Cookie functions from http://www.webreference.com/js/column8/functions.html
2/*
3   name - name of the cookie
4   value - value of the cookie
5   [expires] - expiration date of the cookie
6     (defaults to end of current session)
7   [path] - path for which the cookie is valid
8     (defaults to path of calling document)
9   [domain] - domain for which the cookie is valid
10     (defaults to domain of calling document)
11   [secure] - Boolean value indicating if the cookie transmission requires a secure transmission
12
13   * an argument defaults when it is assigned null as a placeholder
14   * a null placeholder is not required for trailing omitted arguments
15*/
16function setCookie(name, value, expires, path, domain, secure) {
17  var curCookie = name + "=" + escape(value) +
18                  ((expires) ? "; expires=" + expires.toGMTString() : "") +
19                  ((path) ? "; path=" + path : "") +
20                  ((domain) ? "; domain=" + domain : "") +
21                  ((secure) ? "; secure" : "");
22  document.cookie = curCookie;
23}
24
25/*
26  name - name of the desired cookie
27  return string containing value of specified cookie or null if cookie does not exist
28*/
29function getCookie(name) {
30  var dc = document.cookie;
31  var prefix = name + "=";
32  var begin = dc.indexOf("; " + prefix);
33  if (begin == -1) {
34    begin = dc.indexOf(prefix);
35    if (begin != 0) return null;
36  }
37  else begin += 2;
38  var end = document.cookie.indexOf(";", begin);
39  if (end == -1) end = dc.length;
40  return unescape(dc.substring(begin + prefix.length, end));
41}
42
43/*
44   name - name of the cookie
45   [path] - path of the cookie (must be same as path used to create cookie)
46   [domain] - domain of the cookie (must be same as domain used to create cookie)
47   path and domain default if assigned null or omitted if no explicit argument proceeds
48*/
49function deleteCookie(name, path, domain) {
50  if (getCookie(name)) {
51    document.cookie = name + "=" +
52                      ((path) ? "; path=" + path : "") +
53                      ((domain) ? "; domain=" + domain : "") +
54                      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
55  }
56}
57
58function cache(id) {
59  if (document && document.getElementById(id))
60    document.getElementById(id).style.display="none";
61}
62
63function afficheMasque(id) {
64  if (document && document.getElementById(id))
65    if (document.getElementById(id).style.display=="block")
66      document.getElementById(id).style.display="none";
67    else
68      document.getElementById(id).style.display="block";
69}
70
71var timeout;
72var anc_title;
73
74function afficherControles(e, delai) {
75  if (!e) var e = window.event;
76  e.cancelBubble = true;
77  if (e.stopPropagation) e.stopPropagation();
78
79  if (!anc_title) anc_title=document.getElementById('enveloppe').title;
80  if (delai==0) clearSelection();
81
82  clearTimeout(timeout);
83  timeout=setTimeout(function () {
84      var controles=document.getElementsByName("ctrl");
85      if (controles)
86        for (var i=0; i<controles.length; i++) controles[i].style.display="inline";
87      document.getElementById('enveloppe').title="";
88    }, delai);
89}
90
91function masquerControles(e) {
92  if (!e) var e = window.event;
93  e.cancelBubble = true;
94  if (e.stopPropagation) e.stopPropagation();
95
96  clearTimeout(timeout);
97  timeout=setTimeout(function () {
98      var controles=document.getElementsByName("ctrl");
99      if (controles)
100        for (var i=0; i<controles.length; i++) controles[i].style.display="none";
101
102      cache('exclues');
103      document.getElementById('enveloppe').title=anc_title;
104    }, 500);
105}
106
107function clearSelection() {
108  var sel;
109  if(document.selection && document.selection.empty) document.selection.empty();
110  else if(window.getSelection) {
111    sel=window.getSelection();
112    if(sel && sel.removeAllRanges)
113      sel.removeAllRanges();
114  }
115}
116
117function recharge() {
118  window.location.reload();
119}
120
121function sauvePref() {
122  setCookie('fav_maxRec', document.getElementById('maxRec').value, new Date('July 21, 2099 00:00:00'), '/');
123  setCookie('fav_maxFav', document.getElementById('maxFav').value, new Date('July 21, 2099 00:00:00'), '/');
124  recharge();
125}
126