title: JS cookie div visibility
body: <p>I got this JS script that sets the cookie and show / hides the div </p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script type="text/javascript"&gt;
  function setCookie (name, value, expires, path, domain, secure) {
      document.cookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  }
  function getCookie (name) {
      var cookie = " " + document.cookie;
      var search = " " + name + "=";
      var setStr = null;
      var offset = 0;
      var end = 0;
      if (cookie.length &gt; 0) {
          offset = cookie.indexOf(search);
          if (offset != -1) {
              offset += search.length;
              end = cookie.indexOf(";", offset);
              if (end == -1) {
                  end = cookie.length;
              }
              setStr = unescape(cookie.substring(offset, end));
          }
      }
      if (setStr == 'false') {
          setStr = false;
      } 
      if (setStr == 'true') {
          setStr = true;
      }
      if (setStr == 'null') {
          setStr = null;
      }
      return(setStr);
  }
  function hidePopup() {
      setCookie('popup_state', false); 
      document.getElementById('popup').style.display = 'none';
  }
  function showPopup() {
      setCookie('popup_state', null);
      document.getElementById('popup').style.display = 'block';
  }
  function checkPopup() {
      if (getCookie('popup_state') == null) { // if popup was not closed
          document.getElementById('popup').style.display = 'block';
      }   
  }
  
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body onLoad="checkPopup();"&gt;
  &lt;a href="#" onClick="hidePopup(); return false;"&gt;Turn Off&lt;/a&gt;&lt;/br&gt;&lt;/br&gt;
  &lt;a href="#" onClick="showPopup(); return false;"&gt;Turn On&lt;/a&gt;
       &lt;div id="popup" style="display:none"&gt;Hello! Welcome to my site. If you want to hide this message then click&lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I need someone, if anyone is kind enough to explain to me, how can i change the cookie values? (name, expires, etc) and how can i merge the on / off buttons into 1 button that will do the job of toggleing the show/hide and editing the cookie correspondingly.</p>