	function more_info(number_row)
	{
		var active_row = document.getElementById('car_' + number_row);
		if (active_row.className.indexOf(' active_row') == -1) {
			active_row.className += ' active_row';
		} else {
			active_row.className = active_row.className.replace(' active_row', '');
		}
	}

	function hide_show(id)
	{
		var form = document.getElementById(id);
		if (!form.style.display || form.style.display == 'none') {
			form.style.display = 'block';
		} else {
			form.style.display = 'none';
		}
	}

	function xxx(form)
	{
		var active_field = '';
		if (form.tagName == 'SELECT') {
			active_field = form.name.replace('fields_filter[', '').replace(']', '');
		}
		while (form.tagName != 'FORM') {
			form = form.parentNode;
		}
		var id = document.getElementById('id_cat').value;
		var s = '';
		s += '|model=' + getSelectionValue(form, 'fields_filter[model]');
		s += '|motor=' + getSelectionValue(form, 'fields_filter[motor]');
		s += '|gearbox=' + getSelectionValue(form, 'fields_filter[gearbox]');
		s += '|color=' + getSelectionValue(form, 'fields_filter[color]');
		s += '|bodytype=' + getSelectionValue(form, 'fields_filter[bodytype]');
		s += '|price=' + getInputValue(form, 'fields_filter[bestprice][0]').replace(/\s/g, '') + '_' + getInputValue(form, 'fields_filter[bestprice][1]').replace(/\s/g, '');
		s += '_active_field=' + active_field;
		jQuery.ajax({
			url: '/umaps.getSearchField:' + id + s,
			method: 'get',
			complete:
				function(resp) {
					document.getElementById('inputz').innerHTML = resp.responseText;
					call_trackbar(resp.responseText);
				}
		});
	}

	function fix_price()
	{
		var price_min = document.getElementById('price_0');
		var price_max = document.getElementById('price_1');

		price_min.value = price_min.value.replace(/\s/g, '');
		price_max.value = price_max.value.replace(/\s/g, '');
	}

	function getSelectionValue(form, selectName)
	{
		var sel = false;
		for (var n = form.elements.length, i = 0; i < n; i++) {
			el = form.elements[i];
			if (el.name == selectName) {
				sel = el;
			}
		}

		if (sel) {
			return sel.options[sel.selectedIndex].value;
		} else {
			return sel;
		}
	}

	function getInputValue(form, inputName)
	{
		var inp = false;
		for (var n = form.elements.length, i = 0; i < n; i++) {
			el = form.elements[i];
			if (el.name == inputName) {
				inp = el;
			}
		}

		if (inp) {
			return inp.value;
		} else {
			return inp;
		}
	}

	function getValue(name)
	{
		var get = location.search;
		if (!get.length) {
			get = document.baseURI;
		}
		if (get) {
			var p0 = get.indexOf(name);
			if (p0 != -1) {
				p0 = get.indexOf('=', p0) + 1;
				var id = parseInt(get.substr(p0));
				if (isNaN(id)) {
					return '';
				} else {
					return id;
				}
			} else {
				return '';
			}
		} else {
			return '';
		}
	}


	function xxx_loading(id)
	{
		var s = '';
		s += '|model=' + getValue('model');
		s += '|motor=' + getValue('motor');
		s += '|gearbox=' + getValue('gearbox');
		s += '|color=' + getValue('color');
		s += '|bodytype=' + getValue('bodytype');
		s += '|price=' + getValue('bestprice%5D%5B0%5D') + '_' + getValue('bestprice%5D%5B1%5D');

		jQuery.ajax({
			url: '/umaps.getSearchField:' + id + s,
			method: 'get',
			complete:
				function(resp) {
					document.getElementById('inputz').innerHTML = resp.responseText;
					call_trackbar(resp.responseText);
				}
		});
	}


	function call_trackbar(text)
	{
		var min = parseInt(text.match(/bestprice]\[0\D+(\d+)/)[1]);
		var max = parseInt(text.match(/bestprice]\[1\D+(\d+)/)[1]);
		var all_min = parseInt(text.match(/all_min[^>]+>([\d|\s]+)/)[1].replace(/\s+/g, ''));
		var all_max = parseInt(text.match(/all_max[^>]+>([\d|\s]+)/)[1].replace(/\s+/g, ''));

		all_min = Math.floor(all_min / 1000) * 1000;
		all_max = (Math.floor(all_max / 1000) + 1) * 1000;

		trackbar.getObject('one').init({
			onMove : function() {
			},
			width : 212, // px
			leftLimit : all_min,
			leftValue : min,
			rightLimit : all_max,
			rightValue : max,
			roundUp : 1000, // unit of value
			nodeInit : 1
		}, 'price_bar');
	}

	function implode_phone(form)
	{
		var id = getInputValue(form, 'id_car');
		document.getElementById('phone_' + id).value = getInputValue(form, 'p1') + ' ' + getInputValue(form, 'p2') + ' ' + getInputValue(form, 'p3');
		return checkForm(form);
	}

	Number.prototype.formatMoney = function(c, d, t){
		var n = this, c = isNaN(c = Math.abs(c)) ? 2 : c, d = d == undefined ? "," : d, t = t == undefined ? "." : t, s = n < 0 ? "-" : "", i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
		return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
	};


	function reset_form()
	{
		var id = document.getElementById('id_cat').value;
		var s = '';
		s += '|model=';
		s += '|motor=';
		s += '|gearbox=';
		s += '|color=';
		s += '|bodytype=';
		s += '|price=_';

		jQuery.ajax({
			url: '/umaps.getSearchField:' + id + s,
			method: 'get',
			complete:
				function(resp) {
					document.getElementById('inputz').innerHTML = resp.responseText;
					call_trackbar(resp.responseText);
				}
		});
	}
