//
//	Шоу "Стенды"
//
////////////////////////////////////////////////////////////////////////////////
/*
Stands = function ( step ) {

var s1 = $ ( "#Stand_1" );
var s2 = $ ( "#Stand_2" );
var s3 = $ ( "#Stand_3" );

var d1 = $ ( "#Stand_1_div" );
var d2 = $ ( "#Stand_2_div" );
var d3 = $ ( "#Stand_3_div" );

var a1 = $ ( "#Stand_1_div > A" );
var a2 = $ ( "#Stand_2_div > A" );
var a3 = $ ( "#Stand_3_div > A" );

/*	Находим индекс большого поля стенда в массиве стендов*/
/*
var path = "";
var parts = s1.attr ( "src" ).split ( "/" );
for ( i = 0; i < parts.length; i++ ) {

if ( parts[i] != "thumbs" ) {

path += parts[i] + "/";

} else {

break;

}

}
path += "thumbs/";

var index = StandsArray.getIndex ( parts[parts.length - 1].split ( "_" )[0] );
var a = ( step == "back" ? 1 : -1 );

d1.fadeOut ( 300, function () {
i = index+a;
if ( i < 0 )
i = StandsArray.length + i;
if ( i >= StandsArray.length )
i = i - StandsArray.length;
s1.attr ( "src", ( path + StandsArray[i] + "_big.gif" ) );
a1.attr ( "href", "http://" + StandsArray[i] + ".stroitel73.ru/" );
d1.fadeIn ( 300 );
} );
d2.fadeOut ( 500, function () {
i = index+a+1;
if ( i < 0 )
i = StandsArray.length + i;
if ( i >= StandsArray.length )
i = i - StandsArray.length;
s2.attr ( "src", ( path + StandsArray[i] + "_small.gif" ) );
a2.attr ( "href", "http://" + StandsArray[i] + ".stroitel73.ru/" );
d2.fadeIn ( 500 );
} );
d3.fadeOut ( 800, function () {
i = index+a+2;
if ( i < 0 )
i = StandsArray.length + i;
if ( i >= StandsArray.length )
i = i - StandsArray.length;
s3.attr ( "src", ( path + StandsArray[i] + "_small.gif" ) );
a3.attr ( "href", "http://" + StandsArray[i] + ".stroitel73.ru/" );
d3.fadeIn ( 800 );
} );

}
*/
////////////////////////////////////////////////////////////////////////////////

function direct(url){

	if (url){

		location.href = url;
	}
}

////////////////////////////////////////////////////////////////////////////////
//
//	Выставка
//
////////////////////////////////////////////////////////////////////////////////
ChangePhoto = function ( obj, img_id, bordercolor ) {

	if ( !bordercolor ) {
		bordercolor = "red";
	}

	var parts = obj.src.split ( "/" );
	var path = "";
	var img = parts[parts.length - 1];

	var div = $ ( obj ).parents ( "DIV" )[0];
	var images = $ ( div ).children ();
	for ( var i = 0; i < images.length; i++ ) {

		images[i].style.border = "2px solid #f1f1f1";

	}

	//	obj.width = "48px";
	//	obj.height = "48px";
	obj.style.border = "2px solid " + bordercolor;

	for ( i = 0; i < parts.length; i++ ) {

		if ( parts[i] != "thumbs" ) {

			path += parts[i] + "/";

		} else {

			break;

		}

	}

	$ ( "#" + img_id ).attr ( "src", path + img );

}
////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////
//
//	Обработка Search
//
////////////////////////////////////////////////////////////////////////////////
function Seacrh_OnClick () {
	if ( $(formSearch.text).val() == "поиск" )
	$(formSearch.text).val("");
}

function Seacrh_OnBlur () {
	if ( $(formSearch.text).val() == "" )
	$(formSearch.text).val("поиск");
}

function Seacrh_Submit () {
	if ( ($_var('text').value == "" || $_var('text').value == "поиск") && ($_var('texts').style.display == 'block' || $_var('texts').style.display == '')) {
		alert ( "Что ищем?" );
		return false;
	} else {
		switch ($_var('search2').value)
		{
			case 'site':
			$_var('formSearch').action="/search/";
			break;
			case 'estate':
			$_var('formSearch').action="/estate/";
		}
		$_var('formSearch').submit();
		return true;
	}
}

function Search2(rubrika) {
	if((rubrika == 'estate')||((rubrika == 'search')&&(OopsEstateFound=="1"))) {
		$_var('estate_search').style.display='block';
		$_var('texts').style.display = 'none';
		$_var('deals').style.display = 'block';
	} else {
		$_var('estate_search').style.display = 'none';
		$_var('texts').style.display = 'block';
		$_var('deals').style.display = 'none';
	}
}

