function disableLinks() {
  var links = document.getElementsByTagName("a");

  for (i = 0; i < links.length; i++) {
    var link = links[i];
    var cn = link.getAttribute("class");
    var id = link.getAttribute("id");

    /*
     * Hack for IE 6
     */
    if (!cn) cn = link.getAttribute("className");

    if (cn == "getProfile") {
      link.onclick = function() {
                                  getProfile(this.id);
                                  return false;
                                };
    }
  }
}

/*
 * Summary: Object to handle Ajax Requests
 *      Process return based on calling object constructor
 *      WARNING: This class is for testing and is not complete
 */
function cAjax() {
  if (window.XMLHttpRequest) {
    this.req = new XMLHttpRequest();
  } else {
    this.req = new ActiveXObject("Microsoft.XMLHTTP");
  }

  this.loadXMLDoc = function (url) {
    this.req.onreadystatechange = this.processReqChange;
    this.req.open("GET", url, true);
    this.req.send(null);
  }
}

var ajaxGetProfile;

function getProfile(name) {
  ajaxGetProfile = new cAjax;
  url = 'profiles.php?name=' + name + '&ajax=yes';
  ajaxGetProfile.processReqChange = displayResponse;
  ajaxGetProfile.loadXMLDoc(url);
  return false;
}

function displayResponse() {
  if (ajaxGetProfile.req.readyState == 4) {
    var response = ajaxGetProfile.req.responseText;
    document.getElementById('profile').innerHTML = response;
    disableLinks();
  }
}

onload = disableLinks;
