if (window.addEventListener) {
  window.addEventListener("load", initRoboshrub, false);
}
else if (window.attachEvent) {
  window.attachEvent("onload", initRoboshrub);
}
else {
  window.onload = function() {window.onload(); initRoboshrub();};
}

function initRoboshrub() {
  reverseArchive();
  
  // Create links to posters' profiles
  var authors = getElementsByClassName("itemAuthor");
  for (i=0; i<authors.length; i++) {
    authors[i].innerHTML = "<a href='http:\/\/www.blogger.com\/profile\/" + contrib[authors[i].innerHTML] + "'>" + authors[i].innerHTML + "</a>";
  }
  
  // Create personalized comment labels
  var tmp1 = getElementsByClassName("itemComments");
  var tmp2 = [].slice.call(getElementsByClassName("itemCommentCount"), 0);
  if (tmp1.length > 0) {
    for (i=0; i<tmp1.length; i++) {
      tmp1[i].innerHTML = commentNumber(parseInt(tmp2[i].innerHTML), tmp1[i].getElementsByTagName("a")[0].href);
    }
  }
  
  // Label page
  buildLabelPage();
  
  // Create blogroll
  if (g('broll') != null) {
    g('broll').style.display = "block";
    writeBlogroll();
  }
  
  if (!getVox('setTheme')) {
    resetCookies();
  }
  if (getVox('setTheme')) {
    setNewTheme();
  }
  
  if (getVox('robotVoice') == 1) {
    var dir = "http://databathing.com/Vox/";
    
    var a       = document.createElement("audio");
    a.autoplay  = true;
    
    var s1      = document.createElement("source");
        s1.type = "audio/ogg";
        s1.src  = dir + "Vorbis/" + bob + ".ogg";
    
    var s2      = document.createElement("source");
        s2.type = "audio/mpeg";
        s2.src  = dir + "MP3/" + bob + ".mp3";
    
    a.appendChild(s1);
    a.appendChild(s2);
    
    /*@cc_on
      a     = document.createElement("bgsound");
      a.src = dir + "MP3/" + bob + ".mp3";
    @*/
    
    g('voiceSpan').appendChild(a);
  }
  
  if (getVox('randGraph') == 1) {
    g('Robologo').src = buck + "Logos\/logo" + l[Math.round(Math.random() * (l.length-1))] + ".png";
  }
  
  g('jsButtonsForThingey').style.display = "inline";
  g('governor').style.cursor = "pointer";
  g('desc').innerHTML = b[bob];
  initTreeLists();
}
var bob, backtransit, beenHere, buck = "http:\/\/img.photobucket.com\/albums\/v701\/Artiki\/", themeBack = buck + "web_images\/";
var blogs = {
  "A Army of (Cl)one" : "armyofclone",
  "A Little Bent..." : "dykodrama",
  "All Kinds Of Stuff" : "johnkstuff",
  "Captain Picard&rsquo;s Journal" : "jlpicard",
  "Castle of Nannbugg" : "lahilton",
  "Death By Default" : "polyman3",
  "Fakiegrind" : "fakiegrind",
  "Fred&rsquo;s World" : "tampateacher",
  "Fuse the Durn Spores" : "fusethesporesfluke",
  "G3Tfilms" : "g3tfilms",
  "Gistological Institute" : "gistology",
  "I Moved Your Cheese, Moron" : "thecheesepad",
  "Ibizar&rsquo;s Random Thoughts On Life" : "ibizar",
  "Indexed" : "indexed",
  "Intergalactic Gladiator" : "joninterglad",
  "Jaibhakti" : "jaibhakti",
  "Jintrinsique" : "jintrinsique",
  "Last Gladiator Standing" : "last-gladiator",
  "Local-Henchmen-Union432" : "henchy432",
  "Mahndisa&rsquo;s Thoughts" : "mrigmaiden",
  "People Covered in Fish" : "robosquirrel",
  "Professor Xavier&rsquo;s Blog" : "professorxavier",
  "R2K" : "r2000",
  "Ramblings of the Bearded One" : "kimayres",
  "Shaken Not Stirred" : "notstirred",
  "Someone&rsquo;s Treasure Is Another Man&rsquo;s Trash" : "threethumbsdown",
  "That &ldquo;Thing&rdquo;" : "thingisent",
  "The Amazing Mutant Race 3" : "amazingmutantrace3",
  "The Days Of Our Lives" : "grasshopperboy",
  "The Federalist Solution" : "federalistsolution",
  "The Musings Of David Amulet" : "davidamulet",
  "The Replacment Blog" : "thereplacementblog",
  "The Transcending Sovereignty" : "freeconstitution",
  "Ticharu Gets Legs" : "ticharu",
  "Wallycrawler" : "wallycrawler",
  "Who is McDougal?" : "friendsofmcdougal",
  "Written Inc." : "writteninc",
  "Zero Unlimited" : "zerounlimited"
};
var contrib = {
  "Roboshrub Incorporated" : "10142011",
  "Gyrobo" : "10151931",
  "destructobob" : "10275253",
  "-Nathan Earl" : "14630631067739873519",
  "Rick Anonymi" : "10948001",
  "His Majesty" : "14107507",
  "Karl the Sorcerer" : "14667270",
  "Metapirate" : "20151936",
  "OneStar" : "20676655",
  "Mr. R9NE" : "34751868",
  "Swigabre" : "35098057",
  "John “Test Casey” Jones" : "35115144",
  "Professor Huxley" : "35209133",
  "Doctor Moonshine" : "35181095",
  "Delicious" : "09098974702390994318"
};
var b = [];
function g(a) {
  return document.getElementById(a);
}
function getElementsByClassName(c_name) {
  if (document.getElementsByClassName) {
    return document.getElementsByClassName(c_name);
  }
  var temp = document.getElementsByTagName('*');
  var found = [];
  for (i=0; i<temp.length; i++) {
    var c_class = temp[i].className.split(" ");
    for (k=0; k<c_class.length; k++) {
      if (c_class[k] == c_name) {
        found.push(temp[i]);
        break;
      }
    }
  }
  return found;
}
function setVox(cookName,value) {
  var expires = new Date();
  expires.setDate(expires.getDate() + 1000000);
  document.cookie = cookName + "=" + escape(value) + ";expires=" + expires + ";path=\/";
}
function getVox(cookName) {
  c_start = document.cookie.indexOf(cookName + "=");
  if (c_start != -1) { 
    c_start = c_start + cookName.length + 1;
    c_end = document.cookie.indexOf(";", c_start);
    if (c_end == -1) {
      c_end = document.cookie.length;
    }
    return unescape(document.cookie.substring(c_start, c_end));
  }
}

