function showL(id) {// display layer
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.display = "block";
}

function hideL(id) { // hide layer
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.display = "none";
}

function getElemRefs(id) { // get element ID
	var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? document.layers[id]: null;
	if (el) el.css = (el.style)? el.style: el;
	return el;
}

function replaceImg(id, URI){
	theImg=getElemRefs(id);
	theImg.setAttribute("src",URI);
}

//create mailnames by a function to confuse spambots
function mail(m_domain, m_id, m_subject) {
	location.href = (m_subject==null) ? "mailto:" + m_id + "@" + m_domain : "mailto:" + m_id + "@" + m_domain + "?subject=" + m_subject;
}

// Correctly open links in new window through rel="external"

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";
anchor.title = (anchor.title != "") ? anchor.title+" (opens in a new window)" : "opens in a new window";
anchor.className = (anchor.className != '') ? anchor.className+' external' : 'external';
}
else if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "dlfile") {
anchor.target = "_blank";
anchor.title = (anchor.title != "") ? anchor.title+" (Please right-click and save target as)" : "Please right-click and save target as";
anchor.className = (anchor.className != '') ? anchor.className+' dlfile' : 'dlfile';
}
else if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "mail") {
anchor.title = (anchor.title != "") ? anchor.title+" (send email)" : "send email";
anchor.className = (anchor.className != '') ? anchor.className+' mail' : 'mail';
}

}
}

window.onload=externalLinks;
