$(document).ready(function() {
	
	/*
		Aleksey Skubaev

		askubaev@gmail.com
		icq - 322253350
		Разработка шаблонов для DLE и кроссбраузерная верстка
		------------------
		Необходимые jQuery скрипты.
	
	*/
	
	// Простявлем платформы
	$('.anons-block-item-bottom').each(function() {
		var element = $(this).text().split(','); 
		for (j=0; j<element.length; j++)
			{
				var divs = element[j];
				$(this).append('<div class="'+divs+'"></div>');
			}
    });
	
	// Анонсы при наведении
	$('.anons-block-item').hover(
		function() {
			$(this).addClass('anons-block-item-active');
		}, function() {
			$(this).removeClass('anons-block-item-active');
	});
	
	// Вкладки в левой колонке
	$('.tt-tabs').ttabs();
	
	$('.index-tabs2 span').hover(
		function() {
			$(this).addClass('index-tab-hover');
		}, function() {
			$(this).removeClass('index-tab-hover');
	});
	
	// Чередование фона новостей
	$('.news-item:odd').css({'background':'#191919'}).find('.news-item-text').css({'color':'#939393'});
	
	// Значек play при наведении
	$('.play').hover(
		function() {
			$(this).addClass('play2');
		}, function() {
			$(this).removeClass('play2');
	});
	
	// Рассчет позиции всплывающего окна с видео 
	$('.hidden-shotstory').each(function() {
		var fixedWidth = $(this).width();
		var fixedHeight = $(this).height();
		$(this).css({'margin-left':-fixedWidth/2,'margin-top':-fixedHeight/2});
    });
	
	// Показываем окно по клику
	$('.play').click(function(){
		$(this).parent().parent().find('.hidden-shotstory').fadeIn();
		$('.dark').fadeIn();
	});
	
	// Закрываем окно
	$('.close, .dark').click(function(){
		$('.hidden-shotstory').fadeOut(0);
		$('.dark').fadeOut();
	});
	
	$('.video-news:first').addClass('video-news-active');
	
	// Функция кнокпи Next для видео
	function showVideoNext() {
		$('.video-news').removeClass('video-news-active');
		var currentVideo = $(this).parent().parent().parent();
		currentVideo.addClass('video-news-active');
		
		var nextVideo = currentVideo.next('.video-news').length ? currentVideo.next('.video-news') : $('.video-news:first');
		currentVideo.find('.hidden-shotstory').fadeOut(0);
		nextVideo.find('.hidden-shotstory').fadeIn(1000);
		nextVideo.find('.shadow-x').fadeIn(0).fadeOut(800);
		
	}
	
	// Функция кнокпи Prev для видео
	function showVideoPrev() {
		$('.video-news').removeClass('video-news-active');
		var currentVideo = $(this).parent().parent().parent();
		currentVideo.addClass('video-news-active');
		
		var nextVideo = currentVideo.prev('.video-news').length ? currentVideo.prev('.video-news') : $('.video-news:last');
		currentVideo.find('.hidden-shotstory').fadeOut(0);
		nextVideo.find('.hidden-shotstory').fadeIn(1000);
		nextVideo.find('.shadow-x').fadeIn(0).fadeOut(800);
	}
	
	// Вызов функций
	$('.panel-right').click(showVideoNext);
	$('.panel-left').click(showVideoPrev);
	
	// Кнопки туда/назад при наведении
	$('.panel-right').hover(
		function() {
			$(this).addClass('panel-right2');
		}, function() {
			$(this).removeClass('panel-right2');
	});
	
	$('.panel-left').hover(
		function() {
			$(this).addClass('panel-left2');
		}, function() {
			$(this).removeClass('panel-left2');
	});
	
	// Меню-гармошка
	$('.slide-menu-1').hover(
		function() {
			$(this).addClass('slide-menu-2');
		}, function() {
			$(this).removeClass('slide-menu-2');
	});
	
	$('.slide-menu-1').click(function(){
		$(this).toggleClass('slide-menu-3').next('.slide-menu-hidden').slideToggle();
	});
	
	
	// Табы в правой колонке
	$('.tt-tabs3').ttabs({
		activeClass: 'active-ttab2'
	});
	
	// Логин
	$('.login-panel-open').click(function(){
		$('.login-block').slideToggle();
	});
	
	
	
});