function resetCookies() {
  setVox('randGraph', 0);
  setVox('robotVoice', 0);
  setVox('scrollPost', 0);
  setVox('scrollComm', 0);
  setVox('themeDay', 1);
  setVox('setTheme', 3);
}

bob=2012;
b[2012]="Are robot overlords for us? Find out next with Prime Minister Koizumi!";
var l=[
"",
"Ghost",
"Electric",
"Mache",
"Crayon",
"5",
"Static",
"Scratch",
"Spindle",
"Space",
"Bluish",
"Comp",
"White",
"Burning",
"Normal",
"Redglow",
"Stone",
"Unreal",
"Avquest",
"Slab",
"Nova",
"Chalk",
"Boots",
"Autobahn",
"Alien",
"Tiles",
"Simple",
"Mars",
"Granite",
"Felt",
"Cutout",
"Templar",
"SmudgedUp",
"Ripple",
"Blot",
"Reflect",
"Comic",
"Chrome",
"ZoomBlur",
"Nature",
"Underwater",
"Modern",
"Kiloton",
"Hot",
"Fading",
"Cranberry",
"Church",
"Future",
"Fairy",
"Howdy",
"Joy",
"Block",
"Corporate",
"Cracked",
"Domo",
"Drippy",
"Kidz",
"Soviet",
"Squirt",
"Pop",
"Star",
"Han",
"Probe",
"Script",
"Caribbean",
"Orbit",
"Mutant",
"Old",
"Popwarp",
"Questwarp",
"Kilotonwarp",
"Cranwarp"
];

