
	function dg_AddOption(element, value, text)
{
	var anketa = document.forms.anketa;	
	anketa.elements[element].options[anketa.elements[element].options.length]=new Option(text,value);
}

function dg_ForceUpdate(type, lang)
{
	this.UplType = type;
	var anketa = document.forms.anketa;
	var data_frame = frames['data_frame'];
	var country = anketa.elements[this.country_el].options[anketa.elements[this.country_el].selectedIndex].value;

	for (i = anketa.elements[this.town_el].options.length - 1; i >= 1 ; i--){
	    anketa.elements[this.town_el].options[i] = null;
	    // IE anketa.elements[this.town_el].options.remove(i);
	}
			
	anketa.elements[this.town_el].disabled = true;
	if (type == 1)
	{
		if (country == 0)
		{
			anketa.elements[this.region_el].disabled = true;
			anketa.elements[this.town_el].disabled = true;
			return;
		}
		for (i = anketa.elements[this.region_el].options.length - 1; i >= 1 ; i--){
				//IE anketa.elements[this.region_el].options.remove(i);
				anketa.elements[this.region_el].options[i]=null;
		}
		anketa.elements[this.region_el].disabled = true;

		data_frame.location.href = "/help/lrc.php?lang=" + this.lang + "&country=" + country + "&region_el="+this.region_el;
		//this.CheckDataLoaded();
	}
	else
	{
		var region = anketa.elements[this.region_el].options[anketa.elements[this.region_el].selectedIndex].value;
		if (region == 0)
			anketa.elements[this.town_el].disabled = true;
		else
		{
			data_frame.location.href = "/help/lrc.php?lang=" + this.lang + "&country=" + country + "&region=" + region+"&town_el="+this.town_el;
			//this.CheckDataLoaded();
		}
	}
}

function CDynamicGeo(obj_name, lang, country_el, region_el, town_el)
{
	this.to = -1;
	this.cur_el = null;
	this.obj_name = obj_name;
	this.UplType = 0;
	this.lang = lang;
	this.country_el = country_el;
	this.region_el = region_el;
	this.town_el = town_el;

	this.AddOption = dg_AddOption;
	this.ForceUpdate = dg_ForceUpdate;
}
	








function option_range(from, to, dflt)
{
	if (dflt == 0)
		document.write();
	else
		document.write();
	if (from > to)
		mod = -1;
	else
		mod = 1;

	for (var i = from; i != to + mod; i+=mod)
		if (i == dflt)
			document.write('<option value="' + i + '" selected>' + i);
		else
			document.write('<option value="' + i + '">' + i);
}

function make_options(v, d, dflt)
{
	for (var i = 0; i < v.length; i++)
		if (v[i] == dflt)
			document.write('<option value="' + v[i] + '" selected>' + d[i]);
		else
			document.write('<option value="' + v[i] + '">' + d[i]);
}

// Кодирование CheckBox'ов
var NeedPasswd = true;
function Encode(field)
{
	var	value = 0;
	if (anketa.elements[field])
		for (i=0; i<anketa.elements[field].length; i++)
			if (anketa.elements[field][i].checked == true)
				value += Math.pow(2, i)
	return value;
}
// Декодирование CheckBox'ов
function Decode(field, n)
{
	pos = 0;
	while (n > 0)
	{
		if (n%2)
			anketa.elements[field][pos].checked = true;
		n = Math.floor(n/2);
		pos++;
	}
}
// Приглашение ко вводу в элементе	
function SetFocus(element)
{
	anketa.elements[element].scrollIntoView(true);
	anketa.elements[element].focus();
}





