
function ajaxResult(url)
{
	var container = $('#result-container');
	if (container.size()==0)
	{
		var container = $("<div id=\"result-container\"><div id=\"result-bg\"></div><div id=\"result-content\"></div>");
		$('body').append(container);
	}

	container.click(
		function ()
		{
			$(this).hide();
		}
	);
	$('#result-bg').css('opacity',0.5);
	$('#result-content').html('<h1>...</h1><div class=\"sheet\"></div>');
	container.show();

	var charset = 'UTF-8';
	var metas = $('head meta');
	for (i=0; i<metas.size(); i++)
	{
		var meta = metas.eq(i);
		var http_equiv = meta.attr('http-equiv');
		http_equiv = http_equiv!=undefined ? http_equiv : meta.attr('httpEquiv');
		if (http_equiv=='content-type')
		{
			charset = meta.attr('content').replace(/^.*charset=(.*)$/,'$1')
		}
	}

	jQuery.ajax(
		{
			type: 'GET',
			url: url,
			scriptCharset: charset,
			success: function(msg) {
				$('#result-content').html(msg);
			}
		}
	);
}

function addElementsToList(from_select_id, to_select_id)
{
	var jfrom_select = $('#'+from_select_id);
	var jto_select = $('#'+to_select_id);

	if (jfrom_select[0].selectedIndex!=-1)
	{
		var options = jfrom_select[0].options;
		for (var i=0; i<options.length; i++)
		{
			if (options[i].selected)
			{
				var value = $(options[i]).val();
				var text = $(options[i]).text();
				var exist = false;
				for (var j=0; j<jto_select[0].options.length; j++)
				{
					if ($(jto_select[0].options[j]).val()==value) { exist = true; }
				}
				if (!exist)
				{
					var new_option = new Option(text,value);
					jto_select[0].options[jto_select[0].length] = new_option;
				}
			}
		}
	}
}

function removeElementsFromList(from_select_id, to_select_id)
{
	var jfrom_select = $('#'+from_select_id);
	var jto_select = $('#'+to_select_id);

	var options = jto_select[0].options;
	for (var i=0; i<options.length; i++)
	{
		if (options[i].selected)
		{
			jto_select[0].options[i] = null;
			i--;
		}
	}
}

function selectAllOptions(select_id)
{
	var select = document.getElementById(select_id);
	for (var i=0; i<select.options.length; i++) {
		select.options[i].selected = true;
	}
}

