/*
Blogazine Nav Bar
Copyright 2010 Robert J Whitney
Free use under the MIT License
*/

(function(){

window.BlogazineBar = {

  styling: 
    "#zineNav {background: #000; color: #fff; padding: 8px 20px 26px;}" +
    "#zineNav a {color: #666; font-size: 14px; text-decoration: none;}" +
    "#zineNav a:hover {text-decoration: underline;}" +
    "#zineNav #prev {height: 0;}" +
    "#zineNav #title { color: #444;  font-size: 14px; height: 0; text-align: center; width: 100%;}" +
    "#zineNav #next {float:right; height: 0;}",

  blog_title: "My Blogazine"

};

//no need to configure below here

if ( document.addEventListener ) {
  document.addEventListener("DOMContentLoaded", loaded, false);
} else if ( window.attachEvent ) {
  window.attachEvent("onload", loaded);
}

function loaded(){
  //append styles
  if ( BlogazineBar.styling ) {
    var style = document.createElement("style");

    style.type = "text/css";

    try {
      style.appendChild( document.createTextNode( BlogazineBar.styling ) );
    } catch (e) {
      if ( style.styleSheet ) {
        style.styleSheet.cssText = BlogazineBar.styling;
      }
    }
    var head = document.getElementsByTagName("head")[0];
    if( head == null ) {
      document.body.appendChild( style );
    } else {
      head.appendChild( style );
    }
  } 
  
  //build bar
  var linkElements = document.getElementsByTagName("link");
  var i = 0;
  for (i = 0; i < linkElements.length; i++) {
    if (linkElements[i].hasAttribute("rel") && linkElements[i].rel == 'next') {
      var nextHref = linkElements[i].getAttribute("href");
      var nextTitle = linkElements[i].getAttribute("title");
    }
    else if (linkElements[i].hasAttribute("rel") && linkElements[i].rel == 'prev') {
      var prevHref = linkElements[i].getAttribute("href");
      var prevTitle = linkElements[i].getAttribute("title");
    }
  }
  var newdiv = document.createElement('div');
  var divIdName = 'zineNav';
  newdiv.setAttribute('id',divIdName);
  newdiv.innerHTML = 
    "<div id='prev'>" +
      "<a href='" + prevHref + "'>&#8592;&nbsp;" + prevTitle + "</a>" +
    "</div>" +
    "<div id='title'>" +
      BlogazineBar.blog_title +
    "</div>" +
    "<div id='next'>" +
      "<a href='" + nextHref + "'>" + nextTitle + "&nbsp;&#8594;</a>" +
    "</div>";
  document.body.insertBefore(newdiv, document.body.firstChild);
  
}
})();
@@ -791,26 +791,8 @@
 ()%7B%0A
-  //append styles%0A
   if
@@ -815,24 +815,24 @@
 styling ) %7B%0A
+
     var styl
@@ -1291,25 +1291,9 @@
  %7D %0A
-  %0A  //build bar
 %0A
+
   va
@@ -1834,142 +1834,330 @@
 %7D%0A  
-var newdiv = document.createElement('div');%0A  var divIdName = 'zineNav';%0A  newdiv.setAttribute('id',divIdName);%0A  newdiv.innerHTML = %0A
+%0A  function create(htmlStr) %7B%0A      var frag = document.createDocumentFragment(),%0A          temp = document.createElement('div');%0A      temp.innerHTML = htmlStr;%0A      while (temp.firstChild) %7B%0A          frag.appendChild(temp.firstChild);%0A      %7D%0A      return frag;%0A  %7D%0A  %0A  var bar = create(%0A    %22%3Cdiv id='zineNav'%3E%22 +%0A  
     
@@ -2172,24 +2172,26 @@
 ='prev'%3E%22 +%0A
+  
       %22%3Ca hr
@@ -2246,32 +2246,34 @@
  + %22%3C/a%3E%22 +%0A    
+  
 %22%3C/div%3E%22 +%0A    %22
@@ -2259,32 +2259,34 @@
      %22%3C/div%3E%22 +%0A
+  
     %22%3Cdiv id='ti
@@ -2300,16 +2300,18 @@
 +%0A      
+  
 Blogazin
@@ -2328,24 +2328,26 @@
 title +%0A    
+  
 %22%3C/div%3E%22 +%0A 
@@ -2341,24 +2341,26 @@
  %22%3C/div%3E%22 +%0A
+  
     %22%3Cdiv id
@@ -2373,24 +2373,26 @@
 '%3E%22 +%0A      
+  
 %22%3Ca href='%22 
@@ -2449,24 +2449,26 @@
 %22 +%0A    
+  
 %22%3C/div%3E%22
 ;%0A  docu
@@ -2459,17 +2459,39 @@
 %22%3C/div%3E%22
-;
+ +%0A    %22%3C/div%3E%22%0A  );%0A  
 %0A  docum
@@ -2516,14 +2516,11 @@
 ore(
-newdiv
+bar
 , do
@@ -2531,26 +2531,29 @@
 nt.body.
-firstChild
+childNodes%5B0%5D
 );%0A  %0A%7D%0A

use fragment