function getUrl(url, parameters, funct)
{
	http_request = false;
	if (window.XMLHttpRequest)
		{
			http_request = new XMLHttpRequest();
			if (http_request.overrideMimeType)
				{
					http_request.overrideMimeType('text/html');
				}
		} else if (window.ActiveXObject)
		{ // IE
			try
				{
					http_request = new ActiveXObject("Msxml2.XMLHTTP");
				} catch (e)
				{
					try
						{
							http_request = new ActiveXObject("Microsoft.XMLHTTP");
						} catch (e)
						{
						}
				}
		}
	if (!http_request)
		{
			alert('Cannot create XMLHTTP instance');
			return false;
		}
	http_request.onreadystatechange = funct;
	http_request.open('POST', url, true);
	http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http_request.setRequestHeader("Content-length", parameters.length);
	http_request.setRequestHeader("Connection", "close");
	http_request.send(parameters);
}

function flexibleTextarea(b, f)
{
	// инициализация объекта
	var _txt = document.getElementById(b);
	var _minRows = 4; // минимальное количество строк
	if (_txt)
		{
			// функция расчета строк
			function setRows()
			{
				_txt.rows = _minRows; // минимальное количество строк
				// цикл проверки вместимости контента
				do
					{
						if (_txt.clientHeight != _txt.scrollHeight)
							_txt.rows += 1;
					} while (_txt.clientHeight < _txt.scrollHeight);
			}
			// инициализация функции
			setRows();
			// _txt.rows = _minRows;

			// пересчет строк в зависимости от набранного контента
			_txt.onkeyup = function()
			{
				setRows();
			}
		}
	if (f == 'iframe')
		{
			resizeWindow();
		}
}
function test(id)
{

	getUrl('/test.html', 'number=' + id, content);
}

function news()
{
	getUrl('/news_now.html', 'url=news_now', content);
}

function letter()
{
	getUrl('/letter.html', 'url=letter', content);
}

function postajax(id, menu)
{
	if (menu == '1')
		{
			document.getElementById('ads_menu').style.display = 'none';
		}
	getUrl('/' + id + '.html', 'url=' + id, content);
}

function adsent_a(id)
{
	document.getElementById('ads_menu').style.display = 'table';
	getUrl('/adsent_a.html', 'a=' + id, content);
	user_info();
}

function initOverLabels()
{
	if (!document.getElementById)
		return;
	var labels, id, field;
	labels = document.getElementsByTagName('label');
	for ( var i = 0; i < labels.length; i++)
		{
			if (labels[i].className == 'overlabel')
				{
					id = labels[i].htmlFor || labels[i].getAttribute('for');
					if (!id || !(field = document.getElementById(id)))
						{
							continue;
						}
					labels[i].className = 'overlabel-apply';
					if (field.value !== '')
						{
							hideLabel(field.getAttribute('id'), true);
						}
					field.onfocus = function()
					{
						hideLabel(this.getAttribute('id'), true);
					};
					field.onblur = function()
					{
						if (this.value === '')
							{
								hideLabel(this.getAttribute('id'), false);
							}
					};
					labels[i].onclick = function()
					{
						var id, field;
						id = this.getAttribute('for');
						if (id && (field = document.getElementById(id)))
							{
								field.focus();
							}
					};
				}
		}
};

function hideLabel(field_id, hide)
{
	var field_for;
	var labels = document.getElementsByTagName('label');
	for ( var i = 0; i < labels.length; i++)
		{
			field_for = labels[i].htmlFor || labels[i].getAttribute('for');
			if (field_for == field_id)
				{
					labels[i].style.textIndent = (hide) ? '-1000px' : '0px';
					return true;
				}
		}
}
window.onload = function()
{
	setTimeout(initOverLabels, 50);
};

function send_news()
{

	// myInstance = document.import_box_ids.mySubmit;

	t1 = document.getElementById('import_box_ids');
	var form = window.document.t1;
	window.document.import_box_ids.submit();

	title_news = document.getElementById('title_news').value;
	url_news = document.getElementById('url_news').value;
	autor_news = document.getElementById('autor_news').value;
	text_news = document.getElementById('text_news').value;

	// document.forms["имя формы"].submit()
	// myInstance.submit()

	// getUrl('/news_now.html', 'url=send_news' , content);
}

// function onResponse(){
// alert('123');
// }
function onResponse(d)
{
	eval('var obj = ' + d + ';');

	// htm = eval('(' + http_request.responseText +')');

	switch (obj.templer)
		{

			case 'messages':
				{
					messeng_error(obj.text);
				}
				break;
			case 'ok':
				{
					messeng_error(obj.text);
					document.getElementById('html').innerHTML = '';
				}
				break;
		}
}

function file_adsent(d)
{
	eval('var obj = ' + d + ';');

	// htm = eval('(' + http_request.responseText +')');

	switch (obj.templer)
		{
			case 'upload':
				{
					// alert(obj.html);
					document.getElementById('data_select').innerHTML = obj.html;

				}
				break;
			case 'ok':
				{
					messeng_error(obj.text);
					document.getElementById('html').innerHTML = '';
				}
				break;
		}
}

