function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

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";
      else if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "top")
         anchor.target = "_top";
			else if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "back")
         anchor.onclick = function() { history.back(-1); return false; };
   }
}

// define onload events
addLoadEvent(externalLinks);


// align navbar image & footer to bottom of page (IE6 friendly)
function resizeNav()
{
  if ( ! ($("#nav").hasClass("noresize")))
  {
    page_h = $("#page").height();
    main_h = $("#main").height()+95; // padding-top: 25px; padding-bottom: 70px
    nav_h = $("#nav").height();
    ftr_h = $("#footer").height()+6; // border-top: 1px; padding-top: 5px

    page_min_h = (nav_h-ftr_h);
    col_main_h = (main_h+ftr_h);

    if (col_main_h < page_min_h) {
      $("#nav").height(page_min_h); $("#main").height(page_min_h-96);
    }
//    else {
//      $("#nav").height(page_h-ftr_h);
//    }
    }
//  $("#nav .image").attr("style", "position: absolute; bottom: 0");
}

