var ie = 0;
var ie6 = 0;

var is_user = 0;
var is_admin = 0;
var yaNumCounter4site = 0;

var page_from = 1;
//================
$(function() {
  _BtnCompareProp();
  _MenuFloatLeft();
  _MenuFloatSimple($('.menu_top'));
  _MenuFloatSimple($('#menu_p'));
  _MenuFloatSimple($('.menu_in_header'));

  show_our_title ();  // обрабатываем все ps_title на странице, какие найдем

  $('INPUT.mark_input').dblclick(function() {this.select();});

// Логика поведения вкладок в карточке товара
	$("#insets_index DIV").hover(
		function(event) {$(this).toggleClass("over");},
		function(event) {$(this).toggleClass("over");}
	);
  $("#insets_index DIV").click(
  	function(event) {
  		$('#insets_index div').attr('class','');
  		$(this).attr('class','sel');
  		$('.insets_body DIV[id^=inset]').hide();
  		$('.insets_body DIV#inset' + $(this).attr('id')).css('display','block');
  		$('.catalog_up').css('clear','both').css('clear','none'); // чтобы полоска в ИЕ отпрыгивала вниз
  	}
  );
// Первый заголовок в статьях - без отступа
	$('#article').children(':header:first').css('margin-top','0');

// Подкраска формы поиска желтеньким, чтобы видно было
  if ($('#form_search .search_str').val()) {form_search_recolor ();}
  $('#form_search .search_str').click(form_search_recolor);

// Делаем отступ в блоке свойств товаров снизу. А когда с нами случится CSS3, то можно будет это делать в стилевой таблице! :-)
  $('#prop_block_table TR:last-child TD').css('padding-bottom','7px');

// Пыталась сделать, чтобы в хроме меню вело себя прилично, но поломалась опера, закомментировала
//  if($.browser.safari || $.browser.mozilla){
//  	$('#menu_p UL UL').css('top', '26px');
//  	$('#menu_p #btn_bask UL').css('top', '21px');
//  }

  MenuCatalogOpen();

// дрыгание и подсвечивание кнопок в типичных формах (для btn_str убрано)
	$('.form_main INPUT.btn').not($('.form_main INPUT.btn_str')).hover(
		function(event){$(this).addClass('btn_hover')},
		function(event){$(this).removeClass('btn_hover')}
	)
	$('#switch_style_print').click(StylePrint);

// переключение форм для новых и старых клиентов в оформлении заказа
  $('#tbl_reg label.switch').click(function(){
  	$('#tbl_reg FORM').hide();
  	$($('#tbl_reg FORM').get($('#tbl_reg LABEL').index(this))).show();
  	$('#tbl_reg FORM').height();
		$('.catalog_up').css('clear','both').css('border-top','solid 1px #fff'); // чтобы полоска в ИЕ отпрыгивала вниз
  	$('#content_text').css('background','#fff'); // чтобы полоска в ИЕ отпрыгивала вниз
  })

// для RUPOOL - выпадающий список городов
  $('#select_city').hover(
		function(event){$(this).find('#city_div').show()},
		function(event){$(this).find('#city_div').hide()}
	)

  $('#prop_block TD.ul_big').hover(
		function(event){ $(this).find('UL').css({
					'position': 'absolute',
					'background': '#f9f9f9',
					'border-color': '#BBBBBB'})
			.animate({height: $(this).find('LI').size() * 16},300) },
		function(event){ $(this).find('UL').animate(
			{height: 60},
			300,
			function(){$(this).css({'border-color': '#fff', 'background': '#fff'})}) }
	)

	$('.textarea_elastic TEXTAREA').elastic();
	$('.elastic').elastic();

// объединение строк в таблицу для показа реквизитов юридического лица и доставки
	$('.only_jur').wrapAll('<tr class="tr_dop"><td colspan=2><table></table></td></tr>');
	$('.only_delivery').wrapAll('<tr class="tr_dop" id="tr_delivery"><td colspan=2><table></table></td></tr>');
	$('#tr_person_type').add('#tr_deliv_title').find('TD.txt').remove().end().find('TD').attr('colspan','2');

// перекрашивание обязательных input-ов на фокус и открывание доставки, когда выходим из телефона
	$('INPUT.required')
		.bind('focus', function(event){$(this).css('background','#fff')})
		.bind('blur',	function(event){
			if ($(this).val() == '') {$(this).css('background','#fffee4')}
			else if  ($(this).attr('id') == 'input_phone' && !$('INPUT[name=deliv_title]').is(':checked')) {
					$('INPUT[name=deliv_title]').trigger('click');
			}
		})
		.each(function(){if ($(this).val() != '') {$(this).css('background','#fff')}})

// если стоит галочка, то соответствущий кусок таблицы открываем
	$('INPUT[name=person_type]').add($('INPUT[name=deliv_title]')).filter(":checked").addClass('vis').next('LABEL').css('border','none').end().parents('TR').next('TR.tr_dop').show();

});
//===============
function MenuCatalogOpen() {
// Если больших разделов на сайте один (это на большинстве сайтиков) или два (это на егазоне), то
// заголовок раздела (H4) не показываем, а пункты второго уровня показываем жирненьким (класс a2as1)
// Если ни один раздел еще не открыт (такое случается, если пользователь что-то выбрал),
// раскрываем первый, шобы красиво было.
  var m_h4 = $('#menu_catalog H4');
  if(m_h4.size() <= 2) {
		m_h4.hide();
		$('#menu_catalog>UL>LI>A').addClass('a2as1');
		if ($('#menu_catalog LI.over').size() == 0) {$('#menu_catalog LI:first').addClass('over');}
	}

// Если общее количество пунктов меню третьего уровня немного (<=4), то мы их сразу все открываем
// По хорошему, надо было бы запретить их сворачивать здесь же, но не получилось, пришлось делать это в php
  if($('#menu_catalog  UL UL').size() <= 4){
		$('#menu_catalog > UL > LI').addClass('over');
		$('#show_hide_menu').hide();
//		$('#menu_catalog > UL > LI > A').unbind('click'); Не работает оно... :-(
	}

// У меню в стилях стоит visibility hidden, чтобы пока идет вся возня со скрыванием заголовков и
// разворачиванием подпунктов меню не дрыгалось на виду у всех. Когда все закончено - мы его показываем:
	$('.menu_left_cmb').css('visibility','visible');
}