function fadeIn(SWOOP) {
  switch (SWOOP) {
    case 0: return g('mission');
    case 1: return g('credits');
    case 2: return g('custom');
    case 3: return g('bees');
  }
}
var c_timer, inc=7, f0=0, f1=0, f2=0, f3=0;
function setUpCredits(SWOOP) {
  clearTimeout(c_timer);
  if (SWOOP == 0) {
    g('missionlogo').src = buck + "mission_statement.png";
  }
  if (SWOOP == 3) {
    g('bees').style.backgroundImage = "url('" + buck + "bees.gif')";
  }
  document.body.style.overflow = "hidden";
  window.scroll(0, 0);
  cred = fadeIn(SWOOP);
  if (cred == g('credits')) {
    g('profiles').innerHTML = "";
    for (i in contrib) {
      g('profiles').innerHTML += "<br \/><a href='http:\/\/www.blogger.com\/profile\/" + contrib[i] + "'>" + i + "</a>";
    }
  }
  cred.style.display = "block";
  /*@cc_on
    cred.style.width  = document.documentElement.clientWidth;
    cred.style.height = document.documentElement.clientHeight;
  @*/
  beginCredits(SWOOP);
}

function beginCredits(SWOOP) {
  cred = fadeIn(SWOOP);
  if (f0 >= 101) {
    c_timer = setTimeout("showCredits(" + SWOOP + ");", 1000);
    return;
  }
  f0 += inc;
  /*@cc_on true ? cred.style.filter="alpha(opacity=" + f0 + ")" : @*/ cred.style.opacity = (f0 / 100);
  c_timer = setTimeout("beginCredits(" + SWOOP + ")", 24);
}

function showCredits(SWOOP) {
  cred = fadeIn(SWOOP);
  var glyphs = cred.getElementsByTagName("p");
  if (f1 < 101) {
    f1 += inc;
    /*@cc_on true ? glyphs[0].style.filter = "alpha(opacity=" + f1 + ")" : @*/ glyphs[0].style.opacity = (f1/100);
    c_timer = setTimeout("showCredits(" + SWOOP + ")", 24);
    return;
  }
  if (f2 < 101) {
    f2 += inc;
    /*@cc_on true ? glyphs[1].style.filter = "alpha(opacity=" + f2 + ")" : @*/ glyphs[1].style.opacity = (f2/100);
    c_timer = setTimeout("showCredits(" + SWOOP + ")", 24);
    return;
  }
  if (f3 < 101) {
    f3 += inc;
    /*@cc_on true ? glyphs[2].style.filter = "alpha(opacity=" + f3 + ")" : @*/ glyphs[2].style.opacity = (f3/100);
    c_timer = setTimeout("showCredits(" + SWOOP + ")", 24);
    return;
  }
  if (f3 >= 101) {
    if (SWOOP == 0) {
      c_timer = setTimeout("countDown(" + SWOOP + ", 100)", 10000)
    }
    if (SWOOP == 1) {
      c_timer = setTimeout("countDown(" + SWOOP + ", 100)", 6500);
    }
    return;
  }
}

function countDown(SWOOP, a) {
  cred = fadeIn(SWOOP);
  if (a <= 0) {
    resetCredits(SWOOP);
    return;
  }
  /*@cc_on true ? cred.style.filter = "alpha(opacity=" + a + ")" : @*/ cred.style.opacity = (a/100);
  var b = (a - inc);
  c_timer = setTimeout("countDown(" + SWOOP + ", " + b + ")", 42);
}

function resetCredits(SWOOP) {
  cred = fadeIn(SWOOP);
  f0=0, f1=0, f2=0, f3=0;
  var glyphs = cred.getElementsByTagName("p");
  for (i = 0; i < glyphs.length; i++) {
    glyphs[i].style.opacity = 0;
  }
  /*@cc_on true ? cred.style.filter = "alpha(opacity=0)" : @*/ cred.style.opacity = 0;
  cred.style.display = "none";
  document.body.style.overflow = "auto";
}

