function add(obj)
{
}

function del(obj)
{
}

function clear(obj)
{
}

function sortlist(lb)
{  
  arrTexts = new Array();

  for(i=0; i<lb.length; i++)
  {
    arrTexts[i] = lb.options[i].text;
  }

  arrTexts.sort();

  for(i=0; i<lb.length; i++)
  {
    lb.options[i].text = arrTexts[i];
    lb.options[i].value = arrTexts[i];
  }
}

function move(from, to)
{  
  var from = document.getElementById(from);
  var to = document.getElementById(to);

  for (var i=0; i<from.options.length; i++)
  {
    var o = from.options[i];
    if (o.selected)
    {
      var index=to.options.length;
      to.options[index] = new Option( o.text, o.value);
    }
  }

  for (var i=(from.options.length-1); i>=0; i--)
  {
    var o = from.options[i];
    if (o.selected)
    {
      from.options[i] = null;
    }
  }

  sortlist(from);
  sortlist(to);
}

function select_all(obj)
{
  var list = document.getElementById(obj);
  for (var i=0; i<list.options.length; i++)
  {
    var o = list.options[i];
    o.selected = true;
  }
}

function ajax_get(url)
{
  if (window.XMLHttpRequest)
  {
    req = new XMLHttpRequest();    
  }
  else if (window.ActiveXObject)
  {
    req = new ActiveXObject("Microsoft.XMLHTTP");
  }

  req.open('GET', url, true);
  req.send(null);
}

function consultation(id)
{
  var cb = document.getElementById('checkbox' + id);

  if (cb.checked)
  {
    consultation_count ++;
    ajax_get("/index.php?consultation_add=" + id);
  }
  else
  {
    consultation_count --;
    ajax_get("/index.php?consultation_del=" + id);
  }

  var counter = document.getElementById('consultation_count');
  counter.innerHTML = consultation_count;  
}
