var staff_acc_id;

function renderStaff(staff_id, staff_div) {

  staff_acc_id = staff_div.parentNode.parentNode.parentNode.id.substring(15);

  var url = '?';
  var pars = "CoMeT_function=run_module&module=ModStaff&function=render_staff&staff_id=" + staff_id;

  var myAjax = new Ajax.Request(
    url,
    {
      method: 'post',
      postBody: pars,
      encoding: 'ISO-8859-1',
      onComplete: renderStaffResponse
    });
}

function renderStaffResponse(resp) {

  var top = getAbsoluteTop($('dynamicforever_' + staff_acc_id));

  $('staff_item').style.top = top + 50 + "px";
  $('staff_item').innerHTML = resp.responseText;
  $('staff_item').setStyle({ display: 'block' });
}

function staffHeader(staff_id) {

  var url = '?';
  var pars = "CoMeT_function=run_module&module=ModStaff&function=render_staff&staff_id=" + staff_id;

  var myAjax = new Ajax.Request(
    url,
    {
      method: 'post',
      postBody: pars,
      encoding: 'ISO-8859-1',
      onComplete: staffHeaderResponse
    });
}

function staffHeaderResponse(resp) {

  closeProject(); //make sure to close any open project item
  hideSearchResults(); //close search results list

  var top = getAbsoluteTop($('vertical_container'));

  $('staff_item').style.top = top -5 + "px";
  $('staff_item').innerHTML = resp.responseText;
  $('staff_item').setStyle({ display: 'block' });
}



function staffProject(staff_id) {
  var url = '?';
  var pars = "CoMeT_function=run_module&module=ModStaff&function=render_staff&staff_id=" + staff_id;

  var myAjax = new Ajax.Request(
    url,
    {
      method: 'post',
      postBody: pars,
      encoding: 'ISO-8859-1',
      onComplete: staffProjectResponse
    });
}

function staffProjectResponse(resp) {

  var top = getAbsoluteTop($('project_details'));

  $('staff_item').style.top = top +15 + "px";
  $('staff_item').innerHTML = resp.responseText;
  $('staff_item').setStyle({ display: 'block' });
}

function closeStaffItem() {
  $('staff_item').setStyle({ display: 'none' });
}











function ___staffSearch(staff_id) {

  var url = '?';
  var pars = "CoMeT_function=run_module&module=ModStaff&function=render_staff&staff_id=" + staff_id;

  var myAjax = new Ajax.Request(
    url,
    {
      method: 'post',
      postBody: pars,
      encoding: 'ISO-8859-1',
      onComplete: staffSearchResponse
    });

}

function ___staffSearchResponse(resp) {

  closeProject(); //make sure to close any open project item

  var top = getAbsoluteTop($('search_result_personal'));

  $('staff_item').style.top = top + "px";
  $('staff_item').innerHTML = resp.responseText;
  $('staff_item').setStyle({ display: 'block' });
}