// function to initialize external links
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";
    }
}


// popup function from http://www.quirksmode.org/js/popup.html
// modified by lorenz textor to allow passing height and width

var newwindow = '';
function popitup(url, height, width) {
    var height = (height == null) ? 200 : height;
    var width = (width == null) ? 300 : width;
    newwindow=window.open(url,'name','height='+height+',width='+width+',scrollbars=yes');
    if (window.focus) {newwindow.focus()}
    return false;
}


// div switcher for executive team
function showResume(showMember) {
    if(!document.getElementsByTagName) return;
    var divs = document.getElementsByTagName("div");
    for(var i=0;i<divs.length;i++) {
        var div = divs[i];
        var id = div.id;
        if (id.substring(0,5) == 'team-') {
            var member = id.substring(5);
            if (member == showMember) {
                div.style.display = 'block';
            } else {
                div.style.display = 'none';
            }
        }
    }
    return false;
}


// addLoadEvent()
// Adds event to window.onload without overwriting currently assigned onload functions.
// Function found at Simon Willison's weblog - http://simon.incutio.com/
function addLoadEvent(func)
{	
   var oldonload = window.onload;
   if (typeof window.onload != 'function'){
      window.onload = func;
   } else {
      window.onload = function(){
         oldonload();
         func();
      }
   }
}

function addUnLoadEvent(func)
{	
   var oldonunload = window.onunload;
   if (typeof window.onunload != 'function'){
      window.onunload = func;
   } else {
      window.onunload = function(){
         oldonunload();
         func();
      }
   }
}

addLoadEvent(externalLinks);

