// puts together an email address mailto link
// helps avoid having spambots collect your email address

function contact(login, domain, tld) {
  var e = login + "@" + domain + '.' + tld;
  var a = '<a href="mailto:' + e + '">' + e + '</a>'
document.write(a)
  //document.write('<a href="mailto:' + e + '">' + e + '</a>');
}


// makes the class names of li tags change when the mouse
// passes over them (only necessary for IE) which makes the
// dropdown menus defined in CSS work for IE too, courtesy
// of an article in A List Apart called "Suckerfish Dropdowns"
// by Patrick Griffiths, http://www.alistapart.com/articles/dropdowns

function fixDropdownsForIE() {
  // checking for existence of document.all verifies that this code
  // runs only for IE 5+
  if (document.all&&document.getElementById) {
    navRoot = document.getElementById("nav");
    for (i=0; i<navRoot.childNodes.length; i++) {
      node = navRoot.childNodes[i];
      if (node.nodeName=="LI") {
	node.onmouseover=function() {

	  this.className+=" over";
	}
	node.onmouseout=function() {
	  this.className=this.className.replace(" over", "");
	}
      }
    }
  }
}


// returns the available vertical space inside the viewport
// courtesy of an article in A List Apart, called "Exploring Footers",
// by Bobby van der Sluis, http://www.alistapart.com/articles/footers/

function getWindowHeight() {
  var windowHeight = 0;
  if (typeof(window.innerHeight) == 'number') {
    windowHeight = window.innerHeight;
  }
  else {
    if (document.documentElement && document.documentElement.clientHeight) {
      windowHeight = document.documentElement.clientHeight;
    }
    else {
      if (document.body && document.body.clientHeight) {
	windowHeight = document.body.clientHeight;
      }
    }
  }
  return windowHeight;
}


// checks the page height and moves the footer to the bottom if necessary
// courtesy of an article in A List Apart, called "Exploring Footers",
// by Bobby van der Sluis, http://www.alistapart.com/articles/footers/
//
// this function needed to be customized according to the elements in the
// layout that take up vertical space, in our case the header, breadcrumbs,
// content, and footer divs
//
// in the site css file you'll also find a definition:
//
//     div#footer { position: relative; }
//
// that is necessary to make this technique look reasonable in the
// Safari browser

function setFooter() {
  if (document.getElementById) {
    var windowHeight = getWindowHeight();

    if (windowHeight > 0) {
      var headerHeight = document.getElementById('header').offsetHeight;
      var crumbHeight = document.getElementById('breadcrumbs').offsetHeight;
      var contentHeight = document.getElementById('content').offsetHeight;
      var otherHeight = headerHeight + crumbHeight + contentHeight;

      if (!document.all) {
	// when we're not in IE, the height is somehow not right,
	// and this amount will fix it in Mozilla, so hack it on
	// it seems to have something to do with the breadcrumb bar,
	// but I couldn't figure out a clean, systematic relationship
	otherHeight += 13;
      }

      var footerElement = document.getElementById('footer');
      var footerHeight  = footerElement.offsetHeight;

      if (windowHeight - (otherHeight + footerHeight) >= 0) {
	if (navigator.userAgent.indexOf("Opera") != -1) {
	  // Opera needs to do it this way to work
	  footerElement.style.position = 'absolute';
	  footerElement.style.bottom = 0;
	}
	else {
	  // IE and Mozilla/Netscape are happier with this instead
	  footerElement.style.position = 'relative';
	  footerElement.style.top =
	    (windowHeight - (otherHeight + footerHeight)) + 'px';
	}
      }
      else {
	footerElement.style.position = 'static';
      }
    }
  }
}


// loads the correct functions into the onload event handler, so that
// everything that needs to get done upon loading the window happens

window.onload = function() {
  fixDropdownsForIE();
  setFooter();
}


// some functions also need to be run again when the window is resized

window.onresize = function() {
  setFooter();
}

// puts together an email address mailto link
// helps avoid having spambots collect your email address

function writeContact(login, domain, theTitle, theText) {
  var e = login + "@" + domain;
  document.write('<a href="mailto:' + e + '" title="' + theTitle + '">' + theText + '</a>');
}

