
function changeheight(el) {
	if(el.style.height != '240px')	el.style.height = '240px'
	else 				el.style.height = '140px'
}


function blurAnchors(){
  if(document.getElementsByTagName){
    var a = document.getElementsByTagName("a")
    for(var i = 0; i < a.length; i++){
      a[i].onmouseup = function(){this.blur()}
    }
  }
}

function fix() {
	if(!document.getElementById("IVdirectory")) return
	var w = ''
	var t = document.getElementById("IVdirectory").firstChild.childNodes

	for(i=1; i<t.length; i++) {
		w = t[i].childNodes[1].firstChild.nodeValue
		if(w.length >1) {
			a = document.createElement("a")
			a.setAttribute("href", "mailto:"+w+"@duke.edu")
			a.appendChild(document.createTextNode(w))

			t[i].childNodes[1].replaceChild(a, t[i].childNodes[1].firstChild)
		}
	}
}

function fix2() {
	if(!document.getElementById("IValumnidirectory")) return
	var w = ''
	var t = document.getElementById("IValumnidirectory").firstChild.childNodes

	for(i=1; i<t.length; i++) {
		w = t[i].childNodes[1].firstChild.nodeValue.replace(/\[at\]/gi,'@').replace(/\[dot\]/gi,'.')
		if(w.length >1) {
			a = document.createElement("a")
			a.setAttribute("href", "mailto:"+w)
			a.appendChild(document.createTextNode(w))

			t[i].childNodes[1].replaceChild(a, t[i].childNodes[1].firstChild)
		}
	}
}
	
function emailMessage() {
	alert('Your email address is unlikely to be harvested by spam bots.\nEmail addresses on this page are generated dynamically\nafter the page is loaded, keeping them as safe as possible.')
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}
 
addLoadEvent(fix);
addLoadEvent(fix2);
addLoadEvent(blurAnchors);

