    var yPos;
 
    var navState = {"sidebar":true, "categories":true, "meta":false, "upcoming":false, "nerd":true};

    var navSections = new Array("categories","meta","upcoming","nerd");

    function showViewer(artUrl) {
      if (!document.getElementById) return;
       yPos = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
       document.getElementById('contentViewer').style.top = (yPos+50)+'px'; 
       Effect.Fade('wrapper',{to: 0.25});
       document.getElementById('viewerArticle').innerHTML="Loading...";
       var myAjax = new Ajax.Updater('viewerArticle',artUrl,{
                                      method: 'get',
                                      parameters: 'plain=1'
                                      });
       Effect.Appear("contentViewer",{duration:2});
     }

     function hideViewer() {
         Effect.Fade('contentViewer');
         Effect.Appear('wrapper');
         setTimeout('window.scrollTo(0,yPos);',500);
     }
	 

     function sidebarClose() {
         Effect.Puff("sidebar");
         ct = document.getElementById("content");
         setTimeout('ct.style.width = "700px"',1000);
         setTimeout('Effect.BlindDown("sidebar_open")',1400);
         navState.sidebar = false; 
	 setNavCookie();
    }
     
     function sidebarOpen() {
         ct = document.getElementById("content");
         ct.style.width = '530px';
         Effect.Appear("sidebar");
         Effect.BlindUp("sidebar_open");
         navState.sidebar = true;
         setNavCookie();
     }

     function sidebarToggler(section) {
         sd = document.getElementById(section);
	 sb = document.getElementById(section+'_button');
	 if (sd.style.display == 'none') {
	   sb.src = '/wp-content/themes/hitherto/images/clearbits/subtract.gif';
           Effect.BlindDown(section);
	   navState[section] = true;
	 } else {
	   sb.src = '/wp-content/themes/hitherto/images/clearbits/add.gif';
	   Effect.BlindUp(section);
           navState[section] = false;
        }
	setNavCookie();
    }

    function sidebarButtonStates() {
       navSections.each(function(sn) {
         sb = document.getElementById(sn+'_button');
	 sb.src = (navState[sn] ? '/wp-content/themes/hitherto/images/clearbits/subtract.gif' :
	                          '/wp-content/themes/hitherto/images/clearbits/add.gif');
       });
    }
    
    function setCookie(name, value, expires, path, domain, secure) {
        var curCookie = name + "=" + escape(value) +
            ((expires) ? "; expires=" + expires.toGMTString() : "") +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            ((secure) ? "; secure" : "");
        document.cookie = curCookie;
    }

    function getCookie(name) {
        var dc = document.cookie;
        var prefix = name + "=";
        var begin = dc.indexOf("; " + prefix);
        if (begin == -1) {
          begin = dc.indexOf(prefix);
        if (begin != 0) return null;
        } else
          begin += 2;
        var end = document.cookie.indexOf(";", begin);
        if (end == -1)
          end = dc.length;
        return unescape(dc.substring(begin + prefix.length, end));
    }

    function fixDate(date) {
        var base = new Date(0);
        var skew = base.getTime();
        if (skew > 0)
          date.setTime(date.getTime() - skew);
    }

    function setNavCookie() {
        var now = new Date();
        fixDate(now);
        now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
        cookieVals = new Array();
        for (x in navState) {
            cookieVals.push(x + "=" + (navState[x]? 1 : 0));
        }
	cookieString= cookieVals.join('&');
        setCookie('nav',cookieString,now,'/');
    }

    var navCookie = getCookie('nav');
    if (navCookie) {
        cookieVals = new Array();
        cookieVals = navCookie.split('&');
	cookieVals.each(function(x) {
	  navParam = x.split('=');
	  navState[navParam[0]] = (navParam[1] == 1 ? true : false);
	});
     }