function content()
{
	if (http_request.readyState == 4)
		{
			if (http_request.status == 200)
				{
					var htm = new Array();
					htm = eval('(' + http_request.responseText + ')');

					switch (htm['who'])
						{
							case 'iframe':
								{
									document.getElementById(htm['idiframe']).innerHTML = htm['html'];
									// user_info();

									if (htm['idiframe'] == 'data_select')
										{
											document.getElementById("upload").innerHTML = '';
										}
									createIFrame();
									resizeWindow();

								}
								break;

							case 'realtor_add':
								{
									/* {"who":"realtor_add","st":"1","id_adsent":85,"i":false,"iframe":"iframe"} */
									if (htm['st'] == '0')
										{
											words = 'Вы уже сообщали о данном риелторе ранее.';
										} else
										{
											ch = parseInt(document.getElementById('real' + htm['id_adsent']).innerHTML) + 1;
											document.getElementById('real' + htm['id_adsent']).innerHTML = ch;
											words = 'Спасибо, это поможет другим в поиске квартир.';
										}
									if (htm['iframe'] == 'iframe')
										{

											custom_alert(words);
										} else
										{
											messeng(words);
										}

								}
								break;

							case 'spam_add':
								{
									/* {"who":"realtor_add","st":"1","id_adsent":85,"i":false,"iframe":"iframe"} */
									if (htm['st'] == '0')
										{
											words = 'Вы уже жаловались ранее на это объявление';
										} else
										{
											ch = parseInt(document.getElementById('spam' + htm['id_adsent']).innerHTML) + 1;
											document.getElementById('spam' + htm['id_adsent']).innerHTML = ch;
											words = 'Ваша жалоба принята.Спасибо, что обратили внимание.';
										}
									if (htm['iframe'] == 'iframe')
										{

											custom_alert(words);
										} else
										{
											messeng(words);
										}

								}
								break;

							/*
							 * 
							 * function spam_req() { if (http_request.readyState == 4) {
							 * if (http_request.status == 200) { s = new Array(); s =
							 * eval('(' + http_request.responseText + ')'); if (s['0'] ==
							 * 0) { messeng('Вы уже жаловались ранее на это
							 * объявление'); } else { cs =
							 * parseInt(document.getElementById('spam' +
							 * s['1']).innerHTML) + 1; document.getElementById('spam' +
							 * s['1']).innerHTML = cs; messeng('Ваша жалоба
							 * принята.Спасибо, что обратили внимание.'); } } } }
							 * 
							 */

							case 'news_now':
								{
									document.getElementById('html').innerHTML = htm['html'];
								}
								break;

							case 'menu':
								{
									document.getElementById('ads_menu').innerHTML = htm['menu'];
									document.getElementById('data_select').innerHTML = htm['html'];
								}
								break;

							case 'option_menu':
								{
									document.getElementById('ads_menu').innerHTML = htm['menu'];
									document.getElementById('data_select').innerHTML = htm['html'];
									if (htm['m'] == 'sale')
										{
											document.getElementById('ads_menu').style.backgroundColor = '#f5f9ff';
											document.getElementById('upload').style.backgroundColor = '#f5f9ff';
											document.getElementById('upload').style.borderColor = '#f5f9ff';
										} else
										{
											document.getElementById('ads_menu').style.backgroundColor = '#f9f6ff';
											document.getElementById('upload').style.backgroundColor = '#f9f6ff';
											document.getElementById('upload').style.borderColor = '#f9f6ff';
										}
								}
								break;

							case 'letter':
								{
									document.getElementById('html').innerHTML = htm['html'];
								}
								break;

							default:
								messeng_error(word_server_2);
						}

					if (htm['iframe'] == 'iframe')
						{
							resizeWindow();
						}

				} else
				{
					/* no connect */
					messeng_error(word_server_1);
				}
		}
}

function closed_m()
{
	document.getElementById('html').innerHTML = ''
}

function messeng_error(tumb, color)
{
	/* / document.getElementById('bg').innerHTML ='' ) / */
	var st = 'gt_alert' + Math.floor(Math.random() * (99999 + 1));
	var st_ch = 'gt_alert_ch' + Math.floor(Math.random() * (99999 + 1));
	container_ch = document.createElement('div');
	container_ch.setAttribute("id", st_ch);
	container = document.createElement('div');
	container.setAttribute("id", st);
	container.setAttribute("class", st);
	container.className = "bg_error";
	if (color == 1)
		{
			container.className = "bg_error_green";
		}
	box = document.getElementById('bg_error');
	container.innerHTML = tumb;
	container_ch.appendChild(container);
	box.appendChild(container_ch);
	setTimeout(function()
	{
		pop_closed('', st, '', '');
	}, 1500);
	setTimeout(function()
	{
		document.getElementById(st_ch).innerHTML = '';
	}, 1800);
}

function pop_closed_id(show, id, id_tumb)
{
	obj = document.getElementById(id);
	resolution = 30;
	time = 500;
	resolution = (resolution > 0 ? resolution : 50);
	var step = (show ? 1 : -1) * (1 / (time > 0 ? time : 1000)) * resolution;

	var opacity = (typeof (obj.style.KhtmlOpacity) != "undefined") ? parseFloat(obj.style.KhtmlOpacity) : (typeof (obj.style.MozOpacity) != "undefined") ? parseFloat(obj.style.MozOpacity) : (typeof (obj.filters) != "undefined") ? obj.filters.Alpha.opacity / 100 : (typeof (obj.style.opacity) != "undefined") ? parseFloat(obj.style.opacity) : null;

	if (opacity == null)
		return;
	opacity = isNaN(opacity) ? (show ? 0 : 1) : opacity;

	var timer = window.setInterval(function()
	{
		if ((opacity += step) >= 1 || opacity <= 0)
			window.clearInterval(timer);
		if (obj.filters)
			obj.filters.Alpha.opacity = Math.round(opacity * 100);
		obj.style.KhtmlOpacity = obj.style.MozOpacity = obj.style.opacity = opacity;
	}, resolution);

	document.getElementById(id_tumb).style.position = "relative";
	var height = document.getElementById(id_tumb).offsetHeight;
	document.getElementById(id_tumb).style.height = height;

	window.setInterval(function()
	{
		if (height >= 0)
			{
				height -= 3;
				document.getElementById(id_tumb).style.height = height + 'px';
			}
	}, 2);

	setTimeout(function()
	{
		clearInterval(timer);
		document.getElementById(id).innerHTML = '';
	}, 1000);
}

function pop_closed(show, ids, time, resolution)
{
	if (ids != "undefined")
		{
			obj = document.getElementById(ids);
		} else
		{
			obj = document.getElementById("pop_content");
		}

	resolution = 30;
	time = 500;
	resolution = (resolution > 0 ? resolution : 100);
	var step = (show ? 1 : -1) * (1 / (time > 0 ? time : 1000)) * resolution;
	var opacity = (typeof (obj.style.KhtmlOpacity) != "undefined") ? parseFloat(obj.style.KhtmlOpacity) : (typeof (obj.style.MozOpacity) != "undefined") ? parseFloat(obj.style.MozOpacity) : (typeof (obj.filters) != "undefined") ? obj.filters.Alpha.opacity / 100 : (typeof (obj.style.opacity) != "undefined") ? parseFloat(obj.style.opacity) : null;

	if (opacity == null)
		return;
	opacity = isNaN(opacity) ? (show ? 0 : 1) : opacity;
	var timer = window.setInterval(function()
	{
		if ((opacity += step) >= 1 || opacity <= 0)
			window.clearInterval(timer);
		if (obj.filters)
			obj.filters.Alpha.opacity = Math.round(opacity * 100);
		obj.style.KhtmlOpacity = obj.style.MozOpacity = obj.style.opacity = opacity;
	}, resolution);

}

/* city */

var check_posutochno_ls = 0;
var city_advert = 0;
var area_advert = 0;
var tru_add_ads = '1';

var ads = 0;
var room0 = 0;
var room1 = 0;
var room2 = 0;
var room3 = 0;
var room4 = 0;
var room5 = 0;

