// Maximum number of employees displayed per row
var MAX_EMP_PER_ROW = 2;

/**
 * Returns the (x,y) coordinates to which the pop-up to be moved
 */
function getRollOverPopupPosition(empNum)
{
  
  var row = parseInt(empNum / MAX_EMP_PER_ROW);
  var column = parseInt(empNum % MAX_EMP_PER_ROW);

  var empInfoCoordinates = findDiagonalCoordinates('empInfo'+empNum);
  var empNameCoordinates =  findDiagonalCoordinates('empName'+empNum);

  // for column 0, x-position is to the right of the employee info
  // for column 1, x-position is to the left of the employee info
  var popupX =  (column == 0)? empInfoCoordinates.x1 : (empInfoCoordinates.x2 - getRollOverPopupWidth());

  // for rows 0 and 1, y-position is 45px from the name of the employee
  // for rows 1 onwards, y-position is aligned to the top of the employee name
  var popupY = (row <= 1) ? (empNameCoordinates.y1 + 45) : (empNameCoordinates.y1 - getRollOverPopupHeight());

  return [popupX, popupY];
}
