linccce

Help me on this

Sep 10th, 2014
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. /***********************************************
  2. * Switch Menu script- by Martial B of http://getElementById.com/
  3. * Modified by Dynamic Drive for format & NS4/IE4 compatibility
  4. * Visit http://www.dynamicdrive.com/ for full source code
  5. ***********************************************/
  6.  
  7. var persistmenu="yes" //"yes" or "no". Make sure each SPAN content contains an incrementing ID starting at 1 (id="sub1", id="sub2", etc)
  8. var persisttype="sitewide" //enter "sitewide" for menu to persist across site, "local" for this page only
  9.  
  10. if (document.getElementById){ //DynamicDrive.com change
  11. document.write('<style type="text/css">\n')
  12. document.write('.fbsubmenu{display: none;}\n')
  13. document.write('</style>\n')
  14. }
  15.  
  16. function SwitchMenu(obj){
  17. if(document.getElementById){
  18. var el = document.getElementById(obj);
  19. var ar = document.getElementById("masterdiv").getElementsByTagName("span"); //DynamicDrive.com change
  20. if(el.style.display != "block"){ //DynamicDrive.com change
  21. for (var i=0; i<ar.length; i++){
  22. if (ar[i].className=="fbsubmenu") //DynamicDrive.com change
  23. ar[i].style.display = "none";
  24. }
  25. el.style.display = "block";
  26. }else{
  27. el.style.display = "none";
  28. }
  29. }
  30. }
  31.  
  32. function get_cookie(Name) {
  33. var search = Name + "="
  34. var returnvalue = "";
  35. if (document.cookie.length > 0) {
  36. offset = document.cookie.indexOf(search)
  37. if (offset != -1) {
  38. offset += search.length
  39. end = document.cookie.indexOf(";", offset);
  40. if (end == -1) end = document.cookie.length;
  41. returnvalue=unescape(document.cookie.substring(offset, end))
  42. }
  43. }
  44. return returnvalue;
  45. }
  46.  
  47. function onloadfunction(){
  48. if (persistmenu=="yes"){
  49. var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
  50. var cookievalue=get_cookie(cookiename)
  51. if (cookievalue!="")
  52. document.getElementById(cookievalue).style.display="block"
  53. }
  54. }
  55.  
  56. function savemenustate(){
  57. var inc=1, blockid=""
  58. while (document.getElementById("sub"+inc)){
  59. if (document.getElementById("sub"+inc).style.display=="block"){
  60. blockid="sub"+inc
  61. break
  62. }
  63. inc++
  64. }
  65. var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
  66. var cookievalue=(persisttype=="sitewide")? blockid+";path=/" : blockid
  67. document.cookie=cookiename+"="+cookievalue
  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 (persistmenu=="yes" && document.getElementById)
  78. window.onunload=savemenustate
Advertisement
Add Comment
Please, Sign In to add comment