| 1 |
/*
|
| 2 |
permission to GPL granted by original author Kae Verens - kae@verens.com
|
| 3 |
note -- this is a modified version of the original
|
| 4 |
*/
|
| 5 |
|
| 6 |
if (isJsEnabled()) {
|
| 7 |
addLoadEvent(collapse_div);
|
| 8 |
if (document.getElementById)
|
| 9 |
window.onunload=div_save_state
|
| 10 |
}
|
| 11 |
|
| 12 |
function collapse_div(){
|
| 13 |
cdId=0;
|
| 14 |
if(!document.getElementsByTagName)return; // reject non-compliant browsers
|
| 15 |
a=document.getElementsByTagName('DIV');
|
| 16 |
for(i=0;a[i];i++){
|
| 17 |
if (!hasClass(a[i], 'collapsible')) continue;
|
| 18 |
b=a[i].childNodes;
|
| 19 |
for(j=0;b[j];j++){
|
| 20 |
if (hasClass(b[j], 'head')) {
|
| 21 |
wrapper = document.createElement('div');
|
| 22 |
wrapper.setAttribute('class', 'control');
|
| 23 |
b[j].insertBefore(wrapper, b[j].childNodes[0]);
|
| 24 |
|
| 25 |
c=document.createElement('a');
|
| 26 |
c.setAttribute('href','javascript:cdSwitch("cd'+(cdId)+'")');
|
| 27 |
c.setAttribute('id','cd'+(cdId)+'A');
|
| 28 |
c.setAttribute('class','opener');
|
| 29 |
c.style.display='inline';
|
| 30 |
c.innerHTML=' [-]';
|
| 31 |
wrapper.appendChild(c);
|
| 32 |
}
|
| 33 |
if (hasClass(b[j], 'body')) {
|
| 34 |
b[j].setAttribute('id','cd'+(cdId++));
|
| 35 |
b[j].style.display='block';
|
| 36 |
}
|
| 37 |
}
|
| 38 |
}
|
| 39 |
var cookie_value=div_get_cookie("collapsible_div");
|
| 40 |
if (cookie_value.length > 0) {
|
| 41 |
var ids = cookie_value.split('|');
|
| 42 |
for (var j=0; j<ids.length-1; j++) {
|
| 43 |
cdSwitch(ids[j]);
|
| 44 |
}
|
| 45 |
}
|
| 46 |
}
|
| 47 |
|
| 48 |
function cdSwitch(id){
|
| 49 |
a=document.getElementById(id);
|
| 50 |
a.style.display=(a.style.display=='block')?'none':'block';
|
| 51 |
if(parentLinkIsOpener)return;
|
| 52 |
a=document.getElementById(id+'A');
|
| 53 |
a.innerHTML=(a.innerHTML==' [-]')?' [+]':' [-]';
|
| 54 |
}
|
| 55 |
|
| 56 |
function div_save_state() {
|
| 57 |
var cookie_name = "collapsible_div", cookie_value = "", div_id = "";
|
| 58 |
i=0;
|
| 59 |
while (document.getElementById("cd"+i)){
|
| 60 |
a=document.getElementById("cd"+i);
|
| 61 |
b=a.getAttribute("style");
|
| 62 |
if (typeof b == 'string') {
|
| 63 |
c=b;
|
| 64 |
}
|
| 65 |
else if (typeof b == 'object') {
|
| 66 |
c=b.cssText;
|
| 67 |
}
|
| 68 |
if (c=="display: none;" | c=="DISPLAY: none"){
|
| 69 |
cookie_value += a.getAttribute("id")+"|";
|
| 70 |
}
|
| 71 |
i++;
|
| 72 |
parent.document.cookie=cookie_name+"="+cookie_value+";expires=Fri, 31 Dec 2099 23:59:59 GMT;";
|
| 73 |
}
|
| 74 |
}
|
| 75 |
|
| 76 |
function div_get_cookie(name) {
|
| 77 |
var search_value = name + "="
|
| 78 |
var return_value = "";
|
| 79 |
if (document.cookie.length > 0) {
|
| 80 |
begin = document.cookie.indexOf(search_value)
|
| 81 |
if (begin != -1) {
|
| 82 |
begin += search_value.length
|
| 83 |
end = document.cookie.indexOf(";", begin);
|
| 84 |
if (end == -1) end = document.cookie.length;
|
| 85 |
return_value=unescape(document.cookie.substring(begin, end))
|
| 86 |
}
|
| 87 |
}
|
| 88 |
return return_value;
|
| 89 |
}
|