function aimLinks() {
  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';
    }
    else if (anchor.getAttribute("href") && anchor.getAttribute("href").indexOf('#') != -1 && (!anchor.pathname || anchor.pathname == '/')) {
      anchor.href = location.pathname + anchor.getAttribute("href").substr(anchor.getAttribute("href").indexOf('#'));
    }
  }
}

function login() {
  if (document.getElementById('userlame').value == '') { return alert("userlame must not be blank."); }
  if (document.getElementById('assword').value == '') { return alert("password must not be blank."); }
  document.getElementById('assword').value = calcMD5(document.getElementById('assword').value);
  document.forms[0].submit();
}

function help(type) {
  switch(type) {
    case "format":
      window.open('/help/format.html', 'helpbox', 'width=640,height=300,scrollbars=1,resize=0');
      break;
    default:
      break;
  }
}

function rewriteHistory(page) {
  location.replace(page);
}

window.onload = startPage;