function Estate_ShowSub(lodge_id)
{
	switch (lodge_id)
	{
		case '1':
		$_var('room').style.display = 'block';

		$_var('type').style.display = 'block';
		$_var('types').style.display = 'none';
		$_var('typegarage').style.display = 'none';

		$_var('flat_type_enabled').style.display = 'block';
		$_var('lodge_type_enabled').style.display = 'none';
		$_var('garage_type_enabled').style.display = 'none';

		$_var('rooms_count_show').style.display = 'block';
		break;

		case '2':

		case '3':
		$_var('room').style.display = 'none';

		$_var('type').style.display = 'none';
		$_var('types').style.display = 'none';
		$_var('typegarage').style.display = 'none';

		$_var('flat_type_enabled').style.display = 'none';
		$_var('lodge_type_enabled').style.display = 'none';
		$_var('garage_type_enabled').style.display = 'none';

		$_var('rooms_count_show').style.display = 'none';
		break;

		case '4':

		case '5':
		$_var('room').style.display = 'block';

		$_var('type').style.display = 'none';
		$_var('types').style.display = 'none';
		$_var('typegarage').style.display = 'none';

		$_var('flat_type_enabled').style.display = 'none';
		$_var('lodge_type_enabled').style.display = 'none';
		$_var('garage_type_enabled').style.display = 'none';

		$_var('rooms_count_show').style.display = 'block';
		break;

		case '6':
		$_var('room').style.display = 'none';

		$_var('type').style.display = 'none';
		$_var('types').style.display = 'block';
		$_var('typegarage').style.display = 'none';

		$_var('flat_type_enabled').style.display = 'none';
		$_var('lodge_type_enabled').style.display = 'block';
		$_var('garage_type_enabled').style.display = 'none';

		$_var('rooms_count_show').style.display = 'none';
		break;

		case '7':
		$_var('room').style.display = 'none';

		$_var('type').style.display = 'none';
		$_var('types').style.display = 'none';
		$_var('typegarage').style.display = 'none';

		$_var('flat_type_enabled').style.display = 'none';
		$_var('lodge_type_enabled').style.display = 'none';
		$_var('garage_type_enabled').style.display = 'none';

		$_var('rooms_count_show').style.display = 'none';
		break;

		case '8':
		$_var('room').style.display = 'none';

		$_var('type').style.display = 'none';
		$_var('types').style.display = 'none';
		$_var('typegarage').style.display = 'block';

		$_var('flat_type_enabled').style.display = 'none';
		$_var('lodge_type_enabled').style.display = 'none';
		$_var('garage_type_enabled').style.display = 'block';

		$_var('rooms_count_show').style.display = 'none';
		break;

		case '9':
		$_var('room').style.display = 'none';

		$_var('type').style.display = 'none';
		$_var('types').style.display = 'none';
		$_var('typegarage').style.display = 'none';

		$_var('flat_type_enabled').style.display = 'none';
		$_var('lodge_type_enabled').style.display = 'none';
		$_var('garage_type_enabled').style.display = 'none';

		$_var('rooms_count_show').style.display = 'none';
		break;
	}
}
////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////
//
//	Обработка Question
//
////////////////////////////////////////////////////////////////////////////////
function Question_OnClick () {

	if ( $(formQuestion.question).val() == "Ваш вопрос" )
	$(formQuestion.question).val("");

	$ ( "#QSend" ).html ( "" );

}
function Question_OnBlur () {

	if ( $(formQuestion.question).val() == "" )
	$(formQuestion.question).val("Ваш вопрос");

	$ ( "#QSend" ).html ( "" );

}
function Question_Submit () {

	if ( $(formQuestion.question).val() == "" || $(formQuestion.question).val() == "Ваш вопрос" ) {

		alert ( "Введите ваш вопрос" );

	} else {

		JsHttpRequest.query(
		"/questions/",
		{
			"question": $(formQuestion.question).val()
		},
		function(result, errors) {

			$ ( "#QSend" ).html ( "<b>Вопрос отправлен</b>" );

		},
		false
		);

	}

}
////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////
//
//	Обработка Poll
//
////////////////////////////////////////////////////////////////////////////////
var poll_ans = 0;
function Poll_Submit () {

	if ( poll_ans == 0 ) {

		poll_ans = 1;
		var t_poll_id = $(formPoll.poll_id).val();
		var t_arr = $(formPoll.answer);
		var t_flag = false;

		for ( var i = 0; i < t_arr.length; i++ ) {

			if ( t_arr[i].checked == true ) {
				t_flag = true;
				ans = t_arr[i].value;
				continue;
			}

		}

		if ( t_flag == false ) {

			alert ("Необходимо ответить на вопрос");

		} else {

			JsHttpRequest.query(
			"/poll/",
			{
				"poll_id": t_poll_id,
				"ans_id":  ans
			},
			function(result, errors) {
				var f = $("#fieldPoll_body");
				f.fadeOut("slow", function(){
					f.html(result);
					f.fadeIn("slow");
				});
			},
			false
			);

		}

	}

}
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
//
//	Обработка подписки
//
////////////////////////////////////////////////////////////////////////////////

function Subscribe_Submit() {

	if ($(formSubscribe.subscribe).val() != "" && $(formSubscribe.subscribe).val() != "ваш e-mail") {

		JsHttpRequest.query(
		"/subscribe/",
		{
			"email": $(formSubscribe.subscribe).val()
		},
		function(result, errors) {

			$ ( "#SubRes" ).html ( "<b>Адрес добавлен</b>" );

		},
		false
		);


	} else {

		alert("Укажите электронный адрес");

	}

}

///////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
//
//	Динамический показ домов КПД-2
//
////////////////////////////////////////////////////////////////////////////////
function KPD_DynamicHouse () {

	var h1 = random ( 1, 4 );
	var h2 = random ( 1, 4 );

	var table = $ ( "TABLE.table1kpd2" )[0];
	table.style.backgroundImage = "url(/files/image/a"+h1+".gif)";
	var td = $ ( "TD.td1kpd2" )[0];
	td.style.backgroundImage = "url(/files/image/b"+h2+".gif)";

}
////////////////////////////////////////////////////////////////////////////////


$j = jQuery.noConflict();

$j(document).ready(function(){

	$j("#banner-stat").click(function () {

		$j.ajax({
			url: "/handler/banners.handler.php",
			type: "POST",
			data: ({
				types : $j(this).attr("size")
			}),
			success: function(msg){

			}
		});

	});

});


