/*
     $Revision$
     $Id$
*/

function sle_submit()
{
  document.activeElement.blur(); // trigger laatste onChanges
  if (!validateForm("u2"))
    return false;

  if ($("#sel_items").length && !$("#roomArray").length)
  {
      FcltMgr.alert(L("lcl_sle_select_ruimte"));
      return;
  }

  window.document.forms.u2.submit();
  return true;
}

function sle_cancel()
{
  FcltMgr.closeDetail(window, { cancel: true } );
}

function AddItem()
{
  var room_key = $("#ruimtekey").val();
  if (room_key <= 0)
  {
    FcltMgr.alert(L("lcl_sle_no_ruimte"));
    return;
  }

  // Indien al in de lijst toegevoegd, dan return
  if ($("input#roomArray[value="+room_key+"]").length)
    return false;

  var room_name = $("#locatie").val() + " - "
                + $("#gebouw").val() + " - "
                + $("#verdieping").val() + " - "
                + $("#alg_ruimte_nr").val();

  CreateRow(room_key, room_name);
}

function CreateRow(room_key, room_name)
{
  // Create drop button
  // tr class sleroom om in sleClose gemakkelijk op te ruimen
  var tr = "<tr class='sleroom'><td class='result' align='center'>"
         +         "<img src=../Pictures/order_cancel.gif OnClick=CancelRoom(this) style='cursor:pointer'>"
         +      "</td>";

  tr += "<td class'result' align='left'>"
     +      "<input type='hidden' name='roomArray' id='roomArray' value='" + room_key + "'>" + room_name + "</td>";
  tr += "</tr>";
  $("#sel_items").append(tr);
}
function CancelRoom(cell)
{
  $(cell).closest("tr").remove();
  FcltMgr.resized(window);
}