// Build comment link
function bc(c_URL, c_Text) {
  return "<a class='comment-link' href='" + c_URL + "'>" + c_Text + "</a>";
}

// Return personalized comment link
function commentNumber(c_Number, c_URL) {
  switch (c_Number) {
    case 0: return bc(c_URL, "No robo-comments");
    case 1: return bc(c_URL, "A Solitary robo-comment");
    case 2: return bc(c_URL, "A couple of robo-comments");
    case 3: return bc(c_URL, "A trio of robo-comments");
    case 4: return bc(c_URL, "A quartet of robo-comments");
    case 6: return bc(c_URL, "Half a dozen robo-comments");
    case 12: return bc(c_URL, "A dozen robo-comments");
    case 13: return bc(c_URL, "A baker&rsquo;;s dozen robo-comments");
    case 16: return bc(c_URL, "A sweet sixteen robo-comments");
    case 20: return bc(c_URL, "One score robo-comments");
    case 24: return bc(c_URL, "Two dozen robo-comments");
    case 30: return bc(c_URL, "&ldquo;Still just 29&rdquo; robo-comments");
    case 36: return bc(c_URL, "Three dozen robo-comments");
    case 40: return bc(c_URL, "Two score robo-comments");
    case 87: return bc(c_URL, "Four score and seven robo-comments");
    case 100: return bc(c_URL, "10<sup>2</sup> robo-comments");
    case 128: return bc(c_URL, "A 128-bit robo-comment");
    case 144: return bc(c_URL, "One gross robo-comments");
    case 256: return bc(c_URL, "A Hex Dollar of robo-comments");
    case 1000: return bc(c_URL, "One kilo-comment");
    case 1728: return bc(c_URL, "One great gross robo-comments");
    default: return bc(c_URL, c_Number + " robo-comments");
  }
}

function vChk(a, b) {
  setVox(b, g(a).checked ? 1 : 0);
}

function validateCustom() {
  if (!navigator.cookieEnabled) {
    alert("Your settings won't be saved, because you don't have cookies enabled.");
  }
  if (backtransit) {return;}
  vChk('derLog', 'randGraph');
  vChk('derVox', 'robotVoice');
  vChk('derScr', 'scrollPost');
  vChk('derCom', 'scrollComm');
  vChk('derThe', 'themeDay');
  var tmp = g('theOp').selectedIndex;
  setVox('setTheme', g('theOp')[tmp].value);
  setNewTheme();
  countDown(2, 100);
  backtransit = true;
}

function resetDefault() {
  if (backtransit) {return;}
  g('derLog').checked = false;
  g('derVox').checked = false;
  g('derScr').checked = false;
  g('derCom').checked = false;
  g('derThe').checked = true;
  g('theOp').selectedIndex = 2;
  resetCookies();
  setNewTheme();
  countDown(2, 100);
  backtransit = true;
}

function pL(a,b) {
  return "<label for='" + a + "'><input type='checkbox' id='" + a + "'> " + b + "<\/label><br \/>";
}

function setOpt(a,b){
  g(b).checked = (getVox(a) == 1);
}

function setUpCustom() {
  if (!beenHere) {
    var tmp = g('innerCust').innerHTML.toString();
    g('innerCust').innerHTML = pL('derLog', 'Random Title Graphics') + pL('derVox', 'Robot Voice for Slogans') + pL('derScr', 'Scroll Posts') + pL('derCom', 'Scroll Comments') + pL('derThe', 'Theme Days') + tmp;
    beenHere = true;
  }
  setOpt('randGraph', 'derLog');
  setOpt('robotVoice', 'derVox');
  setOpt('scrollPost', 'derScr');
  setOpt('scrollComm', 'derCom');
  setOpt('themeDay', 'derThe');
  g('theOp').selectedIndex = getVox('setTheme')-1;
  backtransit = false;
}