//===============
function CommentsGet() {
  var d = $('#comments_list');
  if (d.size() == 0) {return;}
  getItemsCommon({'id': d.attr('name')},'comments_list','comments_list','');
}
//===============
function _BtnCompareProp() {
  $('#prop4compare').click(function(event) {
    var t = event.target;
    if (t.nodeName != 'INPUT') {return;}
    var ch = $('#prop4compare INPUT:checked');

    if (t.id == 'btn_compare_prop') {
      var p_link_words = '';
      ch.each(function() {
        var val = $(this).next().children('SPAN').html();
        p_link_words +=  this.id.substring(1) + '_' + val + '|' + val + '__';
      });
      location.href = t.alt + escape4url(p_link_words);
      return;
    }

    var btn = $('#btn_compare_prop');
    if (ch.size() > 0) {btn.show();} else {btn.hide();}
  });
}
//===============
function CalcTime(days) {
	var plusDays = days*24*60*60*1000;
	var expDate = new Date();
	expDate.setTime(expDate.getTime() + plusDays);
	return expDate.toGMTString();
}
//================
function IP2city() {
  getItemsCommon({'func_before': 'IPcity2site'},'ip2city','hidden4js_script','');
}
//================
function IPcity2site() {
  if (!$('#hidden4js_script').html()) {return;}
	var reg = /(.+)___(\d+)___(.+)/;
  var t = reg.exec($('#hidden4js_script').html());
  if (!t || t.length != 4) {return;}
  if (t[3] != 'none') {
    $('#cities_str').html(t[1] + ': ' + t[3]);
    $('#zakaz').html('Заказ по телефону (' + t[1] + '): <span>' + t[3] + '</span>');
    $('#cities_dop').html('');
  } else {
    $('#cities_dop').html(t[1]);
  }
  clearTimeout(ctimer);
  setTimeout('get_times(' + t[2] + ')',100);
}
//================
function show_our_title_mouseover () {
	$('#our_title').show();
}

