	var item = new Array();

	$(document).ready( function(){
		h_scroll();
		function h_scroll(){
			$('.tab-switch').each( function() {
				var tabSwitch = $(this);
				var tabSwitchContainer = tabSwitch.parent();
				var list = $('.work-area-news-item-list', tabSwitchContainer);
				var allList = $('.news-list', tabSwitchContainer);
				allList.hide();

				switchContent($('a.tab.tabactive', tabSwitch).attr('id'));
				$('h2.tab-switch a.tab', tabSwitchContainer).click( function(){
					if(!$(this).hasClass('tabactive')){
						$('h2.tab-switch a', tabSwitchContainer).removeClass('tabactive');
						$(this).addClass('tabactive');
						switchContent($(this).attr('id'));
						
						var h = parseInt($('#leftwrap').height()-$('#righttop').height()-$('#rightbottom').height()-$('.height-count').height());
						h = (h < 360)?360:h;
						$('#newscontent').parent().css({ height: h+'px' });
						$('#rightcol #work-area-news-item-list').css({height: h+'px'});
						$('#rightcol #work-area-news-item-list').jScrollPane({showArrows:true});
						$('#rightcol .jScrollPaneContainer').css({height: eval(h-3)+'px'});
					}
				});
				function switchContent(tabAct){
					list.html('');
					$('li', allList).each( function(){
						if($(this).hasClass(tabAct)){
							$(this).clone().appendTo(list);
						}
					});
				}
			});
		}
	})

	function initScrl(scrollUp, scrollDown, actTab, switchTabs, container, scrollArea, scrollFrame){
		var animate = true;
		var pos = 0;
		switchTabContent();



		$(switchTabs).click( function(){
			if(!$(this).hasClass('tabactive')){
				$(switchTabs).removeClass('tabactive');
				$(this).addClass('tabactive');
				actTab = $(this).attr('id');
				switchTabContent();
			}
			return false;
		});



		function switchTabContent(){
			item = [];
			for(i=0; i<item.length; i++){ item.shift(); }
			$(container).html('');
			var i = 0;
			jQuery.each($('.news-list li', $(container).parent()), function(y, val) {
				if($(this).hasClass(actTab)){
					$(this).clone().appendTo($(container));
					height = eval($('li:last', $(container)).height()+32);
					item[i++] = height;
				}
			});
			$(scrollArea).animate({ top: '0px' }, 1000);
			pos = 0;
			$(scrollFrame).animate({ height: $('li:nth-child('+eval(pos+1)+')', $(container)).height()+'px' }, 500, function(){
				var h = parseInt($('#leftwrap').height()-$('#righttop').height()-$('#rightbottom').height()-$('.height-count').height());
				h = (h < 360)?360:h;
				$('#newscontent').parent().css({ height: h+'px' });
				$('#rightcol #work-area-news-item-list').jScrollPane({showArrows:true});
				$('#rightcol .jScrollPaneContainer').css({height: eval(h-3)+'px'});
				$('#rightcol #work-area-news-item-list').css({height: h+'px'});
			});
			checkControls();
			return false;
		};



		scrollDown.click( function(){
			if(animate && pos < item.length-1 && ! $(this).hasClass('scrolldowndisabled')){ scroll(1); };
			checkControls();
		});

		scrollUp.click( function(){
			if(animate && pos < item.length && ! $(this).hasClass('scrollupdisabled')){ scroll(-1); };
			checkControls();
		});



		function scroll(direction){
			animate = false;
			var totalScroll = 0;
			if(direction > 0){ pos++; }else{ pos--; }
			for(i=0; i<pos; i++){ totalScroll += item[i]; }
			$(scrollArea).animate({ top: '-'+totalScroll+'px' }, 1000, function(){
				animate = true;
				$(scrollFrame).animate({ height: $('li:nth-child('+eval(pos+1)+')', $(container)).height()+'px' }, 500, function(){
					var h = parseInt($('#leftwrap').height()-$('#righttop').height()-$('#rightbottom').height()-$('.height-count').height());
					h = (h < 360)?360:h;
					$('#newscontent').parent().css({ height: h+'px' });
					$('#rightcol #work-area-news-item-list').css({height: h+'px'});
					$('#rightcol #work-area-news-item-list').jScrollPane({showArrows:true});
					$('#rightcol .jScrollPaneContainer').css({height: eval(h-3)+'px'});
				});
			});
			return false;
		};



		function checkControls(){
			if(pos == item.length-1){
				scrollDown.removeClass('scrolldown'); scrollDown.addClass('scrolldowndisabled');
			}
			if(pos >= item.length-1){
				scrollDown.removeClass('scrolldown'); scrollDown.addClass('scrolldowndisabled');
				
				scrollUp.addClass('scrollup'); scrollUp.removeClass('scrollupdisabled');
			}else{
				scrollDown.addClass('scrolldown'); scrollDown.removeClass('scrolldowndisabled');
			}
			if(pos > 0){
				scrollUp.addClass('scrollup'); scrollUp.removeClass('scrollupdisabled');
			}else{
				scrollUp.removeClass('scrollup'); scrollUp.addClass('scrollupdisabled');
			}
		};
	}
