function ClearSt()
{
	list2 = document.getElementById('metro_st');
	while (0 < list2.options.length)
	{
		document.getElementById('ch' + list2.options[0].value).style.display = 'none';
		list2.removeChild(list2.options[0]);
	}
}

function AddSt()
{
	list1 = document.getElementById('metro_st1');
	list2 = document.getElementById('metro_st');
	idx = list1.options.selectedIndex;
	opt = list1.options[idx].value;
	if (idx != -1)
	{
		pic = document.getElementById('ch' + opt);
		len = list2.options.length;
		if (pic.style.display == 'none')
		{
			pic.style.display = 'block';
			list2.options[len] = new Option(list1.options[idx].text, list1.options[idx].value);
		}
	}
}

function DelSt()
{
	list1 = document.getElementById('metro_st1');
	list2 = document.getElementById('metro_st');
	idx = list2.options.selectedIndex;
	opt = list2.options[idx].value;
	if (idx != -1)
	{
		pic = document.getElementById('ch' + opt);
		if (pic.style.display != 'none')
		{
			pic.style.display = 'none';
			list2.removeChild(list2.options[idx]);
		}
	}
}

function CheckSt(id)
{
	pic = document.getElementById('ch' + id);
	list2 = document.getElementById('metro_st');
	len2 = list2.options.length;
	if (pic.style.display == 'none')
	{
		list1 = document.getElementById('metro_st1');
		len1 = list1.options.length;
		var idx = -1;
		for (var i = 0; i < len1; i++)
			if (list1.options[i].value == id)
			{
				idx = i;
				break;
			}
		if (idx != -1)
		{
			list2.options[len2] = new Option(list1.options[idx].text, list1.options[idx].value);
			pic.style.display = 'block';
		}
	}
	else
	{
		pic.style.display = 'none';
		var idx = -1;
		for (var i = 0; i < len2; i++)
			if (list2.options[i].value == id)
			{
				idx = i;
				break;
			}
			if (idx != -1)
				list2.removeChild(list2.options[idx]);
	}
}

function CheckForm(form)
{
	form.metro_st1.disabled = true;
	list2 = document.getElementById('metro_st');
	for (var i = 0; i < list2.options.length; i++)
		list2.options[i].selected = true;
	if ((form.price_from.value == '') || (parseInt(form.price_from.value) <= 0))
		form.price_from.disabled = true;
	if ((form.price_to.value == '') || (parseInt(form.price_to.value) <= 0))
		form.price_to.disabled = true;
	if (form.comm_words.value == '')
		form.comm_words.disabled = true;
	if (form.dfm.options[form.dfm.selectedIndex].value == 0)
		form.dfm.disabled = true;
	for (var i = 0; i <= 12; i++)
		document.getElementById('st_l' + i).disabled = true;
	return true;
}

function CheckLine(id)
{
	var arr;
	switch (id)
	{
		case 0: // центр
			arr = new Array(12, 13, 30, 32, 17, 35, 161, 38, 61, 153, 7, 6, 11, 45, 43, 46, 44, 23, 39, 37, 63, 47, 48, 152, 34, 31, 155, 156, 157, 158, 160, 41, 40, 25, 8, 50, 49, 26, 33, 162, 65, 52, 51, 163, 27, 29, 164, 10, 54, 53, 42, 36, 20, 14, 179, 178);
			break;
		case 1: // Сокольническая
			arr = new Array(116, 117, 124, 126, 125, 11, 45, 43, 46, 44, 23, 39, 37, 15, 91, 169, 93, 101, 100);
			break;
		case 2: // Замоскворецкая
			arr = new Array(55, 60, 74, 75, 76, 62, 63, 47, 48, 152, 34, 31, 18, 113, 114, 147, 150, 148, 151, 149);
			break;
		case 3: // Арбатско-Покровская
			arr = new Array(131, 133, 132, 173, 127, 129, 128, 171, 24, 155, 156, 157, 158, 170, 174, 171, 175, 172, 176);
			break;
		case 4: // Филевская
			arr = new Array(85, 87, 84, 88, 83, 5, 4, 184, 185, 160, 41, 40, 25);
			break;
		case 5: // Кольцевая
			arr = new Array(12, 13, 30, 32, 17, 35, 161, 38, 61, 153, 7, 6);
			break;
		case 6: // Калужско-Рижская
			arr = new Array(119, 118, 121, 120, 68, 67, 9, 8, 50, 49, 26, 33, 162, 16, 96, 95, 104, 102, 106, 107, 105, 103, 109, 108);
			break;
		case 7: // Таганско-Краснопресненская
			arr = new Array(56, 81, 82, 77, 78, 90, 64, 66, 65, 52, 51, 163, 27, 28, 22, 139, 141, 138, 140);
			break;
		case 8: // Калининская
			arr = new Array(136, 135, 137, 130, 122, 29, 164);
			break;
		case 9: // Серпуховско-Тимирязевская
			arr = new Array(59, 58, 57, 73, 69, 71, 70, 72, 10, 54, 53, 42, 36, 20, 19, 115, 97, 99, 98, 112, 110, 111, 181, 182, 183);
			break;
		case 10: // Люблинская
			arr = new Array(144, 143, 145, 142, 146, 21, 165, 167, 123, 14, 179, 178);
			break;
		case 11: // Каховская
			arr = new Array(154, 92, 94);
			break;
		case 12: // Бутовская
			arr = new Array(186, 187, 188, 189, 190);
			break;
	}
	if (document.getElementById('st_l' + id).checked)
		for (var i = 0; i < arr.length; i++)
		{
			if (document.getElementById('ch' + arr[i]).style.display == 'none')
				CheckSt(arr[i]);
		}
	else
		for (var i = 0; i < arr.length; i++)
		{
			if (document.getElementById('ch' + arr[i]).style.display == 'block')
				CheckSt(arr[i]);
		}
}
