/*********************************************************
 *  JavaScript: Utilities
 *    General scripts used throughout the site
 *
 *  JDMLabs
 *  Copyright 2001-2009 Jason Moss. All rights reserved.
 *
 *  This site has been hand-developed by Jason Moss.
 *   -  www.jdmlabs.com           |  web
 *   -  jason.moss&#64;gmail.com  |  mail
 *   -  +1-403-850-1496           |  voice
*********************************************************/

document.createElement('article');
document.createElement('aside');
document.createElement('footer');
document.createElement('header');
document.createElement('nav');
document.createElement('section');

function addLoadEvent(func) {
  if(typeof window.onload=="function") {
    var oldFunc = window.onload;
    window.onload = function() { oldFunc(); func(); }
  }
  else { window.onload = func; }
}
function addEvent(o, type, fn) { o.addEventListener(type, fn, false); }
function removeEvent(o, type, fn) { o.removeEventListener(type, fn, false); }

function AnchorsInputs() {
  if (!document.getElementsByTagName && !document.getAttribute && !document.setAttribute) { return; }
  var anchors = document.getElementsByTagName("a");
  for (var i=0;i<anchors.length;i++) {
    var a = anchors[i];
    a.onfocus = function() { this.blur(); }
    if (a.getAttribute('href') && a.getAttribute('rel')=='external') { a.setAttribute('target','_blank'); }
  }
}

function menuAdmin() {
  el = document.getElementById("admin_menu");
  el.style.display = (el.style.display == "block") ? "none" : "block";
}

function menuUser() {
  el = document.getElementById("user_menu");
  el.style.display = (el.style.display == "block") ? "none" : "block";
}

addLoadEvent(AnchorsInputs);