$(document).ready( function(){
	$('.scroller').each( function() {
		InitScroll($(this));
	});



	function InitScroll(container){
		$('.news-list', container).css('display', 'none');
		var frameHeight = $('.content-list', container).parent().height();
		var cont = $('#work-area-news-item-list', container), contHeight = $('#work-area-news-item-list', $(container)).height();
		var offset = 0, animate = true, interval = false;
		var scrollUp = $('.scrollupdisabled', container), scrollDown = $('.scrolldown', $(container));

//	Вставляем элементы активной вкладки
		switchContent($('h2.tabs a.tab.tabactive', container).attr('id'));
		$('h2.tabs a.tab', container).click( function(){
			if(!$(this).hasClass('tabactive')){
				$('h2.tabs a', container).removeClass('tabactive');
				$(this).addClass('tabactive');
				switchContent($(this).attr('id'));
			}
		});

		function switchContent(tabAct){
			cont.html('');
			$('.news-list li', container).each( function(){
				if($(this).hasClass(tabAct)){
					$(this).clone().appendTo(cont);
				}
			});
			offset = 0;
			
			
			var h = parseInt($('#leftwrap').height()-$('#righttop').height()-$('#rightbottom').height()-$('.height-count').height());
			h = (h < 360)?360:h;
			$('#newscontent').parent().css({ height: h+'px' });
			$('#rightcol #work-area-news-item-list').css({height: h+'px'});
			$('#rightcol #work-area-news-item-list').jScrollPane({showArrows:true});
			$('#rightcol .jScrollPaneContainer').css({height: eval(h-3)+'px'});
		}
	};
	$('.bp').each( function() {
		bpFunc($(this));
	});
	function bpFunc(bp){
		var bpListWidth = 0, scroll = 0, count = 0, pos = 0, step = 330, animation = true;
		$('ul li', bp).each( function() {
			count++;
		});
		bpListWidth = eval(count*step);
		$('ul', bp).width(bpListWidth);
		checkControls();
		$('.bp-rarr', bp).click( function(){
			if(!$(this).hasClass('dis') && pos < (count-3)){
				bpScroll(-1);
			}
			checkControls();
			return false;
		});
		$('.bp-larr', bp).click( function(){
			if(!$(this).hasClass('dis') && pos > 0){
				bpScroll(1);
			}
			checkControls();
			return false;
		});
		function bpScroll(direction){
			if(animation){
				animation = false;
				scroll += eval((direction*step));
				pos -= direction;
				$('ul', bp).animate({ left: scroll+'px' }, 500, function(){
					animation = true;
				});
				checkControls();
			}
			return false;
		}
		function checkControls(){
			if(count <= 3){
				$('.bp-rarr', bp).addClass('dis');
				$('.bp-larr', bp).addClass('dis');
			}
			if(pos < (count-3)){
				$('.bp-rarr', bp).removeClass('dis');
			}else{
				$('.bp-rarr', bp).addClass('dis');
			}
			if(pos > 0){
				$('.bp-larr', bp).removeClass('dis');
			}else{
				$('.bp-larr', bp).addClass('dis');
			}
			return false;
		};
		return false;
	}
});

$(function () {
	if($('.social-bmarks').length != 0){
		$.get(
			'/www-include/vkontakte_bookmarks.js', function(data){
				eval(data);
				var vk = VK.Share.button(false,{type: "round", text: "ВКонтакте"});
				var titleenc=encodeURIComponent($("html head title").html());
				$('.social-bmarks').append('\
					<div class="social-bmarks-item">'+vk+'</div>\
					<div class="social-bmarks-item">\
						<a rel="nofollow" href="http://www.livejournal.com/update.bml?event='+window.location+'&subject='+titleenc+'" target="_blank" title="Опубликовать в своем блоге livejournal.com">\
							<img height="26" alt="LiveJournal" src="/pic/decor/social/1.gif">\
						</a>\
					</div>\
					<div class="social-bmarks-item">\
						<a rel="nofollow" title="Запостить в Twitter" href="http://twitter.com/home?status='+encodeURIComponent('Читаю: ')+window.location+'" target="blank" rel="nofollow">\
							<img height="26" border="0" alt="Twitter" src="/pic/decor/social/3.gif">\
						</a>\
					</div>\
					<div class="social-bmarks-item">\
						<a rel="nofollow" title="Google Bookmarks" target="_blank" href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk='+window.location+'&amp;title='+titleenc+'">\
							<img height="26" alt="Google Bookmarks" src="/pic/decor/social/4.gif">\
						</a>\
					</div>\
					<div class="social-bmarks-item">\
						<a rel="nofollow" title="Google Reader" target="_blank" href="http://www.google.com/reader/link?url='+window.location+'&amp;title='+titleenc+'&amp;srcTitle='+window.location.host+'&amp;srcURL='+window.location.host+'">\
							<img height="26" alt="Google Reader" src="/pic/decor/social/5.gif">\
						</a>\
					</div>\
					<div class="social-bmarks-item">\
						<a rel="nofollow" title="Linked In" target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url='+window.location+'&amp;title='+titleenc+'&amp;source='+window.location.host+'">\
							<img height="26" alt="Linked In" src="/pic/decor/social/7.gif">\
						</a>\
					</div>\
					<div class="social-bmarks-item">\
						<a rel="nofollow" title="Яндекс.Закладки" target="_blank" href="http://zakladki.yandex.ru/userarea/links/addfromfav.asp?bAddLink_x=1&amp;lurl='+window.location+'&amp;lname='+titleenc+'">\
							<img height="26" alt="Яндекс.Закладки" src="/pic/decor/social/10.gif">\
						</a>\
					</div>\
					<div class="clear"></div>\
				');
				$('.social-bmarks').before('<div class="clear"></div><hr />');
				$('.social-bmarks').append('<div class="clear"></div><hr />');
			}
		)
	}});