   var calCache = [];
   var currentBit = "";
   var busy = false;
   function loadCalendar(id)
   {
        if (calCache[id])
        {
            display("calendarDiv",calCache[id]);
        } else
        {
            if (busy == true) return;
            busy = true;
            document.body.style.cursor = "wait";
            var url = "/php/blogtask.php?task=calendar&id=" + id + "&callback=calendarHandler";
            findDoc().location.replace(url);
        }
   }
   
   function calendarHandler(e)
   {
        var str = ent2html(e.response);
        str += '<div class="right"><a href="/nast/archives">Archive Index</a></div>';
        calCache[e.id] = str;
        display("calendarDiv",str);
        document.body.style.cursor = "default";
        busy = false;
   }
   
   function doRandomBit()
   {
        if (busy == true) return;
        busy = true;
        document.body.style.cursor = "wait";
        var url = "/php/blogtask.php?task=random&callback=handleRandomBit";
        findDoc().location.replace(url);
   }
   
   function handleRandomBit(e)
   {
        busy = false;
        
        /*if (currentBit == e.id)
        {
            // no dupes!
            doRandomBit();
        } else
        {
            currentBit = e.id;
        */
            var str = ent2html(e.response);
            str += '<div class="right"><a href="#" onclick="doRandomBit(); return false;">Randomize</a></div>';
            display("randomDiv",str);
            document.body.style.cursor = "default";
            window.focus();
        //}
   }
   
   function display(id,str)
   {
        document.getElementById(id).innerHTML = str;
   }
   
   function ent2html(str)
   {
        str = str.split("&gt;").join(">");
        str = str.split("&lt;").join("<");
        str = str.split("&quot;").join("\"");
        str = str.split("&#039;").join("'");
        str = str.split("&amp;").join("&");
        return str;       
   }
   
function findDoc()
{
    var doc;
    var iframe = window.frames["rsFrame"];
    if (iframe.contentDocument) {
        // For NS6
        doc = iframe.contentDocument; 
    } else if (iframe.contentWindow) {
        // For IE5.5 and IE6
        doc = iframe.contentWindow.document;
    } else if (iframe.document) {
        // For IE5
        doc = iframe.document;
    } else {
        return false;
    }
    return doc;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

onload = function()
{
    
}

function OpenComments (c) {
    window.open(c,
               'comments',
               'width=480,height=480,scrollbars=yes,status=yes');
}

