//opens links in a new window when 'rel="external"' is set
//all glory to http://www.sitepoint.com/article/standards-compliant-world/3/
function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
	    var anchor = anchors[i];
	    if (anchor.getAttribute("href") &&
		    anchor.getAttribute("rel") == "external")
		anchor.target = "_blank";
    }
}
window.onload = externalLinks;

//Show the "flair" span with links to bookmarking services like Digg, Newsvine, etc.
function showFlair(postId) {
	var flair = document.getElementById("flair" + postId);
	if ((!(flair.style.display)) || (flair.style.display == "none")) {
		flair.style.display = "inline";
	} else {
		flair.style.display = "none";
	}
}

// toolbox stuff

// alias document.getElementById() to $(), a commonly seen technique
// function from http://www.prototypejs.org
function $(element) {
  if (arguments.length > 1) {
    for (var i = 0, elements = [], length = arguments.length; i < length; i++)
      elements.push($(arguments[i]));
    return elements;
  }
  if (Object.isString(element))
    element = document.getElementById(element);
  return Element.extend(element);
}