/* 4 rooms */
var room6 = 0;

/* 5 rooms */
var room7 = 0;

var sutki = 0;

var summa_min = 0;
var summa_max = 0;

function city()
{
	if (document.getElementById('city').value != null)
		{
			v = document.getElementById('city').value;
			ajax('/city.html', "name=" + v, select_city);
		}
}

function second_telefon(tel)
{
	ajax('/second_telefon.html', "tel=" + tel, content);
}

function city_letter()
{
	if (document.getElementById('city_g').value != null)
		{
			v = document.getElementById('city_g').value;
			ajax('/city.html', "name=" + v, select_city_letter);
		}
}

function option_city()
{

	clear_check_box();
	objCity = document.getElementById("city_select");
	IdCity = objCity.options[objCity.selectedIndex].value;

	document.getElementById("upload").innerHTML = "<img src='/images/upload.gif' alt=''>";

	objAdvert = document.getElementById("adsent_select");
	IdAdvert = objAdvert.options[objAdvert.selectedIndex].value;
	ajax('/search_city.html', "city=" + IdCity + "&advert=" + IdAdvert, content);
}

function option_menu(m)
{
	ajax('/option_menu.html', "m=" + m, content);
}

function komnata0()
{
	check_room = document.getElementById('check_ad0');
	if (room0 == 1)
		{
			room0 = 0;
			check_room.style.backgroundPosition = '0px 0px';
		} else
		{
			room0 = 1;
			check_room.style.backgroundPosition = '0px -14px';
		}
	option_a();
}

function komnata1()
{
	check_room = document.getElementById('check_ad1');
	if (room1 == 1)
		{
			room1 = 0;
			check_room.style.backgroundPosition = '0px 0px';
		} else
		{
			room1 = 1;
			check_room.style.backgroundPosition = '0px -14px';
		}
	option_a();
}

function komnata2()
{
	check_room = document.getElementById('check_ad2');
	if (room2 == 1)
		{
			room2 = 0;
			check_room.style.backgroundPosition = '0px 0px';
		} else
		{
			room2 = 1;
			check_room.style.backgroundPosition = '0px -14px';
		}
	option_a();
}

function komnata3()
{
	check_room = document.getElementById('check_ad3');
	if (room3 == 1)
		{
			room3 = 0;
			check_room.style.backgroundPosition = '0px 0px';
		} else
		{
			room3 = 1;
			check_room.style.backgroundPosition = '0px -14px';
		}
	option_a();
}

function komnata4()
{
	check_room = document.getElementById('check_ad4');
	if (room4 == 1)
		{
			room4 = 0;
			check_room.style.backgroundPosition = '0px 0px';
		} else
		{
			room4 = 1;
			check_room.style.backgroundPosition = '0px -14px';
		}
	option_a();
}
function komnata5()
{
	check_room = document.getElementById('check_ad5');
	if (room5 == 1)
		{
			room5 = 0;
			check_room.style.backgroundPosition = '0px 0px';
		} else
		{
			room5 = 1;
			check_room.style.backgroundPosition = '0px -14px';
		}
	option_a();
}

function sutki_funk()
{
	check_room = document.getElementById('sutki');
	if (sutki == 1)
		{
			sutki = 0;
			check_room.style.backgroundPosition = '0px 0px';
		} else
		{
			sutki = 1;
			check_room.style.backgroundPosition = '0px -14px';
		}
	option_a();
}

/*
 * 
 * 
 * function check_posutochno() {
 * 
 * if (check_posutochno_ls == 1) { check_posutochno_ls = 0;
 * document.getElementById('check_ad').style.backgroundPosition = '0px 0px'; }
 * else { check_posutochno_ls = 1;
 * document.getElementById('check_ad').style.backgroundPosition = '0px -14px'; }
 * 
 * option_a('3'); // document.getElementById('vv').innerHTML =
 * check_posutochno_ls; }
 */
function addadsent_posutochno()
{

	if (check_posutochno_ls == 1)
		{
			check_posutochno_ls = 0;
			document.getElementById('check_ad').style.backgroundPosition = '0px 0px';
		} else
		{
			check_posutochno_ls = 1;
			document.getElementById('check_ad').style.backgroundPosition = '0px -14px';
		}
	// document.getElementById('vv').innerHTML = check_posutochno_ls;
}

function area()
{
	if (document.getElementById('area').value != null)
		{

			ar = document.getElementById('area').value;
			ajax('/areaname.html', "name=" + ar, select_area);
		}
}

function city_check(id, name, area)
{
	document.getElementById('city').value = name;
	city_advert = id;
	document.getElementById('box_city').innerHTML = '';

	if (area >= 1)
		{

			document.getElementById('box_right_city').innerHTML = '<div  class="box_left_area">Район:<br/>Метро:</div><div  class="box_right_area"><div  class="right_adsent_a"><input  type="text"  maxlength="40"  value="" name="area"  onKeyPress="area();" id="area"></div><div id="box_area_pop"></div> </div>';
			ajax('/area.html', "city_id=" + area, select_area);

		}
	// alert(document.getElementById('city_check'+id));
}

function city_check_letter(id, name, area)
{
	document.getElementById('city_g').value = name;
	document.getElementById('box_city_letter').innerHTML = '';
}

function area_check(id, name)
{
	document.getElementById('area').value = name;
	area_advert = id;
	document.getElementById('box_area_pop').innerHTML = '';
	// alert(document.getElementById('city_check'+id));
}

function onBlurcity(id, name)
{
	document.getElementById('box_city').innerHTML = '';
	// alert(document.getElementById('city_check'+id));
}

