
function initMouseOverImages() {
  var swaps = $A(document.getElementsByClassName('swap'));
  swaps.each(function(swap) {
    swap.imgsrc = swap.src;
    var dot = swap.src.lastIndexOf('.');
    swap.imgsrc_on = swap.src.substr(0, dot) + '_on' + swap.src.substr(dot, 4);
    new Image().src = swap.imgsrc_on
    swap.onmouseover = function() { this.src = this.imgsrc_on; };
    swap.onmouseout = function() { this.src = this.imgsrc; };
  });
}

function initOpenNewWindow() {
  var popups = $A(document.getElementsByTagName('a'));
  popups.each(function(popup) {
    if (popup.getAttribute('rel')) {
      var attr = popup.getAttribute('rel');
      if (attr.indexOf('popup') == 0) {
        popup.onclick = function() {
          var option = this.rel.replace(/^[^\?]+\??/,'').replace(/&/g, ',');
          var target = this.rel.replace(/\?.*$/, '').replace(/^popup_/, '');
          window.open(this.href, target, option).focus();
          return false;
        }
      }
    }
  });
}

function windowLinks() {
  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") == "window")
      anchor.target = "_blank";
  }
}
window.onload = windowLinks;

