//*****************************************************************************
// FUNCTION REFRESH_LOOKUPS
//*****************************************************************************
  function refreshLookups() {
    //refreshGroups();
    refreshrecruitedBy();
  }
// END FUNCTION REFRESH_LOOKUPS
//*****************************************************************************


//*****************************************************************************
// FUNCTION SORT_RECORDS
//*****************************************************************************
  function sort_records(sort_order) {
    document.getElementById('data_sort_order').value = sort_order;  
    document.forms[0].submit();
  }
// END FUNCTION SORT_RECORDS
//*****************************************************************************


//*****************************************************************************
// FUNCTION EDIT_MISSION
//*****************************************************************************

function edit_mission(entity_id) {
  document.location.href = 'index.php?action=edit_mission&entity_id='
                           + entity_id;
}
//
// END FUNCTION EDIT_MISSION
//*****************************************************************************


//*****************************************************************************
// FUNCTION CREATE_MISSION
//*****************************************************************************

function create_mission() {
  document.location.href = 'index.php?action=create_mission';
}
//
// END FUNCTION CREATE_MISSION
//*****************************************************************************


//*****************************************************************************
// FUNCTION UPDATE_MISSION
//*****************************************************************************

function update_mission() {
  document.getElementById('data_action').value = "update_mission";
  document.forms[0].submit();
}
// 
// END FUNCTION UPDATE_MISSION
//*****************************************************************************


//*****************************************************************************
// FUNCTION VIEW_MISSION
//*****************************************************************************

function view_mission(entity_id) {
  document.location.href = 'index.php?action=view_mission&entity_id=' 
                              + entity_id; 
}
//
// END FUNCTION VIEW_MISSION
//*****************************************************************************


//*****************************************************************************
// FUNCTION LIST_MISSIONS
//*****************************************************************************

function list_missions() {
  document.location.href = 'index.php?action=list_missions';
}
//
// END FUNCTION LIST_MISSIONS
//*****************************************************************************


//*****************************************************************************
// FUNCTION DELETE_MISSION
//*****************************************************************************
 
function delete_mission(entity_id) {
  document.location.href = 'index.php?action=delete_mission&entity_id=' + entity_id;                                 
}
//
// END FUNCTION DELETE_MISSION
//*****************************************************************************


//*****************************************************************************
// FUNCTION UNDELETE_MISSION
//*****************************************************************************
                              
function undelete_mission(entity_id) {
  document.location.href = 'index.php?action=undelete_mission&entity_id=' + entity_id;
}
//
// END FUNCTION UNDELETE_MISSION
//*****************************************************************************


//*****************************************************************************
// FUNCTION SHOWHIDEBADDVIPS
//*****************************************************************************

function showHideBaddvips(p) {
  var show_baddvips = document.getElementById('data_mission_0_mission_pilot_' + p + '_show_baddvips'); 
  var tbody = document.getElementById('baddvips_' + p);


  if (show_baddvips.value == 'N') {
    show_baddvips.value = 'Y';
    tbody.style.display = 'table-row-group';
    var height = document.getElementById('myDiv').scrollHeight + 20;
    document.getElementById('myDiv').style.height = height + 'px';
    wholeTile();
  }
  else {
    show_baddvips.value = 'N';
    tbody.style.display = 'none';
    var scrollHeight = document.getElementById('myDiv').scrollHeight;
    scrollHeight = scrollHeight - 50;
    document.getElementById('myDiv').style.height = scrollHeight + 'px';
    wholeTile();
  }

}
// END FUNCTION SHOWHIDEBADDVIPS
//*****************************************************************************


//*****************************************************************************
// FUNCTION CHANGESHIPRATING
//*****************************************************************************
  
function changeShipRating(p) {

  var ship_menu = document.getElementById('data_mission_0_mission_pilot_' + p + '_ship_rating_id');
  var ship_menu_ship_id = document.getElementById('data_mission_0_mission_pilot_' + p + '_ship_id');

  var index = ship_menu.selectedIndex;
  ship_menu_ship_id.value = document.getElementById('ship_id_' + index).value;
 
} 
// END FUNCTION SHOWHIDEBADDVIPS
//*****************************************************************************


//*****************************************************************************
// FUNCTION CHANGELOCATION
//*****************************************************************************

function changeLocation(type) {
 
  // type = o (origin) or d (destination)
  var menu;
  var text;

  if (type == "o") {
    menu = document.getElementById('data_mission_0_origin_id');
    text = document.getElementById('data_mission_0_origin_text');
  }
  else {
    menu = document.getElementById('data_mission_0_destination_id');
    text = document.getElementById('data_mission_0_destination_text');    
  }
  
  index = menu.selectedIndex;

  if (index == 0) {
    //text.style.display = '';
    text.value = "";
  }
  else {
    //text.style.display = 'hidden';
    text.value = menu.options[index].text;
  }

}
// END FUNCTION CHANGELOCATION
//*****************************************************************************


//*****************************************************************************
// FUNCTION SHOWJOBDESCRIPTION
//*****************************************************************************
  
function showJobDescription(j) {
  document.getElementById('job_description_' + j).style.display = '';
}

// END FUNCTION SHOWJOBDESCRIPTION
//*****************************************************************************


//*****************************************************************************
// FUNCTION HIDEJOBDESCRIPTION
//*****************************************************************************
  
function hideJobDescription(j) {                 
  document.getElementById('job_description_' + j).style.display = 'none';
}   

// END FUNCTION HIDEJOBDESCRIPTION
//*****************************************************************************