function select_city()
{
	if (http_request.readyState == 4)
		{
			if (http_request.status == 200)
				{
					var s_json = new Array();
					if (http_request.responseText != null)
						{
							s_json = eval('(' + http_request.responseText + ')');
							document.getElementById('vv').innerHTML = '';

							if (s_json.length != '')
								{

									if (0 < s_json.data.length)
										{
											if (s_json.data.length == 1)
												{
													document.getElementById('box_city').innerHTML = '';

													city_advert = s_json.data[0][1];

													document.getElementById('box_city').innerHTML = '<div  class="right_pop"><div onmouseover="this.style.backgroundColor = \'#c6c6f8\';"  onmouseout="this.style.backgroundColor = \'#f9f9f9\';" onClick="city_check(\'' + s_json.data[0][1] + '\',\'' + s_json.data[0][0] + '\',\'' + s_json.data[0][2] + '\')">' + s_json.data[0][0] + '</div></div>';

													if (s_json.data[0][2] > 1)
														{

															document.getElementById('box_right_city').innerHTML = '<div  class="box_left_area">Район:<br/>Метро:</div><div  class="box_right_area"><div  class="right_adsent_a"><input  type="text"  maxlength="40"  value="" name="area"  onKeyPress="area();" id="area"></div><div id="box_area_pop"></div> </div>';
															ajax('/area.html', "city_id=" + s_json.data[0][2], select_area);
														}

												} else
												{
													document.getElementById('box_right_city').innerHTML = '';

													ff = '<div  class="right_pop">';
													for ( var i = 0; i < s_json.data.length; i++)
														{
															ff += '<div onmouseover="this.style.backgroundColor = \'#c6c6f8\';"  onmouseout="this.style.backgroundColor = \'#f9f9f9\';" onClick="city_check(\'' + s_json.data[i][1] + '\',\'' + s_json.data[i][0] + '\',\'' + s_json.data[i][2] + '\')">' + s_json.data[i][0] + '</div>';
														}

													ff += '</div>';
													document.getElementById('box_city').innerHTML = ff;
												}
										}
								}
						}
				}
		}
}

function select_city_letter()
{
	if (http_request.readyState == 4)
		{
			if (http_request.status == 200)
				{
					var s_json = new Array();
					if (http_request.responseText != null)
						{
							s_json = eval('(' + http_request.responseText + ')');
							/*
							 * document.getElementById('vv').innerHTML = '';
							 */
							if (s_json.length != '')
								{
									if (s_json.data.length >= 1)
										{
											if (s_json.data.length == 1)
												{
													document.getElementById('box_city_letter').innerHTML = '';
													// s_json.data['0']

													city_advert = s_json.data[0][1];

													document.getElementById('box_city_letter').innerHTML = '<div  class="right_pop_letter"><div onmouseover="this.style.backgroundColor = \'#c6c6f8\';"  onmouseout="this.style.backgroundColor = \'#f9f9f9\';" onClick="city_check_letter(\'' + s_json.data[0][1] + '\',\'' + s_json.data[0][0] + '\',\'' + s_json.data[0][2] + '\')">' + s_json.data[0][0] + '</div></div>';

												} else
												{

													ff = '<div  class="right_pop_letter">';
													for ( var i = 0; i < s_json.data.length; i++)
														{
															ff += '<div onmouseover="this.style.backgroundColor = \'#c6c6f8\';"  onmouseout="this.style.backgroundColor = \'#f9f9f9\';" onClick="city_check_letter(\'' + s_json.data[i][1] + '\',\'' + s_json.data[i][0] + '\',\'' + s_json.data[i][2] + '\')">' + s_json.data[i][0] + '</div>';
														}
													ff += '</div>';
													document.getElementById('box_city_letter').innerHTML = ff;
												}
										}
								}
						}
				}
		}
}

function select_area()
{
	if (http_request.readyState == 4)
		{
			if (http_request.status == 200)
				{
					var s_json = new Array();
					if (http_request.responseText != null)
						{
							s_json = eval('(' + http_request.responseText + ')');
							document.getElementById('vv').innerHTML = '';
							if (s_json.length != '')
								{
									if (s_json.data.length >= 1)
										{
											if (s_json.data.length == 1)
												{

													ff = '<div  class="right_area"><div onmouseover="this.style.backgroundColor = \'#c6c6f8\';"  onmouseout="this.style.backgroundColor = \'#f9f9f9\';" onClick="area_check(\'' + s_json.data[0][0] + '\',\'' + s_json.data[0][1] + '\')">' + s_json.data[0][1] + '</div></div>';
													document.getElementById('box_area_pop').innerHTML = ff;

												} else
												{
													ff = '<div  class="right_area">';
													for ( var i = 0; i < s_json.data.length; i++)
														{
															ff += '<div onmouseover="this.style.backgroundColor = \'#c6c6f8\';"  onmouseout="this.style.backgroundColor = \'#f9f9f9\';" onClick="area_check(\'' + s_json.data[i][0] + '\',\'' + s_json.data[i][1] + '\')">' + s_json.data[i][1] + '</div>';
														}
													ff += '</div>';
													document.getElementById('box_area_pop').innerHTML = ff;
												}
										}
								}
						}
				}
		}
}

function adsentnew()
{
	if (http_request.readyState == 4)
		{
			if (http_request.status == 200)
				{
					var s_json = new Array();
					s_json = eval('(' + http_request.responseText + ')');
					if (s_json['0'] > 1)
						{
							/* messeng('Данные переданы'); */

							document.getElementById('forms_catalog').innerHTML = '	<div class="adsent_add">' + '<h2>Ваше объявление добавлено в общую базу. </h2>' + '</div><div class="ad_url_adsent_add">' + '<a href="/a_' + s_json['0'] + '.html">Посмотреть Ваше обьявление</a>' + '</div></div>';

						}
				}
		}
	resizeWindow();
}

function ajax(url, parameters, funct)
{
	// pop_closed();

	http_request = false;
	if (window.XMLHttpRequest)
		{ // Mozilla, Safari,...
			http_request = new XMLHttpRequest();
			if (http_request.overrideMimeType)
				{
					// set type accordingly to anticipated content type
					// http_request.overrideMimeType('text/xml');
					http_request.overrideMimeType('text/html');
				}
		} else if (window.ActiveXObject)
		{ // IE
			try
				{
					http_request = new ActiveXObject("Msxml2.XMLHTTP");
				} catch (e)
				{
					try
						{
							http_request = new ActiveXObject("Microsoft.XMLHTTP");
						} catch (e)
						{
						}
				}
		}
	if (!http_request)
		{
			alert('Cannot create XMLHTTP instance');
			return false;
		}
	http_request.onreadystatechange = funct;
	http_request.open('POST', url, true);
	http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http_request.setRequestHeader("Content-length", parameters.length);
	http_request.setRequestHeader("Connection", "close");
	http_request.send(parameters);
}

// 123123

