$(document).ready(function(){
	
	$('.scrollbar1,#scrollbar2').tinyscrollbar();
	
	
	
		
	$('.two_str').each(function(){
		var words = $(this).text().split(" ");
		var text = words.join("</span> <span>");
		$(this).html("<span>" + text + "</span>")
			.find("span:first").addClass('first_word')
			.parent().find("span:last").addClass('last_word')
			.parent().find("span:eq(1)").addClass('two_word')
			.parent().find("span:gt(0)").addClass('last_word')
	})
	
	
	
	$('.search_but').hover(function(){
		$(this).addClass('s_hover')	
	},function(){
		$(this).removeClass('s_hover')		
	})
	
	$('.menu_top a:first').addClass('first')
	$('.menu_top a,.object_menu a').not('.cur').hover(function(){
		$(this).stop().animate({
			backgroundColor: $.Color( '#d51900' )
		},200)	
	},function(){
		$(this).stop().animate({
			backgroundColor: $.Color( '#002861' )
		},1000)	
	})
	
	
	var label_w = $('.form_style label').outerWidth()
	$('.form_style .error,.form_style .help,.form_style .but_1').css({marginLeft:label_w})
	$('#image').next('a').addClass('update_captcha')
	//tables style
	$(".table1 tr,.table2 td").mouseover(function() {$(this).addClass("over");}).mouseout(function() {$(this).removeClass("over");});
	$(".table1 tr:even").addClass("alt");
	$(".table1 tr").find('td:first').addClass('td_first')
	$(".table2,.table1").wrap('<div class="table_wrap">')
	
	//photo Gallery
	$('body').delegate('.img_link','mouseenter',function(){
			$(this).find('img').animate({opacity:'0.5'},100).animate({opacity:'1'},300)
	})


	// img style
	$('.content>img,.content>p>img').addClass('cont_img')

	/*-----------------------*/
	$(window).load(function(){
		$('.slides_item').each(function(){
			var s_item 	= 	$(this),
				img 	= 	$('img',s_item),
				img_first 	= 	$('img:first',s_item).addClass('hide'),
				id = s_item.attr('id'),
				time = id*300
				
			img_first.hide()
			function slide(){
				function sec() { 
				  img.slideToggle(500)
				}
				setTimeout(sec, time) // использовать функцию
			}
			setInterval(slide, 10000)
		})
		
		/*
		$('.coll_h').height('auto')
		var h1 = $('#coll_1').height();
		var h2 = $('#coll_2').height();
		var h3 = $('#coll_3').height();
		var h = h1
		if(h < h2){h = h2}
		if(h < h3){h = h3}
		$('#coll_3').animate({height:h-10})
		if(h1 < h){
			$('<div>').addClass('add_block').height(coll($('#coll_1'),h)-10).appendTo('#coll_1')
		}
		if(h2 < h){
			$('<div>').addClass('add_block').height(coll($('#coll_2'),h)-10).appendTo('#coll_2')
		}
		
		function coll(coll_id,coll_h){
			var p = 0
			coll_id.children().each(function(){
				p += $(this).outerHeight()+10
			})
			p = h - p
			return p
		}
		*/
		$('.coll_h').height('auto')
		var h1 = $('#coll_1').height();
		var h2 = $('#coll_2').height();
		var h3 = $('#coll_3').height();
		var h = h1
		if(h < h2){h = h2}
		if(h < h3){h = h3}
		$('#coll_3').animate({height:h-10})
		if(h1 < h){
			var el_last = $('#coll_1').children(':last')
			el_last.height(coll($('#coll_1'),h) + el_last.height())
		}
		if(h2 < h){
			var el_last = $('#coll_2').children(':last')
			el_last.height(coll($('#coll_2'),h) + el_last.height())
		}
		
		function coll(coll_id,coll_h){
			var p = 0
			coll_id.children().each(function(){
				p += $(this).outerHeight()+10
			})
			p = h - p
			return p
		}
		
		
		
	})
});
