function setupRollovers() {
  if (!document.getElementsByTagName || !document.getElementById || !document.getElementById('nav'))
    return;
  var nav_images = document.getElementById('nav').getElementsByTagName('img');
  for (var i = 0; i < nav_images.length; i++) {
    var link = nav_images[i]; 
    if (link.className && (' ' + link.className + ' ').indexOf(' rollover ') != -1) {
        link.onmouseover = mouseover;
        link.onmouseout = mouseout;
    }
  }
}

function find_target(e)
{
  var target; 

  if (window.event && window.event.srcElement) 
    target = window.event.srcElement;
  else if (e && e.target)
    target = e.target;
  if (!target)
    return null;

  while (target != document.body &&
      target.nodeName.toLowerCase() != 'a')
    target = target.parentNode;

  if (target.nodeName.toLowerCase() != 'a')
    return null;

  return target;
}

function mouseover(e) {
  var target = find_target(e);
  if (!target) return;

  // the only child node of the a tag in target will be an img tag
  var img_tag = target.childNodes[0];

  // Take the "src", which names an image called "something.ext",
  // Make it point to "something_over.ext"
  // This is done with a regular expression
  img_tag.src = img_tag.src.replace(/(\.[^.]+)$/, '_over$1');
}

function mouseout(e) {
  var target = find_target(e);
  if (!target) return;

  // the only child node of the A-tag in |target| will be an IMG-tag
  var img_tag = target.childNodes[0];

  // Take the "src", which names an image as "something_over.ext",
  // Make it point to "something.ext"
  // This is done with a regular expression
  img_tag.src = img_tag.src.replace(/_over(\.[^.]+)$/, '$1');
}

/* 
  Start rollover script when DOM ready rather than when page loads
  (don't wait for image SRCs to load before adding handlers)
  http://dean.edwards.name/weblog/2006/06/again/
*/

 function init() {
     // quit if this function has already been called
     if (arguments.callee.done) return;

     // flag this function so we don't do the same thing twice
     arguments.callee.done = true;

     // create the "page loaded" message
     setupRollovers();
     setupColumns("or_column_wrapper");
     setupColumns("wa_column_wrapper");
 };

 /* for Mozilla */
 if (document.addEventListener) {
     document.addEventListener("DOMContentLoaded", init, false);
 }

// for Internet Explorer (using conditional comments)
/*@cc_on @*/
/*@if (@_win32)
document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
var script = document.getElementById("__ie_onload");
script.onreadystatechange = function() {
	if (this.readyState == "complete") {
		init(); // call the onload handler
	}
};
/*@end @*/

if (/WebKit/i.test(navigator.userAgent)) { // sniff
	var _timer = setInterval(function() {
		if (/loaded|complete/.test(document.readyState)) {
			clearInterval(_timer);
			init(); // call the onload handler
		}
	}, 10);
}

/* for other browsers */
window.onload = init;