function custom_alert(data, site)
{
	if (site == '1')
		{
			messeng(data);
		} else
		{
			VK.addCallback('onScrollTop', function(scroll)
			{
				// ge('popup').style.top = scroll + 'px';
				   // установку топа нашего попапа надо пихать прямо сюда в
				   // обработчик
				   var st = 'gt_alert' + Math.floor(Math.random() * (99999 + 1));
				   var st_ch = 'gt_alert_ch' + Math.floor(Math.random() * (99999 + 1));
				   container_ch = document.createElement('div');
				   container_ch.setAttribute("id", st_ch);
				   container = document.createElement('div');
				   container.setAttribute("id", st);
				   container.setAttribute("class", st);
				   container.className = "bg_error";
				   box = document.getElementById('bg_error');
				   scroll = scroll - 50;
				   box.style.top = scroll + 'px';
				   box.style.margin = '0';
				   container.innerHTML = data;
				   container_ch.appendChild(container);

				   box.appendChild(container_ch);

				   setTimeout(function()
				   {
					   pop_closed('', st, '', '');
				   }, 1000);
				   setTimeout(function()
				   {
					   document.getElementById(st_ch).innerHTML = '';
				   }, 1200);

			   });
			VK.callMethod('scrollTop');

			// вызывали метод получения скрола, он же установит топ нашему
			// алерту
			// ... дальше мы показываем попап и заполняем его сообщением
			// ...
		}
}

function messeng(tumb, color, new_class)
{

	// iframe

	switch (new_class)
		{
			case 'iframe':
				{
				}
				break

			default:
				{
					var st = 'gt_alert' + Math.floor(Math.random() * (99999 + 1));
					var st_ch = 'gt_alert_ch' + Math.floor(Math.random() * (99999 + 1));
					container_ch = document.createElement('div');
					container_ch.setAttribute("id", st_ch);
					container = document.createElement('div');
					container.setAttribute("id", st);
					container.setAttribute("class", st);
					container.className = "bg_error";
					if (color == 1)
						{
							container.className = "bg_error_green";
						}
					box = document.getElementById('bg_error');
					container.innerHTML = tumb;
					container_ch.appendChild(container);
					box.appendChild(container_ch);

					setTimeout(function()
					{
						pop_closed('', st, '', '');
					}, 1500);
					setTimeout(function()
					{
						document.getElementById(st_ch).innerHTML = '';
					}, 1800);

				}
		}

}

function iframe_messeng(tumb, color)
{
	custom_alert(tumb);
	/*
	 * var st = 'gt_alert' + Math.floor(Math.random() * (99999 + 1)); var st_ch =
	 * 'gt_alert_ch' + Math.floor(Math.random() * (99999 + 1)); container_ch =
	 * document.createElement('div'); container_ch.setAttribute("id", st_ch);
	 * container = document.createElement('div'); container.setAttribute("id",
	 * st); container.setAttribute("class", st); container.className =
	 * "iframe_bg_error"; if (color == 1) { container.className =
	 * "bg_error_green"; } box = document.getElementById('iframe_bg_error');
	 * container.innerHTML = tumb; container_ch.appendChild(container);
	 * box.appendChild(container_ch); setTimeout(function() { pop_closed('', st,
	 * '', ''); }, 1500); setTimeout(function() {
	 * document.getElementById(st_ch).innerHTML = ''; }, 1800);
	 */
}

function pop_closed(show, ids, time, resolution)
{
	if (ids != "undefined")
		{
			obj = document.getElementById(ids);
		} else
		{
			obj = document.getElementById("pop_content");
		}

	resolution = 30;
	time = 500;
	resolution = (resolution > 0 ? resolution : 100);
	var step = (show ? 1 : -1) * (1 / (time > 0 ? time : 1000)) * resolution;
	var opacity = (typeof (obj.style.KhtmlOpacity) != "undefined") ? parseFloat(obj.style.KhtmlOpacity) : (typeof (obj.style.MozOpacity) != "undefined") ? parseFloat(obj.style.MozOpacity) : (typeof (obj.filters) != "undefined") ? obj.filters.Alpha.opacity / 100 : (typeof (obj.style.opacity) != "undefined") ? parseFloat(obj.style.opacity) : null;

	if (opacity == null)
		return;
	opacity = isNaN(opacity) ? (show ? 0 : 1) : opacity;
	var timer = window.setInterval(function()
	{
		if ((opacity += step) >= 1 || opacity <= 0)
			window.clearInterval(timer);
		if (obj.filters)
			obj.filters.Alpha.opacity = Math.round(opacity * 100);
		obj.style.KhtmlOpacity = obj.style.MozOpacity = obj.style.opacity = opacity;
	}, resolution);

}

function iframe_add_adsent(who, site)
{
	tru_add_ads = '1';

	if (tru_add_ads == '1')
		{
			if (city_advert == '0')
				{
					custom_alert('Не указан город', site);
					tru_add_ads = '0';
				} else
				{
					tru_add_ads = '1';
				}
		}

	street = document.getElementById('street').value;

	if (tru_add_ads == '1')
		{
			if (street.length == '0')
				{
					custom_alert('Не указана улица', site);
					tru_add_ads = '0';
				} else
				{
					tru_add_ads = '1';
				}
		}

	summa = document.getElementById('summa').value;
	if (tru_add_ads == '1')
		{
			if (summa.length == '0')
				{
					custom_alert('Не указана Сумма', site);
					tru_add_ads = '0';
				} else
				{
					tru_add_ads = '1';
				}
		}

	hause = document.getElementById('hause').value;
	if (tru_add_ads == '1')
		{
			if (hause.length == '0')
				{
					custom_alert('Не указано сколько  этажей в доме', site);
					tru_add_ads = '0';
				} else
				{
					tru_add_ads = '1';
				}
		}

	room = document.getElementById('room').value;

	if (tru_add_ads == '1')
		{
			if (room.length == 0)
				{
					custom_alert('Не указано на каком этаже Ваша квартира', site);
					tru_add_ads = '0';
				} else
				{
					tru_add_ads = '1';
				}
		}

	obcsh = document.getElementById('obcsh').value;
	if (tru_add_ads == '1')
		{
			if (obcsh.length == 0)
				{
					custom_alert('Укажите общую площадь квартиры', site);
					tru_add_ads = '0';
				} else
				{
					tru_add_ads = '1';
				}
		}

	jilaya = document.getElementById('jilaya').value;
	if (tru_add_ads == '1')
		{
			if (jilaya.length == 0)
				{
					custom_alert('Укажите жилую площадь квартиры', site);
					tru_add_ads = '0';
				} else
				{
					tru_add_ads = '1';
				}
		}

	kuhnya = document.getElementById('kuhnya').value;
	if (tru_add_ads == '1')
		{
			if (kuhnya.length == 0)
				{
					custom_alert('Укажите  площадь кухни', site);
					tru_add_ads = '0';
				} else
				{
					tru_add_ads = '1';
				}
		}

	if (check_posutochno_ls == 0)
		{
		}

	telefon = document.getElementById('telefon').value;
	if (tru_add_ads == '1')
		{
			if (telefon.length <= 5)
				{
					custom_alert('Укажите  телефон для связи', site);
					tru_add_ads = '0';
				} else
				{
					tru_add_ads = '1';
				}
		}
	people = document.getElementById('people').value;
	if (tru_add_ads == '1')
		{
			if (people.length <= 5)
				{
					custom_alert('Контактное лицо', site);

					tru_add_ads = '0';
				} else
				{
					tru_add_ads = '1';
				}
		}

	adres = document.getElementById('adres').value;
	if (tru_add_ads == '1')
		{
			if (adres.length <= 20)
				{
					custom_alert('Напишите адрес объекта своими словами', site);
					tru_add_ads = '0';
				} else
				{
					tru_add_ads = '1';
				}
		}

	dopinfo = document.getElementById('dopinfo').value;
	if (tru_add_ads == '1')
		{
			if (dopinfo.length <= 20)
				{
					custom_alert('Укажите дополнительную информацию о объекте', site);
					tru_add_ads = '0';
				} else
				{
					tru_add_ads = '1';
				}
		}

	if (tru_add_ads == '1')
		{
			city_id = document.getElementById('city').value;

			url = "city_advert=" + city_advert + "&area=" + area_advert + "&street=" + street + "&summa=" + summa + "&hause=" + hause + "&room=" + room + "&obcsh=" + obcsh + "&jilaya=" + jilaya + "&kuhnya=" + kuhnya + "&check_posutochno_ls=" + check_posutochno_ls + "&telefon=" + telefon + "&people=" + people + "&who=" + who + "&dopinfo=" + dopinfo + "&adres=" + adres + "&city_id=" + city_id;
			document.getElementById('city').innerHTML = '<div style="width: 69px; eight:16px;"><img src="/images/upload.gif"></div>';
			ajax('/iframe_adsentnew.html', url, content);

		}
}