////////////////////////////////////////////////////////////////////////////////
//
//	Квадратный баннер 150x150 (внизу слева)
//
////////////////////////////////////////////////////////////////////////////////
Banner150_left = function () {
	document.writeln('<div style="z-index:50;">');
	document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
	document.writeln('codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"');
	document.writeln('width="150" height="150">');
	document.writeln('<param name="movie" value="'+PATH_SKIN_FLASH+'sit150.swf">');
	document.writeln('<param name="quality" value="high">');
	document.writeln('<PARAM NAME="wmode" VALUE="opaque">');
	document.writeln('<embed src="'+PATH_SKIN_FLASH+'sit150.swf" quality="high" wmode="opaque" pluginspage="http://www.macromedia.com/go/getflashplayer"');
	document.writeln('type="application/x-shockwaveflash"');
	document.writeln('width="150" height="150">');
	document.writeln('</embed>');
	document.writeln('</object>');
	document.writeln('</div>');
}

Banner150_right = function () {
	document.writeln('<div style="z-index:50;">');
	document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
	document.writeln('codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"');
	document.writeln('width="150" height="150">');
	document.writeln('<param name="movie" value="'+PATH_SKIN_FLASH+'strinjt.swf">');
	document.writeln('<param name="quality" value="high">');
	document.writeln('<PARAM NAME="wmode" VALUE="opaque">');
	document.writeln('<embed src="'+PATH_SKIN_FLASH+'strinjt.swf" quality="high" wmode="opaque" pluginspage="http://www.macromedia.com/go/getflashplayer"');
	document.writeln('type="application/x-shockwaveflash"');
	document.writeln('width="150" height="150">');
	document.writeln('</embed>');
	document.writeln('</object>');
	document.writeln('</div>');
}

////////////////////////////////////////////////////////////////////////////////
//
//	Неквадратный баннер 179x110 (вверху справа)
//
////////////////////////////////////////////////////////////////////////////////
Banner110 = function () {
	document.writeln('<div style="z-index:50;">');
	document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
	document.writeln('codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"');
	document.writeln('width="179" height="110">');
	document.writeln('<param name="movie" value="'+PATH_SKIN_FLASH+'ACTION2.swf">');
	document.writeln('<param name="quality" value="high">');
	document.writeln('<PARAM NAME="wmode" VALUE="opaque">');
	document.writeln('<embed src="'+PATH_SKIN_FLASH+'ACTION2.swf" quality="high" wmode="opaque" pluginspage="http://www.macromedia.com/go/getflashplayer"');
	document.writeln('type="application/x-shockwaveflash"');
	document.writeln('width="170" height="110">');
	document.writeln('</embed>');
	document.writeln('</object>');
	document.writeln('</div>');
}
////////////////////////////////////////////////////////////////////////////////
//
//	Неквадратный баннер 468x60 (вверху в центре)
//
////////////////////////////////////////////////////////////////////////////////
/*Banner60 = function (name) {

	document.writeln('<div style="z-index:50;" id="banner-stat" size="60">');
	document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
	document.writeln('codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"');
	document.writeln('width="468" height="60">');
	document.writeln('<param name="movie" value="'+PATH_SKIN_FLASH+'prometey.swf">');
	document.writeln('<param name="quality" value="high">');
	document.writeln('<param name="wmode" value="opaque">');
	document.writeln('<embed src="'+PATH_SKIN_FLASH+'prometey.swf" quality="high" wmode="opaque" pluginspage="http://www.macromedia.com/go/getflashplayer"');
	document.writeln('type="application/x-shockwaveflash"');
	document.writeln('width="468" height="60">');
	document.writeln('</embed>');
	document.writeln('</object>'); 

	document.writeln('</div>');
}*/
Banner60 = function (name) {

	document.writeln('<div style="z-index:50;" id="banner-stat" size="60">');
	document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
	document.writeln('codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"');
	document.writeln('width="468" height="60">');
	//document.writeln('<param name="movie" value="'+PATH_SKIN_FLASH+'ultop_468x60.swf">');
	document.writeln('<param name="movie" value="/images/banners/ultop_468x60.swf">');
	document.writeln('<param name="quality" value="high">');
	document.writeln('<param name="wmode" value="opaque">');
	//document.writeln('<embed src="'+PATH_SKIN_FLASH+'ultop_468x60.swf" quality="high" wmode="opaque" pluginspage="http://www.macromedia.com/go/getflashplayer"');
	document.writeln('<embed src="/images/banners/ultop_468x60.swf" quality="high" wmode="opaque" pluginspage="http://www.macromedia.com/go/getflashplayer"');
	document.writeln('type="application/x-shockwaveflash"');
	document.writeln('width="468" height="60">');
	document.writeln('</embed>');
	document.writeln('</object>'); 

	document.writeln('</div>');
}
Banner60_static = function (path, link, name) {
	document.writeln('<div style="z-index:50;" id="banner-stat" size="'+name+'">');
	document.writeln('<a href="'+link+'"><img src="'+path+'"></a>')
	document.writeln('</div>');
}
////////////////////////////////////////////////////////////////////////////////

Banner200 = function () {
	document.writeln('<div style="z-index:51;">');
	document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
	document.writeln('codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"');
	document.writeln('width="200" height="100">');
	document.writeln('<param name="movie" value="'+PATH_SKIN_FLASH+'latil.swf">');
	document.writeln('<param name="quality" value="high">');
	document.writeln('<param name="wmode" value="opaque">');
	document.writeln('<embed src="'+PATH_SKIN_FLASH+'latil.swf" quality="high" wmode="opaque" pluginspage="http://www.macromedia.com/go/getflashplayer"');
	document.writeln('type="application/x-shockwaveflash"');
	document.writeln('width="200" height="100">');
	document.writeln('</embed>');
	document.writeln('</object>');
	document.writeln('</div>');
}

