//-------------объявления----------

function onsubboard(form)
{
if(!form.title.value.length)
  {alert('Заполните поле "Название"');return false;
  }
if(!form.cost.value.length)
  {alert('Заполните поле "Цена"');return false;
  }
if(!form.text.value.length)
  {alert('Заполните поле "Текст"');return false;
  }
if(!form.user.value.length)
  {alert('Заполните поле "Контактное лицо"');return false;
  }
if(!form.telephone.value.length)
  {alert('Заполните поле "Телефон"');return false;
  }


if(form.email.value.indexOf('@')==-1)
{
alert('Корректно укажите e-mail');return false;
}

return true;
}

//---------------------------------------------------------------------------------
//---------------------------------------------------------------------------------
// поимск по сайту
//---------------------------------------------------------------------------------
//---------------------------------------------------------------------------------
function get_search_result(code, s, page)
{
	if (page != 1)
		$('#more-' + code).html(get_loading());

	$.post($('#popup').attr('path_to_search'), { code: code, s: s, page:page }, function(txt)
	{//alert(code + "\n\n" + txt);
		var num = txt.indexOf('|');
		var cnt = parseInt(txt.substr(0, num));
		if (cnt > 0)
		{
			if (page == 1)
			{
				$('#tabs ul a[href=#tab-' + code + ']').append(cnt).parent('li').show();
				$('#tab-' + code).html(txt.substr(num+1));
				if ($('#tabs').attr('first') == 'false')
				{
					$('#tabs').attr('first', 'true').show();
					$('#tabs ul a[href=#tab-' + code + ']').click();
				}
			}
			else
				$('#more-' + code).before(txt.substr(num+1)).remove();
		}

		if (parseInt($('#tabs').attr('count')) == 6)
		{
			$('#search_progress').html('Результаты поиска по запросу <b>"' + s + '"</b>:');
			if ($('#tabs').attr('first') == 'false') $('#search_progress').append(' ничего не найдено');
		}
		else
			$('#tabs').attr('count', parseInt($('#tabs').attr('count')) + 1);
	}, 'text');
}
//---------------------------------------------------------------------------------
//---------------------------------------------------------------------------------
// зависимость городов и стран
//---------------------------------------------------------------------------------
//---------------------------------------------------------------------------------
function change_country(id, otherCity)
{
	if (otherCity == undefined) otherCity = true;
	$('.cities_other').hide();
	$('#cities_list option').attr('selected', '');

	if ($('#'+id).val() == 0 &&  $('#country_list_' + $('#'+id).val() + ' select').length == 0)
	{
		$('.cities_list').hide();
	}
	else
	{
		$('.cities_list').show();

		$('#cities_list').html('<option value="0">все</option>' + $('#country_list_' + $('#'+id).val() + ' select').html() + (otherCity ? ('<option value="CityOther">Другой город</option>') : ''));
		if ($('#cities_list').attr('country_id') != $('#'+id).val()) $('#cities_list').val(0);
	}
}
//---------------------------------------------------------------------------------
function change_city(id)
{
	if ($('#'+id).val() == 'CityOther')
	{
		$('.cities_list').hide();
		$('.cities_other').show();
	}
}
//---------------------------------------------------------------------------------
function change_city2(id)
{
	//var city_id = $('#' + id + ' option:selected').val();
	var country_id = $('#' + id + ' option:selected').attr('country_id');
	$('#countries_list').val(country_id);
}
//---------------------------------------------------------------------------------
//---------------------------------------------------------------------------------
// устанавливаем праивльные координаты для некоторых элементов
//---------------------------------------------------------------------------------
//---------------------------------------------------------------------------------
function changeCordnates()
{
	$('#main_bg').css('left', getElementPosition('all').left + main_bg_left);
	$('#main_bg').css('top', getElementPosition('all').top + main_bg_top);

	$('#main_left_news div.new').css('left', function()
	{
		if (!$(this).is('[data-left]')) $(this).attr('data-left', $(this).css('left'));
		return getElementPosition('main_left_news').left + parseInt($(this).attr('data-left'));
	});
	$('#main_left_news div.new').css('top', function()
	{
		if (!$(this).is('[data-top]')) $(this).attr('data-top', $(this).css('top'));
		return getElementPosition('main_left_news').top + parseInt($(this).attr('data-top'));
	});
}
