var data = "";

$j().ready(function() {  
	// -- Link selectie | Nieuwsbrief verzonden
	$j('#handmatiginvoer').click(function() {
		set_sentmethod('handmatiginvoer');
		return false;
	});
	$j('#alleleden').click(function() {
		set_sentmethod('alleleden');
		return false;
	});
	$j('#groep').click(function() {
		set_sentmethod('groep');
		return false;
	});
	$j('#handmatigselectie').click(function() {
		set_sentmethod('handmatigselectie');
		return false;
	});
	
	assign_button_events();
}); 

function assign_button_events()
{
	$j('#add').click(function() {  
		return !$j('#select1 option:selected').remove().appendTo('#select2');  
	});  
	$j('#remove').click(function() {  
		return !$j('#select2 option:selected').remove().appendTo('#select1');  
	});
	$j('#addall').click(function() {  
		$j('#select1 option').each(function(i) {  
			$j(this).remove().appendTo('#select2');
		});  
	}); 
	$j('#removeall').click(function() {  
		$j('#select2 option').each(function(i) {  
			$j(this).remove().appendTo('#select1');
		});  
	}); 
	$j('form').submit(function() {  
		$j('#select2 option').each(function(i) {  
			$j(this).attr("selected", "selected");  
		});  
	});
}

function set_sentmethod(which)
{
	jQuery.get('nb/' + which + '.php', '', function(data) {
		document.data = data;
		$j('#sentmethod').fadeOut("slow", function(){
			document.getElementById('sentmethod').innerHTML = document.data;
			$j('#sentmethod').fadeIn("slow");
			assign_button_events();
		});
	});

}