Banner200_static = function (path, url , desc) {
	document.writeln('<div style="z-index:51;">');
	document.writeln('<a href="'+url+'" target="_blank"><img src="'+path+'" alt="'+desc+'"></a>');
	document.writeln('</div>');
}


Banner200_200 = function () {
	document.writeln('<div style="z-index:51;">');
	document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
	document.writeln('codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"');
	document.writeln('width="200" height="200">');
	document.writeln('<param name="movie" value="'+PATH_SKIN_FLASH+'im_estate.swf">');
	document.writeln('<param name="quality" value="high">');
	document.writeln('<param name="wmode" value="opaque">');
	document.writeln('<embed src="'+PATH_SKIN_FLASH+'im_estate.swf" quality="high" wmode="opaque" pluginspage="http://www.macromedia.com/go/getflashplayer"');
	document.writeln('type="application/x-shockwaveflash"');
	document.writeln('width="200" height="200">');
	document.writeln('</embed>');
	document.writeln('</object>');
	document.writeln('</div>');
}

////////////////////////////////////////////////////////////////////////////////


function expandBlock ( id ) {

	$(id).slideToggle("slow");

}
Array.prototype.in_array = function ( elem ) {

	var i, listed = false;

	for (i = 0; i < this.length; i++) {

		if ( this[i] == elem ) {

			listed = true;
			break;

		}

	}

	return listed;

};

Array.prototype.getIndex = function ( elem ) {

	var i, index = -1;

	for (i = 0; i < this.length; i++) {

		if ( this[i] == elem ) {

			index = i;
			break;

		}

	}

	return index;

};

function trim(str, chars) {

	return ltrim(rtrim(str, chars), chars);

}

function ltrim(str, chars) {

	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");

}

function rtrim(str, chars) {

	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");

}


function round ( value, cnt ) {

	var pw = Math.pow ( 10, cnt );

	return Math.round ( value * pw ) / pw;

}


function random ( a, b ) {

	var num = Math.round ( Math.random () * b );
	while ( a > num )
	num = Math.round ( Math.random () * b );

	return num;

}

function DalexSend () {

	if ($(dalexQuestion.surname).val() != "" && $(dalexQuestion.email).val() != "" && $(dalexQuestion.question).val() != "") {

		JsHttpRequest.query(
		"/stands/dalex/ask/",
		{
			"section": $(dalexQuestion.section).val(),
			"surname": $(dalexQuestion.surname).val(),
			"name": $(dalexQuestion.name).val(),
			"patronymic": $(dalexQuestion.patronymic).val(),
			"spec": $(dalexQuestion.spec).val(),
			"company": $(dalexQuestion.company).val(),
			"address": $(dalexQuestion.address).val(),
			"phone": $(dalexQuestion.phone).val(),
			"email": $(dalexQuestion.email).val(),
			"question": $(dalexQuestion.question).val()
		},
		function(result, errors) {
			$ ( dalexQuestion ).html ( "<b>Вопрос отправлен</b>" );
		},
		false
		);
	} else {
		alert("Заполните поля");
	}
}


var date = new Date();

mm = date.getMonth() + 1;

yy = date.getFullYear();

function Year(res) {

	if (res == "1") {

		yy = yy + 1;

		JsHttpRequest.query(
		"handler/calendar/FunctionActionCalendar.inc.php",
		{
			year : yy,
			month: mm
		},
		function(result, errors) {

			document.getElementById("ActionCalendar").innerHTML = result;
			//alert(result);
		},
		false
		);

		return false;

	}

	if (res == "-1") {

		yy = yy - 1;

		JsHttpRequest.query(
		"handler/calendar/FunctionActionCalendar.inc.php",
		{
			year : yy,
			month: mm
		},
		function(result, errors) {

			document.getElementById("ActionCalendar").innerHTML = result;
			//alert(result);
		},
		false
		);

		return false;
	}

}

function Month(res) {

	if (res == "1") {

		mm = mm + 1;

		if ( mm > 12 ) {

			mm = 1;

			yy++;
		}

		JsHttpRequest.query(
		"handler/calendar/FunctionActionCalendar.inc.php",
		{
			year : yy,
			month: mm
		},
		function(result, errors) {

			document.getElementById("ActionCalendar").innerHTML = result;
			//alert(result);
		},
		false
		);

		return false;

	}

	if (res == "-1") {

		mm = mm - 1;

		if ( mm < 1 ) {

			mm = 12;

			yy--;
		}


		JsHttpRequest.query(
		"handler/calendar/FunctionActionCalendar.inc.php",
		{
			year : yy,
			month: mm
		},
		function(result, errors) {

			document.getElementById("ActionCalendar").innerHTML = result;
			//alert(result);
		},
		false
		);

		return false;
	}

}

function ShowRubric() {

	if (document.getElementById("ListRubric").style.display == "none")

	document.getElementById("ListRubric").style.display = "block";

	else

	document.getElementById("ListRubric").style.display = "none";

}

function ShowPanel(id){

	if (document.getElementById("vacancy["+id+"]").style.display == "none") {

		document.getElementById("vacancy["+id+"]").style.display = "block";

	} else {

		document.getElementById("vacancy["+id+"]").style.display = "none";

	}

}

function DeleteVacancy (id) {

	if (confirm("Действительно хотите удалить?")) {

		JsHttpRequest.query(

		"/handler/delete_vacancy.handler.php",
		{
			id : id,
			password : document.getElementById("password["+id+"]").value
		},
		function(result, errors) {

			if (result == true) {

				location.href = location.href;
			}

		},
		false
		);

		return false;
	} else {

		document.getElementById("vacancy["+id+"]").style.display = "none";

	}
}


