$(document).ready(function(){
	$("div.par > div").click(function(){
	$("div.par > div").each (function(){
		var cls = this.className;
		this.className = cls.slice(0,4);
	});
	var cls = this.className;
	this.className = cls + ' sel' + cls.slice(3,4);
	
	});
	
	$("div.par0 > div").click(function(){
	$("div.par0 > div").each (function(){
		var cls = this.className;
		this.className = cls.slice(0,5);
	});
	var cls = this.className;
	this.className = cls + ' sel' + cls.slice(3,5);
	
	});
	
	
	
	$("div.pars > div").click(function(){
	$("div.pars > div").each (function(){
		var cls = this.className;
		this.className = cls.slice(0,4);		
	});	
	var cls = this.className;
	var nm = cls.slice(3,4)
	this.className = cls + ' sel' + nm;		
	$("div#srch-form > form > div").each (function(){
		var nmf = this.id.slice(4,5);
//@vasiliy		if (nmf == nm) this.style.display = 'block'; 
//@vasiliy		else this.style.display = 'none';
	});	
	});
	
	$("div.pars2 > div").click(function(){
	$("div.pars2 > div").each (function(){
		var cls = this.className;
		this.className = cls.slice(0,4);		
	});	
	var cls = this.className;
	var nm = cls.slice(3,4)
	this.className = cls + ' sel' + nm;		
	$("div.str-col2 > div.srch-form > div.form").each (function(){
		var nmf = this.id.slice(4,5);
//@vasiliy		if (nmf == nm) this.style.display = 'block'; 
//@vasiliy		else this.style.display = 'none';
	});	
	});
	
	$("div#reserve > div > div > span.link").click(function(){
		var tl = this.innerHTML;
		var tl0 = $("div#reserve > div.blk > div.f21 > strong");
		this.innerHTML = tl0[0].innerHTML;
		$("div#reserve > div.blk > div.f21 > strong")[0].innerHTML = tl;		
	});	
	
	$("div.move").click(function(){	
		var f = $("div.move > div > div")[0].className;
		if (f == "close") {
			$("div.close > span")[0].innerHTML = "ðàçâåðíóòü";			
			$("div.move > div > div")[0].className = "open";
			$("#other_par1").css("display", "none");
			$("#other_par2").css("display", "none");					
		}
		else {
			$("div.open > span")[0].innerHTML = "ñâåðíóòü";			
			$("div.move > div > div")[0].className = "close";
			$("#other_par1").css("display", "block");
			$("#other_par2").css("display", "block");		
		}
	});		
	
	var last_col = 0;
	var lnt_td = $("table#narrow-table td").length;			
	var lnt_str = $("table#narrow-table tr.head td").length;				
		
	$("table#narrow-table td").mouseover(function(){			
		var sel_td = this;		
		var str = $(this).parent().find("td");		
		//var lnt_str = str.length;			
		//ñíèìàåì âûäåëåíèå ñ ïðåäûäóù êîëîíêè
		$("table#narrow-table td").each (function(index){
				for(var i = last_col; i < lnt_td+1; i = i + lnt_str ){				
					if(index == last_col) {
						$(this).css("background", "#2D6DAF");
						$(this).css("color", "#FFFFFF");
					}
					else if(index == i) {						
						$(this).css("background", "none");
						if ($(this).find("div.none")[0])	$(this).find("div.none")[0].style.display="none";
					}
				 }
			});
		// èùåì íàâåäåííóþ ÿ÷åéêó
		$(this).parent().find("td").each (function(index){			
			if(this == sel_td) { num_col = index; }
		});
		last_col = num_col;		
		if(num_col != 0 ) {				
			//ïîêàçûâàåì âûäåëåííûé ñòîëáåö
			$("table#narrow-table td").each (function(index){
				for(var i = num_col; i < lnt_td+1; i = i + lnt_str ){				
					if(index == num_col) {
						$(this).css("background", "#C6DDF5");
						$(this).css("color", "#2D6DAF");
					}
					else if(index == i) {						
						$(this).css("background", "#EBF4FE");
						if ($(this).find("div.none")[0])	$(this).find("div.none")[0].style.display="block";
					}
				 }
			});
		}		
	});
	
	$("table#narrow-table").mouseout(function(){		
		$("table#narrow-table td").each (function(index){
				for(var i = last_col; i < lnt_td+1; i = i + lnt_str ){				
					if(index == last_col) {
						$(this).css("background", "#2D6DAF");
						$(this).css("color", "#FFFFFF");
					}
					else if(index == i) {						
						$(this).css("background", "none");
						if ($(this).find("div.none")[0])	$(this).find("div.none")[0].style.display="none";
					}
				 }
			});
	});
	
});

