
function removeOptionSelected(name)
{
  var elSel = document.getElementById(name.name);
  var i;
  for (i = elSel.length - 1; i>=0; i--) {
    if (elSel.options[i].selected) {
      elSel.remove(i);
    }
  }
}

function moveUpOptionSelected(name)
{
  var elSel = document.getElementById(name.name);
  if (name.selectedIndex>0)
  {
      var up=elSel.options[name.selectedIndex].text;
      var upvalue=elSel.options[name.selectedIndex].value;
      elSel.options[name.selectedIndex].text=elSel.options[name.selectedIndex-1].text;
      elSel.options[name.selectedIndex].value=elSel.options[name.selectedIndex-1].value;
      elSel.options[name.selectedIndex-1].text=up;
      elSel.options[name.selectedIndex-1].value=upvalue;
      name.selectedIndex=name.selectedIndex-1;

  }
}

function moveDownOptionSelected(name)
{
  var elSel = document.getElementById(name.name);
  if (name.selectedIndex<name.length)
  {
      var down=elSel.options[name.selectedIndex].text;
      var downvalue=elSel.options[name.selectedIndex].value;
      elSel.options[name.selectedIndex].text=elSel.options[name.selectedIndex+1].text;
      elSel.options[name.selectedIndex].value=elSel.options[name.selectedIndex+1].value;
      elSel.options[name.selectedIndex+1].text=down;
      elSel.options[name.selectedIndex+1].value=downvalue;
      name.selectedIndex=name.selectedIndex+1;

  }
}
function getVar(name)
{
  get_string = document.location.search;         
  return_value = '';
  
  do { //This loop is made to catch all instances of any get variable.
    name_index = get_string.indexOf(name + '=');
    
    if(name_index != -1)
      {
      get_string = get_string.substr(name_index + name.length + 1, get_string.length - name_index);
      
      end_of_value = get_string.indexOf('&');
      if(end_of_value != -1)                
        value = get_string.substr(0, end_of_value);                
      else                
        value = get_string;                
        
      if(return_value == '' || value == '')
         return_value += value;
      else
         return_value += ', ' + value;
      }
    } while(name_index != -1)
    
  //Restores all the blank spaces.
  space = return_value.indexOf('+');
  while(space != -1)
      { 
      return_value = return_value.substr(0, space) + ' ' + 
      return_value.substr(space + 1, return_value.length);
  		 
      space = return_value.indexOf('+');
      }
  
  return(return_value);        
}
function addToSelect(name,value,text)
{
  if (value==getVar('id')) return false;
  var elOptNew = document.createElement('option');
  elOptNew.text = text;
  elOptNew.value = value;
  var elSel = document.getElementById(name.name);
  for (i=0;i<elSel.length;i++)
  {
    if (elSel.options[i].value==value) return false;
  }
  
  try {
    elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
  }
  catch(ex) {
    elSel.add(elOptNew); // IE only
  }
  
}


function checkname(from,name){

 var elSel = document.getElementById(from.name);
  var i;
  name.value="";
  for (i = 0; i<elSel.length ; i++) {
    if (i<elSel.length -1) name.value+=from.options[i].value+","; else name.value+=from.options[i].value;
  }

  

}
