$(document).ready(function()
{
	$('.multiselector').each(function()
	{
		var real = $(this).attr('id');
		var from = real + '_from';
		var to = real + '_to';

		var values = $(this).val().split("\t");

		for(var i = 0; i < values.length; i++ )
		{
			if( parseInt(values[i]) > 0 )
			{
				$('#' + to).append($("#" + from + " option[value='" + parseInt(values[i]) + "']"));
			}
		}
	});

	$('.multiselector_add').click(function()
	{
		var real = $(this).attr('id').replace(/_add$/, '');
		var from = real + '_from';
		var to = real + '_to';

		$('#' + to).append($("#" + from + " option:selected"));

		var value = '';
		$("#" + to + " option").each(function()
		{
			value += $(this).val() + "\t";
		});
		$('#' + real).val(value);

		return;
	});


	$('.multiselector_del').click(function()
	{
		var real = $(this).attr('id').replace(/_del$/, '');
		var from = real + '_from';
		var to = real + '_to';

		$('#' + from).append($("#" + to + " option:selected"));

		var value = '';
		$("#" + to + " option").each(function()
		{
			value += $(this).val() + "\t";
		});
		$('#' + real).val(value);

		return;
	});

});
