function setListNull(listElm) {
	listElm.options.length = 0;
	listElm.options[0] = new Option("выберите значение", "", false,false);
}

function getListLength(listElm) {
	return  (listElm && listElm.options) ? listElm.options.length : 0;
}

function setListOptions(listElm, text, fireEventChange) {
	var name, id, isSelected = false;
	var matches = text.match(/<option[^>]*>(.*?)<\/option>/ig);

	setListNull(listElm);

	if ($type(matches) != 'array')
		return;

	for (var i = 0; i < matches.length; ++i) 
	{
		name 	= matches[i].match(/<option[^>]*>(.*?)<\/option>/i);
		id 	= matches[i].match(/<option.*value="(.*?)".*>*<\/option>/i);
		isSelected = matches[i].test(/<option.*selected.*>*<\/option>/i);
		listElm.options[i] = new Option(name[1], id[1] || '', false, isSelected);
	}

	if(fireEventChange)
		listElm.fireEvent('change');
}