function Show(div) {


	if ($_var("" + div +"").style.display == "none")

	$_var("" + div + "").style.display = "block";

	else

	$_var("" + div + "").style.display = "none";

}



function AccountDeleteVacancy(id) {

	if (confirm("Действительно хотите удалить вакансию ?")) {

		JsHttpRequest.query(

		"/handler/delete_vacancy_account.handler.php",
		{
			id : id

		},
		function(result, errors) {

			if (result == true) {

				location.href = location.href;

			}

		},
		false
		);
	}
}

function AddResponse(id){

	if ($_var("text_response").value != "") {

		JsHttpRequest.query(

		"/handler/add_response_account.handler.php",
		{
			id : id,
			response : document.getElementById("text_response").value
		},
		function(result, errors) {

			if (result == true) {

				document.getElementById("response_"+id+"").innerHTML = "Ваш отклик успешно отправлен";
			}

		},
		false
		);

	}else {

		alert("Введите ваш комментарий");
	}

}


function AccountUpdate(){

	JsHttpRequest.query(

	"/handler/account_update.handler.php",
	{
		reg_email 	: $_var("reg_email").value,
		reg_phone	: $_var("reg_phone").value,
		firm_id		: $_var("firm_id").value,
		name		: $_var("name").value,
		address		: $_var("address").value,
		info		: $_var("info").value,
		phone		: $_var("phone").value,
		email		: $_var("email").value,
		description	: $_var("description").value

	},
	function(result, errors) {

		if (result == true) {

			location.href = location.href;

		}

	},
	false
	);

}

function AccountDeleteTender(id){

	if (confirm("Действительно хотите удалить тендер ?")) {

		JsHttpRequest.query(

		"/handler/delete_tender_account.handler.php",
		{
			id : id

		},
		function(result, errors) {

			if (result) {

				location.href = location.href;

			}

		},
		false
		);
	}

}

function AccountEndTender(id) {

	if (confirm("Действительно хотите завершить тендер ?")) {

		JsHttpRequest.query(

		"/handler/finish_tender_account.handler.php",
		{
			id : id

		},
		function(result, errors) {

			if (result) {

				location.href = location.href;

			}

		},
		false
		);
	}


}


function AccountDeleteEstate(id) {

	if (confirm("Действительно хотите удалить объект ?")) {

		JsHttpRequest.query(

		"/handler/delete_estate_account.handler.php",
		{
			id : id

		},
		function(result, errors) {

			if (result == true) {

				location.href = location.href;

			}

		},
		false
		);
	}

}


function $_var(id) { return document.getElementById(id); }


function AddAttachment() {
	i++;

	var str = "";

	str += "<input type='file' class='file' id='file["+i+"]'><br>";

	$_var("attachment").innerHTML += ""+str+"";

}


function AccountAddVacancy(){

	if ($_var("company_use").value != "" && $_var("city_use").value != "" && $_var("phone_use").value != "" && $_var("spec_use").value != "") {

		JsHttpRequest.query(

		"/handler/add_vacancy_account.handler.php",
		{

			company		: $_var("company_use").value,
			city		: $_var("city_use").value,
			address		: $_var("address").value,
			phone_use	: $_var("phone_use").value,
			email		: $_var("email").value,
			contact		: $_var("contact").value,
			spec_use	: $_var("spec_use").value,
			salary		: $_var("salary").value,
			character_id: $_var("character_id").value,
			timetable_id: $_var("timetable_id").value,
			description : $_var("description").value

		},
		function(result, errors) {

			if (result == true) {

				location.href = location.href;
			}

		},
		false
		);
	} else{

		alert("Необходимо заполнить обязательные поля");
	}

}

function AccountAddTender(){

	if ($_var("type").value != "" && $_var("tender").value != "" && $_var("cost").value != "" && $_var("contact").value != "" && $_var("address").value != "" && $_var("phone").value != "" && $_var("email").value != "") {

		JsHttpRequest.query(

		"/handler/add_tender_account.handler.php",
		{
			type		: $_var("type").value,
			tender		: $_var("tender").value,
			cost		: $_var("cost").value,
			date_start 	: $_var("date_start").value,
			date_end 	: $_var("date_end").value,
			place	 	: $_var("place").value,
			srok		: $_var("srok").value,
			pay			: $_var("pay").value,
			pay_type	: $_var("pay_type").value,
			contact		: $_var("contact").value,
			address		: $_var("address").value,
			phone		: $_var("phone").value,
			email		: $_var("email").value

		},
		function(result, errors) {

			if (result == true) {

				location.href = location.href;
			}
		},
		false
		);

	} else {

		alert("Необходимо заполнить обязательные поля");

	}
}

function light(obj, classname) {

	$_var(""+obj+"").className = ""+classname+"";

}


function DisLight(obj, classname) {

	//$_var(""+obj+"").className = ""+classname+"";
}


but = {
	1:"rbut",
	2:"bbut",
	3:"gbut",
	4:"ybut",
	5:""
}

function StandDis(id, CntDiv) {

	if (id) {

		for (i=1; i<=CntDiv; i++) {

			if (i == id) {

				$_var("content_"+i+"").style.display = "block";
				if (but[i] != "")
				$_var(""+but[i]+"").className = ""+but[i]+"hover";

			} else {

				$_var("content_"+i+"").style.display = "none";
				if (but[i] != "")
				$_var(""+but[i]+"").className = ""+but[i]+"";
			}
		}

	}

}

/* ESTATE FUNCTIONS */



function SeletedObject(iobj){

	for (i = 1; i <= 9; i++)	{

		if ( i == iobj)

		document.getElementById("obj_"+iobj+"").style.color = "red";

		else

		document.getElementById("obj_"+i+"").style.color = "#0072bc";

	}
}