function writeBlogroll() {
  var bTemp = "";
  bTemp += "<ul id='b-roll' style='height:20em; overflow:auto;'>";
  for (i in blogs) {
    bTemp += "<li><a href='http:\/\/" + blogs[i] + ".blogspot.com\/'>" + i + "</a></li>";
  }
  bTemp += "<\/ul><hr \/>";
  g('broll').innerHTML += bTemp;
}

/*******
Indexes:
0:	Theme folder
1:	Navbar background color
2:	Navbar search background color
3:	Page background color

// CSS
4:	h2.date-header
5:	h3.post-title
6:	div#sidebar h2
7:	ul#jsButtonsForThingey li
8:	ul#jsButtonsForThingey a:link
9:	ul#jsButtonsForThingey a:visited
10:	ul#jsButtonsForThingey a:hover
11:	#sidebar hr
12:	.post, #sidebar ul, #comments, #new-archives
********/

var themes = [
  // Atlantic
  ["blue",
  "#003366",
  "#114477",
  "#0B2D4F",
  "color:#AADDFF; text-shadow:0 0 5px #000; -ms-filter:'glow(color=black, strength=1)'; filter:glow(color=black, strength=1);",
  "color:#FFF; text-shadow:0 0 5px #000; -ms-filter:'glow(color=black, strength=1)'; filter:glow(color=black, strength=1);",
  "color:#FFF; text-shadow:0 0 5px aqua; -ms-filter:'glow(color=aqua, strength=1)'; filter:glow(color=black, strength=1);",
  "border-left-color:#FFF;",
  "color:#FF0;",
  "color:#DD8;",
  "color:#FFF;",
  "border-color:#DDD;",
  "box-shadow: 0 0 0 5px #6495ED; -moz-box-shadow: 0 0 0 5px #6495ED; -webkit-box-shadow: 0 0 0 5px #6495ED;"],
  
  // Streaked Dunes
  ["tan",
  "#F5ECE2",
  "#E1D4C0",
  "#D5C4AA",
  "color:#555; text-shadow:none; -ms-filter:'none'; filter:none;",
  "color:#000; text-shadow:none; -ms-filter:'none'; filter:none;",
  "color:#000; text-shadow:0 0 5px #CD853F; -ms-filter:'glow(color=#CD854F, strength=1)'; filter:glow(color=#CD854F, strength=1);",
  "border-left-color:#000;",
  "color:#8B4513;",
  "color:#8B795E;",
  "color:#A52A2A;",
  "border-color:#555;",
  "box-shadow: 0 0 0 5px #DEB887; -moz-box-shadow: 0 0 0 5px #DEB887; -webkit-box-shadow: 0 0 0 5px #DEB887;"
  ],
  
  // Roboshrub Classic
  ["black",
  "#111111",
  "#333333",
  "#000000",
  "color:#777; text-shadow:none; -ms-filter:'none'; filter:none;",
  "color:#AD9; text-shadow:none; -ms-filter:'none'; filter:none;",
  "color:#FFF; text-shadow:0 0 5px aqua; -ms-filter:'glow(color=aqua, strength=1)'; filter:progid:DXImageTransform.Microsoft.Glow(color=aqua, strength=1);",
  "border-left-color:#DDD;",
  "color:#9AD;",
  "color:#A7A;",
  "color:#AD9;",
  "border-color:#555;",
  "box-shadow: 0 0 0 5px #335; -moz-box-shadow: 0 0 0 5px #335; -webkit-box-shadow: 0 0 0 5px #335;"],
  
  // Diamond Mine
  ["gray",
  "#EDEDED",
  "#CCCCCC",
  "#BEBEBE",
  "color:#555; text-shadow:none; -ms-filter:'none'; filter:none;",
  "color:#000; text-shadow:none; -ms-filter:'none'; filter:none;",
  "color:#191970; text-shadow:0 0 5px #87CEFA; -ms-filter:'glow(color=#87CEFA, strength=1)'; filter:glow(color=#87CEFA, strength=1);",
  "border-left-color:#000;",
  "color:#2222DD;",
  "color:#4B0082;",
  "color:#B22222;",
  "border-color:#555;",
  "box-shadow: 0 0 0 5px #F0F8FF; -moz-box-shadow: 0 0 0 5px #F0F8FF; -webkit-box-shadow: 0 0 0 5px #F0F8FF;"],
  
  // Greenscene
  ["green",
  "#008A13",
  "#008A13",
  "#06742A",
  "color:#ABA; text-shadow:0 0 5px #000; -ms-filter:'glow(color=black, strength=1)'; filter:glow(color=black, strength=1);",
  "color:#AFA; text-shadow:0 0 5px #000; -ms-filter:'glow(color=black, strength=1)'; filter:glow(color=black, strength=1);",
  "color:#FFF; text-shadow:0 0 5px #000; -ms-filter:'glow(color=black, strength=1)'; filter:glow(color=black, strength=1);",
  "border-left-color:#FFF;",
  "color:#FFD700;",
  "color:#DAA520;",
  "color:#FFFACD;",
  "border-color:#DDD;",
  "box-shadow: 0 0 0 5px #006400; -moz-box-shadow: 0 0 0 5px #006400; -webkit-box-shadow: 0 0 0 5px #006400;"],
  
  // Rusted Pumpkin
  ["orange",
  "#C65413",
  "#E65613",
  "#E65919",
  "color:#700; text-shadow:none; -ms-filter:'none'; filter:none;",
  "color:#000; text-shadow:none; -ms-filter:'none'; filter:none;",
  "color:#000; text-shadow:0 0 5px #B9430D; -ms-filter:'glow(color=#B9430D, strength=1)'; filter:glow(color=#B9430D, strength=1);",
  "border-left-color:#000;",
  "color:#030315;",
  "color:#64639E;",
  "color:#1A16C3;",
  "border-color:#833;",
  "box-shadow: 0 0 0 5px #B9430D; -moz-box-shadow: 0 0 0 5px #B9430D; -webkit-box-shadow: 0 0 0 5px #B9430D;",
  ]
];

