function Search() {
  this.fields = new Array("photos");
}
Search.prototype.showProfile = function(id, img) {
  var profile = document.getElementById(id);
  if (profile.style.visibility == "visible") {
    return;
  }

  var bigImg = document.getElementById("big_" + img.getAttribute("id"));
  bigImg.src = bigImg.getAttribute("src");

  var x = this.getX(img);
  var y = this.getY(img);
  var browserWidth = document.body.clientWidth;
  var browserHeight = document.body.clientHeight;

  if (x + img.width + profile.clientWidth > browserWidth) {
    profile.style.left = x - 5 - profile.clientWidth;
  } else {
    profile.style.left = x + 5 + img.width;
  }

  var totalHeight = browserHeight + this.getScrollHeight();
  if (y + profile.clientHeight > totalHeight) {
    profile.style.top = totalHeight - 5 - profile.clientHeight;
  } else {
    profile.style.top = y;
  }

  profile.style.visibility = "visible";
}

/**
 * hides the profile of a user
 *
 * @param id ID of the user profile DIV object
 */
Search.prototype.hideProfile = function(id) {
  document.getElementById(id).style.visibility = "hidden";
}


/*********************
 * UTILITY FUNCTIONS *
 *********************/

/**
 * get the x-coordinate for a given node by iteratively summing the x-offset of
 * each parent object
 *
 * @param node The object for which the coordinate is retrieved
 * @return the x-coordinate for node
 */
Search.prototype.getX = function(node) {
  if (node.offsetParent) {
    for (var x = 0; node.offsetParent; node = node.offsetParent) {
      x += node.offsetLeft;
    }
    return x;
  }
  return node.x;
}

/**
 * get the y-coordinate for a given node by iteratively summing the y-offset of
 * each parent object
 *
 * @param node The object for which the coordinate is retrieved
 * @return the y-coordinate for node
 */
Search.prototype.getY = function(node) {
  if (node.offsetParent) {
    for (var y=0; node.offsetParent; node=node.offsetParent) {
      y += node.offsetTop;
    }
    return y;
  }
  return node.y;
}

/**
 * get the height for the scroll area
 *
 * @return the height for the scroll area
 */
Search.prototype.getScrollHeight = function() {
  // firefox
  if (typeof(window.pageYOffset) == "number") {
    return window.pageYOffset;
  }
  // IE
  else if (document.body &&
    (document.body.scrollLeft || document.body.scrollTop)) {
    return document.body.scrollTop;
  }
}