function SeletedOp(iobj){

	for (i = 1; i <= 4; i++)	{

		if ( i == iobj)

		document.getElementById("op_"+iobj+"").style.color = "red";

		else

		document.getElementById("op_"+i+"").style.color = "#0072bc";

	}
}

arr_param_id_box = {
	1:"param_district",
	2:"param_street",
	3:"param_price",
	4:"param_period",
	5:"param_room",
	6:"param_area",
	7:"param_garage",
	8:"param_type",
	9:"param_types",
	10:"param_typeg",
	11:"param_material",
	12:"param_floor",
	13:"param_count_floor",
	14:"param_water",
	15:"param_warm",
	16:"param_part",
	17:"param_lot",
	18:"param_year",
	19:"param_status",
	20:"param_notice_2",
	21:"param_notice_3",
	22:'param_description'
};

function SelectOp(iop) {

	document.getElementById("op").value = iop;

	iobj = document.getElementById("obj").value;

	SeletedOp(iop);

	document.getElementById("select_block").style.display = "none";
	//document.getElementById("photo_block").style.display = "none";
}


function SelectObject(iobj) {

	document.getElementById("obj").value = iobj;

	iop = document.getElementById("op").value;

	SeletedObject(iobj);

	document.getElementById("select_block").style.display = "block";

	if (iop) {

		Block(iop, iobj);

	} else {

		alert("Необходмо выбрать раздел");
	}

}

function Block(iop, iobj){


	for(var k in arr_param_id_box)
	{
		document.getElementById(arr_param_id_box[k]).style.display = "none";
	}

	arr_param_obj = new Array();

	switch(iobj) {

		case '1': // flat
		if (iop == 1) arr_param_obj=new Array(1,2,3,5,6,8,11,12,14,18,19,20);
		if (iop == 2) arr_param_obj=new Array(22);
		if (iop == 3) arr_param_obj=new Array(1,2,3,4,5,6,8,11,12,14,18,19,21);
		if (iop == 4) arr_param_obj=new Array(22);
		break;

		case '2': // room
		if (iop == 1) arr_param_obj=new Array(1,2,3,6,8,11,12,14,18,19,20);
		if (iop == 2) arr_param_obj=new Array(22);
		if (iop == 3) arr_param_obj=new Array(1,2,3,4,6,8,11,12,14,18,19,21);
		if (iop == 4) arr_param_obj=new Array(22);
		break;

		case '3': // kgt
		if (iop == 1) arr_param_obj=new Array(1,2,3,6,8,11,12,14,18,19,20);
		if (iop == 2) arr_param_obj=new Array(22);
		if (iop == 3) arr_param_obj=new Array(1,2,3,4,6,8,11,12,14,18,19,21);
		if (iop == 4) arr_param_obj=new Array(22);
		break;

		case '4': // cottage
		if (iop == 1) arr_param_obj=new Array(1,2,3,6,11,13,14,15,16,17,18,19,20);
		if (iop == 2) arr_param_obj=new Array(22);
		if (iop == 3) arr_param_obj=new Array(1,2,3,6,11,13,14,15,16,17,18,19,20,21);
		if (iop == 4) arr_param_obj=new Array(22);
		break;

		case '5': // house
		if (iop == 1) arr_param_obj=new Array(1,2,3,6,11,14,15,16,17,18,19,20);
		if (iop == 2) arr_param_obj=new Array(22);
		if (iop == 3) arr_param_obj=new Array(1,2,3,4,6,11,14,15,16,17,18,19,21);
		if (iop == 4) arr_param_obj=new Array(22);
		break;

		case '6': // store
		if (iop == 1) arr_param_obj=new Array(1,2,3,6,9,19,20);
		if (iop == 2) arr_param_obj=new Array(22);
		if (iop == 3) arr_param_obj=new Array(1,2,3,4,6,9,19,21);
		if (iop == 4) arr_param_obj=new Array(22);
		break;

		case '7': // soil
		if (iop == 1) arr_param_obj=new Array(1,2,3,17,20);
		if (iop == 2) arr_param_obj=new Array(22);
		if (iop == 3) arr_param_obj=new Array(1,2,3,4,17,21);
		if (iop == 4) arr_param_obj=new Array(22);
		break;

		case '8': // garage
		if (iop == 1) arr_param_obj=new Array(1,2,3,7,10,19,20);
		if (iop == 2) arr_param_obj=new Array(22);
		if (iop == 3) arr_param_obj=new Array(1,2,3,4,7,10,19,21);
		if (iop == 4) arr_param_obj=new Array(22);
		break;

		case '9': // dacha
		if (iop == 1) arr_param_obj=new Array(1,2,3,17,19,20);
		if (iop == 2) arr_param_obj=new Array(22);
		if (iop == 3) arr_param_obj=new Array(1,2,3,4,17,19,21);
		if (iop == 4) arr_param_obj=new Array(22);
		break;
	}

	for(var j in arr_param_obj) {

		if (document.getElementById(arr_param_id_box[arr_param_obj[j]]) != null)
		{
			document.getElementById(arr_param_id_box[arr_param_obj[j]]).style.display = "block";
		}
	}


	if ((iop == 2) || (iop == 4))
	{
		document.getElementById("param_description").style.display = "block";
	}

}


function AddEstate(){

}

