function OpenWin(url, framename, wdth, hght) 
{
	var features = "toolbar=0,location=0,directoties=0,status=0,menubar=0,scrollbars=no,resizable=no,width="+(wdth+16)+",height="+hght+",left="+(screen.availWidth-wdth)/2+",top="+(screen.availHeight-hght)/2;
	var w=window.open(url, framename,features);
		w.focus();
}

function OpenFWin(url, framename, wdth, hght) 
{
		var features = "toolbar=0,location=0,directoties=0,status=0,menubar=1,scrollbars=no,resizable=yes,width="+(wdth+16)+",height="+hght+",left="+(screen.availWidth-wdth)/2+",top="+(screen.availHeight-hght)/2;
		var w=window.open(url, framename,features);
		w.focus();
}

function ShowPicture(url,title,width,height)
{
	var features = "toolbar=0,location=0,directoties=0,status=0,menubar=0,scrollbars=no,resizable=yes,width="+(width)+",height="+height+",left="+(screen.availWidth-width)/2+",top="+(screen.availHeight-height)/2;
	var w=window.open("/picture.php?url="+url+"&title="+title+"&width="+width+"px"+"&height="+height, '', features);
}

function GetYear() 
{
var now = new Date();
var year = now.getYear();
if (!document.all) year +=1900;
if (year < 1500) year +=1900;
document.write(year);
}

function CheckUser() 
{
	var i=document.forms['login'];
	var re_str=/[^\s+]/;var re_email=/^\S+@\S+\.\S+$/;

	if (!re_email.test(i.login.value))
	{ 
		i.login.focus(); alert('Введен неправильный логин!'); return false;
	} else if( !re_str.test(i.password.value)) 
	{
		i.password.focus(); alert('Введите пароль!'); return false;
	} else if( i.password.value.length < 6)
	{
		i.password.focus(); alert('Пароль не может быть меньше 6 символов!');return false;
	} else
	{
		return true;
	}
}

function CheckZakaz() 
{
	var i=document.forms['form_zakaz'];
	var oTable = eval('TABLE_ZAKAZ');
	var re_str=/[^\s+]/;var re_email=/^\S+@\S+\.\S+$/;

	
	if (!re_str.test(i.form_name.value))
	{ 
		i.form_name.focus(); alert('Введите ваше имя!'); return false;
	} else if( !re_str.test(i.form_action.value) || i.form_action.value==0) 
	{
		i.form_action.focus(); alert('Выберите тип действия!'); return false;
	} else if( !re_str.test(i.form_type.value) || i.form_type.value==0) 
	{
		i.form_type.focus(); alert('Выберите тип жилого помещения!'); return false;
	} else if( !re_str.test(i.form_cost.value)) 
	{
		i.form_cost.focus(); alert('Введите минимальную цену!'); return false;
	} else if( !re_str.test(i.form_phone.value) && !re_str.test(i.form_email.value)) 
	{
		i.form_phone.focus(); alert('Введите контактный телефон или E-mail!'); return false;
	} else
	{
		oTable.rows[0].cells[0].innerHTML = "Отправка сообщения...";
		JsHttpRequest.query(
		'/ajax/go_email_main.php', 
		{
			'form_name'			: i.form_name.value,
			'form_action'			: i.form_action.value,
			'form_type'			: i.form_type.value,
			'form_cost'				: i.form_cost.value,
			'form_currency'		: i.form_currency.value,
			'form_phone'			: i.form_phone.value,
			'form_phone2'		: i.form_phone2.value,
			'form_email'			: i.form_email.value,
			'form_description'	: i.form_description.value,
			'form_page'			: i.form_page.value,
			'form_metro'			: i.form_metro.value
		},
		function(result, errors_login) 
		{ 
			if (result["status"] && result["status"] != "empty")
			{
				oTable.rows[0].cells[0].innerHTML = "<span class=green><strong>Сообщение успешно отправлено! Спасибо!</strong></font>";
			} else
			{
				oTable.rows[0].cells[0].innerHTML = "<font color=red><strong>Ошибка отправки письма!</strong></font>";
			}
		}
		);
		return false;
	}
}

function CheckFastMetro() 
{
	var i=document.forms['form_fastmetro'];
	var re_str=/[^\s+]/;var re_email=/^\S+@\S+\.\S+$/;

	if( !re_str.test(i.metro.value) || i.metro.value==0) 
	{
		i.metro.focus(); alert('Выберите станцию метро!'); return false;
	} else
	{
		return true;
	}
}