function hrefurl(link)
{
	location.href = link;
}

function add_adsent(who)
{
	tru_add_ads = '1';

	if (tru_add_ads == '1')
		{
			if (city_advert == '0')
				{
					messeng('Не указан город');
					tru_add_ads = '0';
				} else
				{
					tru_add_ads = '1';
				}
		}

	street = document.getElementById('street').value;

	if (tru_add_ads == '1')
		{
			if (street.length == '0')
				{
					messeng('Не указана улица');
					tru_add_ads = '0';
				} else
				{
					tru_add_ads = '1';
				}
		}

	summa = document.getElementById('summa').value;
	if (tru_add_ads == '1')
		{
			if (summa.length == '0')
				{
					messeng('Не указана Сумма');
					tru_add_ads = '0';
				} else
				{
					tru_add_ads = '1';
				}
		}

	hause = document.getElementById('hause').value;
	if (tru_add_ads == '1')
		{
			if (hause.length == '0')
				{
					messeng('Не указано сколько  этажей в доме');
					tru_add_ads = '0';
				} else
				{
					tru_add_ads = '1';
				}
		}

	room = document.getElementById('room').value;

	if (tru_add_ads == '1')
		{
			if (room.length == 0)
				{
					messeng('Не указано на каком этаже Ваша квартира');
					tru_add_ads = '0';
				} else
				{
					tru_add_ads = '1';
				}
		}

	obcsh = document.getElementById('obcsh').value;
	if (tru_add_ads == '1')
		{
			if (obcsh.length == 0)
				{
					messeng('Укажите общую площадь квартиры');
					tru_add_ads = '0';
				} else
				{
					tru_add_ads = '1';
				}
		}

	jilaya = document.getElementById('jilaya').value;
	if (tru_add_ads == '1')
		{
			if (jilaya.length == 0)
				{
					messeng('Укажите жилую площадь квартиры');
					tru_add_ads = '0';
				} else
				{
					tru_add_ads = '1';
				}
		}

	kuhnya = document.getElementById('kuhnya').value;
	if (tru_add_ads == '1')
		{
			if (kuhnya.length == 0)
				{
					messeng('Укажите  площадь кухни');
					tru_add_ads = '0';
				} else
				{
					tru_add_ads = '1';
				}
		}

	if (check_posutochno_ls == 0)
		{
		}

	telefon = document.getElementById('telefon').value;
	if (tru_add_ads == '1')
		{
			if (telefon.length <= 5)
				{
					messeng('Укажите  телефон для связи');
					tru_add_ads = '0';
				} else
				{
					tru_add_ads = '1';
				}
		}
	people = document.getElementById('people').value;
	if (tru_add_ads == '1')
		{
			if (people.length <= 5)
				{
					messeng('Контактное лицо');
					tru_add_ads = '0';
				} else
				{
					tru_add_ads = '1';
				}
		}

	adres = document.getElementById('adres').value;
	if (tru_add_ads == '1')
		{
			if (adres.length <= 20)
				{
					messeng('Напишите адрес объекта своими словами');
					tru_add_ads = '0';
				} else
				{
					tru_add_ads = '1';
				}
		}

	dopinfo = document.getElementById('dopinfo').value;
	if (tru_add_ads == '1')
		{
			if (dopinfo.length <= 20)
				{
					messeng('Укажите дополнительную информацию о объекте');
					tru_add_ads = '0';
				} else
				{
					tru_add_ads = '1';
				}
		}

	if (tru_add_ads == '1')
		{
			city_id = document.getElementById('city').value;

			url = "city_advert=" + city_advert + "&area=" + area_advert + "&street=" + street + "&summa=" + summa + "&hause=" + hause + "&room=" + room + "&obcsh=" + obcsh + "&jilaya=" + jilaya + "&kuhnya=" + kuhnya + "&check_posutochno_ls=" + check_posutochno_ls + "&telefon=" + telefon + "&people=" + people + "&who=" + who + "&dopinfo=" + dopinfo + "&adres=" + adres + "&city_id=" + city_id;

			document.getElementById('city').innerHTML = '<div style="width: 69px; eight:16px;"><img src="/images/upload.gif"></div>';

			// ajax('/adsentnew.html', url, adsentnew);
			ajax('/adsentnew.html', url, content);
		}
}
/*
 * function option_sale() {
 * 
 * obj = document.getElementById('upload'); image =
 * document.createElement('img'); image.src = '/images/upload.gif';
 * obj.appendChild(image);
 * 
 * 
 * objSel_rs = document.getElementById("adsent_select"); rs =
 * objSel_rs.options[objSel_rs.selectedIndex].value;
 * 
 * if (id_c == 'rent' || id_c == 'sale') { ads = 1;
 * 
 * if (id_c == 'rent') { document.getElementById('lss_d').innerHTML = '<div
 * class="box_d2" onclick="sutki_funk();"><div class="check_ad" id="sutki" ></div><div
 * class="adsen_menu_e">Посуточно</div></div>';
 * document.getElementById("lss_d").style.display = "table"; } else {
 * document.getElementById('lss_d').innerHTML = '';
 * document.getElementById("lss_d").style.display = "none"; sutki = 0; } } else {
 * 
 * objSel = document.getElementById("city_select"); ct =
 * objSel.options[objSel.selectedIndex].value; // messeng(ct); }
 * 
 * summa_min = document.getElementById('summa_min').value summa_max =
 * document.getElementById('summa_max').value // alert(rs); // messeng(ct+' ,
 * '+rs) if (document.getElementById("city_select")) { objSel =
 * document.getElementById("city_select"); ct =
 * objSel.options[objSel.selectedIndex].value; } // url = 'city='+ct+'&ad='+rs;
 * 
 * url = 'ad=' + rs + '&ads=' + ads + '&summa_min=' + summa_min + '&summa_max=' +
 * summa_max + '&room0=' + room0 + '&room1=' + room1 + '&room2=' + room2 +
 * '&room3=' + room3 + '&room4=' + room4 + '&room5=' + room5 + '&sutki=' + sutki +
 * '&city=' + ct + '&id_c=' + id_c; ajax('/search_ajax.html', url, search_ajax); }
 * 
 */