function Estate_CheckFill()
{
	//Обязательно для всех
	if ((document.getElementById('op').value!='')&&(document.getElementById('obj').value!=''))
	{
		if ((document.getElementById('op').value=='1')||(document.getElementById('op').value=='3'))
		{
			if (document.getElementById('district').value=='0')
			{
				return 'Не заполнено поле "Район"';
			}

			if (document.getElementById('contacts').value=='')
			{
				return 'Не заполнено поле "Телефон"';
			}

			if (document.getElementById('street').value=='')
			{
				return 'Не заполнено поле "Улица"';
			}

			//необязательные поля
			if (document.getElementById('obj').value=='1')
			{
				if (document.getElementById('room').value=='0')
				{
					return 'Не указано количество комнат';
				}

				if (document.getElementById('type').value=='0')
				{
					return 'Не указан тип дома';
				}
			}

			if (document.getElementById('obj').value=='2')
			{
				if (document.getElementById('type').value=='0')
				{
					return 'Не указан тип дома';
				}
			}

			if (document.getElementById('obj').value=='3')
			{
				if (document.getElementById('type').value=='0')
				{
					return 'Не указан тип дома';
				}
			}

			if (document.getElementById('obj').value=='6')
			{
				if (document.getElementById('types').value=='0')
				{
					return 'Не указан тип помещения';
				}

			}
		}
		else
		{
			if (document.getElementById('contacts').value=='')
			{
				return 'Не заполнено поле "Телефон"';
			}
		}
	}
	else
	{
		return 'Не выбран раздел или тип объекта'
	}

	return '';
}

function Preview(id, url) {

	document.getElementById("preview["+id+"]").src = "/files/estate/"+url;

}

function SelectT(){

	if (document.getElementById("l").seletedIndex != 0)

	document.getElementById("t").style.display = "block";
}

function SelectEstate(){

	location.href = "?l="+ document.getElementById("l").value +"&t="+ document.getElementById("t").value +"";

}

arr_param_lodge = {
	1:"1",
	2:"1",
	3:"1",
	4:"3",
	5:"3",
	6:"2",
	7:"2",
	8:"2",
	9:"2"
}

function SelectEstate(){

	var div = arr_param_lodge[document.getElementById("l").value];

	if (div == 1) {
		document.getElementById("estate_1").style.display = "block";
		document.getElementById("estate_2").style.display = "none";
	} else if (div == 2)  {
		document.getElementById("estate_1").style.display = "none";
		document.getElementById("estate_2").style.display = "block";
	}

}



function LogoPreview() {

	document.getElementById("site_logo_preview").src ="";

}

function ReturnColor(color, div){

	document.getElementById(""+div+"").value = color;
}

function ApplySite (){

	document.getElementById("site").style.background 	= document.getElementById("site_bgcolor_param").value;
	document.getElementById("site").style.width	  	= document.getElementById("site_width_param").value;
	document.getElementById("site").style.height	  	= document.getElementById("site_height_param").value;
	document.getElementById("site").style.backgroundImage = "url(/files/profile/logo/"+document.getElementById("site_background_params").value+")";

	document.getElementById("site_domain").value		= document.getElementById("site_domain_param").value;
	document.getElementById("site_name").value		= document.getElementById("site_name_param").value;
	document.getElementById("site_background").value	= document.getElementById("site_background_params").value;
	document.getElementById("site_bgcolor").value 	= $_var("site_bgcolor_param").value;
	document.getElementById("site_width").value 		= document.getElementById("site_width_param").value;
	document.getElementById("site_height").value 		= document.getElementById("site_height_param").value;

	SiteSave();
}


function ApplySiteTitle (){

	document.getElementById("site_title").innerHTML 			= document.getElementById("title_name_param").value;
	document.getElementById("site_title").style.background 	= document.getElementById("title_bgcolor_param").value;
	document.getElementById("site_title").style.color 		= document.getElementById("title_fgcolor_param").value;
	document.getElementById("site_title").style.fontFamily	= document.getElementById("title_font_param").value;
	document.getElementById("site_title").style.fontSize		= document.getElementById("title_size_param").value;

	document.getElementById("title_name").value 	 =  document.getElementById("title_name_param").value;
	document.getElementById("title_font").value 	 =  document.getElementById("title_font_param").value;
	document.getElementById("title_size").value 	 =  document.getElementById("title_size_param").value;
	document.getElementById("title_bgcolor").value =  document.getElementById("title_bgcolor_param").value;
	document.getElementById("title_fgcolor").value =  document.getElementById("title_fgcolor_param").value;

	TitleSave();
}


function UploadImage (input_name) {

	JsHttpRequest.query(

	"/handler/upload_files.handler.php",
	{
		file : document.getElementById(""+input_name+"")

	},
	function(result, errors) {

		if (result) {

			document.getElementById("site_background_params").value = result;

			document.getElementById("logo_src").value = result;

			document.getElementById(input_name+"_preview").style.backgroundImage = "url(/files/profile/logo/" + result + ")";
		}

	},
	false
	);
}

function ResetBackground(){

	document.getElementById("site").style.backgroundImage 	= "";
	document.getElementById("site_background_params").value 	= "";
	document.getElementById("site_background_param_preview").style.backgroundImage = "";

}

function ApplySiteMenu (){

	for (i=1; i<=4; i++) {

		if (document.getElementById("site_menu_param_"+i+"").checked == true) {

			document.getElementById("a_menu_"+i+"").style.color 		= document.getElementById("menu_fgcolor_param").value;

			document.getElementById("a_menu_"+i+"").style.fontFamily	= document.getElementById("menu_font_param").value;

			document.getElementById("a_menu_"+i+"").style.fontSize	= document.getElementById("menu_size_param").value;

			document.getElementById("site_menu_"+i+"").style.display = "block";

			document.getElementById("menu_value_"+i+"").value = document.getElementById("site_menu_value_"+i+"").value;

			document.getElementById("menu_font").value = document.getElementById("menu_font_param").value;

			document.getElementById("menu_size").value = document.getElementById("menu_size_param").value;

			document.getElementById("menu_fgcolor").value = document.getElementById("menu_fgcolor_param").value;

		} else {

			document.getElementById("site_menu_"+i+"").style.display = "none";

			document.getElementById("menu_value_"+i+"").value = document.getElementById("site_menu_value_"+i+"").value;
		}
	}


	MenuSave();
}