function setNewTheme() {
  // Scroll posts?
  var tPBody = getElementsByClassName("post-body");
  for (i=0; i<tPBody.length; i++) {
    tPBody[i].className = (getVox('scrollPost') == 1) ? "post-body innerPost" : "post-body";
  }
  // Scroll comments?
  tPBody = getElementsByClassName("post-comments-body");
  for (i=0; i<tPBody.length; i++) {
    tPBody[i].className = (getVox('scrollComm') == 1) ? "post-comments-body innerPost" : "post-comments-body";
  }
  setDailyTheme();
  
  var tIndex = parseInt(getVox('setTheme'))-1;
  var themeURL = "http://databathing.com/roboshrub_navbar/" + themes[tIndex][0] + "/";
  
  // Navbar
  g('b-navbar').style.backgroundColor = themes[tIndex][1];
  g('b-navbar').style.backgroundImage = "url(" + themeURL + "navbar.png)";
  
  // Searchbar
  g('b-search').style.backgroundColor = themes[tIndex][2];
  g('b-search').style.backgroundImage = "url(" + themeURL + "searchbar.png)";
  
  // Buttons
  g('b-logobar').src		= themeURL + "logobar.gif";
  g('b-getblog').src		= themeURL + "btn_getblog.gif";
  g('b-nextblog').src		= themeURL + "btn_nextblog.gif";
  g('b-searchbtn').src		= themeURL + "btn_search_this.gif";
  g('b-searchallbtn').src	= themeURL + "btn_search_all.gif";
  
  // Page theme
  var docBody = document.getElementsByTagName('body')[0];
  docBody.style.backgroundImage = "url(" + themeURL + "pageback.png)";
  docBody.style.backgroundColor = themes[tIndex][3];
  
  /*** Other CSS ***/
  var extCSS = "";
  tIndex = themes[tIndex];
  
  extCSS += "h2.date-header	{"+tIndex[4]+"}";
  extCSS += "h3.post-title	{"+tIndex[5]+"}";
  extCSS += "div#sidebar h2	{"+tIndex[6]+"}";
  extCSS += "ul#jsButtonsForThingey li {"+tIndex[7]+"}";
  extCSS += "ul#jsButtonsForThingey a:link {"+tIndex[8]+"}";
  extCSS += "ul#jsButtonsForThingey a:visited {"+tIndex[9]+"}";
  extCSS += "ul#jsButtonsForThingey a:hover {"+tIndex[10]+"}";
  extCSS += "#sidebar hr {"+tIndex[11]+"}";
  extCSS += ".post, #sidebar ul, #comments, #new-archives {"+tIndex[12]+"}";
  
  // IE fix
  /*@cc_on
    document.body.innerHTML += "<style type='text/css'>"+extCSS+"<\/style>";
    return;
  @*/

  var newCSS = document.createElement('style');
  newCSS.appendChild(document.createTextNode(extCSS));
  document.getElementsByTagName('head')[0].appendChild(newCSS);
}