function option_a()
{
	obj = document.getElementById('upload');
	image = document.createElement('img');
	image.src = '/images/upload.gif';
	obj.innerHTML = '';
	obj.appendChild(image);

	// document.getElementById("upload").innerHTML = "<img
	// src='/images/upload.gif'
	// alt=''>";

	objSel_rs = document.getElementById("adsent_select");
	advert_sr = objSel_rs.options[objSel_rs.selectedIndex].value;

	objSel = document.getElementById("city_select");
	ct = objSel.options[objSel.selectedIndex].value;

	summa_min = document.getElementById('summa_min').value
	summa_max = document.getElementById('summa_max').value
	url = 'ad=' + advert_sr + '&summa_min=' + summa_min + '&summa_max=' + summa_max + '&room0=' + room0 + '&room1=' + room1 + '&room2=' + room2 + '&room3=' + room3 + '&room4=' + room4 + '&room5=' + room5 + '&sutki=' + sutki + '&city=' + ct;

	ajax('/search_ajax.html', url, content);
}

function resizeWindow()
{
	hg = document.compatMode == 'CSS1Compat' && !window.opera ? document.getElementById('forms_search').clientHeight : document.body.getElementById('forms_search').clientHeight;
	wg = document.compatMode == 'CSS1Compat' && !window.opera ? document.getElementById('forms_search').clientWidth : document.body.getElementById('forms_search').clientWidth;
	VK.init(function()
	{
		VK.callMethod("resizeWindow", wg, hg);
	});
}

function user_info()
{
	VK._apiId = 2408021;
	VK.init(function()
	{
		var parts = document.location.search.substr(1).split("&");
		var flashVars = {}, curr;
		for (i = 0; i < parts.length; i++)
			{
				curr = parts[i].split('=');
				flashVars[curr[0]] = curr[1];
			}
		var viewer_id = flashVars['viewer_id'];
		VK.api("getProfiles",
			{
			   uids : viewer_id,
			   fields : "photo_big"
			}, function(data)
		{
			user_info_temp = data.response[0].first_name + ' ' + data.response[0].last_name;
			return user_info_temp;
		});
	});
}

/*
 * 
 * function search_ajax() { if (http_request.readyState == 4) { if
 * (http_request.status == 200) { var s_json = new Array(); s_json = eval('(' +
 * http_request.responseText + ')'); document.getElementById('upload').innerHTML =
 * ''; document.getElementById('data_select').innerHTML = s_json['html'];
 * document.getElementById('rs').innerHTML = s_json['menu'];
 * 
 * if (s_json['iframe'] == 'iframe') { resizeWindow(); } } } }
 * 
 */

function comm_a(id)
{
	div = '<div id="pop" class="pop"><div id="messeng">' + '<div class="header_button_reg">' + '<div  onclick="closed_m();" class="box_x_button"></div>' + '<div class="namebutton_reg">Ваш комментарий к объявлению</div>' + '</div>' + ' <div id="pop_send" class="pop_content_text_reg">' + '<table>' + '<tbody>' + '<tr>' + '<td class="reg_span1">' + '<span>Ваше имя:</span>' + '</td>' + '<td class="reg_span3">' + '<div>' + '<input type="text" value="" maxlength="20" id="name_comment"  class="name_comment">' + '</div>' + '</td>' + '</tr>' + '<tr>' + '<td class="reg_span1">' + '<span>Текст сообщения:</span>' + '</td>' + '<td class="reg_span3">' + '<div>' + '<textarea maxlength="300" id="text_comment"></textarea>' + '</div>' + '</td>' + '</tr>' + '</tbody></table>' + '</div>' + '<div id="pop_content_submit">' + '<div id="tt"><a class="reg_button" onclick="closed_m();"   id="reg_resed">Отмена</a></div>' + '<div id="ss"><a class="reg_button" onclick="comment_out(' + id
	      + ')"  id="reg_resed">Комментировать</a></div>' + '</div></div>';
	document.getElementById('html').innerHTML = div;
}

function comment_out(id)
{
	name_comment = document.getElementById('name_comment').value;
	text_comment = document.getElementById('text_comment').value;
	document.getElementById('pop_send').innerHTML = '<div style="width: 382px; height:160px;"><img src="/images/loading.gif" alt=""></div>';
	document.getElementById('ss').innerHTML = '';
	ajax('/comment_adsent.html', 'id=' + id + '&name_comment=' + name_comment + '&text_comment=' + text_comment, comment_adsent);
	resizeWindow();
}

function comment_out_new(id, ifr)
{
	text_comment = document.getElementById('adv_text').value;

	if (ifr == 'iframe')
		{
			user_info();
			name_comment = user_info_temp;
			ifr_check = '1';
		} else
		{
			name_comment = document.getElementById('names_comm').value;
			ifr_check = '0';
		}

	if (text_comment.length > 5)
		{
			document.getElementById('com_l').innerHTML = '<img src="/images/upload.gif" alt="">';
			ajax('/comment_adsent.html', 'id=' + id + '&name_comment=' + name_comment + '&text_comment=' + text_comment + '&iframe=' + ifr_check, comment_adsent);

		} else
		{
			messeng('комментарий не информативен');
		}
}

function spam_a(ds)
{
	ajax('/spam_add.html', 'id=' + ds, content);
}

function realtor(ds)
{
	ajax('/realtor_add.html', 'id=' + ds, content)
}

