function A_trim(strSource)
{
 return strSource.replace(/^\s*/,'').replace(/\s*$/,'');
}

function ch_options(v,def_dm)
{
	
	var str = '';
	for (var x in v)
	{
		if(A_trim(def_dm)==x)
		   str += "<option value='" + x + "' selected>" + v[x] + "</option>";
		else
		  str += "<option value='" + x + "'>" + v[x] + "</option>";
	}
	return str;
}

function to_options(v)
{
	var str = '';
	for (var x in v)
	{
		str += "<option value='" + x + "'>" + v[x] + "</option>";
	}
	return str;
}

function clearOptions(sel)
{
	if (!sel || !sel.options || sel.selectedIndex < 0) {
		return;
	}
	while (sel.options && sel.options.length > 1)
		sel.options[1] = null;

	if (sel.options[0].value == '') 
	{
		sel.value = '';
		return; 
	}
	sel.options[0] = null;
}

