function handle_lookup(data) {
  if (data.code == 0) {
    // Project lookup was successful
    // redirect to join-this-project.php?project_id=id
    // get project from value field, and project_id from that
    var project = data.value
    var url = "join-this-project.php?project_id=" + project.project_id;
    window.location.href = url;
  } else {
    // Handle error case
    $('#finderror').append(data.output);
    $('#findname').select();
  }
}

function handle_error(jqXHR, textStatus, errorThrown) {
  // An unknown error has occurred. Pop up a dialog box.
  alert("An unknown error occurred.");
}

function lookup_project(project_name) {
  // Clear out any previous errors
  $('#finderror').empty();
  var lookup_url = "/secure/lookup-project.php"
  var data = {name: project_name}
  $.post(lookup_url, data, handle_lookup, 'json').fail(handle_error);
}

function do_lookup_project(event) {
        event.preventDefault();
        lookup_project($('#findname').val());
}


$(document).ready( function () {
  /* datatables.net (for sortable/searchable tables) */
  $('#projects').DataTable({paging: false});
  $('#findbtn').click(do_lookup_project);
} );

@@ -1,24 +1,119 @@
+function show_lookup_error(msg) %7B%0A  $('#finderror').append(msg);%0A  $('#findname').select();%0A%7D%0A%0A
 function handle_lookup(d
@@ -326,16 +326,136 @@
 a.value%0A
+    if (project.expired) %7B%0A      show_lookup_error(%22Project %22 + project.project_name + %22 has expired.%22);%0A    %7D else %7B%0A  
     var 
@@ -522,16 +522,18 @@
 id;%0A    
+  
 window.l
@@ -552,16 +552,22 @@
  = url;%0A
+    %7D%0A
   %7D else
@@ -602,71 +602,37 @@
     
-$('#finderror').append(data.output);%0A    $('#findname').select(
+show_lookup_error(data.output
 );%0A 

Handle expired projects in join lookup