function check_telefon()
{
	if (http_request.readyState == 4)
		{
			if (http_request.status == 200)
				{
					var s = new Array();
					s = eval('(' + http_request.responseText + ')');
					if (s['0'] >= 1)
						{
							messeng('Внимание! В базе ' + s['0'] + ' объявления с данным номером.');
						}
				}
		}
}

// регистрация пользователя, проверка введёных данных на стороне пользователя
function checktelefona(input)
{

	telefon = document.getElementById('telefon').value;
	ajax('/check_telefon.html', 'tel=' + telefon, check_telefon);
	input.value = input.value.replace(/[^0-9]/ig, '');

}

function checknumber_summa_min(input)
{

	summa_max = document.getElementById('summa_max').value;
	input.value = input.value.replace(/[^0-9]/ig, '');
	if (summa_max != '')
		{
			if (input.value >= summa_max)
				{
					document.getElementById('summa_max').value = input.value;
				}
		}
	option_a();
}

function checknumber_summa_max(input)
{
	input.value = input.value.replace(/[^0-9]/ig, '');
	summa_min = document.getElementById('summa_min').value;

	if (input.value <= summa_min)
		{
			document.getElementById('summa_min').value = input.value;
		}
	option_a();
}

function checknumber(input)
{
	input.value = input.value.replace(/[^0-9]/ig, '');
}

function comment_adsent()
{
	if (http_request.readyState == 4)
		{
			if (http_request.status == 200)
				{
					s_comm = new Array();
					s_comm = eval('(' + http_request.responseText + ')');
					document.getElementById('html').innerHTML = '';

					if (s_comm['ok'] == 0)
						{
							messeng('Ваш комментарий отсеян роботом.');
						} else
						{
							messeng('Ваш комментарий размещён под объявлением.');
							document.getElementById('adv_text').value = '';

							n_comment2 = document.getElementById('n_comment2').innerHTML;

							if (s_comm['iframe'] == '1')
								{
									user_info();
									resizeWindow();
								}

							document.getElementById('n_comment2').innerHTML = '<div class="coms"><div class="coms4">' + s_comm['text'] + '</div><div class="coms_5"><div class="coms2">' + s_comm['name'] + '</div><div class="coms3">' + s_comm['time'] + '</div></div></div>' + n_comment2;

							document.getElementById('adv_text').style.height = "30px";

							document.getElementById('com_l').innerHTML = '';

						}
				}
		}
}

files_images_adsent = 0;

function add_file(ids)
{
	// container_file = document.createElement('div');
	if (files_images_adsent <= 5)
		{
			files_images_adsent = files_images_adsent + 1;
			container_f = document.createElement('div');
			container_f.setAttribute("class", "new_files_box");
			box = document.getElementById('add_file');
			tumb_file = '<div class="add_file1"><input type="file" size="0"  ' + 'name="images[]"></div><div class="add_file2" id="clear_plus_' + files_images_adsent + '"><img onclick="add_file();"' + ' src="/images/add.jpg" alt=""></div>';
			container_f.innerHTML = tumb_file;
			box.appendChild(container_f);
		}
	if (files_images_adsent == 5)
		{
			document.getElementById('clear_plus_0').innerHTML = '';
			document.getElementById('clear_plus_1').innerHTML = '';
			document.getElementById('clear_plus_2').innerHTML = '';
			document.getElementById('clear_plus_3').innerHTML = '';
			document.getElementById('clear_plus_4').innerHTML = '';
			document.getElementById('clear_plus_5').innerHTML = '';
			files_images_adsent = 0;
		}
}

// браузер хранится в объекте browser
function createIFrame()
{

	// браузер хранится в объекте browser
	// function createIFrame(fname, src, debug){
	// var el = document.createElement("iframe");
	// document.getElementById('data_select').appendChild(el);
	// el.id = 'myIframe';
	// el.src = '/send_file_images.html';
	// el.name = 'myIframe';
}

// прячем фрейм
function hideIframe(iframeNode)
{
	with (iframeNode.style)
		{
			if (!browser.isSafari)
				{
					position = "absolute";
				}
			left = top = "0px";
			height = width = "1px";
			visibility = "hidden";
		}
}

function upload_file()
{

	document.getElementById('addadvert_upl').style.display = 'none';
	document.getElementById('addadvert_upl2').innerHTML = '<div class="upload_fils"><div class="upload_fils_title">Загружаю фото</div><div><img src="/images/loading.gif" alt=""></div><div class="upload_fils_title">Подождите чуток</div></div>';

	// document.getElementById('data_select').innerHTML = '<div
	// class="upload_fils"><div class="upload_fils_title">Загружаю
	// фото</div><div><img src="/images/loading.gif" alt=""></div><div
	// class="upload_fils_title">Подождите чуток</div></div>';
}

function add_advert_ad_url_onmouse(id)
{
	document.getElementById(id).innerHTML = 'qw';
}

function reimages(asd)
{
	imageCentr = document.getElementById('FotoCenter');
	NewFoto = imageCentr.src;
	re = /([\d]{14}).jpg/i;
	found = NewFoto.match(re);
	imageOld = asd.src
	foundOld = imageOld.match(re);
	imageCentr.src = '/images/advert/349/' + foundOld['1'] + '.jpg';
	asd.src = '/images/advert/69/' + found['1'] + '.jpg';

}

function clear_check_box()
{

	/* 0 room apartment */
	room0 = 0;
	document.getElementById('check_ad0').style.backgroundPosition = '0px 0px';

	/* 1 room apartment */
	room1 = 0;
	document.getElementById('check_ad1').style.backgroundPosition = '0px 0px';

	/* 2 room apartment */
	room2 = 0;
	document.getElementById('check_ad2').style.backgroundPosition = '0px 0px';

	/* 3 room apartment */
	room3 = 0;
	document.getElementById('check_ad3').style.backgroundPosition = '0px 0px';

	/* 4 room apartment */
	room4 = 0;
	document.getElementById('check_ad4').style.backgroundPosition = '0px 0px';

	/* 5 room apartment */
	room5 = 0;
	document.getElementById('check_ad5').style.backgroundPosition = '0px 0px';

	/* in day */

	sutki = 0;

	objAdvert_sutki = document.getElementById("adsent_select");
	IdAdvert_sutki = objAdvert_sutki.options[objAdvert_sutki.selectedIndex].value;

	if (IdAdvert_sutki == '2')
		{
			document.getElementById('sutki').style.backgroundPosition = '0px 0px';
		}

	/* summa */
	document.getElementById('summa_min').value = document.getElementById('summa_max').value = '';
}
