function confirmDelete()
{
  return confirm( "Are you sure you wish to delete this item?" );
}

function selectItem(boxName, id, select)
{
  box = document.getElementById( boxName );
  for ( var i = 0; i < box.options.length; i++ )
  {
    if ( box.options[i].value == id )
    {
      box.options[i].selected = select;
      return true;
    }
  }
  return false;
}

function populate_ul( targetId )
{
  var root = document.getElementById( targetId + "_ul" );
  box = document.getElementById( targetId );
  while ( root.hasChildNodes() )
  {
    root.removeChild( root.lastChild );
  }
  var found = false;
  for ( var i = 0; i < box.options.length; i++ )
  {
    if ( box.options[i].selected )
    {
      var element = document.createElement( "li" );
      element.innerHTML = box.options[i].text + '&nbsp;<a href="#" onclick="selectItem(\'' + targetId + '\', \'' + box.options[i].value + '\', false);populate_ul(\''+targetId+'\')">Delete</a>';
      root.appendChild( element );
      found = true;
    }
  }
  if ( !found )
  {
    root.innerHTML = "None selected.";
  }
}

function selectFromSelect(targetId, srcId)
{
  src = document.getElementById( srcId );
  idx = src.selectedIndex;
  if ( idx != -1 )
  {
    if ( selectItem( targetId, src.options[idx].value, true ) )
    {
      populate_ul( targetId )
      return true;
    }
    else
    {
      return false;
    }
  }
  return false;
}

function showhide(id)
{
  box = document.getElementById(id);
  if ( box.style.display == "none" )
  {
    box.style.display = "block";
  }
  else
  {
    box.style.display = "none";
  }
}