function show_our_title () {
	if ($('#our_title').size() == 0) {
		$('<div id="our_title"></div>').appendTo('BODY').hide();
	}
  $('[ps_title]').mouseover(
  	function(event) {
			var tm = ($(this).attr('ps_time')) ? 600 : 0;
			$('#our_title').empty().append($(this).attr('ps_title'))
			if (!$.browser.msie && !is_user) {
				if ($(this).attr('ps_time')) {$('#our_title').corner("round 8px").parent().css('padding', '4px').corner("round 10px")}
				else {$('#our_title').corner("round 1px")}
			}
			var alt = $(this).find('IMG').attr('alt');
			$(this).find('IMG').attr('alt','');
  		timeoutID = setTimeout('show_our_title_mouseover()',tm);

			$(this).mousemove(
		  	function(event) {
		  		var x_scr = window.pageXOffset || document.body.scrollLeft;
		  				x_scr = x_scr + document.documentElement.clientWidth;
		  		var x_left = event.pageX + $('#our_title').width() + 16;
		  		var x = (x_left < x_scr)
		  					? event.pageX + 10
		  					: event.pageX - $('#our_title').width() - 20;

		  		var y_scr = window.pageYOffset || document.body.scrollTop;
		  				y_scr = y_scr + document.documentElement.clientHeight;
		  		var y_bot = event.pageY + $('#our_title').height() + 16;
		  		var y = (y_bot < y_scr)
		  					? event.pageY + 20
		  					: event.pageY - $('#our_title').height() - 20;

		  		$('#our_title')
		  		  .css('left', x + 'px')
		  		  .css('top', y + 'px');
		  	}
		  );

			$(this).mouseout(
		  	function(event) {
		  		clearTimeout(timeoutID)
					$(this).find('IMG').attr('alt',alt);
		  		$('#our_title').hide();
		  	}
		  );
  	}
  );
}
//================
function TABLE_hover () {
  $('.psmt_table TR, .tbl_list TR').hover(
		function(event) {$(this).addClass('hover');},
		function(event) {$(this).removeClass('hover');}
  );
}
//================
function form_search_recolor () {
	$('#form_search .search_str').css('background-position','0 0');
}
//================
function change_url() {
  $('#form_search FORM').attr('action','/search/' + escape4url($('#search_str').val()) + '/1page_rows' + get_cookie_str('page_rows'));
}
//================
function escape4url(str) {
  str = str.replace(/\+/g, '%2B').replace(/\"/g, '%22').replace(/\'/g, '%27');
  	// Инициализируем таблицу перевода
  	var trans = [];
  	for (var i = 0x410; i <= 0x44F; i++)
  	  trans[i] = i - 0x350; // А-Яа-я
  	trans[0x401] = 0xA8;    // Ё
  	trans[0x451] = 0xB8;    // ё

	  var ret = [];
	  // Составляем массив кодов символов, попутно переводим кириллицу
	  for (var i = 0; i < str.length; i++)
	  {
	    var n = str.charCodeAt(i);
	    if (typeof trans[n] != 'undefined')
	      n = trans[n];
	    if (n <= 0xFF)
	      ret.push(n);
	  }
	  return window.escape(String.fromCharCode.apply(null, ret));
}
//================
function ICQsend(str,uins,icq) {
  getItemsOnlyQuest({'str4send': str,'uin': uins,'icq': icq},'icq_send');
}
//-----------------------------------------------

//--------------------------
function SortCatChange(num) {
  document.cookie = "cookie[sort_cat_n]=" + num + "; expires=" + CalcTime(30) + '; path=/';
}
//-----------------------------------------------
function ChangeNoItem(item,old_item) {
  if (old_item) {document.cookie = "cookie[" + old_item + "]=0; expires=" + CalcTime(30) + '; path=/';}
  if (item) {document.cookie = "cookie[" + item + "]=1; expires=" + CalcTime(30) + '; path=/';}
  location_random();
}
//----------------------------------------------------------------------------
function location_random() {
  var dop = '?rnd=' + Math.random();
  var l_href = location.href;
 	var pos = location.href.indexOf('?rnd=');
 	if (pos != -1) {l_href = l_href.substring(0,pos);}
  location.href = l_href + dop;
//  location.reload();
}

//--- ВЫБОР РЕГИОНА --------------------------------------------
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
function ShowBlock(id_block) {
  var obj = document.getElementById(id_block);
  obj.style.display = 'block';
}
//-----------------------------------------------
function HideBlock(id_block) {
  var obj = document.getElementById(id_block);
  obj.style.display = 'none';
}
//-----------------------------------------------
function ChangeCity(o_select) {
	id_s = o_select.id.substring(2);
  document.cookie = "cookie[city]=" + id_s + "; expires=" + CalcTime(30) + '; path=/';
  if (location.href.indexOf('edit_zakaz') != -1) {location.href = '/basket/';}
  else {location.reload();}
}
//--- КОНЕЦ ВЫБОРА РЕГИОНА --------------------------------------------

//----------------------------------------------------------------------------
function returnBack() {
  if (history.length) {history.back();}
  else {window.location = '/';}
}
//----------------------------------------------------------------------------
var o;
var o_color = 'red';
var counter = 1;
var o_frm_now;
//----------------------------------------------------------------------------
function CheckRequared(o_frm,vars) {
  for (var k in vars) {
    if (o_frm[vars[k]].value && o_frm[vars[k]].value != '0') {continue;}
    o = o_frm[vars[k]];
    counter = 1;
    o_color = 'red';
    o.value = ' Введите данные';
    o.focus();
    setTimeout("ChangeBg()",10);
    return false;
  }
  if (o_frm.submit) {o_frm_now = o_frm; setTimeout("o_frm_now.submit.disabled = true;",300);}
  return true;
}
//----------------------------------------------------------------------------
function ChangeBg() {
  counter++;
  if (counter > 8) {o.value = ''; return;}
  o_color = (o_color == 'red') ? 'white' : 'red';
  o.style.background = o_color;
  setTimeout("ChangeBg()",300)
}
//----------------------------------------------------------------------------
function DeliveryView() {
  var o_frm = document.getElementById("frm_reg");
  if (!o_frm.phone_delivery.value) {o_frm.phone_delivery.value = o_frm.phone.value;}
  if (!o_frm.person_delivery.value) {o_frm.person_delivery.value = o_frm.name_f.value + ' ' + o_frm.name_i.value + ' ' + o_frm.name_o.value;}
}
//----------------------------------------------------------------------------
function CheckJuridical(o_radio) {
//  var r_val = (o_radio) ? o_radio.value : 1;
//  if (r_val == 1) {$(o_radio).parents('TABLE').find('TR.only_jur').attr('class','view_jur');}
//  else {$(o_radio).parents('TABLE').find('TR.view_jur').attr('class','only_jur');}
//  $('#content_text').css('background','#fff'); // чтобы полоска в ИЕ отпрыгивала вниз
}
//----------------------------------------------------------------------------
function ShowDopTR(inp) {
	if (!$(inp).hasClass('vis')) {
		if ($(inp).attr('name') == 'deliv_title') {DeliveryView()}
		$(inp).next('LABEL').css('border','none').end().addClass('vis').parents('TR').next('TR.tr_dop').show(400);
	}	else {
		$(inp).removeClass('vis').parents('TR').next('TR.tr_dop').hide(400);
		$(inp).next('LABEL').css('border-bottom','1px dotted #666')
	}
  $('#content_text').css('background','#fff'); // чтобы полоска в ИЕ отпрыгивала вниз
}
//----------------------------------------------------------------------------
function ViewContacts(o_btn,idblock) {
  if (!idblock) {idblock = "zakaz_verify";}
  var o = document.getElementById(idblock);
  o.style.display = 'block';
  o_btn.style.display = 'none';
  $('.catalog_up').css('clear','both'); // чтобы полоска в ИЕ отпрыгивала вниз
}
//----------------------------------------------------------------------------
function ChangeValuta1(v_id) {
  document.cookie = "cookie[valuta]=" + v_id + "; expires=" + CalcTime(30) + '; path=/';
  ViewPrices(v_id);
  var o = document.getElementById("price_in");
  var arr = o.getElementsByTagName('a');
  for (var i = 0; i < arr.length; i++) {
    arr[i].className = (arr[i].id == "a"+v_id) ? 'sel' : '';
  }
}
//----------------------------------------------------------------------------
function ViewPrices(val) {
  var o = document.getElementById("catalog");
  var arr = o.getElementsByTagName('span');
  var temp,tt,v;
  for (var i = 0; i < arr.length; i++) {
    tt = arr[i].title;
    if (tt == 'цена в рублях') {v = 0;}
    else if (tt == 'цена в евро') {v = 1;}
    else if (tt == 'цена в долларах') {v = 2;}
    else {continue;}
    arr[i].className = (v == val) ? 'price_view' : 'price_no_view';
  }
}
//----------------------------------------------------------------------------
function StylePrint() {
	o_link = $('#switch_style_print');
  if (o_link.attr('class') == 'for_print') {
    $('link[media=print]').removeAttr('media');
    o_link.attr('class','for_screen');
  } else {
    $('link[href*=print]').attr('media','print');
    o_link.attr('class','for_print');
  }
  var a = o_link.attr('alt');
  o_link.attr('alt',o_link.html());
  o_link.html(a);
}
//--- MENU -------------------------------------------------------------------
function vtest(event) {
  if (event.target.tagName != 'LI') {return;}
  $(event.target).css('border','1px solid red');
}
function vtest2(event) {
  if (event.target.tagName != 'LI') {return;}
  $(event.target).css('border','0');
}
//----------------------------------------------------------------------------
var vars_catalog = new Object;
//----------------------------------------------------------------------------
function vv(node) {
  if (node.className == "over"){$(node).attr('class',''); return;}
  $(node).attr('class','over');
}
//----------------------------------------------------------------------------
function _MenuFloatSimple(menu) {
  menu.find('LI').hover(
  	function() {$(this).addClass('over')},
  	function() {$(this).removeClass('over')}
  );
}
//----------------------------------------------------------------------------
function _MenuFloatLeft() {
  var menu_block = $('#menu_catalog')[0];
  if (!menu_block) {return;}

  menu_block.onmouseover = function(e) {
    var el = e && e.target || event.srcElement;
    while (el && el.tagName != 'LI') {el = el.parentNode}
    if (!el || !$(el).attr('id')) {return;}

    if ($(el).attr('alt') != 'no_childs') {
      var ch = $(el).children();
      var l = ch.attr('href');
      if (!ch.is('UL')) {
        var idcat_parent = l.substring(l.lastIndexOf('/') + 1);
        ch.after('<ul id="u' + idcat_parent +'"></ul>');    // заводим пустой список, фатал
        vars_catalog['id'] = idcat_parent;
        getItemsCommon(vars_catalog,'catalog_view','u' + idcat_parent,'');
      }
    }

    $(el).hover(
    	function() {$(this).addClass('over')},
    	function() {$(this).removeClass('over')}
    ).addClass('over');
  }
}
//----------------------------------------------------------------------------
function ViewMenuCatalog(idcat,idsite) {
  vars_catalog['id_dop'] = idcat;
  vars_catalog['idsite'] = idsite;
//  alert(vars_catalog['id_sel']);
  if (!vars_catalog['id_sel']) {return;}
  var li_sel = $('#l' + vars_catalog['id_sel']);
  li_sel.children('A').addClass('sel');
  li_sel.parents('LI').addClass('over').children('A').addClass('sel');

  // для страниц групп второго уровня типа "бассейны и спа": чтобы открывались их детки (надо же как-то выделять эту группу в меню)
  $('#m' + vars_catalog['id_sel']).addClass('sel').parents('LI').addClass('over');
//  getItemsCommon(vars_catalog,'catalog','menu_catalog');
}
//--- end of MENU ------------------------------------------------------------
//----------------------------------------------------------------------------
function ShowHideBlock(o, id_block) {
  var obj = document.getElementById(id_block);
  obj.style.display = (obj.style.display == 'block') ? 'none': 'block';
  s = o.src;
  alert(s);
  if (s.substring(s.length-6,s.length-4) == '_u') {re = /marker_u/; str = 'marker_d'}
  else {re = /marker_d/; str = 'marker_u'}
	o.src = s.replace(re, str);
}
//----------------------------------------------------------------------------
function ShowHideBlockSimple(id_block) {
  var obj = document.getElementById(id_block);
  obj.style.display = (obj.style.display == 'block') ? 'none': 'block';
}
//----------------------------------------------------------------------------
function ShowItem(id_show) {
  var obj_s = document.getElementById(id_show);
  obj_s.style.display = 'block';
}
//----------------------------------------------------------------------------
function ShowHideMenu() {
  var obj = document.getElementById('menu_l');
  var obj_a = document.getElementById('show_hide_menu');
  if  (obj_a.innerHTML == "Свернуть меню") {
	  obj.className = 'menu_left_cmb';
	  obj_a.innerHTML = "Развернуть меню";
  } else {
	  obj.className = 'menu_left_cmb menu_left_all';
	  obj_a.innerHTML = "Свернуть меню";
	  //swf_show("/images/baners/intex.swf", "baner_left", "183", "102", "7", "#000");
  }
}

//-----------------------------------------------
function video_open(f,w,h) {
  window.open("/video.php?f=" + f + "&width=" + w + "&height=" + h, "", "help=no; status=no,location=no,toolbar=no,menubar=0,directories=no,height=" + h + ",width=" + w + ",top=100,left=300,dependent=yes,scrollbars=no");
}
//-----------------------------------------------
function swf_show(swf, div, w, h, vers, backgr) {
	var so = new SWFObject(swf, div+'obj', w, h, vers, backgr);
	so.addParam("wmode", "transparent");
	so.write(div);
}
//----------------------------------------------------------------------------
function td_hover(node) {
  obj = node.parentNode;
  if (obj) {obj.className="titl hover";}
}
//----------------------------------------------------------------------------
function td_out(node) {
  obj = node.parentNode;
  if (obj) {obj.className="titl";}
}
//----------------------------------------------------------------------------
function TdHover(td, st) {
	td.className="hover";
  if (st) {window.status=st;}
}
//----------------------------------------------------------------------------
function TdNoHover(td, st) {
	td.className="";
  if (st) {window.status=st;}
}
//--------------------------
function TdClick(a_href,e) {
  if (!e) {return;}
  var o_input = (ie) ? e.srcElement : e.target;
  if (o_input.onclick || (o_input.type && (o_input.type == "button" || o_input.type == "image" || o_input.type == "textarea" || o_input.type == "submit")) || (o_input.className && o_input.className.substr(0,5) == "price")) {return;}
  location.href = a_href;
}
//----------------------------------------------------------------------------
function Links2Slide(idblock) {
  var bl = document.getElementById(idblock);
  if (!bl) {return;}
  var arr = bl.getElementsByTagName('IMG');
  var o, o_link, new_div, new_txt;
  for (var i = 0; i < arr.length; i++) {
    o = arr[i];
    var o_link = o.parentNode;
    var is_link = false;
    for (var j = 0; j < 4; j++) {
      if (!o_link) {break;}
      if (o_link.href && (o_link.href.indexOf('jpg') != -1 || o_link.href.indexOf('gif') != -1 || o_link.href.indexOf('JPG') != -1 || o_link.href.indexOf('GIF') != -1)) {
        is_link = true;
        break;
      }
      o_link = o_link.parentNode;
    }
    if (!is_link) {continue;}
    o_link.className = 'highslide';
    o_link.onclick = function() { return hs.expand(this) };
    if (!o_link.title) {continue;}
    new_div = document.createElement('div');
    o_link.parentNode.appendChild(new_div);
    new_txt = document.createTextNode(o_link.title);
    new_div.appendChild(new_txt);
    new_div.className = 'highslide-caption';
    o_link.title = '';
  }
}
//-----------------------------------------------
function analis_form(o_frm,vars,is_submit) {
  var num = o_frm.elements.length;
  var i,nn,tt,vv;
  for (i = 0; i < num; i++) {
    tt = o_frm.elements[i].type;
    if (!tt) continue;
    if (tt == 'submit' && !is_submit) {continue;}

    if ((tt == 'checkbox' || tt == 'radio') && !o_frm.elements[i].checked) {continue;}
    vv = o_frm.elements[i].value;
    nn = o_frm.elements[i].name;
    vars[nn] = vv;
  }
}
//-----------------------------------------------
function GotoPage(page_to,act,frm_id,div_id) {
  $('#p' + page_from).attr('class','');
  $('#p' + page_to).attr('class','now_page');
  page_from = page_to;

  var o_frm = document.getElementById('search_' + act);
  if (!o_frm && frm_id) {o_frm = $('#' + frm_id)[0];}

  if (!div_id) {div_id = 'tbl_search';}

  var vars = {};
  analis_form(o_frm,vars);
  vars['page'] = page_to;

  if (window.getItems) {getItems(vars,act,div_id);} else {getItemsCommon(vars,act,div_id);}

  if ($(o_frm).attr('alt')) {setTimeout($(o_frm).attr('alt'),timeout4refresh * 2);}
  if (o_frm.page) {o_frm.page.value = page_to;}
}
//-----------------------------------------------
function getItemsOnlyQuest(vars,php_action) {
    var req = new JsHttpRequest();
      req.caching = false;
      req.open('POST','/lib/JsHttpRequest/this.php',true);
      vars['action'] = php_action;
      req.send(vars);
}
//-----------------------------------------------
function getItemsCommon(vars,php_action,block_name,bl_txt) {
  var o = document.getElementById(block_name);
  if (o && bl_txt == null) {o.innerHTML = '<p>Пожалуйста, подождите...</p>';}
    var req = new JsHttpRequest();
      req.onreadystatechange = function() {
        if (req.readyState == 4) {
          if (req.responseJS) {
            var str = '';
            if (req.responseJS.good_mess) {
              str = req.responseJS.good_mess;
            }
            if (o) {
              o.innerHTML = str;
              if (vars['func_before']) {setTimeout(vars['func_before'] + '()',10);}
            }
          }
          var t = document.getElementById('debug');
          if (t) {document.getElementById('debug').innerHTML = req.responseText;}
         }
      }
      req.caching = false;
      req.open('POST','/lib/JsHttpRequest/this.php',true);
      vars['action'] = php_action;
      req.send(vars);
}
//--- Для выделения текста в блоке на щелчок мышью --------------------------------------------
//function SelectText(o) {
//}