function writeTheme(swfURL, caption) {
  g('themeContainer').innerHTML = "<embed src='" + buck + "Animate\/" + swfURL + ".swf' style='width:164px;height:130px;' quality='high' wmode='transparent' bgcolor='#000000'><\/embed>";
  g('zani').innerHTML = caption;
}

function specialSunday() {
  g('governor').style.display = "block";
  g('themeContainer').style.display = "none";
  g('governor').src = buck + "dont-click.gif";
  g('governor').style.borderWidth = "0";
  g('zani').innerHTML = "It&rsquo;s Self-Restraint Sunday!";
  g('governor').onclick=function() {setUpCredits(3); backtransit = false;};
}

function setDailyTheme() {
  if (getVox('themeDay') != 0) {
    g('governor').style.display = "none";
    g('themeContainer').style.display = "block";
    
    var week = (new Date()).getDay();
    switch (week) {
      case 1: writeTheme('ebd', "It&rsquo;s Manic Monarchical Monday!"); return;
      case 2: writeTheme('karl', "It&rsquo;s Flame-Retardent Tuesday!"); return;
      case 5: writeTheme('Clownface', "It&rsquo;s Crazy Robot Friday!"); return;
      case 6: writeTheme('metatest', "It&rsquo;s Sea Sickness Saturday!"); return;
      case 0: specialSunday(); return;
      default: break;
    }
  }
  
  g('governor').style.display = "block";
  g('themeContainer').innerHTML = "";
  g('themeContainer').style.display = "none";
  g('zani').innerHTML = "Beware the Roboshrub!";
  
}

function buildLabelPage() {
  if (location.href.split('/')[location.href.split('/').length-2] == "label") {
    var a = getElementsByClassName('date-header');
    
    if (a.length == 0) {
      a = "<h3 class='post-title'>No Posts Found<\/h3>";
      a += "<div class='post'><div class='post-body'><div>";
      a += "There are no more posts with the label <q>" + location.href.split('/')[location.href.split('/').length-1] + "<\/q><br \/><br \/><a href='" + location.href.split('.com')[0] + ".com\/'>" + document.title + " Home Page<\/a>";
      a += "<\/div><\/div><\/div>";
      g('main').innerHTML = a;
    }
    
    else {
      a = a[getElementsByClassName('date-header').length-1].innerHTML.split('.');
      var tmp = a[0];
      a[0] = a[2].length >= 2 ? a[2] : "0" + a[2];
      a[2] = a[1].length >= 2 ? a[1] : "0" + a[1];
      a[1] = tmp.length >= 2 ? tmp : "0" + tmp;
      a = a.join("-");
      if (getElementsByClassName('post').length >= 20) {
        tmp = document.createElement('a');
        tmp.href = location.href.split("?")[0] + "?updated-max=" + a + "T21%3A33%3A00-05%3A00&max-results=20";
        tmp.innerHTML = "Older Posts &gt;&gt;";
        g('main').appendChild(tmp);
      }
      document.title = document.title + " -- Label: \"" + location.href.split('/')[location.href.split('/').length-1] + "\"";
    }
  }
}

