// scripts for conferences

/*
_available
_used
use_
unuse_
*/

function leftListSelected(id) {
	document.getElementById('use_' + id ).disabled = false;
}

function rightListSelected(id) {
	document.getElementById('unuse_' + id ).disabled = false;
}

function _moveOption( from, to, btn ) {
	
	from_len = from.options.length;
	
	for( i = from_len - 1; i >= 0; i-- ) {
		if ( false == from.options[i].selected ) continue;
		var opt = document.createElement('option');
		opt.text = from.options[i].text;
		opt.value = from.options[i].value;
		to.add( opt, null ); 
		from.remove(i);
		from_len--;
	}
	
	btn.disabled = true;
}

function useTo(id) {
	from   = document.getElementById( id + '_available' );
	to = document.getElementById( id + '_used' );
	btn  = document.getElementById( 'use_' +  id);
	_moveOption( from, to, btn );
}

function unuseTo(id) {
	from = document.getElementById( id + '_used' );
	to   = document.getElementById( id + '_available' );
	btn  = document.getElementById( 'unuse_' +  id);
	_moveOption( from, to, btn );
}

function setRightListSelected() {
	m   = document.getElementById( 'moderator_used' );
	s   = document.getElementById( 'speaker_used' );
	for( i = 0; i < m.length; i++ ) m.options[i].selected = true;
	for( i = 0; i < s.length; i++ ) s.options[i].selected = true;
}