var found=false;
function cb_removeEmpty(sel){   //entfernt die leere options
  
  if (found){return true;}
  
  for(var i=0;i<sel.options.length;i++){
    
    if (sel.options[i].value==''){
        sel.options[i]=null;
        
        found=true;
    }
  }
}
function cb_move(srcid,destid){
  src=document.getElementById(srcid);
	dest=document.getElementById(destid);
    cb_removeEmpty(src);
    cb_removeEmpty(dest);
	if(src.selectedIndex!=-1){
    dest.options[dest.length]=new Option(src.options[src.selectedIndex].text,src.options[src.selectedIndex].value,false,false);
		src.options[src.selectedIndex]=null;
	}
}
function cb_delElem(srcid)
{
    src=document.getElementById(srcid);
 	cb_removeEmpty(src);
    src.options[src.selectedIndex]=null;
}
function cb_addElem(destid,txt,val)
{

	dest=document.getElementById(destid);
    cb_removeEmpty(dest);
    dest.options[dest.length]=new Option(txt,val,false,false);
}

function cb_moveAll(srcid,destid){
    src=document.getElementById(srcid);
	dest=document.getElementById(destid);
    cb_removeEmpty(src);
    cb_removeEmpty(dest);
	while(src.length>0){
	  dest.options[dest.length]=new Option(src.options[0].text,src.options[0].value,false,false);
		src.options[0]=null;
	}
}

function cb_modifyform(){
  h=document.getElementById("cb_desth");
	h.value="";
	d=document.getElementById("choosbox_dest");
    cb_removeEmpty(d);
	i=0;
	for(i=0;i<d.length;i++){
	  h.value+=d.options[i].value+",";
	}
	return i;
}

function cb_modifyform2(){
  h=document.getElementById("cb_desth");
	h.value="";
	d=document.getElementById("choosbox_dest");
    cb_removeEmpty(d);
	i=0;
	for(i=0;i<d.length;i++){
	  h.value+=d.options[i].value+"\n";
	}
	return i;
}