function reverseArchive() {
  var archList=g('archives').innerHTML.toLowerCase().replace(/\n|<li>|<\/li>|\t/g, "");
  archList=archList.split("</a>");
  archList.reverse();
  archList.shift();
  var years=new Array(archList.length);
  for (i=0; i<archList.length; i++) {
    for (k=0; k<years.length; k++) {
      if (years[k]==null) {
        years[k]=[];
        years[k].push(archList[i]);
        break;
      }
      if (archList[i].split(".")[archList[i].split(".").length-1] == years[k][0].split(".")[years[k][0].split(".").length-1]) {
        years[k].push(archList[i]);
        break;
      }
    }
  }
  var s="";
  for (i=0; i<years.length-1; i++) {
    if (years[i]==[] || years[i]==null) {break;};
    s+="<dl class='tree no-scanlines-all"+((i==0)?' no-collapse':'')+"'>";
    s+="<dt>"+years[i][0].split(".")[years[i][0].split(".").length-1]+"</dt>";
    for (k=0; k<years[i].length; k++) {
      s+="<dd>"+years[i][k]+"</a></dd>";
    }
    s+="</dl>";
  }
  g('new-archives').innerHTML=s;
  g('new-archives').style.display="block";
  g('sidebar').removeChild(g('archives'));
}

var iconL="◄";
var iconD="▼";
var iconR="►";
var iconU="▲";

function initTreeLists() {
  var defLists = getElementsByClassName('tree');
  if (window.opera != null) {
    iconR = "▶";
    iconL = "◀";
  }
  
  // List clicking behavior
  for (i=0; i<defLists.length; i++) {
    defLists[i].getElementsByTagName('dt')[0].innerHTML = "<span>" + iconR + "</span> " + defLists[i].getElementsByTagName('dt')[0].innerHTML;
    defLists[i].getElementsByTagName('dt')[0].onclick = function() {
      this.getElementsByTagName('span')[0].innerHTML = (this.getElementsByTagName('span')[0].innerHTML == iconR) ? iconD : iconR;
      var temp = this.parentNode.getElementsByTagName('dd');
      var ddVisible = (this.getElementsByTagName('span')[0].innerHTML == iconR);
      for (k=0; k<temp.length; k++) {
        if (temp[k].parentNode.className.match("tree") == null) {continue;} // Ignore <DL> that aren't trees.
        
        // Takes into account nested trees
        temp[k].style.display = (ddVisible || temp[k].parentNode.getElementsByTagName('span')[0].innerHTML == iconR) ? 'none' : 'block';
      }
    };
  }
  
  // Hide <dd> initially
  for (i=0; i<defLists.length; i++) {
    var temp = defLists[i].getElementsByTagName('dd');
    for (k=0; k<temp.length; k++) {
      // Don't collapse these lists
      if (defLists[i].className.match("no-collapse") == null) {
        temp[k].style.display = 'none';
      }
      else if (temp[k].parentNode.className.match("tree") != null) {
        defLists[i].getElementsByTagName('dt')[0].getElementsByTagName('span')[0].innerHTML = iconD;
      }
    }
  }
  
  // Check for no-collapse-all
  for (i=0; i<defLists.length; i++) {
    if (defLists[i].className.match("no-collapse-all") != null) {
      var tempDT = defLists[i].getElementsByTagName("dt");
      var tempDD = defLists[i].getElementsByTagName("dd");
      for (k=0; k<tempDT.length; k++) {
        tempDT[k].getElementsByTagName("span")[0].innerHTML = iconD;
      }
      for (k=0; k<tempDD.length; k++) {
        tempDD[k].style.display = "block";
      }
    }
  }
  
  // Makes sure nested <DL> that aren't trees are visible
  var DLs=document.getElementsByTagName('dl');
  for (i=0; i<DLs.length; i++) {
    if (DLs[i].className.match("tree")==null) {
      var tempDD=DLs[i].getElementsByTagName('dd');
      for (k=0; k<tempDD.length; k++) {
        tempDD[k].style.display='';
      }
    }
  }
}