| 1 |
|
| 2 |
/***********************************************
|
| 3 |
* Switch Menu script- by Martial B of http://getElementById.com/
|
| 4 |
* Modified by Dynamic Drive for format & NS4/IE4 compatibility
|
| 5 |
* Visit http://www.dynamicdrive.com/ for full source code
|
| 6 |
***********************************************/
|
| 7 |
|
| 8 |
if (document.getElementById){ //DynamicDrive.com change
|
| 9 |
document.write('<style type="text/css">\n')
|
| 10 |
document.write('.submenu{display: none;}\n')
|
| 11 |
document.write('</style>\n')
|
| 12 |
}
|
| 13 |
|
| 14 |
function SwitchMenu(obj){
|
| 15 |
if(document.getElementById){
|
| 16 |
var el = document.getElementById(obj);
|
| 17 |
var parent = document.getElementById("menu-" + obj);
|
| 18 |
if(el.style.display != "block"){ //DynamicDrive.com change
|
| 19 |
el.style.display = "block";
|
| 20 |
parent.className = "menutitle expanded";
|
| 21 |
}else{
|
| 22 |
el.style.display = "none";
|
| 23 |
parent.className = "menutitle collapsed";
|
| 24 |
}
|
| 25 |
}
|
| 26 |
}
|
| 27 |
|
| 28 |
function get_cookie(Name) {
|
| 29 |
var search = Name + "="
|
| 30 |
var returnvalue = "";
|
| 31 |
if (document.cookie.length > 0) {
|
| 32 |
offset = document.cookie.indexOf(search)
|
| 33 |
if (offset != -1) {
|
| 34 |
offset += search.length
|
| 35 |
end = document.cookie.indexOf(";", offset);
|
| 36 |
if (end == -1) end = document.cookie.length;
|
| 37 |
returnvalue = unescape(document.cookie.substring(offset, end))
|
| 38 |
}
|
| 39 |
}
|
| 40 |
return returnvalue;
|
| 41 |
}
|
| 42 |
|
| 43 |
function onloadfunction(){
|
| 44 |
var cookievalue = get_cookie("switchmenu");
|
| 45 |
if (cookievalue != "") {
|
| 46 |
var cookieList = cookievalue.split(",");
|
| 47 |
for (var i = 0; i < cookieList.length; i++) {
|
| 48 |
document.getElementById(cookieList[i]).style.display = "block"
|
| 49 |
document.getElementById("menu-" + cookieList[i]).className = "menutitle expanded";
|
| 50 |
}
|
| 51 |
}
|
| 52 |
}
|
| 53 |
|
| 54 |
function savemenustate(){
|
| 55 |
|
| 56 |
var blocks = "";
|
| 57 |
var spans = document.getElementsByTagName("span"); //DynamicDrive.com change
|
| 58 |
for (var i = 0; i < spans.length; i++ ) {
|
| 59 |
if (spans[i].className == "submenu" && spans[i].style.display == "block") {
|
| 60 |
if (blocks != "") {
|
| 61 |
blocks += ",";
|
| 62 |
}
|
| 63 |
blocks += spans[i].id;
|
| 64 |
}
|
| 65 |
}
|
| 66 |
|
| 67 |
document.cookie = "switchmenu=" + blocks + ";path=/" ;
|
| 68 |
}
|
| 69 |
|
| 70 |
if (window.addEventListener)
|
| 71 |
window.addEventListener("load", onloadfunction, false)
|
| 72 |
else if (window.attachEvent)
|
| 73 |
window.attachEvent("onload", onloadfunction)
|
| 74 |
else if (document.getElementById)
|
| 75 |
window.onload = onloadfunction
|
| 76 |
|
| 77 |
if (document.getElementById)
|
| 78 |
window.onunload = savemenustate
|