	var actTab=null;
	var hotEl=[];
	var srch='';
	var mark01=0;
	function overEl(el) {
		el.className="over";
	}
	function itemEl(el) {
		el.className="item";
	}

	function showValues() {
		var numi="";
		jQuery.each(document.forms, function(i, value){
			if(value.id=="fltr"){
				numi=i;
			}
		});
		var ttt= $(":input", document.forms[numi]);
		for(var i=0; i < ttt.length; ++i){
			if(ttt[i].className=="hd"){
				$(ttt[i].parentNode.previousSibling).removeClass("hotSch");
				$(ttt[i]).removeAttr("checked");
			}
		}
		var fields = $(":input", document.forms[numi]).serializeArray();
		$("#SrchRes").empty();
		var schpar="?";
		jQuery.each(fields, function(i, field){
				schpar+=field.name+"="+field.value+"&";
		});
		schpar=schpar.substr(0,schpar.length-1);
		$("#SrchRes").load("/SrchRes.cgi"+schpar);
	}

	function InitBar() {
		var bar = $(this).find("table.flr");
		//		загрузка второй строки
		bar.find("td").click(function(ev) {
			$("#SrchRes").empty();
			if(mark01!=0) {
				return false;
				}
			mark01=1;
			ev.preventDefault();
			ev.stopPropagation();
			if(actTab) {
				$(actTab).removeClass("hot").addClass("nohot");
			}
			$(this).animate( { opacity: "hide" }, 10 );
			$(this).removeClass("nohot").addClass("hot");
			$(this).animate( { opacity: "show" }, 2000, "easeOutBack");
			actTab = this;
			var insch=$('#insch');
			insch.css("width","0px");
			insch.css("overflow","hidden");


			insch.load(this.firstChild.href, function(){
				$(this).animate( {width:'+=590'}, 400, "easeInExpo", function(){mark01=0;});

				var itm = $(this).find("div.nmCtg");
//				загрузка вертикальных столбцов
				itm.click(function(ev) {
					var cont=$(this.nextSibling);
					ev.preventDefault();
					ev.stopPropagation();
					if(cont[0].childNodes.length>0){
						if(cont[0].style.display=='none'){
							var hd=$(this.nextSibling).find("td.nameC");
		 					for(var i=0; i < hd.length; ++i){
							 	if ($(hd)[i].className.match(/hotSch/)!=null) {
									$($(hd)[i].nextSibling.firstChild).removeClass("hd");
								}
		 					}

							cont.show();
						}
						else{
							var hd=$(this.nextSibling).find("td.nameC");
		 					for(var i=0; i < hd.length; ++i){
							 	if ($(hd)[i].className.match(/hotSch/)!=null) {
									$($(hd)[i].nextSibling.firstChild).addClass("hd");
								}
		 					}

							cont.hide();
						}
					}
					else{
						cont.load(this.firstChild.href, function(){
							var kol=$(this).find("td.nameC");
							kol.each(function(index) {
//									var dly=index*500;
//							 		$(this).delay(dly).animate( { opacity: "show" }, 800, "linear");
									$(this).animate( { opacity: "show" }, 800, "linear");
  						});
//							выбрать элементы в столбцах
							var itm2=$(this).find("td.nameC");
							itm2.click(function(ev) {
								var selItm=$(this.nextSibling.firstChild);
								if ($(this)[0].className.match(/hotSch/)==null) {
									$(this).addClass("hotSch");
									selItm[0].checked=true;
								}
								else{
									$(this).removeClass("hotSch");
									selItm.removeAttr("checked");

								}
							});
						});
					}
				}); //end itm.click
				itm.trigger("click");
			});
		});
		setTimeout(function() {
			$(bar.find("td")[0]).trigger("click");
 		},500);


		var pck = $(this).find("#tgt");
		pck.click(function(){
			showValues();
		});
	}

	$(function() {
		var bloon=$('#bloon');
		var filtr=$('#filtr');
		var fin=$('#fin');
		var insch=$('#insch');
		var SrchRes=$('#SrchRes');
		var wFiltr=$('#wFiltr');
 		var cFiltr=getCookie("filtr");
		bloon.mouseover(function() {
				bloon.css('opacity','1');
				if(window.shift!='true'){
					bloon.animate({top:'+=10'},{duration: 400, specialEasing: {top: 'easeInBack'}});
					bloon.animate({top:'-=10'},100);
				}
				window.shift='true';
				setTimeout(function() {
					window.shift='false';
 				},1000);
  	});

		bloon.mouseout(function() {
				bloon.css('opacity','0.6');
		});

		var clcount='false';

		bloon.bind('click',function() {
			bloon[0].src="/img/filtr_sClick.gif";
			if(filtr.css('width')=='36px'){
	 			document.cookie = "filtr=1; path=/";

				filtr.animate({width:'+=590'},{duration: 400,	specialEasing: {top: 'easeOutExpo'}});
				if(clcount=='false'){
//					загрузка первой строки
					srch=location.search;
	 				fin.load("/filtr.cgi"+srch, InitBar);
//					alert(fin[0].tagName);
//	 				$.get("/filtr.cgi"+srch,
//					 function(txt){
//					 		alert('Load was performed.'+ this.innerHTML);
//					 		alert(txt);

//						});

					clcount="true";
					wFiltr.css("display","none");
					fin.show();
					insch.show();
					SrchRes.show();
				}
				else {
					wFiltr.css("display","none");
					fin.show();
					insch.show();
					SrchRes.show();
					}
			}
			else{
				bloon[0].src="/img/filtr_s.gif";
 		 		document.cookie = "filtr=0; path=/";
				filtr.animate({width:'-=590'},{duration: 400,	specialEasing: {top: 'easeOutExpo'}});
				fin.hide();
				insch.hide();
				SrchRes.hide();
				wFiltr.css("display","block");
			}
		});
		if(cFiltr && cFiltr>0){
			bloon.trigger("click");
		}
	});

