incorporating the temp panel into check_second(card)
function check_second(card) {
  var ok;
  if (empty(card)) {
    ok=true;
  } else {
    if (klass(card)=='temp') {
      ok=false;
    } else { // must be main
      if (last(card)) { // check for sequence
        ...
      }
    }
  }
  return ok;
}

But still no success. This time it's the move function's turn to fall over.

But now we really need to stop and think!

There are three very different possible moves.

click me for the answer

Really test yourself - try to modify the move function to incorporate all three possibilities.