function ApplySiteContent () {

	var content_id = document.getElementById("content_menu_param").value;

	document.getElementById("content_param_value_"+content_id+"").value = document.getElementById("contents").value;

	document.getElementById("site_content").innerHTML = document.getElementById("content_param_value_1").value;

	ContentSave();
}

function SelectMenuContent () {

	var content_id = document.getElementById("content_menu_param").value;

	document.getElementById("contents").value = document.getElementById("content_param_value_"+content_id+"").value;

	if (content_id == 3) {

		document.getElementById("category_text").style.display = "none";
		document.getElementById("category_portfolio").style.display = "block";

	} else {

		document.getElementById("category_text").style.display = "block";
		document.getElementById("category_portfolio").style.display = "none";

	}

}

function ApplySiteContact () {

	document.getElementById("contact_address").value = document.getElementById("contact_address_param").value;
	document.getElementById("contact_phone").value = document.getElementById("contact_phone_param").value;
	document.getElementById("contact_email").value = document.getElementById("contact_email_param").value;
	document.getElementById("contact_www").value = document.getElementById("contact_www_param").value;

	document.getElementById("contacts").innerHTML = document.getElementById("contact_address_param").value
	document.getElementById("phone").innerHTML = document.getElementById("contact_phone_param").value
	document.getElementById("email").innerHTML = document.getElementById("contact_email_param").value
	document.getElementById("www").innerHTML = document.getElementById("contact_www_param").value

	ContactSave();
}

/**/

function SiteSave(){

	JsHttpRequest.query(

	"/handler/site_save.handler.php",
	{
		site_domain   	: $_var("site_domain").value,
		site_name   	: $_var("site_name").value,
		site_width  	: $_var("site_width").value,
		site_height 	: $_var("site_height").value,
		site_bgcolor 	: $_var("site_bgcolor").value,
		site_background : $_var("site_background").value,
		site_border 	: $_var("site_border").value

	},
	function(result, errors) {

		//alert(result);
		alert("Сохранено");

	},
	false
	);

}



function TitleSave() {

	JsHttpRequest.query(

	"/handler/title_save.handler.php",
	{
		site_id		: $_var("site_id").value,
		title_name	: $_var("title_name").value,
		title_font	: $_var("title_font").value,
		title_size	: $_var("title_size").value,
		title_bgcolor: $_var("title_bgcolor").value,
		title_fgcolor: $_var("title_fgcolor").value

	},
	function(result, errors) {

		//alert(result);
		alert("Сохранено");

	},
	false
	);

}

function MenuSave () {

	JsHttpRequest.query(

	"/handler/menu_save.handler.php",
	{
		site_id		: $_var("site_id").value,
		menu_font	: $_var("menu_font").value,
		menu_size	: $_var("menu_size").value,
		menu_fgcolor: $_var("menu_fgcolor").value,
		menu_value_1: $_var("menu_value_1").value,
		menu_value_2: $_var("menu_value_2").value,
		menu_value_3: $_var("menu_value_3").value,
		menu_value_4: $_var("menu_value_4").value,
		menu_param_1: $_var("site_menu_param_1").checked,
		menu_param_2: $_var("site_menu_param_2").checked,
		menu_param_3: $_var("site_menu_param_3").checked,
		menu_param_4: $_var("site_menu_param_4").checked

	},
	function(result, errors) {

		//alert(result);
		alert("Сохранено");

	},
	false
	);

}

function ContentSave () {


	JsHttpRequest.query(

	"/handler/content_save.handler.php",
	{
		site_id			: $_var("site_id").value,
		content_value_1 : $_var("content_param_value_1").value,
		content_value_2 : $_var("content_param_value_2").value,
		content_value_3 : $_var("content_param_value_3").value,
		content_value_4 : $_var("content_param_value_4").value

	},
	function(result, errors) {

		//alert(result);
		alert("Сохранено");

	},
	false
	);
}

function ContactSave () {


	JsHttpRequest.query(

	"/handler/contact_save.handler.php",
	{
		site_id	: $_var("site_id").value,
		address	: $_var("contact_address").value,
		phone	: $_var("contact_phone").value,
		email	: $_var("contact_email").value,
		www		: $_var("contact_www").value
	},
	function(result, errors) {

		//alert(result);
		alert("Сохранено");

	},
	false
	);
}

function SelectCategory(id){

	if (id != 3) {

		JsHttpRequest.query(

		"/handler/select_category.handler.php",
		{
			category_id	: id,
			site_id		: $_var("site_id").value

		},
		function(result, errors) {

			if (result) {

				$_var("site_content").innerHTML = result;
			}

		},
		false
		);
	} else {

		JsHttpRequest.query(

		"/handler/select_portfolio.php",
		{
			category_id	: id

		},
		function(result, errors) {

			if (result) {

				$_var("site_content").innerHTML = result;
			}

		},
		false
		);

	}
}

function CheckAll() {

	for (i = 1; i <= $_var("cEl").value; i++){

		if (!$_var("dEl["+i+"]").checked) {

			$_var("dEl["+i+"]").checked = true;

		} else{

			$_var("dEl["+i+"]").checked = false;
		}

	}

}

function PermitReg() {

	if ($_var("permit").checked&&login_correct&&email_correct&&password_correct&&($_var("reg_password").value==$_var("reg_repassword").value)){

		$_var("reg_button").disabled = false;
	} else {

		$_var("reg_button").disabled = true;
	}

}
